Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/dwread.asm @ 2711:a1e65a5ef4cf lwtools-port
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
author | Boisy Pitre <boisy.pitre@nuance.com> |
---|---|
date | Tue, 24 Jul 2012 10:09:58 -0500 (2012-07-24) |
parents | 963688cd0596 |
children | 8399491c0821 |
rev | line source |
---|---|
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
1 ******************************************************* |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
2 * |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
3 * DWRead |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
4 * Receive a response from the DriveWire server. |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
5 * Times out if serial port goes idle for more than 1.4 (0.7) seconds. |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
6 * Serial data format: 1-8-N-1 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
7 * 4/12/2009 by Darren Atkinson |
2182 | 8 * |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
9 * Entry: |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
10 * X = starting address where data is to be stored |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
11 * Y = number of bytes expected |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
12 * |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
13 * Exit: |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
14 * CC = carry set on framing error, Z set if all bytes received |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
15 * X = starting address of data received |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
16 * Y = checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
17 * U is preserved. All accumulators are clobbered |
2182 | 18 * |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
19 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
20 |
2711
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
21 IFNE atari |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
22 * ATARI SIO Version |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
23 DWRead |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
24 clrb clear carry |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
25 pshs cc,a,x,y,u |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
26 tfr x,u |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
27 ldx #$0000 |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
28 orcc #$50 |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
29 * lda D.IRQENSHDW |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
30 * sta IRQEN |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
31 * ora #%00100000 |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
32 * enable the serial input interrupt |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
33 |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
34 ldb SERIN read what is in the buffer |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
35 lda #$13 |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
36 sta SKCTL |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
37 sta SKRES |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
38 |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
39 inloop@ |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
40 lda D.IRQENSHDW |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
41 ora #%00100000 |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
42 sta IRQEN |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
43 ldd #$0000 |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
44 loop@ |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
45 subd #$0001 |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
46 beq outtahere@ |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
47 pshs b |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
48 ldb IRQST |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
49 bitb #%00100000 |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
50 puls b |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
51 bne loop@ |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
52 ldb SERIN |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
53 lda D.IRQENSHDW |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
54 sta IRQEN |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
55 * check for framing error |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
56 lda SKSTAT |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
57 bpl outtahere@ framing error |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
58 lsla |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
59 bpl outtahere@ data input overrun |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
60 stb ,u+ |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
61 abx |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
62 leay -1,y |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
63 bne inloop@ |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
64 stx 4,s |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
65 bye |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
66 sta SKRES clear framing or data input overrun bits |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
67 puls cc,a,x,y,u,pc |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
68 outtahere@ |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
69 sta SKRES clear framing or data input overrun bits |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
70 puls cc,a |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
71 stx 2,s |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
72 orcc #$01 |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
73 puls x,y,u,pc |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
74 |
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
75 ELSE |
2546 | 76 IFNE BECKER |
2711
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
77 |
2551 | 78 * NOTE: There is no timeout currently on here... |
79 DWRead pshs cc,d,x,u | |
80 leau ,x | |
81 ldx #$0000 | |
82 orcc #IntMasks | |
83 loop@ ldb $FF41 | |
84 bitb #$02 | |
85 beq loop@ | |
86 ldb $FF42 | |
87 stb ,u+ | |
88 abx | |
89 leay -1,y | |
90 bne loop@ | |
2546 | 91 |
2551 | 92 tfr x,y |
93 puls cc | |
94 andcc #^Carry | |
95 orcc #Zero | |
96 puls d,x,u,pc | |
2546 | 97 |
98 ELSE | |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
99 IFNE BAUD38400 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
100 ******************************************************* |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
101 * 38400 bps using 6809 code and timimg |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
102 ******************************************************* |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
103 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
104 DWRead clra ; clear Carry (no framing error) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
105 deca ; clear Z flag, A = timeout msb ($ff) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
106 tfr cc,b |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
107 pshs u,x,dp,b,a ; preserve registers, push timeout msb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
108 orcc #$50 ; mask interrupts |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
109 tfr a,dp ; set direct page to $FFxx |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
110 setdp $ff |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
111 leau ,x ; U = storage ptr |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
112 ldx #0 ; initialize checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
113 adda #2 ; A = $01 (serial in mask), set Carry |
2182 | 114 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
115 * Wait for a start bit or timeout |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
116 rx0010 bcc rxExit ; exit if timeout expired |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
117 ldb #$ff ; init timeout lsb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
118 rx0020 bita <BBIN ; check for start bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
119 beq rxByte ; branch if start bit detected |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
120 subb #1 ; decrement timeout lsb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
121 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
122 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
123 bcc rx0020 ; loop until timeout lsb rolls under |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
124 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
125 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
126 addb ,s ; B = timeout msb - 1 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
127 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
128 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
129 stb ,s ; store decremented timeout msb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
130 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
131 bne rx0010 ; loop if still no start bit |
2182 | 132 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
133 * Read a byte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
134 rxByte leay ,-y ; decrement request count |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
135 ldd #$ff80 ; A = timeout msb, B = shift counter |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
136 sta ,s ; reset timeout msb for next byte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
137 rx0030 exg a,a |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
138 nop |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
139 lda <BBIN ; read data bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
140 lsra ; shift into carry |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
141 rorb ; rotate into byte accumulator |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
142 lda #$01 ; prep stop bit mask |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
143 bcc rx0030 ; loop until all 8 bits read |
2182 | 144 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
145 stb ,u+ ; store received byte to memory |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
146 abx ; update checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
147 ldb #$ff ; set timeout lsb for next byte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
148 anda <BBIN ; read stop bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
149 beq rxExit ; exit if framing error |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
150 leay ,y ; test request count |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
151 bne rx0020 ; loop if another byte wanted |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
152 lda #$03 ; setup to return SUCCESS |
2182 | 153 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
154 * Clean up, set status and return |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
155 rxExit leas 1,s ; remove timeout msb from stack |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
156 inca ; A = status to be returned in C and Z |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
157 ora ,s ; place status information into the.. |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
158 sta ,s ; ..C and Z bits of the preserved CC |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
159 leay ,x ; return checksum in Y |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
160 puls cc,dp,x,u,pc ; restore registers and return |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
161 setdp $00 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
162 |
2182 | 163 |
164 ELSE | |
165 IFNE H6309-1 | |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
166 ******************************************************* |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
167 * 57600 (115200) bps using 6809 code and timimg |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
168 ******************************************************* |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
169 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
170 DWRead clra ; clear Carry (no framing error) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
171 deca ; clear Z flag, A = timeout msb ($ff) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
172 tfr cc,b |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
173 pshs u,x,dp,b,a ; preserve registers, push timeout msb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
174 orcc #$50 ; mask interrupts |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
175 tfr a,dp ; set direct page to $FFxx |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
176 setdp $ff |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
177 leau ,x ; U = storage ptr |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
178 ldx #0 ; initialize checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
179 lda #$01 ; A = serial in mask |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
180 bra rx0030 ; go wait for start bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
181 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
182 * Read a byte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
183 rxByte leau 1,u ; bump storage ptr |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
184 leay ,-y ; decrement request count |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
185 lda <BBIN ; read bit 0 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
186 lsra ; move bit 0 into Carry |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
187 ldd #$ff20 ; A = timeout msb, B = shift counter |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
188 sta ,s ; reset timeout msb for next byte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
189 rorb ; rotate bit 0 into byte accumulator |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
190 rx0010 lda <BBIN ; read bit (d1, d3, d5) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
191 lsra |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
192 rorb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
193 bita 1,s ; 5 cycle delay |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
194 bcs rx0020 ; exit loop after reading bit 5 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
195 lda <BBIN ; read bit (d2, d4) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
196 lsra |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
197 rorb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
198 leau ,u |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
199 bra rx0010 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
200 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
201 rx0020 lda <BBIN ; read bit 6 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
202 lsra |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
203 rorb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
204 leay ,y ; test request count |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
205 beq rx0050 ; branch if final byte of request |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
206 lda <BBIN ; read bit 7 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
207 lsra |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
208 rorb ; byte is now complete |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
209 stb -1,u ; store received byte to memory |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
210 abx ; update checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
211 lda <BBIN ; read stop bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
212 anda #$01 ; mask out other bits |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
213 beq rxExit ; exit if framing error |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
214 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
215 * Wait for a start bit or timeout |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
216 rx0030 bita <BBIN ; check for start bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
217 beq rxByte ; branch if start bit detected |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
218 bita <BBIN ; again |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
219 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
220 ldb #$ff ; init timeout lsb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
221 rx0040 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
222 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
223 subb #1 ; decrement timeout lsb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
224 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
225 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
226 bcc rx0040 ; loop until timeout lsb rolls under |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
227 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
228 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
229 addb ,s ; B = timeout msb - 1 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
230 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
231 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
232 stb ,s ; store decremented timeout msb |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
233 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
234 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
235 bcs rx0030 ; loop if timeout hasn't expired |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
236 bra rxExit ; exit due to timeout |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
237 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
238 rx0050 lda <BBIN ; read bit 7 of final byte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
239 lsra |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
240 rorb ; byte is now complete |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
241 stb -1,u ; store received byte to memory |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
242 abx ; calculate final checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
243 lda <BBIN ; read stop bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
244 anda #$01 ; mask out other bits |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
245 ora #$02 ; return SUCCESS if no framing error |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
246 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
247 * Clean up, set status and return |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
248 rxExit leas 1,s ; remove timeout msb from stack |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
249 inca ; A = status to be returned in C and Z |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
250 ora ,s ; place status information into the.. |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
251 sta ,s ; ..C and Z bits of the preserved CC |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
252 leay ,x ; return checksum in Y |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
253 puls cc,dp,x,u,pc ; restore registers and return |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
254 setdp $00 |
2180 | 255 |
256 | |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
257 ELSE |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
258 ******************************************************* |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
259 * 57600 (115200) bps using 6309 native mode |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
260 ******************************************************* |
2180 | 261 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
262 DWRead clrb ; clear Carry (no framing error) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
263 decb ; clear Z flag, B = $FF |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
264 pshs u,x,dp,cc ; preserve registers |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
265 orcc #$50 ; mask interrupts |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
266 * ldmd #1 ; requires 6309 native mode |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
267 tfr b,dp ; set direct page to $FFxx |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
268 setdp $ff |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
269 leay -1,y ; adjust request count |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
270 leau ,x ; U = storage ptr |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
271 tfr 0,x ; initialize checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
272 lda #$01 ; A = serial in mask |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
273 bra rx0030 ; go wait for start bit |
2180 | 274 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
275 * Read a byte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
276 rxByte sexw ; 4 cycle delay |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
277 ldw #$006a ; shift counter and timing flags |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
278 clra ; clear carry so next will branch |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
279 rx0010 bcc rx0020 ; branch if even bit number (15 cycles) |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
280 nop ; extra (16th) cycle |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
281 rx0020 lda <BBIN ; read bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
282 lsra ; move bit into carry |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
283 rorb ; rotate bit into byte accumulator |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
284 lda #0 ; prep A for 8th data bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
285 lsrw ; bump shift count, timing bit to carry |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
286 bne rx0010 ; loop until 7th data bit has been read |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
287 incw ; W = 1 for subtraction from Y |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
288 inca ; A = 1 for reading bit 7 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
289 anda <BBIN ; read bit 7 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
290 lsra ; move bit 7 into carry, A = 0 |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
291 rorb ; byte is now complete |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
292 stb ,u+ ; store received byte to memory |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
293 abx ; update checksum |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
294 subr w,y ; decrement request count |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
295 inca ; A = 1 for reading stop bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
296 anda <BBIN ; read stop bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
297 bls rxExit ; exit if completed or framing error |
2180 | 298 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
299 * Wait for a start bit or timeout |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
300 rx0030 clrw ; initialize timeout counter |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
301 rx0040 bita <BBIN ; check for start bit |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
302 beq rxByte ; branch if start bit detected |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
303 addw #1 ; bump timeout counter |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
304 bita <BBIN |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
305 beq rxByte |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
306 bcc rx0040 ; loop until timeout rolls over |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
307 lda #$03 ; setup to return TIMEOUT status |
2180 | 308 |
2231
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
309 * Clean up, set status and return |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
310 rxExit beq rx0050 ; branch if framing error |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
311 eora #$02 ; toggle SUCCESS flag |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
312 rx0050 inca ; A = status to be returned in C and Z |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
313 ora ,s ; place status information into the.. |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
314 sta ,s ; ..C and Z bits of the preserved CC |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
315 leay ,x ; return checksum in Y |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
316 puls cc,dp,x,u,pc ; restore registers and return |
27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
boisy
parents:
2182
diff
changeset
|
317 setdp $00 |
2180 | 318 |
2182 | 319 ENDC |
320 ENDC | |
2546 | 321 ENDC |
2711
a1e65a5ef4cf
Moved Atari SIO read/write routines into main dwread.asm and dwwrite.asm
Boisy Pitre <boisy.pitre@nuance.com>
parents:
2551
diff
changeset
|
322 ENDC |