changeset 2546:f0977fc3f2d6

Added code for Gary's CoCo3FPGA interface
author boisy
date Sat, 12 Jun 2010 11:59:39 +0000
parents cb2bec98a11d
children 141cfa8a4302
files level1/modules/dwread.asm level1/modules/dwwrite.asm
diffstat 2 files changed, 106 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/level1/modules/dwread.asm	Sun May 30 22:58:04 2010 +0000
+++ b/level1/modules/dwread.asm	Sat Jun 12 11:59:39 2010 +0000
@@ -18,6 +18,51 @@
 *
 
 
+          IFNE BECKER
+DWRead    clra                          ; clear Carry (no framing error)
+          deca                          ; clear Z flag, A = timeout msb ($ff)
+          tfr       cc,b
+          pshs      u,x,b,a          ; preserve registers, push timeout msb
+          orcc      #$50                ; mask interrupts
+;          tfr       a,dp                ; set direct page to $FFxx
+;          setdp     $ff
+          leau      ,x                  ; U = storage ptr
+          ldx       #0                  ; initialize checksum
+          adda      #2                  ; A = $01 (serial in mask), set Carry
+
+* Wait for byte or timeout
+rx0010    bcc       rxExit              ; exit if timeout expired
+          ldb       #$ff                ; init timeout lsb
+rx0020    lda       $FF41               ; check for byte ready
+          bita      #$01
+          bne       rxByte              ; branch if start bit detected
+          subb      #1                  ; decrement timeout lsb
+          bcc       rx0020              ; loop until timeout lsb rolls under
+          beq       rxByte
+          addb      ,s                  ; B = timeout msb - 1
+          stb       ,s                  ; store decremented timeout msb
+          bra       rx0010              ; loop if still no start bit
+
+* Read a byte
+rxByte    ldb       $FF42
+
+          stb       ,u+                 ; store received byte to memory
+          abx                           ; update checksum
+          ldb       #$ff                ; set timeout lsb for next byte
+          leay      ,y                  ; test request count
+          bne       rx0020              ; loop if another byte wanted
+          lda       #$03                ; setup to return SUCCESS
+
+* Clean up, set status and return
+rxExit    leas      1,s                 ; remove timeout msb from stack
+          inca                          ; A = status to be returned in C and Z
+          ora       ,s                  ; place status information into the..
+          sta       ,s                  ; ..C and Z bits of the preserved CC
+          leay      ,x                  ; return checksum in Y
+          puls      cc,x,u,pc        ; restore registers and return
+;          setdp     $00
+
+          ELSE
           IFNE BAUD38400
 *******************************************************
 * 38400 bps using 6809 code and timimg
@@ -240,5 +285,4 @@
 
           ENDC
           ENDC
-
-
+          ENDC
--- a/level1/modules/dwwrite.asm	Sun May 30 22:58:04 2010 +0000
+++ b/level1/modules/dwwrite.asm	Sat Jun 12 11:59:39 2010 +0000
@@ -16,6 +16,65 @@
 *
 
 
+          IFNE BECKER
+DWWrite   pshs      u,d,cc              ; preserve registers
+          orcc      #$50                ; mask interrupts
+;          ldu       #BBOUT              ; point U to bit banger out register
+;          lda       3,u                 ; read PIA 1-B control register
+;          anda      #$f7                ; clear sound enable bit
+;          sta       3,u                 ; disable sound output
+;          fcb       $8c                 ; skip next instruction
+
+txByte    
+          lda       ,x+                
+          sta       $FF42
+          leay      -1,y                ; decrement byte counter
+          bne       txByte              ; loop if more to send
+
+          puls      cc,d,u,pc           ; restore registers and return
+
+
+          ELSE
+          IFNE H6309-1
+*******************************************************
+* 57600 (115200) bps using 6809 code and timimg
+*******************************************************
+
+DWWrite   pshs      dp,d,cc             ; preserve registers
+          orcc      #$50                ; mask interrupts
+          ldd       #$04ff              ; A = loop counter, B = $ff
+          tfr       b,dp                ; set direct page to $FFxx
+          setdp     $ff
+          ldb       <$ff23              ; read PIA 1-B control register
+          andb      #$f7                ; clear sound enable bit
+          stb       <$ff23              ; disable sound output
+          fcb       $8c                 ; skip next instruction
+
+txByte    stb       <BBOUT              ; send stop bit
+          ldb       ,x+                 ; get a byte to transmit
+          nop
+          lslb                          ; left rotate the byte two positions..
+          rolb                          ; ..placing a zero (start bit) in bit 1
+tx0020    stb       <BBOUT              ; send bit (start bit, d1, d3, d5)
+          rorb                          ; move next bit into position
+          exg       a,a
+          nop
+          stb       <BBOUT              ; send bit (d0, d2, d4, d6)
+          rorb                          ; move next bit into position
+          leau      ,u
+          deca                          ; decrement loop counter
+          bne       tx0020              ; loop until 7th data bit has been sent
+
+          stb       <BBOUT              ; send bit 7
+          ldd       #$0402              ; A = loop counter, B = MARK value
+          leay      ,-y                 ; decrement byte counter
+          bne       txByte              ; loop if more to send
+
+          stb       <BBOUT              ; leave bit banger output at MARK
+          puls      cc,d,dp,pc          ; restore registers and return
+          setdp     $00
+
+          ELSE
           IFNE BAUD38400
 *******************************************************
 * 38400 bps using 6809 code and timimg
@@ -130,5 +189,4 @@
 
           ENDC
           ENDC
-
-
+          ENDC