annotate bootman/llio_6551.a @ 2163:2db06bc0742a

Start of BootMan
author boisy
date Tue, 20 May 2008 14:43:00 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2163
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
1 NAM llio_coco3
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
2 TTL CoCo 3 low-level I/O handler
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
3
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
4 PSECT llio_coco3,0,0,0,0,llio
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
5
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
6 VSECT
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
7 ENDSECT
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
8
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
9 llio:
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
10 lbsr llinit
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
11 lbsr llread
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
12 lbsr llwrite
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
13 lbsr llterm
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
14
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
15 ********** I/O ROUTINES **********
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
16
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
17 * 6551 Parameters
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
18 ADDR EQU $FF68
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
19
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
20 A_RXD EQU ADDR+$00
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
21 A_TXD EQU ADDR+$00
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
22 A_STATUS EQU ADDR+$01
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
23 A_RESET EQU ADDR+$01
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
24 A_CMD EQU ADDR+$02
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
25 A_CTRL EQU ADDR+$03
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
26
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
27 * Baud rates
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
28 _B2400 EQU $1A 2400 bps, 8-N-1
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
29 _B4800 EQU $1C 4800 bps, 8-N-1
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
30 _B9600 EQU $1E 9600 bps, 8-N-1
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
31 _B19200 EQU $1F 19200 bps, 8-N-1
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
32
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
33 BAUD EQU _B9600
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
34
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
35 * ll_init - Initialize the low-level I/O
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
36 * Exit: Carry = 0: Init success; Carry = 1; Init failed
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
37 llinit
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
38 sta A_RESET soft reset (value not important)
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
39 * Set specific modes and functions:
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
40 * - no parity, no echo, no Tx interrupt
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
41 * - no Rx interrupt, enable Tx/Rx
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
42 lda #$0B
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
43 sta A_CMD save to command register
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
44 lda #BAUD
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
45 sta A_CTRL select proper baud rate
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
46 * Read any junk rx byte that may be in the register
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
47 lda A_RXD
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
48 rts
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
49
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
50
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
51 * llread - Read one character from 6551
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
52 *
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
53 * Entry: None
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
54 * Exit: A = character that was read
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
55 *
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
56 * Note, this routine currently doesn't timeout
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
57 llread
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
58 r lda A_STATUS get status byte
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
59 anda #$08 mask rx buffer status flag
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
60 beq r loop if rx buffer empty
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
61 lda A_RXD get byte from ACIA data port
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
62 rts
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
63
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
64 * llwrite - Write one character to 6551
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
65 *
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
66 * Entry: A = character to write
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
67 * Exit: None
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
68 llwrite
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
69 pshs a save byte to write
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
70 w lda A_STATUS get status byte
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
71 anda #$10 mask tx buffer status flag
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
72 beq w loop if tx buffer full
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
73 puls a get byte
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
74 sta A_TXD save to ACIA data port
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
75 rts
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
76
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
77
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
78 llterm
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
79 rts
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
80
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
81 IFNE 0
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
82 * llwout - Write an entire string
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
83 * llwerr - Write an entire string
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
84 llwerr
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
85 llwout
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
86 pshs a
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
87 l@ lda ,x+
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
88 cmpa #C$CR
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
89 beq e@
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
90 leay -1,y
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
91 beq f@
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
92 bsr Write
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
93 bra l@
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
94 e@ bsr Write
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
95 lda #C$LF
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
96 bsr Write
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
97 f@ ldx <buffptr
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
98 clrb
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
99 puls a,pc
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
100
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
101 * ReadLine - Read an entire string, up to CR
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
102 * Entry: X = address to place string being read (CR terminated)
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
103 * Y = maximum number of bytes to read (including nul byte)
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
104 ReadLine
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
105 ldx <buffptr
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
106 pshs y,x,a
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
107 ldy #80
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
108 l@ bsr Read read 1 character
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
109 cmpa #C$CR carriage return?
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
110 beq e@ branch if so...
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
111 cmpa #$08 backspace?
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
112 beq bs@
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
113 cmpy #$0000 anymore room?
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
114 beq l@
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
115 leay -1,y back up one char
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
116 sta ,x+ and save in input buffer
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
117 m@ bsr Write echo back out
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
118 bra l@
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
119 e@ sta ,x
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
120 bsr Write
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
121 lda #C$LF
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
122 bsr Write
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
123 clrb
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
124 puls a,x,y,pc
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
125 bs@ cmpx 1,s are we at start
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
126 beq l@ if so, do nothing
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
127 clr ,-x else erase last byte
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
128 lbsr Write write backspace
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
129 lda #C$SPAC a space...
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
130 lbsr Write write it
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
131 leay 1,y count back up free char
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
132 lda #$08 another backspace
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
133 bra m@
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
134 ENDC
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
135
2db06bc0742a Start of BootMan
boisy
parents:
diff changeset
136 endsect