Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/menu_custom.asm @ 94:ce3283064cde
Check all CF in surfacemode, pop warning is oobounds
author | JeanDo |
---|---|
date | Sat, 11 Dec 2010 13:54:37 +0100 |
parents | 6655b1c59adc |
children | dc349e4264bb |
comparison
equal
deleted
inserted
replaced
93:6ee3a42fd006 | 94:ce3283064cde |
---|---|
358 | 358 |
359 bcf menubit3 ; clear flag | 359 bcf menubit3 ; clear flag |
360 bra customfunctions_loop | 360 bra customfunctions_loop |
361 | 361 |
362 ;----------------------------------------------------------------------------- | 362 ;----------------------------------------------------------------------------- |
363 ; Read default value (into hi:lo), cf_type, and cf_min/cf_max if any. | 363 ; Read default value, type, and constraints |
364 ; | 364 ; |
365 ; Input: customfunction_page, cf32_x4 | |
366 ; Output: hi:lo, cf_type, cf_min, cf_max. | |
367 ; Trashes: TBLPTR | |
368 | |
365 cf_read_default: | 369 cf_read_default: |
366 movlw LOW(cf_default_table0) ; Get 24bit PROM pointer. SKIP | 370 movlw LOW(cf_default_table0) ; Get 24bit PROM pointer. SKIP |
367 movwf TBLPTRL | 371 movwf TBLPTRL |
368 movlw HIGH(cf_default_table0) | 372 movlw HIGH(cf_default_table0) |
369 movwf TBLPTRH | 373 movwf TBLPTRH |
743 movff hi,EEDATA | 747 movff hi,EEDATA |
744 call write_eeprom ; Highbyte | 748 call write_eeprom ; Highbyte |
745 movlw d'5' | 749 movlw d'5' |
746 movwf menupos | 750 movwf menupos |
747 bra menu_custom_functions1 ; also debounces switches | 751 bra menu_custom_functions1 ; also debounces switches |
752 | |
753 ;----------------------------------------------------------------------------- | |
754 ; Check all CF values that have max and min constraints. | |
755 ; Input: cf_checker_counter. | |
756 ; Output: Pop warning with the first CF number if bad. | |
757 ; cf_checker_counter incremented. | |
758 ; Trashes: TBLPTR, EEADR, PROD | |
759 | |
760 check_customfunctions: | |
761 movf cf_checker_counter,W ; Get current CF to ckeck | |
762 | |
763 ; Setup cf32_x4 and cf page bit: | |
764 rlcf WREG ; x4 | |
765 rlcf WREG | |
766 bcf customfunction_page | |
767 btfsc WREG,7 | |
768 bsf customfunction_page | |
769 andlw 4*.31 | |
770 movwf cf32_x4 | |
771 | |
772 ; Do the check | |
773 rcall check_one_cf | |
774 btfsc WREG,7 | |
775 bra check_cf_ok | |
776 | |
777 ; Went wrong: pop the warning | |
778 movwf temp1 | |
779 call custom_warn_surfmode | |
780 | |
781 ; Increment counter (modulo 64) | |
782 check_cf_ok: | |
783 movlw 1 | |
784 addwf cf_checker_counter,W | |
785 andlw .63 | |
786 movwf cf_checker_counter | |
787 return | |
788 | |
789 ; Check one CF value --------------------------------------------------------- | |
790 check_one_cf: | |
791 rcall cf_read_default ; Sets hi:lo, cf_type, cf_min, cf_max. | |
792 | |
793 movf cf_type,W ; MIN or MAX set ? | |
794 andlw (CF_MIN + CF_MAX) | |
795 bnz check_cf_check ; yes: do something. | |
796 retlw -1 ; no: no problem there. | |
797 | |
798 ; It does have bound: | |
799 check_cf_check: | |
800 movf cf32_x4,W ; Compute current CF number | |
801 rrncf WREG ; Div 4 | |
802 rrncf WREG | |
803 btfsc customfunction_page ; Upper page ? | |
804 addlw .32 ; just add 32. | |
805 movwf TABLAT ; saved to return error, if any. | |
806 | |
807 btfss cf_type,7 ; 15 or 8 bit value ? | |
808 bra cf_check_8bit | |
809 | |
810 ; Do a 15bit check | |
811 rcall getcustom15_1 ; Read into hi:lo | |
812 | |
813 movf cf_min,W ; Compute (bound-value) -> hi:lo | |
814 subwf lo,F | |
815 movf cf_max,W | |
816 subwfb hi,F | |
817 | |
818 movf lo,W ; Is it a 0 result ? | |
819 iorwf hi,W | |
820 bnz cf_15_not_equal ; NO: check sign. | |
821 retlw -1 ; YES: then it is ok. | |
822 | |
823 cf_15_not_equal: | |
824 btfss cf_type,CF_MIN_BIT ; Checking min or max ? | |
825 btg hi,6 ; exchange wanted sign | |
826 | |
827 setf WREG ; -1 for return w/o error | |
828 btfss hi,6 ; Is sign correct ? | |
829 movf TABLAT,W ; NO: get back failed CF number | |
830 return ; and return that. | |
831 | |
832 ; Do a 8bit check | |
833 cf_check_8bit: | |
834 rcall getcustom8_1 ; Read into WREG | |
835 movwf lo ; Save it. | |
836 | |
837 btfss cf_type,CF_MIN_BIT | |
838 bra check_no_min | |
839 | |
840 cpfsgt cf_min ; Compare to cf_min | |
841 bra check_no_min | |
842 | |
843 movf TABLAT,W ; NO: get back failed CF number | |
844 return | |
845 | |
846 check_no_min: | |
847 btfss cf_type,CF_MAX_BIT | |
848 bra check_no_max | |
849 | |
850 movf lo,W ; Compute value-max | |
851 cpfslt cf_max | |
852 bra check_no_max | |
853 | |
854 movf TABLAT,W ; NO: get back failed CF number | |
855 return | |
856 | |
857 check_no_max: ; Then everything was ok... | |
858 retlw -1 |