chiark / gitweb /
readout works
authorian <ian>
Sun, 10 Apr 2005 20:37:55 +0000 (20:37 +0000)
committerian <ian>
Sun, 10 Apr 2005 20:37:55 +0000 (20:37 +0000)
cebpic/panic.asm

index 4b034eca7e10a28ed4d92c1d070316871a94c143..4d885ce534a144e8ee3ca92c7282e79bcad79cae 100644 (file)
@@ -77,47 +77,36 @@ err_SOS     equ     0       ; msg 0 = SOS
 ;      endm
 
 ;----------------------------------------
-; readout(READOUTREG,GREEN)
-;      transmits the contents of the chosen byte by flashing LED
-;      in chosen colour [GREEN=1: green (=blue); GREEN=0: red (=orange)]
-
-;      NB using WREG2 as copy of READOUTREG contents
-;         using WREG3 as GREEN store
-;         using WREG4 as counter
-
-
-readout macro ERRCODE, GREEN
-       movlw   GREEN
-       movwf   WREG3,0         ; copy GREEN into WREG3
+readout
+; Flashes the per-pic led red and black in a specified pattern.
+; The pattern is specified as the state for 8 identically-long time
+; periods each as long as a morse `dot', encoded into a byte with
+; most significant bit first.
+;              On entry                On exit
+; W            any                     undefined
+; WREG2                flash pattern           preserved
+; WREG4                any                     undefined
+;
        clrf    WREG4,0         ; clear loop counter (WREG4)
-       movff   ERRCODE,WREG2   ; copy ERRCODE into WREG2
+       rrncf   WREG2,1
 
 readout_loop
        movlw   8
        cpfslt  WREG4,0         ; if loop counter >=8, return
        return
-       rlcf    WREG2,1
-       bc      readout_led_off
-       bra     readout_led_on
-
-readout_led_on
-        ifbit0 WREG3,0         ; check desired colour
-       call    led_red
-       ifbit1  WREG3,0
-       call    led_green
-       incf    WREG4,1,0       ; increment loop counter
-       call    waiting
-       goto    readout_loop
 
-
-readout_led_off
+       rlncf   WREG2,1         ; top bit goes into N flag, ie Negative if 1
+       bn      readout_if_led_on
+readout_if_led_off
         call   led_black
+       bra     readout_endif_led
+
+readout_if_led_on
+       call    led_red
+readout_endif_led
        incf    WREG4,1,0       ; increment loop counter
        call    waiting
-       goto    readout_loop
-
-       endm
-
+       bra     readout_loop
 
 ;****************************************************************************
 
@@ -223,7 +212,8 @@ informative_panic
        clrf    BLANK,0
 panic_loop
 ;      errmsg  err_SOS,0       ; transmit SOS in red
-       readout TESTFLASH,0     ; transmit contents of SSPCON1 in red
+       movff   TESTFLASH,WREG2
+       rcall   readout
 ;      readout BLANK,0         ; transmit blank buffer
        call    led_green
        call    waiting