Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/menu_custom.asm @ 100:db4a20b413df
Checking all CF values at once.
Fix minor false negative check on 15bit CF values.
author | JeanDo |
---|---|
date | Tue, 14 Dec 2010 02:20:04 +0100 |
parents | 39d325b2a5f9 |
children | 6a94f96e9cea |
comparison
equal
deleted
inserted
replaced
99:39d325b2a5f9 | 100:db4a20b413df |
---|---|
421 ; Display optional min/max values. | 421 ; Display optional min/max values. |
422 ; Inputs: cf_value, cf_min, cf_max (and cf_type to display min/max). | 422 ; Inputs: cf_value, cf_min, cf_max (and cf_type to display min/max). |
423 ; Trashed: hi:lo while display min and max values. | 423 ; Trashed: hi:lo while display min and max values. |
424 display_minmax: | 424 display_minmax: |
425 ; Min/max unsupported for 15bit values yet... | 425 ; Min/max unsupported for 15bit values yet... |
426 btfsc cf_type,7 ; A 15bit value ? | |
427 return | |
428 | |
429 movff EEADRH, FSR1H ; Backup... | 426 movff EEADRH, FSR1H ; Backup... |
430 | 427 |
431 ; Display min line | 428 ; Display min line |
432 WIN_TOP .65 | 429 WIN_TOP .65 |
433 WIN_LEFT .100 | 430 WIN_LEFT .100 |
434 lfsr FSR2, letter | 431 lfsr FSR2, letter |
432 | |
433 btfsc cf_type,7 ; A 15bit value ? | |
434 bra cf_no_min ; Don't display, hence clear line... | |
435 | 435 |
436 btfss cf_type, CF_MIN_BIT ; A min value exists ? | 436 btfss cf_type, CF_MIN_BIT ; A min value exists ? |
437 bra cf_no_min | 437 bra cf_no_min |
438 | 438 |
439 movf cf_min,W ; Retrieve current 8b value | 439 movf cf_min,W ; Retrieve current 8b value |
458 ; Display max line | 458 ; Display max line |
459 WIN_TOP .95 | 459 WIN_TOP .95 |
460 call PLED_standard_color | 460 call PLED_standard_color |
461 WIN_INVERT 0 | 461 WIN_INVERT 0 |
462 lfsr FSR2, letter | 462 lfsr FSR2, letter |
463 | |
464 btfsc cf_type,7 ; A 15bit value ? | |
465 bra cf_no_max ; Don't display, hence clear line too... | |
463 | 466 |
464 btfss cf_type, CF_MAX_BIT ; A max value exists ? | 467 btfss cf_type, CF_MAX_BIT ; A max value exists ? |
465 bra cf_no_max | 468 bra cf_no_max |
466 | 469 |
467 movf cf_value,W ; Retrieve current max bound | 470 movf cf_value,W ; Retrieve current max bound |
755 ; Check all CF values that have max and min constraints. | 758 ; Check all CF values that have max and min constraints. |
756 ; Input: cf_checker_counter. | 759 ; Input: cf_checker_counter. |
757 ; Output: Pop warning with the first CF number if bad. | 760 ; Output: Pop warning with the first CF number if bad. |
758 ; cf_checker_counter incremented. | 761 ; cf_checker_counter incremented. |
759 ; Trashes: TBLPTR, EEADR, PROD | 762 ; Trashes: TBLPTR, EEADR, PROD |
763 ; | |
764 ; Note: the trick here is to do two sweep over the 64 CF values, to make sure | |
765 ; they are all ok. | |
760 | 766 |
761 check_customfunctions: | 767 check_customfunctions: |
762 ; rcall check_next_cf ; Check 5 at a time... | 768 ; Did we finished the two sweeps ? |
763 ; rcall check_next_cf | 769 btfsc cf_checker_counter,7 ; Already at position 128 ? |
764 ; rcall check_next_cf | 770 return ; YES: just do nothing. |
765 ; rcall check_next_cf | |
766 ; | |
767 ;check_next_cf: | |
768 | |
769 movf cf_checker_counter,W ; Get current CF to ckeck | |
770 | 771 |
771 ; Setup cf32_x4 and cf page bit: | 772 ; Setup cf32_x4 and cf page bit: |
773 movf cf_checker_counter,W | |
772 rlcf WREG ; x4 | 774 rlcf WREG ; x4 |
773 rlcf WREG | 775 rlcf WREG |
774 bcf customfunction_page | 776 bcf customfunction_page |
775 btfsc WREG,7 | 777 btfsc WREG,7 |
776 bsf customfunction_page | 778 bsf customfunction_page ; Setup CF page bit. |
777 andlw 4*.31 | 779 andlw 4*.31 |
778 movwf cf32_x4 | 780 movwf cf32_x4 |
779 | 781 |
780 ; Do the check | 782 ; Do the check |
781 rcall check_one_cf | 783 rcall check_one_cf |
782 btfsc WREG,7 | 784 iorwf WREG ; Test return value. |
783 bra check_cf_ok | 785 bz check_failed ; 0 == FAILED. |
784 | 786 |
785 ; Went wrong: pop the warning | 787 ; Passed: Simple loop until 128 is reached: |
786 movwf temp1 | 788 incf cf_checker_counter ; Next CF to check. |
787 call custom_warn_surfmode | 789 bra check_customfunctions ; And loop until 128 reached (ie twice) |
788 | 790 |
789 ; Increment counter (modulo 64) | 791 check_failed: |
790 check_cf_ok: | 792 movlw .63 ; Make sure number is back to range 0..63 |
791 movlw 1 | 793 andwf cf_checker_counter,F |
792 addwf cf_checker_counter,W | 794 |
793 andlw .63 | 795 ; Went wrong: draw the warning line... |
796 WIN_TOP .200 | |
797 WIN_LEFT .80 - (6*.7)/2 ; Center 8 chars of width 14pix. | |
798 WIN_FONT FT_SMALL | |
799 WIN_INVERT .1 ; Init new Wordprocessor | |
800 call PLED_warnings_color | |
801 | |
802 lfsr FSR2,letter | |
803 movlw ' ' | |
804 movwf POSTINC2 | |
805 movlw 'C' | |
806 movwf POSTINC2 | |
807 movlw 'F' | |
808 movwf POSTINC2 | |
809 movff cf_checker_counter,lo | |
810 output_99x | |
811 movlw ' ' | |
812 movwf POSTINC2 | |
813 call word_processor | |
814 | |
815 ; When failed, increment counter modulo 64, to restart checks. | |
816 incf cf_checker_counter,W | |
817 andlw .63 ; Modulo 64 | |
794 movwf cf_checker_counter | 818 movwf cf_checker_counter |
795 return | 819 return |
796 | 820 |
797 ; Check one CF value --------------------------------------------------------- | 821 ; Check one CF value --------------------------------------------------------- |
798 check_one_cf: | 822 check_one_cf: |
799 rcall cf_read_default ; Sets hi:lo, cf_type, cf_min, cf_max. | 823 rcall cf_read_default ; Sets hi:lo, cf_type, cf_min, cf_max. |
800 | 824 |
801 movf cf_type,W ; MIN or MAX set ? | 825 btfsc cf_type,7 ; A 15bit type ? |
826 bra check_cf_check ; Then we have to check it... | |
827 | |
828 movf cf_type,W ; 8bit MIN or MAX set ? | |
802 andlw (CF_MIN + CF_MAX) | 829 andlw (CF_MIN + CF_MAX) |
803 bnz check_cf_check ; yes: do something. | 830 bnz check_cf_check ; yes: do something. |
804 retlw -1 ; no: no problem there. | 831 retlw -1 ; no: no problem then. |
805 | 832 |
806 ; It does have bound: | 833 ; It does have bound: |
807 check_cf_check: | 834 check_cf_check: |
808 movf cf32_x4,W ; Compute current CF number | 835 movf cf_checker_counter,W ; Get current CF number |
809 rrncf WREG ; Div 4 | 836 andlw .63 ; Keep range 0..63 |
810 rrncf WREG | |
811 btfsc customfunction_page ; Upper page ? | |
812 addlw .32 ; just add 32. | |
813 movwf TABLAT ; saved to return error, if any. | |
814 | 837 |
815 btfss cf_type,7 ; 15 or 8 bit value ? | 838 btfss cf_type,7 ; 15 or 8 bit value ? |
816 bra cf_check_8bit | 839 bra cf_check_8bit |
817 | 840 |
818 ; Implement the 15bit check, even if not displayed... | 841 ; Implement the 15bit check, even if not displayed... |
819 rcall getcustom15_1 ; Read into hi:lo | 842 rcall getcustom15_1 ; Read into hi:lo |
820 | 843 |
821 movf cf_min,W ; Compute (bound-value) -> hi:lo | 844 movf cf_min,W ; Compute (bound-value) -> hi:lo |
822 subwf lo,F | 845 subwf lo,F |
823 movf cf_max,W | 846 movf cf_max,W |
824 bcf WREG,7 ; Clear min or max bit | 847 bcf WREG,7 ; Clear min/max bit |
825 subwfb hi,F | 848 subwfb hi,F |
826 | 849 |
827 movf lo,W ; Is it a 0 result ? | 850 movf lo,W ; Is it a 0 result ? |
828 iorwf hi,W | 851 iorwf hi,W |
829 bnz cf_15_not_equal ; NO: check sign. | 852 bnz cf_15_not_equal ; NO: check sign. |
831 | 854 |
832 cf_15_not_equal: | 855 cf_15_not_equal: |
833 btfss cf_max,7 ; Checking min or max ? | 856 btfss cf_max,7 ; Checking min or max ? |
834 btg hi,6 ; exchange wanted sign | 857 btg hi,6 ; exchange wanted sign |
835 | 858 |
836 setf WREG ; -1 for return w/o error | |
837 btfss hi,6 ; Is sign correct ? | 859 btfss hi,6 ; Is sign correct ? |
838 movf TABLAT,W ; NO: get back failed CF number | 860 retlw 0 ; NO: return failed. |
839 return ; and return that. | 861 retlw -1 ; YES: return passed. |
840 | 862 |
841 ; Do a 8bit check | 863 ; Do a 8bit check |
842 cf_check_8bit: | 864 cf_check_8bit: |
843 rcall getcustom8_1 ; Read into WREG | 865 rcall getcustom8_1 ; Read into WREG |
844 movwf lo ; Save it. | 866 movwf lo ; Save it. |
845 | 867 |
846 btfss cf_type,CF_MIN_BIT | 868 btfss cf_type,CF_MIN_BIT |
847 bra check_no_min | 869 bra check_no_min |
848 | 870 |
849 cpfsgt cf_min ; Compare to cf_min | 871 cpfsgt cf_min ; Compare to cf_min |
850 bra check_no_min | 872 bra check_no_min ; PASSED: continue. |
851 | 873 retlw 0 ; NO: return failed. |
852 movf TABLAT,W ; NO: get back failed CF number | |
853 return | |
854 | 874 |
855 check_no_min: | 875 check_no_min: |
856 btfss cf_type,CF_MAX_BIT | 876 btfss cf_type,CF_MAX_BIT ; Is there a MAX bound ? |
857 bra check_no_max | 877 retlw -1 ; No check: return OK. |
858 | 878 |
859 movf lo,W ; Compute value-max | 879 movf lo,W ; Compute value-max |
860 cpfslt cf_max | 880 cpfslt cf_max |
861 bra check_no_max | 881 retlw -1 ; Bound met: return OK. |
862 | 882 retlw 0 ; NO: return failed. |
863 movf TABLAT,W ; NO: get back failed CF number | |
864 return | |
865 | |
866 check_no_max: ; Then everything was ok... | |
867 retlw -1 |