annotate level1/modules/wbug.asm @ 2185:c0bb67e4bd97

Start of WireBug
author boisy
date Mon, 09 Mar 2009 01:03:07 +0000
parents
children e10177e83238
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2185
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
1 ********************************************************************
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
2 * wbug - WireBug for 6809/6309
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
3 *
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
4 * $Id$
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
5 *
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
6 * For Level 1, wbug must be run from the command line in order for
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
7 * the debugger to be properly setup.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
8 *
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
9 * For Level 2, this module is called by the kernel at boot time.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
10 *
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
11 * A process can invoke the debugger by executing an os9 F$Debug instruction.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
12 * SWI can also invoke the debugger but should be reserved for breakpoints only.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
13 *
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
14 * Edt/Rev YYYY/MM/DD Modified by
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
15 * Comment
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
16 * ------------------------------------------------------------------
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
17 * 1 2005/04/03 Boisy G. Pitre
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
18 * Started.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
19 *
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
20 * 2 2008/02/07 Boisy G. Pitre
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
21 * Revamped to use F$Debug for debugger entry and SWI for breakpoints.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
22 * Confirmed working under Level 1, but under Level 2, system calls
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
23 * currently crash the CoCo 3.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
24
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
25 NAM KrnP3
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
26 TTL WireBug for 6809/6309
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
27
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
28 IFP1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
29 USE defsfile
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
30 USE dwdefs.d
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
31 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
32
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
33 IFEQ LEVEL-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
34 tylg SET Prgrm+Objct
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
35 ELSE
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
36 tylg SET Systm+Objct
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
37 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
38 atrv SET ReEnt+rev
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
39 rev SET $00
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
40 edition SET 2
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
41
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
42 cbsize EQU 24
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
43
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
44 * offsets into our on-stack storage
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
45 ORG 0
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
46 callregs RMB 2
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
47 IFEQ LEVEL-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
48 l1exitvct RMB 2
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
49 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
50 combuff RMB cbsize
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
51 size EQU .
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
52
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
53
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
54 L0000 MOD eom,name,tylg,atrv,start,size
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
55
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
56 SvcTbl equ *
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
57 fcb F$Debug
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
58 fdb dbgent-*-2
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
59 fcb $80
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
60
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
61
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
62 name EQU *
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
63 IFEQ LEVEL-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
64 FCS /wbug/
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
65 ELSE
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
66 FCS /KrnP3/
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
67 FCB edition
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
68
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
69 nextname FCC /KrnP4/ next module name to link to
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
70 FCB C$CR
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
71 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
72
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
73 subname FCS /dw3/
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
74
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
75 start
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
76 * attach to low level module
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
77 clra
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
78 leax subname,pcr
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
79 os9 F$Link
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
80 bcs ex@
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
81 IFGT Level-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
82 sty <D.DWSUB
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
83 ELSE
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
84 sty >D.DWSUB
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
85 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
86 * install F$Debug system call
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
87 leay SvcTbl,pcr
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
88 os9 F$SSvc
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
89 bcs ex@
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
90 leax brkent,pcr get pointer to breakpoint entry
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
91 IFEQ LEVEL-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
92 stx >D.SWI store in D.SWI global
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
93 clrb clear carry
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
94 ex@ os9 F$Exit and exit
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
95 ELSE
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
96 stx <D.XSWI store in D.XSWI global
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
97 * get next KrnP module going
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
98 gol2 lda #tylg get next module type (same as this one!)
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
99 leax <nextname,pcr get address of next module name
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
100 os9 F$Link attempt to link to it
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
101 bcs ex@ no good...skip this
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
102 jsr ,y else go execute it
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
103 ex@ rts return
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
104 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
105
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
106
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
107 * Breakpoint Entry
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
108 *
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
109 * We enter here when a process or the system executes an SWI instruction.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
110 brkent
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
111 IFEQ LEVEL-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
112 * In Level 1, we get called right from the SWI vector, so we need to set U to point to the registers on the stack.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
113 leau ,s point X to regs on stack
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
114 leay rtiexit,pc
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
115 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
116 * This is a breakpoint; back up PC to point at SWI
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
117 ldd R$PC,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
118 subd #$01 length of SWI instruction
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
119 std R$PC,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
120 IFEQ LEVEL-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
121 bra cmn
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
122 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
123
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
124 * Code common to both debugger and breakpoint entries
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
125 * Debugger Entry
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
126 *
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
127 * We enter here when a process or the system executes an os9 F$Debug instruction.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
128 dbgent
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
129 IFEQ LEVEL-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
130 leay rtsexit,pc
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
131 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
132 cmn pshs cc
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
133 orcc #IntMasks
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
134 leas -size,s make room on stack for temp statics
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
135 leax ,s point X to our temp statics
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
136 exg x,u exchange X and U
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
137 stx callregs,u save pointer to caller regs
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
138 IFEQ LEVEL-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
139 sty l1exitvct,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
140 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
141 pshs u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
142 IFGT Level-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
143 ldu <D.DWSUB
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
144 ELSE
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
145 ldu >D.DWSUB
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
146 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
147 jsr ,u initialize I/O
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
148 puls u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
149
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
150 lda #OP_WIREBUG_MODE
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
151 IFEQ LEVEL-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
152 ldb #$02 assume CoCo 2
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
153 ELSE
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
154 ldb #$03 assume CoCo 3
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
155 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
156 std combuff,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
157 IFNE H6309
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
158 lda #$03 6309
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
159 ELSE
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
160 lda #$08 6809
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
161 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
162 sta combuff+2,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
163 lbsr _sendtohost
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
164
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
165 * mainloop - processes requests from the server
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
166 mainloop
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
167 leax combuff,u point to comm buffer
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
168 pshs u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
169 IFGT Level-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
170 ldu <D.DWSUB
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
171 ELSE
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
172 ldu >D.DWSUB
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
173 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
174 l@
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
175 ldy #24
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
176 ldd #133
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
177 jsr 3,u get packet
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
178 cmpd #$0000 no data?
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
179 beq l@
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
180 puls u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
181 * bcs
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
182 tfr y,d put checksum in D
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
183 subb 23,x
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
184 cmpb combuff+23,u does it match the checksum from the packet?
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
185 beq processmsg if not, send checksum error
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
186 bsr _sendcsumerror
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
187 bra mainloop
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
188
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
189 * Here we have a message with a valid checksum.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
190 * Now we evaluate the command byte.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
191 processmsg
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
192 lda combuff,u get command byte
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
193 cmpa #OP_WIREBUG_READMEM Read Memory?
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
194 lbeq _readmem branch if so
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
195 cmpa #OP_WIREBUG_READREGS Read Registers?
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
196 lbeq _readregs branch if so
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
197 cmpa #OP_WIREBUG_WRITEMEM Write Memory?
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
198 lbeq _writemem branch if so
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
199 cmpa #OP_WIREBUG_WRITEREGS Write Registers?
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
200 lbeq _writeregs branch if so
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
201 cmpa #OP_WIREBUG_GO Run Target?
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
202 bne mainloop
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
203
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
204 _go
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
205 * clr combuff,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
206 * bsr _sendtohost
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
207 leas size,s recover space on stack
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
208 IFEQ LEVEL-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
209 jmp [l1exitvct,u]
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
210 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
211 rtsexit puls cc
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
212 clrb
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
213 rts
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
214 rtiexit puls cc
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
215 rti
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
216
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
217
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
218 * Destroys A
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
219 _sendcsumerror
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
220 lda #E$CRC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
221 _senderror
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
222 sta combuff,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
223 bra _sendtohost
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
224
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
225 * Destroys A
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
226 _sendillnumerror
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
227 lda #16
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
228 bra _senderror
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
229
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
230 * This routine reads memory from the calling process' address space
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
231 * using F$Move.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
232 _readmem
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
233 ldx combuff+1,u get source pointer
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
234 ldb combuff+3,u get count
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
235 cmpb #1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
236 bge ok1@
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
237 bad1@ bsr _sendillnumerror
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
238 bra mainloop
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
239 ok1@ cmpb #22
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
240 bgt bad1@ if > 22, its illegal count
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
241
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
242 IFEQ LEVEL-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
243 * Level 1 copy
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
244 leay combuff+1,u point U to destination
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
245 l@ lda ,x+ get byte at Y and inc
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
246 sta ,y+ save byte at X and inc
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
247 decb done?
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
248 bne l@ branch if not
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
249 ELSE
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
250 * Level 2 copy
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
251 clra
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
252 tfr d,y put count in Y
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
253 pshs u,x save source pointer
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
254 leau combuff+1,u point U to destination
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
255 ldx D.Proc get current process pointer
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
256 lda P$Task,x get source task #
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
257 ldb D.SysTsk get destination task #
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
258 puls x restore source pointer
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
259 os9 F$Move move 'em out!
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
260 puls u restore statics pointer
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
261 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
262
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
263 bsr _sendtohost
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
264 lbra mainloop
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
265
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
266
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
267 * This routine writes memory from the host to the calling process'
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
268 * address space using F$Move.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
269 _writemem
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
270 leax combuff+4,u point X to source
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
271 IFEQ LEVEL-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
272 * Level 1 copy
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
273 ldb combuff+3,u get count of packet
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
274 ldy combuff+1,u get destination pointer
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
275 l@ lda ,x+ get byte at Y and inc
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
276 sta ,y+ save byte at X and inc
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
277 decb done?
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
278 bne l@ branch if not
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
279 ELSE
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
280 * Level 2
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
281 clra
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
282 ldb combuff+3,u get count of packet
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
283 tfr d,y put count in Y
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
284 pshs u,x save on stack
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
285 ldu combuff+1,u get destination pointer
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
286 ldx <D.Proc get current process pointer
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
287 lda <D.SysTsk get source task #
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
288 ldb P$Task,x get destination task #
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
289 puls x restore source pointer
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
290 os9 F$Move move 'em out!
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
291 puls u restore our static pointer
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
292 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
293 ldd #$0100 assume successful write
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
294 bsr _sendtohost
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
295 lbra mainloop
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
296
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
297
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
298 * This routine sends the contents of combuff,u to the communications
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
299 * hardware.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
300 *
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
301 * Also, we compute the checksum as we send the bytes out so that
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
302 * we do not have to call a separate routine.
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
303 *
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
304 * Entry:
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
305 * X = address of packet to send
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
306 _sendtohost
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
307 leax combuff,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
308 ldb #23 B = count of packet - 1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
309 clra A = checksum
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
310 l@ adda ,x+ add up
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
311 decb until
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
312 bne l@ we've reached the end
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
313 sta ,x save computed checksum
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
314 leax -23,x
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
315 ldy #24
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
316 pshs u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
317 IFGT Level-1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
318 ldu <D.DWSUB
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
319 ELSE
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
320 ldu >D.DWSUB
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
321 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
322 jsr 6,u write it out
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
323 puls u,pc
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
324
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
325
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
326 * Target registers: DO NOT CHANGE!
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
327 TASK_REGS
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
328 REG_STATE RMB 1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
329 REG_PAGE RMB 1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
330 REG_SP RMB 2
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
331 REG_U RMB 2
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
332 REG_Y RMB 2
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
333 REG_X RMB 2
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
334 REG_F RMB 1 F BEFORE E, SO W IS LEAST SIG. FIRST
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
335 REG_E RMB 1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
336 REG_B RMB 1 B BEFORE A, SO D IS LEAST SIG. FIRST
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
337 REG_A RMB 1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
338 REG_DP RMB 1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
339 REG_CC RMB 1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
340 REG_MD RMB 1
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
341 REG_V RMB 2
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
342 REG_PC RMB 2
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
343 TASK_REG_SZ EQU *-TASK_REGS
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
344
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
345
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
346 _readregs
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
347 ldy callregs,u get pointer to caller's regs
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
348 leax combuff+1,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
349 ldb R$DP,y
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
350 stb ,x+ DP
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
351 ldb R$CC,y
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
352 stb ,x+ CC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
353 ldd R$D,y D
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
354 std ,x++
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
355 IFNE H6309
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
356 ldd R$W,y W
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
357 exg a,b
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
358 std ,x++
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
359 ELSE
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
360 leax 2,x
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
361 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
362 ldd R$X,y X
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
363 exg a,b
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
364 std ,x++
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
365 ldd R$Y,y Y
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
366 exg a,b
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
367 std ,x++
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
368 ldd R$U,y U
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
369 exg a,b
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
370 std ,x++
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
371
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
372 IFNE H6309
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
373 * construct MD from shadow register in NitrOS-9 globals
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
374 lda >D.MDREG MD
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
375 sta ,x+
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
376 tfr v,d
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
377 std x++ V
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
378 ELSE
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
379 leax 3,x
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
380 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
381
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
382 ldd R$PC,y
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
383 std 2,x PC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
384 ldy >D.Proc get SP from proc desc
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
385 ldd P$SP,y
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
386 std ,x
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
387 bsr _sendtohost
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
388 lbra mainloop
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
389
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
390
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
391
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
392 _writeregs
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
393 ldy callregs,u get caller's reg ptr
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
394 ldd combuff+1,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
395 std R$DP,y
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
396 ldd combuff+3,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
397 std R$D,y
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
398 IFNE H6309
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
399 ldd combuff+5,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
400 std R$W,y
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
401 ENDC
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
402 ldd combuff+7,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
403 std R$X,y
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
404 ldd combuff+9,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
405 std R$Y,y
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
406 ldd combuff+11,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
407 std R$U,y
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
408
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
409 ldd combuff+17,u
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
410 std R$PC,y
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
411
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
412 ldy >D.Proc
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
413 std P$SP,y
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
414
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
415 lbra mainloop
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
416
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
417 EMOD
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
418 eom EQU *
c0bb67e4bd97 Start of WireBug
boisy
parents:
diff changeset
419 END