Home » Archimedes archive » Acorn User » AU 1998-13 (Christmas).adf » Regulars » RTR/LEDtst

RTR/LEDtst

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1998-13 (Christmas).adf » Regulars
Filename: RTR/LEDtst
Read OK:
File size: 2039 bytes
Load address: 0000
Exec address: 0000
File contents
 ;Multiplexed LED matrix display test
 ;For an 10 MHz clock
 ;A0 - Serial out
 ;A1 - Serial in
 ;A2 - CTS allows serial input
 ;A3 - RTS output held until this is low
 
 ;Note for 16F84 invert the state of the PWRTE
      LIST P=16C84
       
 
 C       EQU     0
 PCL     EQU     2
 Z       EQU     2
 PORTB   EQU     6
 PORTA   EQU     5
 TRISB   EQU     86H
 TRISA   EQU     85H
 EECON1  EQU     88H
 EEDATA  EQU     8
 INTCON  EQU     0bH
 EEADR   EQU     9
 STATUS  EQU     3
 RP0     EQU     5
 INC     EQU     1
 cts     EQU     2
 rts     EQU     3
 ; Output bits
 cdat    EQU     1      ;Coloum data
 cck     EQU     2      ;Coloum clock
 rclr    EQU     3      ;Row clear
 rck     EQU     4      ;Row clock
 rdat    EQU     5      ;Row data
 
 sBuf    EQU    0ch     ;Serial send buffer
 Scount  EQU    0dh     ;Tempory Counter
 Cdown   EQU    0eh     ;Time delay countdown
 rBuf    EQU    0fh     ;Recieve buffer
 ScanNo  EQU    10h     ;Number of row we are on
 RowC    EQU    11h     ;Row counter
 Sstore  EQU    12h     ;Scrole store
 Com1    EQU    13h     ;Command 1
 Com2    EQU    14h     ;Command 2
 save_w  EQU    15h     ;save w reg
 save_s  EQU    16H     ;save status
 save_p  EQU    17h     ;save port LEDs
 DisBuf  EQU    1Ah     ;Display buffer
 

;
   ORG 0
        GOTO    Start
  ORG 4
        movwf   save_w          ;save w and s regs
        swapf   STATUS,w        ;swapf doesn't affect Z like movf
        movwf   save_s
        movf    PORTB,w         ;Save state of LEDs
        movwf   save_p
        clrf    PORTB           ;Turn LEDs off

        call    Rx              ;Recieve byte
        incf    Com2,f          ;Increment the data to put in
        call    sleft           ;Scroll left command

out     movf    save_p,w
        movwf   PORTB           ;Turn LEDs back on        
        swapf   save_s,w
        movwf   STATUS          ; restore registers
        swapf   save_w,f
        swapf   save_w,w
        bcf     INTCON,1        ;Clear edge interrupt
        retfie

             
;Recieve a serial byte
Rx      movlw   8               ;Number of data bits to get
        movwf   Scount
Sb      btfsc   PORTA,1         ;Hold until start bit
        goto    Sb
        call    hDelay          ;Half a baud delay
Rnb     bcf     STATUS,C        ;Clear the carry bit
        rrf     rBuf,f          ;Prepare for next bit  
        call    rDelay          ;Full baud delay for recieve
        btfsc   PORTA,1         ;Test input
        bsf     rBuf,7          ;Set if needed
        decfsz  Scount,f        ;See if finished
        goto    Rnb             ;Round again if not
        call    rDelay          ;Allow for stop bit to start
        movf    rBuf,w          ;Put recieved chractor into W
        return
        

;Send a serial byte
Send    btfsc   PORTA,rts       ;Only proceed when rts is low
        goto    Send
        movlw   9               ;Number of data bits to send
        movwf   Scount
        bcf     PORTA,0         ;Start bit
        call    cDelay          ;Extra delay compensation
Sloop   call    Delay
        btfsc   sBuf,0          ;Set the next bit
        bsf     PORTA,0
        btfss   sBuf,0
        bcf     PORTA,0
        rrf     sBuf,f          ;Shift for next time
        decfsz  Scount,f
        goto    Sloop           ;Round until finished
        bsf     PORTA,0         ;Stop bit
        call    cDelay          ;Extra delay compensation
        call    Delay
        call    Delay
        call    cDelay          ;For good measure
        return
        
cDelay  movlw   2               ;Small delay at end of send
        movwf   Cdown           
        goto    Dloop
        
hDelay  movlw   21              ;half delay for serial recieve 10MHz clock
        movwf   Cdown           ; 19,200 Baud rate
        goto    Dloop
        
rDelay  movlw   38              ;Delay for serial recieve 10MHz clock
        movwf   Cdown           ; 19,200 Baud rate
        goto    Dloop
        
Delay   movlw   39              ;Delay for serial send 10MHz clock
        movwf   Cdown           ; 19,200 Baud rate
Dloop   decfsz  Cdown,f
        goto    Dloop
        return
        

Start
        BSF     STATUS,RP0      ;SELECT REGISTER BANK 1
        MOVLW   1Ah             ;Bits 4,3 & 2 inputs
        MOVWF   TRISA^80H
        MOVLW   1               ;Bit 0 input rest outputs
        MOVWF   TRISB^80H
        MOVLW   3               ;16 prescaler -ve edge interrupt
        MOVWF   1               ;Option register
        MOVLW   90H             ;Enable bit 0 interrupt
        MOVWF   INTCON

        BCF     STATUS,RP0      ;SELECT REGISTER BANK 0
        
        BSF     PORTA,0         ;Serial at Mark
        BCF     PORTA,cts       ;CTS enabled
        CLRF    PORTB
        CLRF    ScanNo
        CLRF    Com2
        
;Just put some test data into some memory
        movlw   0AAh
        movwf    DisBuf
        movwf    DisBuf!1
        movwf    DisBuf!2
        
        movwf    DisBuf!6
        movwf    DisBuf!7
        movwf    DisBuf!8
        
        movwf    DisBuf!12
        movwf    DisBuf!13
        movwf    DisBuf!14
        
        movwf    DisBuf!18
        movwf    DisBuf!19
        movwf    DisBuf!20

        movlw   055h
        movwf    DisBuf!3
        movwf    DisBuf!4
        movwf    DisBuf!5
        
        movwf    DisBuf!9
        movwf    DisBuf!10
        movwf    DisBuf!11
        
        movwf    DisBuf!15
        movwf    DisBuf!16
        movwf    DisBuf!17
  
Main    btfss   0bh,2           ;Test timer
        GOTO    Main            ;Loop until time
        bcf     0bh,2           ;Clear it for next time
        incf    ScanNo,f
        movlw   7               ;See if it is at end
        subwf   ScanNo,w
        btfsc   STATUS,Z        ;Wrap it round after 7
        clrf    ScanNo
        call    scan 
        GOTO    Main
        
scan    clrf    PORTB           ; Blank out row
        bcf     STATUS,C
        rlf     ScanNo,w        ;Scan No * 3 + DisBuf = reg address
        addwf   ScanNo,w
        addlw   DisBuf
        movwf   4               ;to indirect register
        call    rbout           ;Output first byte
        incf    4,f             ;Next byte
        call    rbout
        incf    4,f             ;Last byte
        call    hrout
        movf    ScanNo,w
        movwf   RowC             ;Row Count
        incf    RowC,f           ;One more pulse
        bcf     STATUS,C
        rlf     RowC,f
        rlf     RowC,f
        rlf     RowC,w
        movwf   PORTB
        return
        
hrout   movlw   4               ;Only 4 bits out
        GOTO    he        
rbout   movlw   8               ;number of shifts to do
he      movwf   RowC            ;shift store
        movf    0,w             ;get byte to send
        movwf   Sstore          ;store it
rloop   rrf     Sstore,f        ;get next bit into carry
        bcf     PORTB,cdat      ;Get data line right
        btfsc   STATUS,C
        bsf     PORTB,cdat
        bsf     PORTB,cck       ;Toggle clock
        bcf     PORTB,cck
        decfsz  RowC,f          ;All bits done?
        GOTO    rloop
        return
        
;Commands
        
sleft   movlw   DisBuf          ;Scroll memory left
        movwf   4               ;into indirect register
        movlw   7               ;Number of rows to scroll
        movwf   sBuf            ;Temp storage
        bcf     STATUS,C
slloop  rlf     0,f             ;Move first byte
        incf    4,f
        rlf     0,f             ;Move second byte
        incf    4,f
        rlf     0,f             ;Move last byte
        bcf     0,4             ;Blank bit fallen off the end
        incf    4,f             ;Move on for next time
        decfsz  sBuf,f          ;Loop until all 7 rows are out
        goto    slloop
        btfsc   Com2,0          ;Now put new data in
        bsf     DisBuf,0
        btfsc   Com2,1
        bsf     DisBuf!3,0
        btfsc   Com2,2
        bsf     DisBuf!6,0
        btfsc   Com2,3
        bsf     DisBuf!9,0
        btfsc   Com2,4
        bsf     DisBuf!12,0
        btfsc   Com2,5
        bsf     DisBuf!15,0
        btfsc   Com2,6
        bsf     DisBuf!18,0
        return
        end                
