annotate 3rdparty/p2mods/noice/noice.asm @ 1995:2bb2f8b975b0

additional preliminary changes made by R. Gault
author boisy
date Sun, 19 Feb 2006 15:09:42 +0000
parents d5e3d4f5c45a
children abf447bacf71
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
1 ********************************************************************
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
2 * KrnP3 - NoICE Serial Debugger for 6809/6309
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
3 *
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
4 * $Id$
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
5 *
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
6 * This module is called by the kernel at boot time and initializes itself
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
7 * by creating a new system call: os9 F$Debug
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
8 *
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
9 * The process that called the F$Debug system call is the one that will
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
10 * be debugged.
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
11 *
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
12 * Using the NoICE serial protocol, the debugger can talk to a host, and can be
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
13 * driven by simple commands to read/write registers and memory, and continue
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
14 * execution.
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
15 *
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
16 * Notes:
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
17 * o The NoICE protocol specifies a 'page' byte in addition to the
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
18 * 16-bit memory address when reading/writing memory. We currently
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
19 * ignore this page, and I cannot think of a need for this.
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
20 *
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
21 * o The 6309 is now a supported processor under the Windows version
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
22 * of NoICE. Its processor ID is 17.
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
23 *
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
24 * Edt/Rev YYYY/MM/DD Modified by
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
25 * Comment
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
26 * ------------------------------------------------------------------
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
27 * 1 2005/04/03 Boisy G. Pitre
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
28 * Started
1990
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
29 *
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
30 * 2 2006/02/02 Boisy G. Pitre
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
31 * Added USERSTATE flag to allow module to debug current process or
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
32 * system.
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
33
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
34 NAM KrnP3
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
35 TTL NoICE Serial Debugger for 6809/6309
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
36
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
37 IFP1
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
38 USE defsfile
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
39 ENDC
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
40
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
41 IFNE KRNMOD
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
42 tylg SET Systm+Objct
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
43 ELSE
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
44 tylg SET Prgrm+Objct
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
45 ENDC
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
46 atrv SET ReEnt+rev
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
47 rev SET $00
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
48 edition SET 1
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
49
1992
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
50 * If an MPI is being used, set RS232SLOT to slot value - 1 and set MPI to 1
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
51 MPICTRL EQU $FF7F
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
52 RS232SLOT EQU 1 slot 2
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
53
1992
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
54 *MPI EQU 1
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
55
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
56 FN_ERROR EQU $F0
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
57 FN_SET_BYTES EQU $F9
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
58 FN_RUN_TARGET EQU $FA
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
59 FN_WRITE_REGS EQU $FB
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
60 FN_READ_REGS EQU $FC
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
61 FN_WRITE_MEM EQU $FD
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
62 FN_READ_MEM EQU $FE
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
63 FN_GET_STATUS EQU $FF
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
64
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
65
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
66 cbsize EQU 200
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
67
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
68 * this location is in lo-System RAM. We clear the low bit upon
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
69 * initialization from the kernel, then on subsequent breakpoints,
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
70 * we set the low bit
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
71
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
72 * offsets into our on stack storage
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
73 ORG 0
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
74 callregs RMB 2
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
75 firsttime RMB 1
1992
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
76 IFNE MPI
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
77 slot RMB 1
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
78 ENDC
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
79 combuff RMB cbsize
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
80 size EQU .
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
81
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
82
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
83 L0000 MOD eom,name,tylg,atrv,start,size
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
84
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
85 name EQU *
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
86 IFNE KRNMOD
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
87 FCS /KrnP3/
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
88 ELSE
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
89 FCS /noice/
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
90 ENDC
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
91 FCB edition
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
92
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
93 nextname FCC /krnp4/ next module name to link to
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
94 FCB C$CR
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
95
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
96 svctabl FCB F$Debug
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
97 FDB dbgent-*-2
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
98 FCB $80
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
99
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
100 start
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
101 IFNE KRNMOD
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
102 leay <svctabl,pcr
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
103 os9 F$SSvc
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
104 bcs ex@
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
105 ldd #$0100
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
106 os9 F$SRqMem allocate memory
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
107 bcs ex@
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
108 stu <D.DbgMem save our allocated memory
1991
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
109 * clear the firsttime flag so that the first time we get
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
110 * called at dbgent, we DON'T subtract the SWI from the PC.
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
111 sta firsttime,u A = $01
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
112 * get next KrnP module going
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
113 lda #tylg get next module type (same as this one!)
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
114 leax <nextname,pcr get address of next module name
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
115 os9 F$Link attempt to link to it
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
116 bcs ex@ no good...skip this
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
117 jsr ,y else go execute it
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
118 ex@ rts return
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
119 ENDC
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
120
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
121
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
122 * Debugger Entry Point
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
123 *
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
124 * We enter here when a process or the system makes an os9 F$Debug call.
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
125 dbgent
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
126 ldx <D.DbgMem get pointer to our statics in X
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
127 stu callregs,x save pointer to caller's regs
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
128 exg x,u exchange X and U
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
129 * If this is a breakpoint (state = 1) then back up PC to point at SWI2
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
130 tst firsttime,u
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
131 bne notbp
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
132 ldd R$PC,x
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
133 subd #$03
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
134 std R$PC,x
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
135 * set bit so next time we do the sub on the $PC
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
136 notbp clr firsttime,u
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
137 lbsr llinit initialize I/O
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
138 lda #FN_RUN_TARGET
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
139 sta combuff,u
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
140 lbra _readregs
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
141
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
142 * mainloop - processes requests from the server
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
143 mainloop
1990
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
144
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
145 * ADDITION: We insist on having a "Pre-Opcode" OP_XBUG if we are using
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
146 * this client in conjunction with DriveWire on the same serial line.
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
147 * This is because DriveWire's Opcodes conflict with NoICE's.
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
148 * lbsr llread get command byte
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
149 * cmpa #OP_XBUG X-Bug Op-Code?
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
150 * bne mainloop if not, continue waiting
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
151
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
152 clrb clear B (for checksum)
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
153 leax combuff,u point to comm buffer
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
154 lbsr llread get command byte
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
155 sta ,x+ save in comm buffer and inc X
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
156 addb -1,x compute checksum
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
157 lbsr llread get byte count of incoming message
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
158 sta ,x+ save in comm buffer and inc X
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
159 addb -1,x compute checksum
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
160 pshs a save count on stack
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
161 tsta count zero?
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
162 beq csum@ branch if so
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
163 n@ lbsr llread read data byte (count on stack)
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
164 sta ,x+ save in our local buffer
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
165 addb -1,x compute checksum
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
166 dec ,s decrement count
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
167 bne n@ if not zero, get next byte
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
168 csum@ lbsr llread read checksum byte from host
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
169 sta ,s save on stack (where count was)
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
170 negb make 2's complement
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
171 cmpa ,s+ same as host's?
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
172 bne mainloop if not, ignore message
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
173
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
174 * Here we have a message with a valid checksum.
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
175 * Now we evaluate the command byte.
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
176 processmsg
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
177 lda combuff,u get command byte
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
178 bpl _sendstatus command byte hi bit not set
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
179 cmpa #FN_READ_MEM Read Memory?
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
180 lbeq _readmem branch if so
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
181 cmpa #FN_READ_REGS Read Registers?
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
182 lbeq _readregs branch if so
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
183 cmpa #FN_WRITE_MEM Write Memory?
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
184 lbeq _writemem branch if so
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
185 cmpa #FN_WRITE_REGS Write Registers?
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
186 lbeq _writeregs branch if so
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
187 cmpa #FN_GET_STATUS Get Status?
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
188 lbeq _getstatus branch if so
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
189 cmpa #FN_SET_BYTES Set Bytes?
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
190 beq _setbytes branch if so
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
191 cmpa #FN_RUN_TARGET Run Target?
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
192 lbeq _runtarget
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
193
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
194 * Here we send an error status
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
195 _senderror
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
196 lda #FN_ERROR
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
197 sta combuff,u
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
198 lda #1
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
199 _sendstatus
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
200 sta combuff+2,u
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
201 lda #1
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
202 sta combuff+1,u
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
203 lbsr _sendtohost
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
204 bra mainloop
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
205
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
206 _runtarget
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
207 IFNE KRNMOD
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
208 clrb
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
209 rts
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
210 ELSE
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
211 clrb
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
212 os9 F$Exit
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
213 ENDC
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
214
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
215 * This routine is given a list of bytes to change. It must read the current
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
216 * byte at that location and return it in a packet to the host so that
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
217 * the host can restore the contents at a later time.
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
218 _setbytes
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
219 ldb combuff+1,u get count byte
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
220 clr combuff+1,u set return count as zero
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
221 lsrb divide number of bytes by 4
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
222 lsrb
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
223 beq sb9@
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
224 pshs u save our statics pointer
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
225 leau combuff+2,u point U to write outgoing data
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
226 tfr u,y point Y to first 4 bytes
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
227 sb1@ pshs b save loop counter
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
228 ldd 1,y get address to write to
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
229 exg a,b swap!
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
230 tfr d,x memory address is now in X
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
231 * Here, X = memory address to read
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
232 * Y = 4 byte component in input packet
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
233 * U = next place in com buffer to write "previous" byte
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
234 * Read current data at byte location in process' space
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
235 pshs u,a save byte spot for later and "next" ptr
1990
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
236 IFNE USERSTATE
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
237 ldu <D.Proc
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
238 ldb P$Task,u
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
239 os9 F$LDABX
1990
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
240 ELSE
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
241 lda ,x
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
242 ENDC
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
243 sta ,s save original ,X value on stack for now
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
244 * A now holds the data byte -- insert new data at byte location
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
245 lda 3,y get byte to store
1990
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
246 IFNE USERSTATE
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
247 os9 F$STABX
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
248 * Re-read current data at byte location in process' space
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
249 os9 F$LDABX
1990
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
250 ELSE
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
251 sta ,x
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
252 lda ,x
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
253 ENDC
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
254 cmpa 3,y compare what we read from what we wrote
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
255 puls a,u get "original" value and next ptr
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
256 puls b restore loop count
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
257 bne sb8@ carry affected by last cmpa
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
258 * Save target byte in return buffer
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
259 sta ,u+
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
260 ldx ,s get original statics ptr in X for now
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
261 inc combuff+1,x count one return byte
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
262 * Loop for next byte
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
263 leay 4,y step to next byte in specifier
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
264 cmpb combuff+1,x done?
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
265 bne sb1@
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
266 * Return buffer with data from byte locations
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
267 sb8@ puls u restore our original statics ptr
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
268 sb9@ lbsr _sendtohost
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
269 lbra mainloop
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
270 sbe@ puls u restore what's on the stack
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
271 bra _senderror
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
272
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
273 * This routine reads memory from the calling process' address space
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
274 * using F$Move.
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
275 _readmem
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
276 ldd combuff+3,u get source pointer
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
277 exg a,b byte swap!
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
278 tfr d,x and put in X
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
279 clra clear A
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
280 ldb combuff+5,u get count
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
281 stb combuff+1,u and store count back in our header
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
282 tfr d,y put count in Y
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
283 pshs u,x save source pointer
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
284 leau combuff+2,u point U to destination
1990
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
285 IFNE USERSTATE
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
286 * User state
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
287 ldx <D.Proc get current process pointer
1990
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
288 * cmpx <D.SysPrc same as system process?
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
289 * beq copysys
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
290 lda P$Task,x get source task #
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
291 ldb <D.SysTsk get destination task #
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
292 puls x restore source pointer
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
293 os9 F$Move move 'em out!
1990
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
294 ELSE
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
295 * System state
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
296 puls x
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
297 l@ lda ,x+ get byte at source and inc
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
298 sta ,u+ save byte at dest and inc
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
299 leay -1,y done?
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
300 bne l@ branch if not
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
301 ENDC
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
302 puls u restore statics pointer
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
303 bsr _sendtohost
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
304 lbra mainloop
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
305
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
306 * This routine writes memory from the host to the calling process'
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
307 * address space using F$Move.
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
308 _writemem
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
309 leax combuff+5,u point X to source
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
310 clra
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
311 ldb combuff+1,u get count of packet
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
312 subb #3 subtract 3 -- now we have our write count
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
313 tfr d,y put count in Y
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
314 ldd combuff+3,u get destination pointer
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
315 exg a,b byte swap!
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
316 pshs u,x save on stack
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
317 tfr d,u and put source in U
1990
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
318 IFNE USERSTATE
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
319 * User state
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
320 ldx <D.Proc get current process pointer
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
321 lda <D.SysTsk get source task #
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
322 ldb P$Task,x get destination task #
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
323 puls x restore source pointer
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
324 os9 F$Move move 'em out!
1990
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
325 ELSE
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
326 * System state
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
327 puls x
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
328 l@ lda ,x+ get byte at source and inc
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
329 sta ,u+ save byte at dest and inc
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
330 leay -1,y done?
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
331 bne l@ branch if not
a5ea3e11a460 Updated
boisy
parents: 1978
diff changeset
332 ENDC
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
333 puls u restore our static pointer
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
334 ldd #$0100 assume successful write
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
335 std combuff+1,u
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
336 bsr _sendtohost
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
337 lbra mainloop
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
338
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
339
1991
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
340 * This data is provided to the NoICE server upon receipt of FN_GET_STATUS.
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
341 statdata
1991
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
342 FCB 33 number of bytes to send
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
343 IFNE H6309
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
344 FCB 17 processor type: 6309
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
345 ELSE
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
346 FCB 5 processor type: 6809
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
347 ENDC
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
348 FCB cbsize size of communications buffer
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
349 FCB %00000000 options flags
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
350 FDB $0000 target mapped memory low bound
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
351 FDB $FFFF target mapped memory high bound
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
352 FCB 3 length of breakpoint instruction
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
353 FCB $10,$3F,F$Debug breakpoint instruction
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
354 * target description
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
355 FCC "NitrOS-9/6"
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
356 IFNE H6309
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
357 FCC "3"
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
358 ELSE
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
359 FCC "8"
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
360 ENDC
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
361 FCC "09 Level "
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
362 IFEQ Level-1
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
363 FCC "1"
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
364 ELSE
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
365 FCC "2"
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
366 ENDC
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
367 FCB 0
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
368
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
369 _getstatus
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
370 * copy status to our buffer
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
371 leax statdata,pcr
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
372 leay combuff+1,u
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
373 ldb statdata,pcr
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
374 l@ lda ,x+
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
375 sta ,y+
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
376 decb
1991
b2c463319b9a Fixed minor issues in code
boisy
parents: 1990
diff changeset
377 bpl l@
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
378 bsr _sendtohost
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
379 lbra mainloop
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
380
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
381
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
382 * This routine sends the contents of combuff,u to the communications
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
383 * hardware. Note that the count that is stored at combuff+1,u is
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
384 * set by the caller, and reflects the number of data bytes to be sent.
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
385 *
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
386 * Also, we compute the checksum as we send the bytes out so that
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
387 * we don't have to call a separate routine.
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
388 _sendtohost
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
389 leax combuff,u point X to communications buffer
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
390 ldb 1,x get count from header into B
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
391 addb #2 add header bytes to count var B
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
392 pshs b save on stack (this is our counter)
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
393 clrb B is now used for checksum
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
394 n@ addb ,x compute checksum
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
395 lda ,x+ get byte from buffer and inc X
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
396 lbsr llwrite write it out
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
397 dec ,s decrement count on stack
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
398 bne n@ if not zero, branch
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
399 negb make 2's complement
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
400 * comb make 2's complement
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
401 * incb
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
402 tfr b,a put in A
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
403 lbsr llwrite write it
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
404 puls b,pc return
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
405
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
406
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
407 _readregs
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
408 ldy callregs,u get pointer to caller's regs
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
409 leax combuff+1,u
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
410 IFNE H6309
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
411 ldb #21 get number of bytes to send
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
412 ELSE
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
413 ldb #16 get number of bytes to send
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
414 ENDC
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
415 stb ,x+ save number of bytes
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
416 lda firsttime,u get first time called flag
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
417 sta ,x+ write it
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
418 clr ,x+ clear page reg
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
419 ldd R$U,y
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
420 exg a,b
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
421 std ,x++
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
422 ldd R$Y,y
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
423 exg a,b
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
424 std ,x++
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
425 ldd R$X,y
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
426 exg a,b
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
427 std ,x++
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
428 IFNE H6309
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
429 ldd R$E,y
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
430 exg a,b
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
431 std ,x++
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
432 ENDC
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
433 ldd R$A,y
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
434 exg a,b
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
435 std ,x++
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
436 ldb R$DP,y
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
437 stb ,x+ DP
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
438 ldb R$CC,y
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
439 stb ,x+ CC
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
440 ldd R$PC,y
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
441 exg a,b
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
442 std ,x++ PC
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
443 ldy <D.Proc get SP from proc desc
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
444 ldd P$SP,y
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
445 exg a,b
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
446 std combuff+4,u
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
447 bsr _sendtohost
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
448 lbra mainloop
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
449
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
450
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
451 _writeregs
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
452 ldy callregs,u get caller's reg ptr
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
453 leax combuff+6,u
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
454 * lda D.Debug
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
455 * anda #D_BRKPT
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
456 * sta <D.Debug
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
457 ldd ,x++
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
458 exg a,b
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
459 std R$U,y
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
460 ldd ,x++
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
461 exg a,b
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
462 std R$Y,y
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
463 ldd ,x++
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
464 exg a,b
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
465 std R$X,y
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
466 IFNE H6309
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
467 ldd ,x++
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
468 exg a,b
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
469 std R$E,y
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
470 ENDC
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
471 ldd ,x++
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
472 exg a,b
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
473 std R$A,y
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
474 ldb ,x+
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
475 stb R$DP,y
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
476 ldb ,x+
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
477 stb R$CC,y
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
478 ldd ,x++
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
479 exg a,b
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
480 std R$PC,y
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
481 ldd combuff+4,u
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
482 exg a,b
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
483 ldy <D.Proc
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
484 std P$SP,y
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
485 ldd #$0100
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
486 std combuff+1,u
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
487 lbsr _sendtohost
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
488 lbra mainloop
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
489
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
490
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
491
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
492 ********** I/O ROUTINES **********
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
493
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
494 * 6551 Parameters
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
495 ADDR EQU $FF68
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
496
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
497 A_RXD EQU ADDR+$00
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
498 A_TXD EQU ADDR+$00
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
499 A_STATUS EQU ADDR+$01
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
500 A_RESET EQU ADDR+$01
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
501 A_CMD EQU ADDR+$02
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
502 A_CTRL EQU ADDR+$03
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
503
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
504 * Baud rates
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
505 _B2400 EQU $1A 2400 bps, 8-N-1
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
506 _B4800 EQU $1C 4800 bps, 8-N-1
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
507 _B9600 EQU $1E 9600 bps, 8-N-1
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
508 _B19200 EQU $1F 19200 bps, 8-N-1
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
509
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
510 BAUD EQU _B9600
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
511
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
512 * llinit - Initialize the low-level I/O
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
513 * Exit: Carry = 0: Init success; Carry = 1; Init failed
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
514 llinit
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
515 IFNE MPI
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
516 pshs a
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
517 lda MPICTRL
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
518 sta slot,u
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
519 lda #RS232SLOT
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
520 sta MPICTRL
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
521 puls a
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
522 ENDC
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
523 sta A_RESET soft reset (value not important)
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
524 * Set specific modes and functions:
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
525 * - no parity, no echo, no Tx interrupt
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
526 * - no Rx interrupt, enable Tx/Rx
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
527 lda #$0B
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
528 sta A_CMD save to command register
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
529 lda #BAUD
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
530 sta A_CTRL select proper baud rate
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
531 * Read any junk rx byte that may be in the register
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
532 lda A_RXD
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
533 IFNE MPI
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
534 pshs a
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
535 lda slot,u
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
536 sta MPICTRL
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
537 puls a
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
538 ENDC
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
539 rts
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
540
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
541
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
542 * llread - Read one character from 6551
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
543 *
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
544 * Entry: None
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
545 * Exit: A = character that was read
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
546 *
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
547 * Note, this routine currently doesn't timeout
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
548 llread
1992
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
549 IFNE MPI
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
550 lda MPICTRL
1992
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
551 sta slot,u
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
552 lda #RS232SLOT
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
553 sta $FF7F
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
554 ENDC
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
555 r@ lda A_STATUS get status byte
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
556 anda #$08 mask rx buffer status flag
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
557 beq r@ loop if rx buffer empty
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
558 lda A_RXD get byte from ACIA data port
1992
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
559 IFNE MPI
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
560 pshs b
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
561 ldb slot,u
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
562 stb MPICTRL
1992
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
563 puls b,pc
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
564 ELSE
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
565 rts
1992
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
566 ENDC
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
567
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
568 * llwrite - Write one character to 6551
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
569 *
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
570 * Entry: A = character to write
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
571 * Exit: None
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
572 llwrite
1992
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
573 IFNE MPI
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
574 pshs d
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
575 ldb MPICTRL
1992
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
576 stb slot,u
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
577 ldb #RS232SLOT
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
578 stb MPICTRL
1992
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
579 ELSE
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
580 pshs a save byte to write
1992
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
581 ENDC
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
582 w@ lda A_STATUS get status byte
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
583 anda #$10 mask tx buffer status flag
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
584 beq w@ loop if tx buffer full
1992
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
585 IFNE MPI
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
586 puls d get byte
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
587 sta A_TXD save to ACIA data port
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
588 lda slot,u
1995
2bb2f8b975b0 additional preliminary changes made by R. Gault
boisy
parents: 1993
diff changeset
589 sta MPICTRL
1992
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
590 ELSE
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
591 puls a get byte
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
592 sta A_TXD save to ACIA data port
1992
4f05cb56a8ec Added MPI support code
boisy
parents: 1991
diff changeset
593 ENDC
1978
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
594 rts
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
595
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
596 * llterm - Terminate
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
597 *llterm
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
598 * rts
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
599
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
600
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
601 IFNE 0
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
602 * llwout - Write an entire string
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
603 * llwerr - Write an entire string
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
604 llwerr
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
605 llwout
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
606 pshs a
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
607 l@ lda ,x+
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
608 cmpa #C$CR
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
609 beq e@
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
610 leay -1,y
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
611 beq f@
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
612 bsr Write
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
613 bra l@
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
614 e@ bsr Write
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
615 lda #C$LF
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
616 bsr Write
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
617 f@ ldx <buffptr
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
618 clrb
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
619 puls a,pc
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
620
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
621 * ReadLine - Read an entire string, up to CR
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
622 * Entry: X = address to place string being read (CR terminated)
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
623 * Y = maximum number of bytes to read (including nul byte)
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
624 ReadLine
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
625 ldx <buffptr
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
626 pshs y,x,a
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
627 ldy #80
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
628 l@ bsr Read read 1 character
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
629 cmpa #C$CR carriage return?
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
630 beq e@ branch if so...
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
631 cmpa #$08 backspace?
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
632 beq bs@
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
633 cmpy #$0000 anymore room?
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
634 beq l@
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
635 leay -1,y back up one char
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
636 sta ,x+ and save in input buffer
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
637 m@ bsr Write echo back out
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
638 bra l@
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
639 e@ sta ,x
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
640 bsr Write
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
641 lda #C$LF
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
642 bsr Write
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
643 clrb
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
644 puls a,x,y,pc
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
645 bs@ cmpx 1,s are we at start
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
646 beq l@ if so, do nothing
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
647 clr ,-x else erase last byte
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
648 lbsr Write write backspace
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
649 lda #C$SPAC a space...
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
650 lbsr Write write it
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
651 leay 1,y count back up free char
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
652 lda #$08 another backspace
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
653 bra m@
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
654 ENDC
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
655
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
656 EMOD
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
657 eom EQU *
c2d3c4232663 Added remote debugging
boisy
parents:
diff changeset
658 END