Files
Sepp J Morris 31738079c4 Upload
Digital Research
2020-11-06 18:50:37 +01:00

329 lines
20 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

C P / M 6 8 0 0 0 A s s e m b l e r Revision 02.03 Page 1
Source File: exceptn.s
1
2 *************************************************
3 * *
4 * CP/M-68k Basic Disk Operating System *
5 * Exception Handling Module *
6 * *
7 * Version 0.0 -- July 21, 1982 *
8 * Version 0.1 -- July 25, 1982 *
9 * Version 0.2 -- October 6, 1982 *
10 * Version 0.3 -- December 21, 1982 *
11 * *
12 *************************************************
13
14
15 .globl _initexc
16 .globl _tpa_lp
17 .globl _tpa_hp
18
19 bgetseg = 18
20 bsetexc = 22
21 buserr = 2
22 spurious = 24
23 trap0 = 32
24 trap2 = 34
25 trap3 = 35
26 endvec = 48
27
28 _initexc:
29 * Initialize Exception Vector Handlers
30 * It has 1 passed parameter: the address of the exception vector array
31 00000000 7016 move #bsetexc,d0
32 00000002 7202 moveq #2,d1
33 00000004 243C00000072 move.l #exchndl,d2
34 init1:
35 0000000A 48E7E000 movem.l d0-d2,-(sp)
36 0000000E 4E43 trap #3 * BIOS call to set exception vector
37 00000010 4CDF0007 movem.l (sp)+,d0-d2
38 00000014 5241 init2: addq #1,d1
39 00000016 5882 add.l #4,d2
40 00000018 0C410018 cmpi #spurious,d1
41 0000001C 6602 bne init3
42 0000001E 7220 move #trap0,d1
43 00000020 0C410022 init3: cmpi #trap2,d1
44 00000024 67EE beq init2 * don't init trap 2 or trap 3
45 00000026 0C410023 cmpi #trap3,d1
46 0000002A 67E8 beq init2
47 0000002C 0C410030 cmpi #endvec,d1
48 00000030 6DD8 blt init1
49 * initialize the exception vector array
50
51 00000032 7012 moveq #bgetseg,d0
52 00000034 4E43 trap #3 * get the original TPA limits
53 00000036 2040 movea.l d0,a0
54 00000038 4A58 tst.w (a0)+
55 0000003A 2218 move.l (a0)+,d1 * d1 = original low TPA limit
C P / M 6 8 0 0 0 A s s e m b l e r Revision 02.03 Page 2
Source File: exceptn.s
56 0000003C 2401 move.l d1,d2
57 0000003E D490 add.l (a0),d2 * d2 = original high TPA limit
58 00000040 263900000000 move.l _tpa_lp,d3 * d3 = new low TPA limit
59 00000046 283900000000 move.l _tpa_hp,d4 * d4 = new high TPA limit
60 0000004C 7011 move #17,d0
61 0000004E 206F0004 movea.l 4(sp),a0
62 00000052 23C800000000 move.l a0,evec_adr * save exception vector address
63 init4:
64 00000058 B290 cmp.l (a0),d1
65 0000005A 620C bhi do_init * if old exception outside orig TPA, clear it
66 0000005C B490 cmp.l (a0),d2
67 0000005E 6308 bls do_init
68 * current exception array entry is in original TPA
69 00000060 B690 cmp.l (a0),d3
70 00000062 6206 bhi dontinit * if old exception in old TPA but outside new
71 00000064 B890 cmp.l (a0),d4 * TPA, don't clear it
72 00000066 6302 bls dontinit
73 do_init:
74 00000068 4290 clr.l (a0)
75 dontinit:
76 0000006A 4A98 tst.l (a0)+
77 0000006C 51C8FFEA dbf d0,init4
78 00000070 4E75 rts
79
80 exchndl:
81 00000072 61000056 bsr.w except
82 excrtn0:
83 00000076 61000052 bsr.w except
84 0000007A 6100004E bsr.w except
85 0000007E 6100004A bsr.w except
86 00000082 61000046 bsr.w except
87 00000086 61000042 bsr.w except
88 0000008A 613E bsr.w except
89 0000008C 613C bsr.w except
90 0000008E 613A bsr.w except
91 00000090 6138 bsr.w except
92 00000092 6136 bsr.w except
93 00000094 6134 bsr.w except
94 00000096 6132 bsr.w except
95 00000098 6130 bsr.w except
96 0000009A 612E bsr.w except
97 0000009C 612C bsr.w except
98 0000009E 612A bsr.w except
99 000000A0 6128 bsr.w except
100 000000A2 6126 bsr.w except
101 000000A4 6124 bsr.w except
102 000000A6 6122 bsr.w except
103 000000A8 6120 bsr.w except
104 000000AA 611E bsr.w except
105 000000AC 611C bsr.w except
106 000000AE 611A bsr.w except
107 000000B0 6118 bsr.w except
108 000000B2 6116 bsr.w except
109 000000B4 6114 bsr.w except
110 000000B6 6112 bsr.w except
C P / M 6 8 0 0 0 A s s e m b l e r Revision 02.03 Page 3
Source File: exceptn.s
111 000000B8 6110 bsr.w except
112 000000BA 610E bsr.w except
113 000000BC 610C bsr.w except
114 000000BE 610A bsr.w except
115 000000C0 6108 bsr.w except
116 000000C2 6106 bsr.w except
117 000000C4 6104 bsr.w except
118 000000C6 6102 bsr.w except
119 000000C8 4E71 bsr.w except
120
121
122 except:
123 000000CA 4267 clr.w -(sp)
124 000000CC 48E78080 movem.l a0/d0,-(sp) * 10 words now on stack in following order:
125 * _______________________________
126 * |____________D0.L_______________|
127 * |____________A0.L_______________|
128 * |____0000______|________________
129 * |_______Handler Return__________|
130 * If bus error, extra 2 longs are here
131 * ______________
132 * |__Status Reg__|________________
133 * |_____Exception Return__________|
134
135 000000D0 202F000A move.l 10(sp),d0 * get return address from above array
136 000000D4 90BC00000076 sub.l #excrtn0,d0 * d0 now has 4 * (encoded excptn nmbr), where
137 * encoded excptn nmbr is in [0..21,22..37]
138 * representing [2..23,32..47]
139 000000DA 0C400024 cmpi #36,d0 * if d0/4 is in [0..9,22..29] then
140 000000DE 6F10 ble chkredir * the exception may be redirected
141 000000E0 0C400058 cmpi #88,d0
142 000000E4 6D20 blt dfltexc
143 000000E6 0C400074 cmpi #116,d0
144 000000EA 6E1A bgt dfltexc
145 * in range of redirected exceptions
146 000000EC 04400030 subi #48,d0 * subtract 4*12 to normalize [0..9,22..29]
147 * into [0..9,10..17]
148 chkredir:
149 000000F0 207900000000 movea.l evec_adr,a0
150 000000F6 D0C0 adda d0,a0 * index into exception vector array
151 000000F8 4A90 tst.l (a0) * if 00000000, then not redirected
152 000000FA 6658 bne usrexc
153 * not redirected, do default handler
154 000000FC 0C400028 cmpi #40,d0
155 00000100 6D04 blt dfltexc
156 00000102 06400030 addi #48,d0 * add 4*12 that was sub'd above
157 dfltexc:
158 00000106 DEFC000E adda #14,sp * throw away 7 words that we added to stack
159 0000010A E440 asr #2,d0 * divide d0 by 4
160 * now d0 is in [0..21,22..37]
161 * to represent [2..23,32..47]
162 0000010C 0C400002 cmpi #2,d0 * bus or address error?
163 00000110 6C04 bge nobusexc
164 00000112 4CDF0300 movem.l (sp)+,a0-a1 * if yes, throw away 4 words from stack
165 nobusexc:
C P / M 6 8 0 0 0 A s s e m b l e r Revision 02.03 Page 4
Source File: exceptn.s
166 00000116 4A5F tst.w (sp)+ * throw away stacked SR
167 00000118 5440 addi #2,d0
168 0000011A 0C400017 cmpi #23,d0 * get back real excptn nmbr in [2..23,32..47]
169 0000011E 6F02 ble lowexc
170 00000120 5040 addi #8,d0
171 00000122 3F00 lowexc: move d0,-(sp) * save excptn nmbr
172 00000124 41F900000000 lea excmsg1,a0
173 0000012A 6100009A bsr print * print default exception message
174 0000012E 301F move (sp)+,d0
175 00000130 610000B2 bsr prtbyte
176 00000134 41F90000000F lea excmsg2, a0
177 0000013A 6100008A bsr print
178 0000013E 201F move.l (sp)+,d0
179 00000140 61000092 bsr prtlong
180 00000144 41F900000022 lea excmsg3, a0
181 0000014A 6100007A bsr print
182 0000014E 4280 clr.l d0
183 00000150 4E42 trap #2 * warm boot
184 00000152 4E73 rte
185
186 usrexc:
187 * Call user exception handler
188 * make sure exception information is on his stack
189 00000154 2F50000A move.l (a0),10(sp) * put user handler address on our stack
190 00000158 4E68 move.l usp,a0 * user stack pointer to a0
191 0000015A 0C400008 cmpi #8,d0 * address or bus error?
192 0000015E 6D24 blt addrexc * if yes, skip
193 00000160 082F000D000E btst #13,14(sp) * exception occured in user state?
194 00000166 664A bne supstat1 * if no, go to supervisor handler
195 00000168 212F0010 move.l 16(sp),-(a0) * put exception return on user stack
196 0000016C 312F000E move.w 14(sp),-(a0) * put SR on user stack
197 00000170 4E60 move.l a0,usp * update user stack pointer
198 00000172 4CDF0101 movem.l (sp)+,a0/d0 * restore regs
199 00000176 2F6F00020008 move.l 2(sp),8(sp) * move address of user handler to excptn rtn
200 0000017C 5C4F addq #6,sp * clear junk from stack
201 0000017E 02577FFF andi #$7fff,(sp) * clear trace bit
202 00000182 4E73 rte * go to user handler
203 addrexc:
204 00000184 082F000D0016 btst #13,22(sp) * exception occured in user state?
205 0000018A 662E bne supstat2 * if no, go to supervisor handler
206 0000018C 212F0018 move.l 24(sp),-(a0) * put exception return on user stack
207 00000190 312F0016 move.w 22(sp),-(a0) * put SR on user stack
208 00000194 212F0012 move.l 18(sp),-(a0) * put extra 2 longs on user stack
209 00000198 212F000E move.l 14(sp),-(a0)
210 0000019C 4E60 move.l a0,usp * update user stack pointer
211 0000019E 4CDF0101 movem.l (sp)+,a0/d0 * restore regs
212 000001A2 2F6F00020010 move.l 2(sp),16(sp) * move address of user handler to excptn rtn
213 000001A8 DEFC000E adda #14,sp * clear junk from stack
214 000001AC 02577FFF andi #$7fff,(sp) * clear trace bit
215 000001B0 4E73 rte * go to user handler
216
217 supstat1:
218 000001B2 3F6F000E0008 move.w 14(sp),8(sp) * move SR to our exception return
219 000001B8 6006 bra supstat3
220 supstat2:
C P / M 6 8 0 0 0 A s s e m b l e r Revision 02.03 Page 5
Source File: exceptn.s
221 000001BA 3F6F00160008 move.w 22(sp),8(sp)
222 supstat3:
223 000001C0 4CDF0101 movem.l (sp)+,a0/d0
224 000001C4 4E73 rte
225
226 *
227 * Subroutines
228 *
229
230 print:
231 000001C6 4281 clr.l d1
232 000001C8 1218 move.b (a0)+, d1
233 000001CA 6706 beq prtdone
234 000001CC 7002 move #2, d0
235 000001CE 4E42 trap #2
236 000001D0 60F4 bra print
237 prtdone:
238 000001D2 4E75 rts
239
240 prtlong:
241 * Print d0.l in hex format
242 000001D4 3F00 move d0,-(sp)
243 000001D6 4840 swap d0
244 000001D8 6102 bsr prtword
245 000001DA 301F move (sp)+,d0
246
247 prtword:
248 * Print d0.w in hex format
249 000001DC 3F00 move d0,-(sp)
250 000001DE E048 lsr #8,d0
251 000001E0 6102 bsr prtbyte
252 000001E2 301F move (sp)+,d0
253
254 prtbyte:
255 * Print d0.b in hex format
256 000001E4 3F00 move d0,-(sp)
257 000001E6 E848 lsr #4,d0
258 000001E8 6102 bsr prtnib
259 000001EA 301F move (sp)+,d0
260
261 prtnib:
262 000001EC 0240000F andi #$f,d0
263 000001F0 0C40000A cmpi #10,d0
264 000001F4 6D04 blt lt10
265 000001F6 06000007 addi.b #'A'-'9'-1,d0
266 lt10:
267 000001FA 06000030 addi.b #'0',d0
268 000001FE 3200 move d0,d1
269 00000200 7002 move #2,d0
270 00000202 4E42 trap #2
271 00000204 4E75 rts
272
273
274 00000000 .data
275
C P / M 6 8 0 0 0 A s s e m b l e r Revision 02.03 Page 6
Source File: exceptn.s
276 excmsg1:
277 00000000 0D0A0A4578636570 .dc.b 13,10,10,'Exception $',0
277 00000008 74696F6E202400
278
279 excmsg2:
280 0000000F 2061742075736572 .dc.b ' at user address $',0
280 00000017 2061646472657373
280 0000001F 202400
281
282 excmsg3:
283 00000022 2E202041626F7274 .dc.b '. Aborted.',0
283 0000002A 65642E00
284
285
286 00000000 .bss
287
288 evec_adr:
289 00000000 .ds.l 1
290
291 00000004 .end
C P / M 6 8 0 0 0 A s s e m b l e r Revision 02.03 Page 7
Source File: exceptn.s
S y m b o l T a b l e
_initexc 00000000 TEXT _tpa_hp ******** EXT _tpa_lp ******** EXT addrexc 00000184 TEXT
bgetseg 00000012 ABS bsetexc 00000016 ABS buserr 00000002 ABS chkredir 000000F0 TEXT
dfltexc 00000106 TEXT do_init 00000068 TEXT dontinit 0000006A TEXT endvec 00000030 ABS
evec_adr 00000000 BSS except 000000CA TEXT exchndl 00000072 TEXT excmsg1 00000000 DATA
excmsg2 0000000F DATA excmsg3 00000022 DATA excrtn0 00000076 TEXT init1 0000000A TEXT
init2 00000014 TEXT init3 00000020 TEXT init4 00000058 TEXT lowexc 00000122 TEXT
lt10 000001FA TEXT nobusexc 00000116 TEXT print 000001C6 TEXT prtbyte 000001E4 TEXT
prtdone 000001D2 TEXT prtlong 000001D4 TEXT prtnib 000001EC TEXT prtword 000001DC TEXT
spurious 00000018 ABS supstat1 000001B2 TEXT supstat2 000001BA TEXT supstat3 000001C0 TEXT
trap0 00000020 ABS trap2 00000022 ABS trap3 00000023 ABS usrexc 00000154 TEXT