00000000  20 3b 4d 75 6c 74 69 70  6c 65 78 65 64 20 4c 45  | ;Multiplexed LE|
00000010  44 20 6d 61 74 72 69 78  20 64 69 73 70 6c 61 79  |D matrix display|
00000020  20 74 65 73 74 0a 20 3b  46 6f 72 20 61 6e 20 31  | test. ;For an 1|
00000030  30 20 4d 48 7a 20 63 6c  6f 63 6b 0a 20 3b 41 30  |0 MHz clock. ;A0|
00000040  20 2d 20 53 65 72 69 61  6c 20 6f 75 74 0a 20 3b  | - Serial out. ;|
00000050  41 31 20 2d 20 53 65 72  69 61 6c 20 69 6e 0a 20  |A1 - Serial in. |
00000060  3b 41 32 20 2d 20 43 54  53 20 61 6c 6c 6f 77 73  |;A2 - CTS allows|
00000070  20 73 65 72 69 61 6c 20  69 6e 70 75 74 0a 20 3b  | serial input. ;|
00000080  41 33 20 2d 20 52 54 53  20 6f 75 74 70 75 74 20  |A3 - RTS output |
00000090  68 65 6c 64 20 75 6e 74  69 6c 20 74 68 69 73 20  |held until this |
000000a0  69 73 20 6c 6f 77 0a 20  0a 20 3b 4e 6f 74 65 20  |is low. . ;Note |
000000b0  66 6f 72 20 31 36 46 38  34 20 69 6e 76 65 72 74  |for 16F84 invert|
000000c0  20 74 68 65 20 73 74 61  74 65 20 6f 66 20 74 68  | the state of th|
000000d0  65 20 50 57 52 54 45 0a  20 20 20 20 20 20 4c 49  |e PWRTE.      LI|
000000e0  53 54 20 50 3d 31 36 43  38 34 0a 20 20 20 20 20  |ST P=16C84.     |
000000f0  20 20 0a 20 0a 20 43 20  20 20 20 20 20 20 45 51  |  . . C       EQ|
00000100  55 20 20 20 20 20 30 0a  20 50 43 4c 20 20 20 20  |U     0. PCL    |
00000110  20 45 51 55 20 20 20 20  20 32 0a 20 5a 20 20 20  | EQU     2. Z   |
00000120  20 20 20 20 45 51 55 20  20 20 20 20 32 0a 20 50  |    EQU     2. P|
00000130  4f 52 54 42 20 20 20 45  51 55 20 20 20 20 20 36  |ORTB   EQU     6|
00000140  0a 20 50 4f 52 54 41 20  20 20 45 51 55 20 20 20  |. PORTA   EQU   |
00000150  20 20 35 0a 20 54 52 49  53 42 20 20 20 45 51 55  |  5. TRISB   EQU|
00000160  20 20 20 20 20 38 36 48  0a 20 54 52 49 53 41 20  |     86H. TRISA |
00000170  20 20 45 51 55 20 20 20  20 20 38 35 48 0a 20 45  |  EQU     85H. E|
00000180  45 43 4f 4e 31 20 20 45  51 55 20 20 20 20 20 38  |ECON1  EQU     8|
00000190  38 48 0a 20 45 45 44 41  54 41 20 20 45 51 55 20  |8H. EEDATA  EQU |
000001a0  20 20 20 20 38 0a 20 49  4e 54 43 4f 4e 20 20 45  |    8. INTCON  E|
000001b0  51 55 20 20 20 20 20 30  62 48 0a 20 45 45 41 44  |QU     0bH. EEAD|
000001c0  52 20 20 20 45 51 55 20  20 20 20 20 39 0a 20 53  |R   EQU     9. S|
000001d0  54 41 54 55 53 20 20 45  51 55 20 20 20 20 20 33  |TATUS  EQU     3|
000001e0  0a 20 52 50 30 20 20 20  20 20 45 51 55 20 20 20  |. RP0     EQU   |
000001f0  20 20 35 0a 20 49 4e 43  20 20 20 20 20 45 51 55  |  5. INC     EQU|
00000200  20 20 20 20 20 31 0a 20  63 74 73 20 20 20 20 20  |     1. cts     |
00000210  45 51 55 20 20 20 20 20  32 0a 20 72 74 73 20 20  |EQU     2. rts  |
00000220  20 20 20 45 51 55 20 20  20 20 20 33 0a 20 3b 20  |   EQU     3. ; |
00000230  4f 75 74 70 75 74 20 62  69 74 73 0a 20 63 64 61  |Output bits. cda|
00000240  74 20 20 20 20 45 51 55  20 20 20 20 20 31 20 20  |t    EQU     1  |
00000250  20 20 20 20 3b 43 6f 6c  6f 75 6d 20 64 61 74 61  |    ;Coloum data|
00000260  0a 20 63 63 6b 20 20 20  20 20 45 51 55 20 20 20  |. cck     EQU   |
00000270  20 20 32 20 20 20 20 20  20 3b 43 6f 6c 6f 75 6d  |  2      ;Coloum|
00000280  20 63 6c 6f 63 6b 0a 20  72 63 6c 72 20 20 20 20  | clock. rclr    |
00000290  45 51 55 20 20 20 20 20  33 20 20 20 20 20 20 3b  |EQU     3      ;|
000002a0  52 6f 77 20 63 6c 65 61  72 0a 20 72 63 6b 20 20  |Row clear. rck  |
000002b0  20 20 20 45 51 55 20 20  20 20 20 34 20 20 20 20  |   EQU     4    |
000002c0  20 20 3b 52 6f 77 20 63  6c 6f 63 6b 0a 20 72 64  |  ;Row clock. rd|
000002d0  61 74 20 20 20 20 45 51  55 20 20 20 20 20 35 20  |at    EQU     5 |
000002e0  20 20 20 20 20 3b 52 6f  77 20 64 61 74 61 0a 20  |     ;Row data. |
000002f0  0a 20 73 42 75 66 20 20  20 20 45 51 55 20 20 20  |. sBuf    EQU   |
00000300  20 30 63 68 20 20 20 20  20 3b 53 65 72 69 61 6c  | 0ch     ;Serial|
00000310  20 73 65 6e 64 20 62 75  66 66 65 72 0a 20 53 63  | send buffer. Sc|
00000320  6f 75 6e 74 20 20 45 51  55 20 20 20 20 30 64 68  |ount  EQU    0dh|
00000330  20 20 20 20 20 3b 54 65  6d 70 6f 72 79 20 43 6f  |     ;Tempory Co|
00000340  75 6e 74 65 72 0a 20 43  64 6f 77 6e 20 20 20 45  |unter. Cdown   E|
00000350  51 55 20 20 20 20 30 65  68 20 20 20 20 20 3b 54  |QU    0eh     ;T|
00000360  69 6d 65 20 64 65 6c 61  79 20 63 6f 75 6e 74 64  |ime delay countd|
00000370  6f 77 6e 0a 20 72 42 75  66 20 20 20 20 45 51 55  |own. rBuf    EQU|
00000380  20 20 20 20 30 66 68 20  20 20 20 20 3b 52 65 63  |    0fh     ;Rec|
00000390  69 65 76 65 20 62 75 66  66 65 72 0a 20 53 63 61  |ieve buffer. Sca|
000003a0  6e 4e 6f 20 20 45 51 55  20 20 20 20 31 30 68 20  |nNo  EQU    10h |
000003b0  20 20 20 20 3b 4e 75 6d  62 65 72 20 6f 66 20 72  |    ;Number of r|
000003c0  6f 77 20 77 65 20 61 72  65 20 6f 6e 0a 20 52 6f  |ow we are on. Ro|
000003d0  77 43 20 20 20 20 45 51  55 20 20 20 20 31 31 68  |wC    EQU    11h|
000003e0  20 20 20 20 20 3b 52 6f  77 20 63 6f 75 6e 74 65  |     ;Row counte|
000003f0  72 0a 20 53 73 74 6f 72  65 20 20 45 51 55 20 20  |r. Sstore  EQU  |
00000400  20 20 31 32 68 20 20 20  20 20 3b 53 63 72 6f 6c  |  12h     ;Scrol|
00000410  65 20 73 74 6f 72 65 0a  20 43 6f 6d 31 20 20 20  |e store. Com1   |
00000420  20 45 51 55 20 20 20 20  31 33 68 20 20 20 20 20  | EQU    13h     |
00000430  3b 43 6f 6d 6d 61 6e 64  20 31 0a 20 43 6f 6d 32  |;Command 1. Com2|
00000440  20 20 20 20 45 51 55 20  20 20 20 31 34 68 20 20  |    EQU    14h  |
00000450  20 20 20 3b 43 6f 6d 6d  61 6e 64 20 32 0a 20 73  |   ;Command 2. s|
00000460  61 76 65 5f 77 20 20 45  51 55 20 20 20 20 31 35  |ave_w  EQU    15|
00000470  68 20 20 20 20 20 3b 73  61 76 65 20 77 20 72 65  |h     ;save w re|
00000480  67 0a 20 73 61 76 65 5f  73 20 20 45 51 55 20 20  |g. save_s  EQU  |
00000490  20 20 31 36 48 20 20 20  20 20 3b 73 61 76 65 20  |  16H     ;save |
000004a0  73 74 61 74 75 73 0a 20  73 61 76 65 5f 70 20 20  |status. save_p  |
000004b0  45 51 55 20 20 20 20 31  37 68 20 20 20 20 20 3b  |EQU    17h     ;|
000004c0  73 61 76 65 20 70 6f 72  74 20 4c 45 44 73 0a 20  |save port LEDs. |
000004d0  44 69 73 42 75 66 20 20  45 51 55 20 20 20 20 31  |DisBuf  EQU    1|
000004e0  41 68 20 20 20 20 20 3b  44 69 73 70 6c 61 79 20  |Ah     ;Display |
000004f0  62 75 66 66 65 72 0a 20  0a 0a 3b 0a 20 20 20 4f  |buffer. ..;.   O|
00000500  52 47 20 30 0a 20 20 20  20 20 20 20 20 47 4f 54  |RG 0.        GOT|
00000510  4f 20 20 20 20 53 74 61  72 74 0a 20 20 4f 52 47  |O    Start.  ORG|
00000520  20 34 0a 20 20 20 20 20  20 20 20 6d 6f 76 77 66  | 4.        movwf|
00000530  20 20 20 73 61 76 65 5f  77 20 20 20 20 20 20 20  |   save_w       |
00000540  20 20 20 3b 73 61 76 65  20 77 20 61 6e 64 20 73  |   ;save w and s|
00000550  20 72 65 67 73 0a 20 20  20 20 20 20 20 20 73 77  | regs.        sw|
00000560  61 70 66 20 20 20 53 54  41 54 55 53 2c 77 20 20  |apf   STATUS,w  |
00000570  20 20 20 20 20 20 3b 73  77 61 70 66 20 64 6f 65  |      ;swapf doe|
00000580  73 6e 27 74 20 61 66 66  65 63 74 20 5a 20 6c 69  |sn't affect Z li|
00000590  6b 65 20 6d 6f 76 66 0a  20 20 20 20 20 20 20 20  |ke movf.        |
000005a0  6d 6f 76 77 66 20 20 20  73 61 76 65 5f 73 0a 20  |movwf   save_s. |
000005b0  20 20 20 20 20 20 20 6d  6f 76 66 20 20 20 20 50  |       movf    P|
000005c0  4f 52 54 42 2c 77 20 20  20 20 20 20 20 20 20 3b  |ORTB,w         ;|
000005d0  53 61 76 65 20 73 74 61  74 65 20 6f 66 20 4c 45  |Save state of LE|
000005e0  44 73 0a 20 20 20 20 20  20 20 20 6d 6f 76 77 66  |Ds.        movwf|
000005f0  20 20 20 73 61 76 65 5f  70 0a 20 20 20 20 20 20  |   save_p.      |
00000600  20 20 63 6c 72 66 20 20  20 20 50 4f 52 54 42 20  |  clrf    PORTB |
00000610  20 20 20 20 20 20 20 20  20 20 3b 54 75 72 6e 20  |          ;Turn |
00000620  4c 45 44 73 20 6f 66 66  0a 0a 20 20 20 20 20 20  |LEDs off..      |
00000630  20 20 63 61 6c 6c 20 20  20 20 52 78 20 20 20 20  |  call    Rx    |
00000640  20 20 20 20 20 20 20 20  20 20 3b 52 65 63 69 65  |          ;Recie|
00000650  76 65 20 62 79 74 65 0a  20 20 20 20 20 20 20 20  |ve byte.        |
00000660  69 6e 63 66 20 20 20 20  43 6f 6d 32 2c 66 20 20  |incf    Com2,f  |
00000670  20 20 20 20 20 20 20 20  3b 49 6e 63 72 65 6d 65  |        ;Increme|
00000680  6e 74 20 74 68 65 20 64  61 74 61 20 74 6f 20 70  |nt the data to p|
00000690  75 74 20 69 6e 0a 20 20  20 20 20 20 20 20 63 61  |ut in.        ca|
000006a0  6c 6c 20 20 20 20 73 6c  65 66 74 20 20 20 20 20  |ll    sleft     |
000006b0  20 20 20 20 20 20 3b 53  63 72 6f 6c 6c 20 6c 65  |      ;Scroll le|
000006c0  66 74 20 63 6f 6d 6d 61  6e 64 0a 0a 6f 75 74 20  |ft command..out |
000006d0  20 20 20 20 6d 6f 76 66  20 20 20 20 73 61 76 65  |    movf    save|
000006e0  5f 70 2c 77 0a 20 20 20  20 20 20 20 20 6d 6f 76  |_p,w.        mov|
000006f0  77 66 20 20 20 50 4f 52  54 42 20 20 20 20 20 20  |wf   PORTB      |
00000700  20 20 20 20 20 3b 54 75  72 6e 20 4c 45 44 73 20  |     ;Turn LEDs |
00000710  62 61 63 6b 20 6f 6e 20  20 20 20 20 20 20 20 0a  |back on        .|
00000720  20 20 20 20 20 20 20 20  73 77 61 70 66 20 20 20  |        swapf   |
00000730  73 61 76 65 5f 73 2c 77  0a 20 20 20 20 20 20 20  |save_s,w.       |
00000740  20 6d 6f 76 77 66 20 20  20 53 54 41 54 55 53 20  | movwf   STATUS |
00000750  20 20 20 20 20 20 20 20  20 3b 20 72 65 73 74 6f  |         ; resto|
00000760  72 65 20 72 65 67 69 73  74 65 72 73 0a 20 20 20  |re registers.   |
00000770  20 20 20 20 20 73 77 61  70 66 20 20 20 73 61 76  |     swapf   sav|
00000780  65 5f 77 2c 66 0a 20 20  20 20 20 20 20 20 73 77  |e_w,f.        sw|
00000790  61 70 66 20 20 20 73 61  76 65 5f 77 2c 77 0a 20  |apf   save_w,w. |
000007a0  20 20 20 20 20 20 20 62  63 66 20 20 20 20 20 49  |       bcf     I|
000007b0  4e 54 43 4f 4e 2c 31 20  20 20 20 20 20 20 20 3b  |NTCON,1        ;|
000007c0  43 6c 65 61 72 20 65 64  67 65 20 69 6e 74 65 72  |Clear edge inter|
000007d0  72 75 70 74 0a 20 20 20  20 20 20 20 20 72 65 74  |rupt.        ret|
000007e0  66 69 65 0a 0a 20 20 20  20 20 20 20 20 20 20 20  |fie..           |
000007f0  20 20 0a 3b 52 65 63 69  65 76 65 20 61 20 73 65  |  .;Recieve a se|
00000800  72 69 61 6c 20 62 79 74  65 0a 52 78 20 20 20 20  |rial byte.Rx    |
00000810  20 20 6d 6f 76 6c 77 20  20 20 38 20 20 20 20 20  |  movlw   8     |
00000820  20 20 20 20 20 20 20 20  20 20 3b 4e 75 6d 62 65  |          ;Numbe|
00000830  72 20 6f 66 20 64 61 74  61 20 62 69 74 73 20 74  |r of data bits t|
00000840  6f 20 67 65 74 0a 20 20  20 20 20 20 20 20 6d 6f  |o get.        mo|
00000850  76 77 66 20 20 20 53 63  6f 75 6e 74 0a 53 62 20  |vwf   Scount.Sb |
00000860  20 20 20 20 20 62 74 66  73 63 20 20 20 50 4f 52  |     btfsc   POR|
00000870  54 41 2c 31 20 20 20 20  20 20 20 20 20 3b 48 6f  |TA,1         ;Ho|
00000880  6c 64 20 75 6e 74 69 6c  20 73 74 61 72 74 20 62  |ld until start b|
00000890  69 74 0a 20 20 20 20 20  20 20 20 67 6f 74 6f 20  |it.        goto |
000008a0  20 20 20 53 62 0a 20 20  20 20 20 20 20 20 63 61  |   Sb.        ca|
000008b0  6c 6c 20 20 20 20 68 44  65 6c 61 79 20 20 20 20  |ll    hDelay    |
000008c0  20 20 20 20 20 20 3b 48  61 6c 66 20 61 20 62 61  |      ;Half a ba|
000008d0  75 64 20 64 65 6c 61 79  0a 52 6e 62 20 20 20 20  |ud delay.Rnb    |
000008e0  20 62 63 66 20 20 20 20  20 53 54 41 54 55 53 2c  | bcf     STATUS,|
000008f0  43 20 20 20 20 20 20 20  20 3b 43 6c 65 61 72 20  |C        ;Clear |
00000900  74 68 65 20 63 61 72 72  79 20 62 69 74 0a 20 20  |the carry bit.  |
00000910  20 20 20 20 20 20 72 72  66 20 20 20 20 20 72 42  |      rrf     rB|
00000920  75 66 2c 66 20 20 20 20  20 20 20 20 20 20 3b 50  |uf,f          ;P|
00000930  72 65 70 61 72 65 20 66  6f 72 20 6e 65 78 74 20  |repare for next |
00000940  62 69 74 20 20 0a 20 20  20 20 20 20 20 20 63 61  |bit  .        ca|
00000950  6c 6c 20 20 20 20 72 44  65 6c 61 79 20 20 20 20  |ll    rDelay    |
00000960  20 20 20 20 20 20 3b 46  75 6c 6c 20 62 61 75 64  |      ;Full baud|
00000970  20 64 65 6c 61 79 20 66  6f 72 20 72 65 63 69 65  | delay for recie|
00000980  76 65 0a 20 20 20 20 20  20 20 20 62 74 66 73 63  |ve.        btfsc|
00000990  20 20 20 50 4f 52 54 41  2c 31 20 20 20 20 20 20  |   PORTA,1      |
000009a0  20 20 20 3b 54 65 73 74  20 69 6e 70 75 74 0a 20  |   ;Test input. |
000009b0  20 20 20 20 20 20 20 62  73 66 20 20 20 20 20 72  |       bsf     r|
000009c0  42 75 66 2c 37 20 20 20  20 20 20 20 20 20 20 3b  |Buf,7          ;|
000009d0  53 65 74 20 69 66 20 6e  65 65 64 65 64 0a 20 20  |Set if needed.  |
000009e0  20 20 20 20 20 20 64 65  63 66 73 7a 20 20 53 63  |      decfsz  Sc|
000009f0  6f 75 6e 74 2c 66 20 20  20 20 20 20 20 20 3b 53  |ount,f        ;S|
00000a00  65 65 20 69 66 20 66 69  6e 69 73 68 65 64 0a 20  |ee if finished. |
00000a10  20 20 20 20 20 20 20 67  6f 74 6f 20 20 20 20 52  |       goto    R|
00000a20  6e 62 20 20 20 20 20 20  20 20 20 20 20 20 20 3b  |nb             ;|
00000a30  52 6f 75 6e 64 20 61 67  61 69 6e 20 69 66 20 6e  |Round again if n|
00000a40  6f 74 0a 20 20 20 20 20  20 20 20 63 61 6c 6c 20  |ot.        call |
00000a50  20 20 20 72 44 65 6c 61  79 20 20 20 20 20 20 20  |   rDelay       |
00000a60  20 20 20 3b 41 6c 6c 6f  77 20 66 6f 72 20 73 74  |   ;Allow for st|
00000a70  6f 70 20 62 69 74 20 74  6f 20 73 74 61 72 74 0a  |op bit to start.|
00000a80  20 20 20 20 20 20 20 20  6d 6f 76 66 20 20 20 20  |        movf    |
00000a90  72 42 75 66 2c 77 20 20  20 20 20 20 20 20 20 20  |rBuf,w          |
00000aa0  3b 50 75 74 20 72 65 63  69 65 76 65 64 20 63 68  |;Put recieved ch|
00000ab0  72 61 63 74 6f 72 20 69  6e 74 6f 20 57 0a 20 20  |ractor into W.  |
00000ac0  20 20 20 20 20 20 72 65  74 75 72 6e 0a 20 20 20  |      return.   |
00000ad0  20 20 20 20 20 0a 0a 3b  53 65 6e 64 20 61 20 73  |     ..;Send a s|
00000ae0  65 72 69 61 6c 20 62 79  74 65 0a 53 65 6e 64 20  |erial byte.Send |
00000af0  20 20 20 62 74 66 73 63  20 20 20 50 4f 52 54 41  |   btfsc   PORTA|
00000b00  2c 72 74 73 20 20 20 20  20 20 20 3b 4f 6e 6c 79  |,rts       ;Only|
00000b10  20 70 72 6f 63 65 65 64  20 77 68 65 6e 20 72 74  | proceed when rt|
00000b20  73 20 69 73 20 6c 6f 77  0a 20 20 20 20 20 20 20  |s is low.       |
00000b30  20 67 6f 74 6f 20 20 20  20 53 65 6e 64 0a 20 20  | goto    Send.  |
00000b40  20 20 20 20 20 20 6d 6f  76 6c 77 20 20 20 39 20  |      movlw   9 |
00000b50  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 4e  |              ;N|
00000b60  75 6d 62 65 72 20 6f 66  20 64 61 74 61 20 62 69  |umber of data bi|
00000b70  74 73 20 74 6f 20 73 65  6e 64 0a 20 20 20 20 20  |ts to send.     |
00000b80  20 20 20 6d 6f 76 77 66  20 20 20 53 63 6f 75 6e  |   movwf   Scoun|
00000b90  74 0a 20 20 20 20 20 20  20 20 62 63 66 20 20 20  |t.        bcf   |
00000ba0  20 20 50 4f 52 54 41 2c  30 20 20 20 20 20 20 20  |  PORTA,0       |
00000bb0  20 20 3b 53 74 61 72 74  20 62 69 74 0a 20 20 20  |  ;Start bit.   |
00000bc0  20 20 20 20 20 63 61 6c  6c 20 20 20 20 63 44 65  |     call    cDe|
00000bd0  6c 61 79 20 20 20 20 20  20 20 20 20 20 3b 45 78  |lay          ;Ex|
00000be0  74 72 61 20 64 65 6c 61  79 20 63 6f 6d 70 65 6e  |tra delay compen|
00000bf0  73 61 74 69 6f 6e 0a 53  6c 6f 6f 70 20 20 20 63  |sation.Sloop   c|
00000c00  61 6c 6c 20 20 20 20 44  65 6c 61 79 0a 20 20 20  |all    Delay.   |
00000c10  20 20 20 20 20 62 74 66  73 63 20 20 20 73 42 75  |     btfsc   sBu|
00000c20  66 2c 30 20 20 20 20 20  20 20 20 20 20 3b 53 65  |f,0          ;Se|
00000c30  74 20 74 68 65 20 6e 65  78 74 20 62 69 74 0a 20  |t the next bit. |
00000c40  20 20 20 20 20 20 20 62  73 66 20 20 20 20 20 50  |       bsf     P|
00000c50  4f 52 54 41 2c 30 0a 20  20 20 20 20 20 20 20 62  |ORTA,0.        b|
00000c60  74 66 73 73 20 20 20 73  42 75 66 2c 30 0a 20 20  |tfss   sBuf,0.  |
00000c70  20 20 20 20 20 20 62 63  66 20 20 20 20 20 50 4f  |      bcf     PO|
00000c80  52 54 41 2c 30 0a 20 20  20 20 20 20 20 20 72 72  |RTA,0.        rr|
00000c90  66 20 20 20 20 20 73 42  75 66 2c 66 20 20 20 20  |f     sBuf,f    |
00000ca0  20 20 20 20 20 20 3b 53  68 69 66 74 20 66 6f 72  |      ;Shift for|
00000cb0  20 6e 65 78 74 20 74 69  6d 65 0a 20 20 20 20 20  | next time.     |
00000cc0  20 20 20 64 65 63 66 73  7a 20 20 53 63 6f 75 6e  |   decfsz  Scoun|
00000cd0  74 2c 66 0a 20 20 20 20  20 20 20 20 67 6f 74 6f  |t,f.        goto|
00000ce0  20 20 20 20 53 6c 6f 6f  70 20 20 20 20 20 20 20  |    Sloop       |
00000cf0  20 20 20 20 3b 52 6f 75  6e 64 20 75 6e 74 69 6c  |    ;Round until|
00000d00  20 66 69 6e 69 73 68 65  64 0a 20 20 20 20 20 20  | finished.      |
00000d10  20 20 62 73 66 20 20 20  20 20 50 4f 52 54 41 2c  |  bsf     PORTA,|
00000d20  30 20 20 20 20 20 20 20  20 20 3b 53 74 6f 70 20  |0         ;Stop |
00000d30  62 69 74 0a 20 20 20 20  20 20 20 20 63 61 6c 6c  |bit.        call|
00000d40  20 20 20 20 63 44 65 6c  61 79 20 20 20 20 20 20  |    cDelay      |
00000d50  20 20 20 20 3b 45 78 74  72 61 20 64 65 6c 61 79  |    ;Extra delay|
00000d60  20 63 6f 6d 70 65 6e 73  61 74 69 6f 6e 0a 20 20  | compensation.  |
00000d70  20 20 20 20 20 20 63 61  6c 6c 20 20 20 20 44 65  |      call    De|
00000d80  6c 61 79 0a 20 20 20 20  20 20 20 20 63 61 6c 6c  |lay.        call|
00000d90  20 20 20 20 44 65 6c 61  79 0a 20 20 20 20 20 20  |    Delay.      |
00000da0  20 20 63 61 6c 6c 20 20  20 20 63 44 65 6c 61 79  |  call    cDelay|
00000db0  20 20 20 20 20 20 20 20  20 20 3b 46 6f 72 20 67  |          ;For g|
00000dc0  6f 6f 64 20 6d 65 61 73  75 72 65 0a 20 20 20 20  |ood measure.    |
00000dd0  20 20 20 20 72 65 74 75  72 6e 0a 20 20 20 20 20  |    return.     |
00000de0  20 20 20 0a 63 44 65 6c  61 79 20 20 6d 6f 76 6c  |   .cDelay  movl|
00000df0  77 20 20 20 32 20 20 20  20 20 20 20 20 20 20 20  |w   2           |
00000e00  20 20 20 20 3b 53 6d 61  6c 6c 20 64 65 6c 61 79  |    ;Small delay|
00000e10  20 61 74 20 65 6e 64 20  6f 66 20 73 65 6e 64 0a  | at end of send.|
00000e20  20 20 20 20 20 20 20 20  6d 6f 76 77 66 20 20 20  |        movwf   |
00000e30  43 64 6f 77 6e 20 20 20  20 20 20 20 20 20 20 20  |Cdown           |
00000e40  0a 20 20 20 20 20 20 20  20 67 6f 74 6f 20 20 20  |.        goto   |
00000e50  20 44 6c 6f 6f 70 0a 20  20 20 20 20 20 20 20 0a  | Dloop.        .|
00000e60  68 44 65 6c 61 79 20 20  6d 6f 76 6c 77 20 20 20  |hDelay  movlw   |
00000e70  32 31 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |21              |
00000e80  3b 68 61 6c 66 20 64 65  6c 61 79 20 66 6f 72 20  |;half delay for |
00000e90  73 65 72 69 61 6c 20 72  65 63 69 65 76 65 20 31  |serial recieve 1|
00000ea0  30 4d 48 7a 20 63 6c 6f  63 6b 0a 20 20 20 20 20  |0MHz clock.     |
00000eb0  20 20 20 6d 6f 76 77 66  20 20 20 43 64 6f 77 6e  |   movwf   Cdown|
00000ec0  20 20 20 20 20 20 20 20  20 20 20 3b 20 31 39 2c  |           ; 19,|
00000ed0  32 30 30 20 42 61 75 64  20 72 61 74 65 0a 20 20  |200 Baud rate.  |
00000ee0  20 20 20 20 20 20 67 6f  74 6f 20 20 20 20 44 6c  |      goto    Dl|
00000ef0  6f 6f 70 0a 20 20 20 20  20 20 20 20 0a 72 44 65  |oop.        .rDe|
00000f00  6c 61 79 20 20 6d 6f 76  6c 77 20 20 20 33 38 20  |lay  movlw   38 |
00000f10  20 20 20 20 20 20 20 20  20 20 20 20 20 3b 44 65  |             ;De|
00000f20  6c 61 79 20 66 6f 72 20  73 65 72 69 61 6c 20 72  |lay for serial r|
00000f30  65 63 69 65 76 65 20 31  30 4d 48 7a 20 63 6c 6f  |ecieve 10MHz clo|
00000f40  63 6b 0a 20 20 20 20 20  20 20 20 6d 6f 76 77 66  |ck.        movwf|
00000f50  20 20 20 43 64 6f 77 6e  20 20 20 20 20 20 20 20  |   Cdown        |
00000f60  20 20 20 3b 20 31 39 2c  32 30 30 20 42 61 75 64  |   ; 19,200 Baud|
00000f70  20 72 61 74 65 0a 20 20  20 20 20 20 20 20 67 6f  | rate.        go|
00000f80  74 6f 20 20 20 20 44 6c  6f 6f 70 0a 20 20 20 20  |to    Dloop.    |
00000f90  20 20 20 20 0a 44 65 6c  61 79 20 20 20 6d 6f 76  |    .Delay   mov|
00000fa0  6c 77 20 20 20 33 39 20  20 20 20 20 20 20 20 20  |lw   39         |
00000fb0  20 20 20 20 20 3b 44 65  6c 61 79 20 66 6f 72 20  |     ;Delay for |
00000fc0  73 65 72 69 61 6c 20 73  65 6e 64 20 31 30 4d 48  |serial send 10MH|
00000fd0  7a 20 63 6c 6f 63 6b 0a  20 20 20 20 20 20 20 20  |z clock.        |
00000fe0  6d 6f 76 77 66 20 20 20  43 64 6f 77 6e 20 20 20  |movwf   Cdown   |
00000ff0  20 20 20 20 20 20 20 20  3b 20 31 39 2c 32 30 30  |        ; 19,200|
00001000  20 42 61 75 64 20 72 61  74 65 0a 44 6c 6f 6f 70  | Baud rate.Dloop|
00001010  20 20 20 64 65 63 66 73  7a 20 20 43 64 6f 77 6e  |   decfsz  Cdown|
00001020  2c 66 0a 20 20 20 20 20  20 20 20 67 6f 74 6f 20  |,f.        goto |
00001030  20 20 20 44 6c 6f 6f 70  0a 20 20 20 20 20 20 20  |   Dloop.       |
00001040  20 72 65 74 75 72 6e 0a  20 20 20 20 20 20 20 20  | return.        |
00001050  0a 0a 53 74 61 72 74 0a  20 20 20 20 20 20 20 20  |..Start.        |
00001060  42 53 46 20 20 20 20 20  53 54 41 54 55 53 2c 52  |BSF     STATUS,R|
00001070  50 30 20 20 20 20 20 20  3b 53 45 4c 45 43 54 20  |P0      ;SELECT |
00001080  52 45 47 49 53 54 45 52  20 42 41 4e 4b 20 31 0a  |REGISTER BANK 1.|
00001090  20 20 20 20 20 20 20 20  4d 4f 56 4c 57 20 20 20  |        MOVLW   |
000010a0  31 41 68 20 20 20 20 20  20 20 20 20 20 20 20 20  |1Ah             |
000010b0  3b 42 69 74 73 20 34 2c  33 20 26 20 32 20 69 6e  |;Bits 4,3 & 2 in|
000010c0  70 75 74 73 0a 20 20 20  20 20 20 20 20 4d 4f 56  |puts.        MOV|
000010d0  57 46 20 20 20 54 52 49  53 41 5e 38 30 48 0a 20  |WF   TRISA^80H. |
000010e0  20 20 20 20 20 20 20 4d  4f 56 4c 57 20 20 20 31  |       MOVLW   1|
000010f0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 3b  |               ;|
00001100  42 69 74 20 30 20 69 6e  70 75 74 20 72 65 73 74  |Bit 0 input rest|
00001110  20 6f 75 74 70 75 74 73  0a 20 20 20 20 20 20 20  | outputs.       |
00001120  20 4d 4f 56 57 46 20 20  20 54 52 49 53 42 5e 38  | MOVWF   TRISB^8|
00001130  30 48 0a 20 20 20 20 20  20 20 20 4d 4f 56 4c 57  |0H.        MOVLW|
00001140  20 20 20 33 20 20 20 20  20 20 20 20 20 20 20 20  |   3            |
00001150  20 20 20 3b 31 36 20 70  72 65 73 63 61 6c 65 72  |   ;16 prescaler|
00001160  20 2d 76 65 20 65 64 67  65 20 69 6e 74 65 72 72  | -ve edge interr|
00001170  75 70 74 0a 20 20 20 20  20 20 20 20 4d 4f 56 57  |upt.        MOVW|
00001180  46 20 20 20 31 20 20 20  20 20 20 20 20 20 20 20  |F   1           |
00001190  20 20 20 20 3b 4f 70 74  69 6f 6e 20 72 65 67 69  |    ;Option regi|
000011a0  73 74 65 72 0a 20 20 20  20 20 20 20 20 4d 4f 56  |ster.        MOV|
000011b0  4c 57 20 20 20 39 30 48  20 20 20 20 20 20 20 20  |LW   90H        |
000011c0  20 20 20 20 20 3b 45 6e  61 62 6c 65 20 62 69 74  |     ;Enable bit|
000011d0  20 30 20 69 6e 74 65 72  72 75 70 74 0a 20 20 20  | 0 interrupt.   |
000011e0  20 20 20 20 20 4d 4f 56  57 46 20 20 20 49 4e 54  |     MOVWF   INT|
000011f0  43 4f 4e 0a 0a 20 20 20  20 20 20 20 20 42 43 46  |CON..        BCF|
00001200  20 20 20 20 20 53 54 41  54 55 53 2c 52 50 30 20  |     STATUS,RP0 |
00001210  20 20 20 20 20 3b 53 45  4c 45 43 54 20 52 45 47  |     ;SELECT REG|
00001220  49 53 54 45 52 20 42 41  4e 4b 20 30 0a 20 20 20  |ISTER BANK 0.   |
00001230  20 20 20 20 20 0a 20 20  20 20 20 20 20 20 42 53  |     .        BS|
00001240  46 20 20 20 20 20 50 4f  52 54 41 2c 30 20 20 20  |F     PORTA,0   |
00001250  20 20 20 20 20 20 3b 53  65 72 69 61 6c 20 61 74  |      ;Serial at|
00001260  20 4d 61 72 6b 0a 20 20  20 20 20 20 20 20 42 43  | Mark.        BC|
00001270  46 20 20 20 20 20 50 4f  52 54 41 2c 63 74 73 20  |F     PORTA,cts |
00001280  20 20 20 20 20 20 3b 43  54 53 20 65 6e 61 62 6c  |      ;CTS enabl|
00001290  65 64 0a 20 20 20 20 20  20 20 20 43 4c 52 46 20  |ed.        CLRF |
000012a0  20 20 20 50 4f 52 54 42  0a 20 20 20 20 20 20 20  |   PORTB.       |
000012b0  20 43 4c 52 46 20 20 20  20 53 63 61 6e 4e 6f 0a  | CLRF    ScanNo.|
000012c0  20 20 20 20 20 20 20 20  43 4c 52 46 20 20 20 20  |        CLRF    |
000012d0  43 6f 6d 32 0a 20 20 20  20 20 20 20 20 0a 3b 4a  |Com2.        .;J|
000012e0  75 73 74 20 70 75 74 20  73 6f 6d 65 20 74 65 73  |ust put some tes|
000012f0  74 20 64 61 74 61 20 69  6e 74 6f 20 73 6f 6d 65  |t data into some|
00001300  20 6d 65 6d 6f 72 79 0a  20 20 20 20 20 20 20 20  | memory.        |
00001310  6d 6f 76 6c 77 20 20 20  30 41 41 68 0a 20 20 20  |movlw   0AAh.   |
00001320  20 20 20 20 20 6d 6f 76  77 66 20 20 20 20 44 69  |     movwf    Di|
00001330  73 42 75 66 0a 20 20 20  20 20 20 20 20 6d 6f 76  |sBuf.        mov|
00001340  77 66 20 20 20 20 44 69  73 42 75 66 21 31 0a 20  |wf    DisBuf!1. |
00001350  20 20 20 20 20 20 20 6d  6f 76 77 66 20 20 20 20  |       movwf    |
00001360  44 69 73 42 75 66 21 32  0a 20 20 20 20 20 20 20  |DisBuf!2.       |
00001370  20 0a 20 20 20 20 20 20  20 20 6d 6f 76 77 66 20  | .        movwf |
00001380  20 20 20 44 69 73 42 75  66 21 36 0a 20 20 20 20  |   DisBuf!6.    |
00001390  20 20 20 20 6d 6f 76 77  66 20 20 20 20 44 69 73  |    movwf    Dis|
000013a0  42 75 66 21 37 0a 20 20  20 20 20 20 20 20 6d 6f  |Buf!7.        mo|
000013b0  76 77 66 20 20 20 20 44  69 73 42 75 66 21 38 0a  |vwf    DisBuf!8.|
000013c0  20 20 20 20 20 20 20 20  0a 20 20 20 20 20 20 20  |        .       |
000013d0  20 6d 6f 76 77 66 20 20  20 20 44 69 73 42 75 66  | movwf    DisBuf|
000013e0  21 31 32 0a 20 20 20 20  20 20 20 20 6d 6f 76 77  |!12.        movw|
000013f0  66 20 20 20 20 44 69 73  42 75 66 21 31 33 0a 20  |f    DisBuf!13. |
00001400  20 20 20 20 20 20 20 6d  6f 76 77 66 20 20 20 20  |       movwf    |
00001410  44 69 73 42 75 66 21 31  34 0a 20 20 20 20 20 20  |DisBuf!14.      |
00001420  20 20 0a 20 20 20 20 20  20 20 20 6d 6f 76 77 66  |  .        movwf|
00001430  20 20 20 20 44 69 73 42  75 66 21 31 38 0a 20 20  |    DisBuf!18.  |
00001440  20 20 20 20 20 20 6d 6f  76 77 66 20 20 20 20 44  |      movwf    D|
00001450  69 73 42 75 66 21 31 39  0a 20 20 20 20 20 20 20  |isBuf!19.       |
00001460  20 6d 6f 76 77 66 20 20  20 20 44 69 73 42 75 66  | movwf    DisBuf|
00001470  21 32 30 0a 0a 20 20 20  20 20 20 20 20 6d 6f 76  |!20..        mov|
00001480  6c 77 20 20 20 30 35 35  68 0a 20 20 20 20 20 20  |lw   055h.      |
00001490  20 20 6d 6f 76 77 66 20  20 20 20 44 69 73 42 75  |  movwf    DisBu|
000014a0  66 21 33 0a 20 20 20 20  20 20 20 20 6d 6f 76 77  |f!3.        movw|
000014b0  66 20 20 20 20 44 69 73  42 75 66 21 34 0a 20 20  |f    DisBuf!4.  |
000014c0  20 20 20 20 20 20 6d 6f  76 77 66 20 20 20 20 44  |      movwf    D|
000014d0  69 73 42 75 66 21 35 0a  20 20 20 20 20 20 20 20  |isBuf!5.        |
000014e0  0a 20 20 20 20 20 20 20  20 6d 6f 76 77 66 20 20  |.        movwf  |
000014f0  20 20 44 69 73 42 75 66  21 39 0a 20 20 20 20 20  |  DisBuf!9.     |
00001500  20 20 20 6d 6f 76 77 66  20 20 20 20 44 69 73 42  |   movwf    DisB|
00001510  75 66 21 31 30 0a 20 20  20 20 20 20 20 20 6d 6f  |uf!10.        mo|
00001520  76 77 66 20 20 20 20 44  69 73 42 75 66 21 31 31  |vwf    DisBuf!11|
00001530  0a 20 20 20 20 20 20 20  20 0a 20 20 20 20 20 20  |.        .      |
00001540  20 20 6d 6f 76 77 66 20  20 20 20 44 69 73 42 75  |  movwf    DisBu|
00001550  66 21 31 35 0a 20 20 20  20 20 20 20 20 6d 6f 76  |f!15.        mov|
00001560  77 66 20 20 20 20 44 69  73 42 75 66 21 31 36 0a  |wf    DisBuf!16.|
00001570  20 20 20 20 20 20 20 20  6d 6f 76 77 66 20 20 20  |        movwf   |
00001580  20 44 69 73 42 75 66 21  31 37 0a 20 20 0a 4d 61  | DisBuf!17.  .Ma|
00001590  69 6e 20 20 20 20 62 74  66 73 73 20 20 20 30 62  |in    btfss   0b|
000015a0  68 2c 32 20 20 20 20 20  20 20 20 20 20 20 3b 54  |h,2           ;T|
000015b0  65 73 74 20 74 69 6d 65  72 0a 20 20 20 20 20 20  |est timer.      |
000015c0  20 20 47 4f 54 4f 20 20  20 20 4d 61 69 6e 20 20  |  GOTO    Main  |
000015d0  20 20 20 20 20 20 20 20  20 20 3b 4c 6f 6f 70 20  |          ;Loop |
000015e0  75 6e 74 69 6c 20 74 69  6d 65 0a 20 20 20 20 20  |until time.     |
000015f0  20 20 20 62 63 66 20 20  20 20 20 30 62 68 2c 32  |   bcf     0bh,2|
00001600  20 20 20 20 20 20 20 20  20 20 20 3b 43 6c 65 61  |           ;Clea|
00001610  72 20 69 74 20 66 6f 72  20 6e 65 78 74 20 74 69  |r it for next ti|
00001620  6d 65 0a 20 20 20 20 20  20 20 20 69 6e 63 66 20  |me.        incf |
00001630  20 20 20 53 63 61 6e 4e  6f 2c 66 0a 20 20 20 20  |   ScanNo,f.    |
00001640  20 20 20 20 6d 6f 76 6c  77 20 20 20 37 20 20 20  |    movlw   7   |
00001650  20 20 20 20 20 20 20 20  20 20 20 20 3b 53 65 65  |            ;See|
00001660  20 69 66 20 69 74 20 69  73 20 61 74 20 65 6e 64  | if it is at end|
00001670  0a 20 20 20 20 20 20 20  20 73 75 62 77 66 20 20  |.        subwf  |
00001680  20 53 63 61 6e 4e 6f 2c  77 0a 20 20 20 20 20 20  | ScanNo,w.      |
00001690  20 20 62 74 66 73 63 20  20 20 53 54 41 54 55 53  |  btfsc   STATUS|
000016a0  2c 5a 20 20 20 20 20 20  20 20 3b 57 72 61 70 20  |,Z        ;Wrap |
000016b0  69 74 20 72 6f 75 6e 64  20 61 66 74 65 72 20 37  |it round after 7|
000016c0  0a 20 20 20 20 20 20 20  20 63 6c 72 66 20 20 20  |.        clrf   |
000016d0  20 53 63 61 6e 4e 6f 0a  20 20 20 20 20 20 20 20  | ScanNo.        |
000016e0  63 61 6c 6c 20 20 20 20  73 63 61 6e 20 0a 20 20  |call    scan .  |
000016f0  20 20 20 20 20 20 47 4f  54 4f 20 20 20 20 4d 61  |      GOTO    Ma|
00001700  69 6e 0a 20 20 20 20 20  20 20 20 0a 73 63 61 6e  |in.        .scan|
00001710  20 20 20 20 63 6c 72 66  20 20 20 20 50 4f 52 54  |    clrf    PORT|
00001720  42 20 20 20 20 20 20 20  20 20 20 20 3b 20 42 6c  |B           ; Bl|
00001730  61 6e 6b 20 6f 75 74 20  72 6f 77 0a 20 20 20 20  |ank out row.    |
00001740  20 20 20 20 62 63 66 20  20 20 20 20 53 54 41 54  |    bcf     STAT|
00001750  55 53 2c 43 0a 20 20 20  20 20 20 20 20 72 6c 66  |US,C.        rlf|
00001760  20 20 20 20 20 53 63 61  6e 4e 6f 2c 77 20 20 20  |     ScanNo,w   |
00001770  20 20 20 20 20 3b 53 63  61 6e 20 4e 6f 20 2a 20  |     ;Scan No * |
00001780  33 20 2b 20 44 69 73 42  75 66 20 3d 20 72 65 67  |3 + DisBuf = reg|
00001790  20 61 64 64 72 65 73 73  0a 20 20 20 20 20 20 20  | address.       |
000017a0  20 61 64 64 77 66 20 20  20 53 63 61 6e 4e 6f 2c  | addwf   ScanNo,|
000017b0  77 0a 20 20 20 20 20 20  20 20 61 64 64 6c 77 20  |w.        addlw |
000017c0  20 20 44 69 73 42 75 66  0a 20 20 20 20 20 20 20  |  DisBuf.       |
000017d0  20 6d 6f 76 77 66 20 20  20 34 20 20 20 20 20 20  | movwf   4      |
000017e0  20 20 20 20 20 20 20 20  20 3b 74 6f 20 69 6e 64  |         ;to ind|
000017f0  69 72 65 63 74 20 72 65  67 69 73 74 65 72 0a 20  |irect register. |
00001800  20 20 20 20 20 20 20 63  61 6c 6c 20 20 20 20 72  |       call    r|
00001810  62 6f 75 74 20 20 20 20  20 20 20 20 20 20 20 3b  |bout           ;|
00001820  4f 75 74 70 75 74 20 66  69 72 73 74 20 62 79 74  |Output first byt|
00001830  65 0a 20 20 20 20 20 20  20 20 69 6e 63 66 20 20  |e.        incf  |
00001840  20 20 34 2c 66 20 20 20  20 20 20 20 20 20 20 20  |  4,f           |
00001850  20 20 3b 4e 65 78 74 20  62 79 74 65 0a 20 20 20  |  ;Next byte.   |
00001860  20 20 20 20 20 63 61 6c  6c 20 20 20 20 72 62 6f  |     call    rbo|
00001870  75 74 0a 20 20 20 20 20  20 20 20 69 6e 63 66 20  |ut.        incf |
00001880  20 20 20 34 2c 66 20 20  20 20 20 20 20 20 20 20  |   4,f          |
00001890  20 20 20 3b 4c 61 73 74  20 62 79 74 65 0a 20 20  |   ;Last byte.  |
000018a0  20 20 20 20 20 20 63 61  6c 6c 20 20 20 20 68 72  |      call    hr|
000018b0  6f 75 74 0a 20 20 20 20  20 20 20 20 6d 6f 76 66  |out.        movf|
000018c0  20 20 20 20 53 63 61 6e  4e 6f 2c 77 0a 20 20 20  |    ScanNo,w.   |
000018d0  20 20 20 20 20 6d 6f 76  77 66 20 20 20 52 6f 77  |     movwf   Row|
000018e0  43 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 52  |C             ;R|
000018f0  6f 77 20 43 6f 75 6e 74  0a 20 20 20 20 20 20 20  |ow Count.       |
00001900  20 69 6e 63 66 20 20 20  20 52 6f 77 43 2c 66 20  | incf    RowC,f |
00001910  20 20 20 20 20 20 20 20  20 20 3b 4f 6e 65 20 6d  |          ;One m|
00001920  6f 72 65 20 70 75 6c 73  65 0a 20 20 20 20 20 20  |ore pulse.      |
00001930  20 20 62 63 66 20 20 20  20 20 53 54 41 54 55 53  |  bcf     STATUS|
00001940  2c 43 0a 20 20 20 20 20  20 20 20 72 6c 66 20 20  |,C.        rlf  |
00001950  20 20 20 52 6f 77 43 2c  66 0a 20 20 20 20 20 20  |   RowC,f.      |
00001960  20 20 72 6c 66 20 20 20  20 20 52 6f 77 43 2c 66  |  rlf     RowC,f|
00001970  0a 20 20 20 20 20 20 20  20 72 6c 66 20 20 20 20  |.        rlf    |
00001980  20 52 6f 77 43 2c 77 0a  20 20 20 20 20 20 20 20  | RowC,w.        |
00001990  6d 6f 76 77 66 20 20 20  50 4f 52 54 42 0a 20 20  |movwf   PORTB.  |
000019a0  20 20 20 20 20 20 72 65  74 75 72 6e 0a 20 20 20  |      return.   |
000019b0  20 20 20 20 20 0a 68 72  6f 75 74 20 20 20 6d 6f  |     .hrout   mo|
000019c0  76 6c 77 20 20 20 34 20  20 20 20 20 20 20 20 20  |vlw   4         |
000019d0  20 20 20 20 20 20 3b 4f  6e 6c 79 20 34 20 62 69  |      ;Only 4 bi|
000019e0  74 73 20 6f 75 74 0a 20  20 20 20 20 20 20 20 47  |ts out.        G|
000019f0  4f 54 4f 20 20 20 20 68  65 20 20 20 20 20 20 20  |OTO    he       |
00001a00  20 0a 72 62 6f 75 74 20  20 20 6d 6f 76 6c 77 20  | .rbout   movlw |
00001a10  20 20 38 20 20 20 20 20  20 20 20 20 20 20 20 20  |  8             |
00001a20  20 20 3b 6e 75 6d 62 65  72 20 6f 66 20 73 68 69  |  ;number of shi|
00001a30  66 74 73 20 74 6f 20 64  6f 0a 68 65 20 20 20 20  |fts to do.he    |
00001a40  20 20 6d 6f 76 77 66 20  20 20 52 6f 77 43 20 20  |  movwf   RowC  |
00001a50  20 20 20 20 20 20 20 20  20 20 3b 73 68 69 66 74  |          ;shift|
00001a60  20 73 74 6f 72 65 0a 20  20 20 20 20 20 20 20 6d  | store.        m|
00001a70  6f 76 66 20 20 20 20 30  2c 77 20 20 20 20 20 20  |ovf    0,w      |
00001a80  20 20 20 20 20 20 20 3b  67 65 74 20 62 79 74 65  |       ;get byte|
00001a90  20 74 6f 20 73 65 6e 64  0a 20 20 20 20 20 20 20  | to send.       |
00001aa0  20 6d 6f 76 77 66 20 20  20 53 73 74 6f 72 65 20  | movwf   Sstore |
00001ab0  20 20 20 20 20 20 20 20  20 3b 73 74 6f 72 65 20  |         ;store |
00001ac0  69 74 0a 72 6c 6f 6f 70  20 20 20 72 72 66 20 20  |it.rloop   rrf  |
00001ad0  20 20 20 53 73 74 6f 72  65 2c 66 20 20 20 20 20  |   Sstore,f     |
00001ae0  20 20 20 3b 67 65 74 20  6e 65 78 74 20 62 69 74  |   ;get next bit|
00001af0  20 69 6e 74 6f 20 63 61  72 72 79 0a 20 20 20 20  | into carry.    |
00001b00  20 20 20 20 62 63 66 20  20 20 20 20 50 4f 52 54  |    bcf     PORT|
00001b10  42 2c 63 64 61 74 20 20  20 20 20 20 3b 47 65 74  |B,cdat      ;Get|
00001b20  20 64 61 74 61 20 6c 69  6e 65 20 72 69 67 68 74  | data line right|
00001b30  0a 20 20 20 20 20 20 20  20 62 74 66 73 63 20 20  |.        btfsc  |
00001b40  20 53 54 41 54 55 53 2c  43 0a 20 20 20 20 20 20  | STATUS,C.      |
00001b50  20 20 62 73 66 20 20 20  20 20 50 4f 52 54 42 2c  |  bsf     PORTB,|
00001b60  63 64 61 74 0a 20 20 20  20 20 20 20 20 62 73 66  |cdat.        bsf|
00001b70  20 20 20 20 20 50 4f 52  54 42 2c 63 63 6b 20 20  |     PORTB,cck  |
00001b80  20 20 20 20 20 3b 54 6f  67 67 6c 65 20 63 6c 6f  |     ;Toggle clo|
00001b90  63 6b 0a 20 20 20 20 20  20 20 20 62 63 66 20 20  |ck.        bcf  |
00001ba0  20 20 20 50 4f 52 54 42  2c 63 63 6b 0a 20 20 20  |   PORTB,cck.   |
00001bb0  20 20 20 20 20 64 65 63  66 73 7a 20 20 52 6f 77  |     decfsz  Row|
00001bc0  43 2c 66 20 20 20 20 20  20 20 20 20 20 3b 41 6c  |C,f          ;Al|
00001bd0  6c 20 62 69 74 73 20 64  6f 6e 65 3f 0a 20 20 20  |l bits done?.   |
00001be0  20 20 20 20 20 47 4f 54  4f 20 20 20 20 72 6c 6f  |     GOTO    rlo|
00001bf0  6f 70 0a 20 20 20 20 20  20 20 20 72 65 74 75 72  |op.        retur|
00001c00  6e 0a 20 20 20 20 20 20  20 20 0a 3b 43 6f 6d 6d  |n.        .;Comm|
00001c10  61 6e 64 73 0a 20 20 20  20 20 20 20 20 0a 73 6c  |ands.        .sl|
00001c20  65 66 74 20 20 20 6d 6f  76 6c 77 20 20 20 44 69  |eft   movlw   Di|
00001c30  73 42 75 66 20 20 20 20  20 20 20 20 20 20 3b 53  |sBuf          ;S|
00001c40  63 72 6f 6c 6c 20 6d 65  6d 6f 72 79 20 6c 65 66  |croll memory lef|
00001c50  74 0a 20 20 20 20 20 20  20 20 6d 6f 76 77 66 20  |t.        movwf |
00001c60  20 20 34 20 20 20 20 20  20 20 20 20 20 20 20 20  |  4             |
00001c70  20 20 3b 69 6e 74 6f 20  69 6e 64 69 72 65 63 74  |  ;into indirect|
00001c80  20 72 65 67 69 73 74 65  72 0a 20 20 20 20 20 20  | register.      |
00001c90  20 20 6d 6f 76 6c 77 20  20 20 37 20 20 20 20 20  |  movlw   7     |
00001ca0  20 20 20 20 20 20 20 20  20 20 3b 4e 75 6d 62 65  |          ;Numbe|
00001cb0  72 20 6f 66 20 72 6f 77  73 20 74 6f 20 73 63 72  |r of rows to scr|
00001cc0  6f 6c 6c 0a 20 20 20 20  20 20 20 20 6d 6f 76 77  |oll.        movw|
00001cd0  66 20 20 20 73 42 75 66  20 20 20 20 20 20 20 20  |f   sBuf        |
00001ce0  20 20 20 20 3b 54 65 6d  70 20 73 74 6f 72 61 67  |    ;Temp storag|
00001cf0  65 0a 20 20 20 20 20 20  20 20 62 63 66 20 20 20  |e.        bcf   |
00001d00  20 20 53 54 41 54 55 53  2c 43 0a 73 6c 6c 6f 6f  |  STATUS,C.slloo|
00001d10  70 20 20 72 6c 66 20 20  20 20 20 30 2c 66 20 20  |p  rlf     0,f  |
00001d20  20 20 20 20 20 20 20 20  20 20 20 3b 4d 6f 76 65  |           ;Move|
00001d30  20 66 69 72 73 74 20 62  79 74 65 0a 20 20 20 20  | first byte.    |
00001d40  20 20 20 20 69 6e 63 66  20 20 20 20 34 2c 66 0a  |    incf    4,f.|
00001d50  20 20 20 20 20 20 20 20  72 6c 66 20 20 20 20 20  |        rlf     |
00001d60  30 2c 66 20 20 20 20 20  20 20 20 20 20 20 20 20  |0,f             |
00001d70  3b 4d 6f 76 65 20 73 65  63 6f 6e 64 20 62 79 74  |;Move second byt|
00001d80  65 0a 20 20 20 20 20 20  20 20 69 6e 63 66 20 20  |e.        incf  |
00001d90  20 20 34 2c 66 0a 20 20  20 20 20 20 20 20 72 6c  |  4,f.        rl|
00001da0  66 20 20 20 20 20 30 2c  66 20 20 20 20 20 20 20  |f     0,f       |
00001db0  20 20 20 20 20 20 3b 4d  6f 76 65 20 6c 61 73 74  |      ;Move last|
00001dc0  20 62 79 74 65 0a 20 20  20 20 20 20 20 20 62 63  | byte.        bc|
00001dd0  66 20 20 20 20 20 30 2c  34 20 20 20 20 20 20 20  |f     0,4       |
00001de0  20 20 20 20 20 20 3b 42  6c 61 6e 6b 20 62 69 74  |      ;Blank bit|
00001df0  20 66 61 6c 6c 65 6e 20  6f 66 66 20 74 68 65 20  | fallen off the |
00001e00  65 6e 64 0a 20 20 20 20  20 20 20 20 69 6e 63 66  |end.        incf|
00001e10  20 20 20 20 34 2c 66 20  20 20 20 20 20 20 20 20  |    4,f         |
00001e20  20 20 20 20 3b 4d 6f 76  65 20 6f 6e 20 66 6f 72  |    ;Move on for|
00001e30  20 6e 65 78 74 20 74 69  6d 65 0a 20 20 20 20 20  | next time.     |
00001e40  20 20 20 64 65 63 66 73  7a 20 20 73 42 75 66 2c  |   decfsz  sBuf,|
00001e50  66 20 20 20 20 20 20 20  20 20 20 3b 4c 6f 6f 70  |f          ;Loop|
00001e60  20 75 6e 74 69 6c 20 61  6c 6c 20 37 20 72 6f 77  | until all 7 row|
00001e70  73 20 61 72 65 20 6f 75  74 0a 20 20 20 20 20 20  |s are out.      |
00001e80  20 20 67 6f 74 6f 20 20  20 20 73 6c 6c 6f 6f 70  |  goto    slloop|
00001e90  0a 20 20 20 20 20 20 20  20 62 74 66 73 63 20 20  |.        btfsc  |
00001ea0  20 43 6f 6d 32 2c 30 20  20 20 20 20 20 20 20 20  | Com2,0         |
00001eb0  20 3b 4e 6f 77 20 70 75  74 20 6e 65 77 20 64 61  | ;Now put new da|
00001ec0  74 61 20 69 6e 0a 20 20  20 20 20 20 20 20 62 73  |ta in.        bs|
00001ed0  66 20 20 20 20 20 44 69  73 42 75 66 2c 30 0a 20  |f     DisBuf,0. |
00001ee0  20 20 20 20 20 20 20 62  74 66 73 63 20 20 20 43  |       btfsc   C|
00001ef0  6f 6d 32 2c 31 0a 20 20  20 20 20 20 20 20 62 73  |om2,1.        bs|
00001f00  66 20 20 20 20 20 44 69  73 42 75 66 21 33 2c 30  |f     DisBuf!3,0|
00001f10  0a 20 20 20 20 20 20 20  20 62 74 66 73 63 20 20  |.        btfsc  |
00001f20  20 43 6f 6d 32 2c 32 0a  20 20 20 20 20 20 20 20  | Com2,2.        |
00001f30  62 73 66 20 20 20 20 20  44 69 73 42 75 66 21 36  |bsf     DisBuf!6|
00001f40  2c 30 0a 20 20 20 20 20  20 20 20 62 74 66 73 63  |,0.        btfsc|
00001f50  20 20 20 43 6f 6d 32 2c  33 0a 20 20 20 20 20 20  |   Com2,3.      |
00001f60  20 20 62 73 66 20 20 20  20 20 44 69 73 42 75 66  |  bsf     DisBuf|
00001f70  21 39 2c 30 0a 20 20 20  20 20 20 20 20 62 74 66  |!9,0.        btf|
00001f80  73 63 20 20 20 43 6f 6d  32 2c 34 0a 20 20 20 20  |sc   Com2,4.    |
00001f90  20 20 20 20 62 73 66 20  20 20 20 20 44 69 73 42  |    bsf     DisB|
00001fa0  75 66 21 31 32 2c 30 0a  20 20 20 20 20 20 20 20  |uf!12,0.        |
00001fb0  62 74 66 73 63 20 20 20  43 6f 6d 32 2c 35 0a 20  |btfsc   Com2,5. |
00001fc0  20 20 20 20 20 20 20 62  73 66 20 20 20 20 20 44  |       bsf     D|
00001fd0  69 73 42 75 66 21 31 35  2c 30 0a 20 20 20 20 20  |isBuf!15,0.     |
00001fe0  20 20 20 62 74 66 73 63  20 20 20 43 6f 6d 32 2c  |   btfsc   Com2,|
00001ff0  36 0a 20 20 20 20 20 20  20 20 62 73 66 20 20 20  |6.        bsf   |
00002000  20 20 44 69 73 42 75 66  21 31 38 2c 30 0a 20 20  |  DisBuf!18,0.  |
00002010  20 20 20 20 20 20 72 65  74 75 72 6e 0a 20 20 20  |      return.   |
00002020  20 20 20 20 20 65 6e 64  20 20 20 20 20 20 20 20  |     end        |
00002030  20 20 20 20 20 20 20 20  0a                       |        .|
00002039