0
|
1 ********************************************************************
|
|
2 * OS9p1 - OS-9 Level Two V3 P1 module
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Ed. Comments Who YY/MM/DD
|
|
7 * ------------------------------------------------------------------
|
|
8 * ?? Cleaned up some formatting KDM 87/05/15
|
|
9 * ?? Added comments and added new defines KDM 87/03/31
|
460
|
10 * 18 Added time of creation to process descriptor BRI 88/11/18
|
|
11 * 18r1 Added F$AllTsk call error exit to F$Chain BRI 88/12/05
|
|
12 * 18r2 Changed time tag to use F$Time - No ticks BRI 88/12/08
|
|
13 * 18r3 Removed bogus assumptions regarding init BGP 98/10/05
|
0
|
14 * module in order to shrink code size, added
|
|
15 * check for CRC bit in compabibility byte of
|
|
16 * init module.
|
460
|
17 * 18r9 Made minor optimizations as per Curtis Boyle's BGP 98/10/10
|
0
|
18 * optimization document
|
460
|
19 * 18r10 Removed FastBoot flag, CRC check is done via BGP 02/09/26
|
|
20 * D.CRC now
|
0
|
21
|
|
22 nam OS9p1
|
|
23 ttl OS9 Level Two V3 P1 module
|
|
24
|
|
25 ifp1
|
|
26 use defsfile
|
|
27 endc
|
|
28
|
460
|
29 rev set 10
|
0
|
30 edition set 18
|
|
31
|
|
32 mod eom,name,Systm,ReEnt+rev,entry,msiz ++
|
|
33
|
|
34 org $0000
|
|
35 msiz equ .
|
|
36
|
|
37 name fcs "OS9p1"
|
|
38 fcb edition
|
|
39
|
|
40 *------------------------------------------------*
|
|
41 * OS9p1 begins here:
|
|
42 *------------------------------------------------*
|
|
43 entry ldx #$100 clear rest of first 8k Block: ++
|
|
44 ldy #8192-$100 ++
|
|
45 clra
|
|
46 clrb
|
|
47 L001C std ,x++
|
|
48 leay -2,y
|
|
49 bne L001C
|
|
50
|
|
51 inca
|
|
52 std D.Tasks =$0100 task flags (32)
|
|
53 addb #$20 (DAT.TkCt) ++
|
|
54 std D.TskIPt =$0120 temporary images ++
|
|
55
|
|
56 inca
|
|
57 aslb
|
|
58 std D.BlkMap+2 =$0240 end of block map
|
|
59 clrb
|
|
60 std D.BlkMap =$0200 mem block map (64)
|
|
61
|
|
62 inca ++
|
|
63 std D.SysDis =$0300 sys dispatch table
|
|
64 inca
|
|
65 std D.UsrDis =$0400 usr dispatch table
|
|
66 inca
|
|
67 std D.PrcDBT =$0500 proc desc pointers
|
|
68 inca
|
|
69 std D.SysPrc =$0600 original sys proc
|
|
70 std D.Proc =$0600 original proc
|
|
71 adda #P$Size/256 desc
|
|
72 tfr d,s SP=$0800 sys SP within sys desc
|
|
73 inca
|
|
74 std D.SysStk =$0900 main sys stack ptr
|
|
75 std D.SysMem =$0900 sys memmap
|
|
76 inca
|
|
77 std D.ModDir =$0A00 module dir
|
|
78 std D.ModEnd =$0A00 (grows upward)
|
|
79 adda #$06
|
|
80 std D.ModDir+2 =$1000 module DAT images
|
|
81 std D.ModDAT =$1000 (grows downward)
|
|
82 std D.CCMem =$1000 CC3IO static memory ++
|
460
|
83 * In following line, CRC=ON if it is STA <D.CRC, CRC=OFF if it is a STB <D.CRC
|
|
84 stb <D.CRC set CRC checking flag to off
|
0
|
85
|
|
86 asla d=$2000 GrfDrv stack area ++
|
|
87
|
|
88 std D.CCStk ++
|
|
89
|
|
90 *------------------------------------------------*
|
|
91 leax Vectors,pcr put jmp[,x] vectors:
|
|
92 tfr x,d
|
|
93 ldx #D.SWI3
|
|
94
|
|
95 * used by top 256 to jmp to sys.
|
|
96
|
|
97 L0065 std ,x++
|
|
98 cmpx #D.NMI
|
|
99 bls L0065
|
|
100
|
|
101 leax >eo,pcr move secondary vectors
|
|
102 pshs x from end of rom:
|
|
103 leay >D.VECTRS,pcr
|
|
104 ldx #D.Clock (Tick-NMI)
|
|
105 L0079 ldd ,y++ get vector
|
|
106 addd ,s add offset
|
|
107 std ,x++ store
|
|
108 cmpx #D.XNMI done?
|
|
109 bls L0079 ..no
|
|
110 leas 2,s drop offset
|
|
111
|
|
112 ldx D.XSWI2 set calls to sys
|
|
113 stx D.UsrSvc
|
|
114 ldx D.XIRQ set IRQ to sys
|
|
115 stx D.UsrIRQ
|
|
116
|
|
117 leax SysCall,pcr set syscall handler
|
|
118 stx D.SysSvc
|
|
119 stx D.XSWI2
|
|
120
|
|
121 leax S.SysIRQ,pcr set sysirq handler
|
|
122 stx D.SysIRQ
|
|
123 stx D.XIRQ
|
|
124
|
|
125 leax >S.SvcIRQ,pcr IRQ svc handler
|
|
126 stx D.SvcIRQ
|
|
127 leax >S.POLL,pcr default poll 'til IOMan
|
|
128 stx D.Poll
|
|
129 leax S.AltIRQ,pcr default keyboard till CC3io ++
|
|
130 stx D.AltIRQ ++
|
|
131 leax S.Flip0,pcr Grfdrv return vector ++
|
|
132 stx D.Flip0 ++
|
|
133 leax S.Flip1,pcr GrfDrv exec vector ++
|
|
134 stx D.Flip1 ++
|
|
135
|
|
136 leay SysCalls,pcr enter os9p1 svc calls:
|
|
137 lbsr InstSSvc
|
|
138
|
|
139 *------------------------------------------------*
|
|
140 ldu D.PrcDBT set up first proc desc:
|
|
141 ldx D.SysPrc
|
|
142 stx 0,u proc table entries
|
|
143 stx 1,u zero and one
|
|
144
|
|
145 lda #1 sys proc id=01
|
|
146 sta P$ID,x
|
|
147 lda #SysState set sys state
|
|
148 sta P$State,x
|
|
149 lda #SysTask sys task # ++
|
|
150 sta D.SysTsk
|
|
151 sta P$Task,x
|
|
152 * optimization below saves one byte
|
|
153 ldd #$FFFF top priority/age
|
|
154 std P$Prior,x store it
|
|
155 * lda #$FF
|
|
156 * sta P$Prior,x
|
|
157 * sta P$Age,x
|
|
158
|
|
159 leax P$DATImg,x point sysdat -> sys proc
|
|
160 stx D.SysDAT
|
|
161 clra
|
|
162 clrb
|
|
163 std ,x++ first block always sys
|
|
164
|
|
165 * DAT.BlCt-ROMCount-RAMCount:
|
|
166 ldy #6 next 6 are unused ++
|
|
167 ldd #DAT.Free
|
|
168 L00EF std ,x++
|
|
169 leay -1,y
|
|
170 bne L00EF
|
|
171
|
|
172 ldd #IOBlock last one is Kernel ++
|
|
173 std ,x++
|
|
174
|
|
175 ldx D.Tasks first task# is sys's
|
|
176 inc 0,x
|
|
177 inc 1,x Task 1 is GrfDrv ++
|
|
178
|
|
179 *------------------------------------------------*
|
|
180 * set 1st 8K sys mem used
|
|
181 ldx D.SysMem
|
|
182 ldb D.CCStk (=$20) ++
|
|
183 L0104 inc ,x+
|
|
184 decb
|
|
185 bne L0104
|
|
186
|
|
187 *------------------------------------------------*
|
|
188 * determine size of CoCo's memory (128K/512K)
|
|
189 clr D.MemSz default is 128k ++
|
|
190 ldd #$0313 blocks $03 and $13 ++
|
|
191 std DAT.Regs+5 map at logical $A000 ++
|
|
192 ldx #$A000 point to first block ++
|
|
193 ldd #$DC78 get inverted sync bytes ++
|
|
194 std ,x store at start of first block ++
|
|
195 cmpd 8192,x in second block too? ++
|
|
196 beq L0122 yes, just 128k ++
|
|
197 inc D.MemSz else set 512k flag ++
|
|
198
|
|
199 L0122 ldy #$2000 point to second block in map ++
|
|
200 ldx D.BlkMap X=$0200
|
|
201
|
|
202 * Check Memory Blocks Loop:
|
|
203
|
|
204 L0128 pshs x save current map pointer
|
|
205 ldd ,s D=map ptr
|
|
206 subd D.BlkMap D=block number
|
|
207 cmpb #IOBlock is it sys?
|
|
208 bne L0136 ..no, test for 512k ++
|
|
209 ldb #RAMinUse load marker ++
|
|
210 bra L015B go set in map ++
|
|
211
|
|
212 L0136 lda D.MemSz 512k memory? ++
|
|
213 bne L013E yes, continue ++
|
|
214 cmpb #$0F end of 128k mem? ++
|
|
215 bhs L0159 yes, set notram ++
|
|
216
|
|
217 L013E stb >DAT.Regs+1 set block at $2000 for test ++
|
|
218 ldu ,y get two bytes
|
|
219 ldx #$00FF store test bytes
|
|
220 stx ,y
|
|
221 cmpx ,y same on read
|
|
222 bne L0159 ..end if no mem here
|
|
223
|
|
224 ldx #$FF00 make sure again
|
|
225 stx ,y
|
|
226 cmpx ,y
|
|
227 bne L0159 ..bad mem
|
|
228 stu ,y restore original bytes
|
|
229 bra L015D do next
|
|
230
|
|
231 * End of Memory:
|
|
232
|
|
233 L0159 ldb #NotRAM set non-mem flag
|
|
234
|
|
235 L015B stb [,s] store at ,X in table ++
|
|
236
|
|
237 L015D puls x get current map pointer
|
|
238 leax 1,x next block
|
|
239 cmpx D.BlkMap+2 end of map?
|
|
240 blo L0128 ..no, keep trying
|
|
241
|
|
242 *------------------------------------------------*
|
|
243 * Search For ROM Modules:
|
|
244
|
|
245 ldx D.BlkMap X=map strt (X=$0200)
|
|
246 inc ,x mark as RAMinUse
|
|
247 ldx D.BlkMap+2 start at end of map (X=$0240)
|
|
248
|
|
249 leax -1,x back up 1 (X=$023F)
|
|
250
|
|
251 *------------------------------------------------*
|
|
252 tfr x,d else D=block number (D=$023F)
|
|
253 subd D.BlkMap make into block number (D=$003F)
|
|
254
|
|
255 pshs d save block number
|
|
256 leay ,s Y = var pointer for routine below
|
|
257
|
|
258 ldx #$0D00 offset in block ++
|
|
259
|
|
260 *------------------------------------------------*
|
|
261 * Check Block for Modules Loop:
|
|
262
|
|
263 L017F pshs x,y
|
|
264 lbsr L0AF0 set up Y for X offset
|
|
265 ldb 1,y B=block# from image
|
|
266 stb >DAT.Regs map into sys zero
|
|
267 lda ,x get byte from block
|
|
268 clr >DAT.Regs back to sys
|
|
269 puls x,y
|
|
270 cmpa #M$ID1 module?
|
|
271 bne L01A7
|
|
272
|
|
273 lbsr L0463 do verify
|
|
274 bcc L019D
|
|
275 cmpb #E$KwnMod 'Known Module'?
|
|
276 bne L01A7 ..no, continue
|
|
277 L019D ldd #M$Size else get mod size
|
|
278 lbsr lddxy
|
|
279 leax d,x skip over it
|
|
280 bra L01A9
|
|
281
|
|
282 * Not Known Module:
|
|
283
|
|
284 L01A7 leax 1,x byte ptr+1
|
|
285
|
|
286 L01A9 cmpx #$1E00 don't overrun vector page! ++
|
|
287 blo L017F ok to continue ++
|
|
288 bsr L01D2 setup system mem map ++
|
|
289
|
|
290 *------------------------------------------------*
|
|
291 * OS9p1 init finished:
|
|
292
|
|
293 L01B0 os9 F$Boot boot!
|
|
294 bcs Crash crash if problem
|
|
295 leax InitMod,pcr 'Init'
|
|
296 bsr LinkSys link to it
|
|
297 bcs Crash crash if error
|
|
298 L01BF stu D.Init save Init ptr
|
460
|
299 lda Feature1,u get feature byte #1
|
|
300 bita #CRCOn CRC checking on?
|
|
301 beq L01C1 branch if not...
|
|
302 inc <D.CRC else inc. CRC flag
|
0
|
303 L01C1 leax OS9p2Nm,pcr 'OS9p2'
|
|
304 bsr LinkSys link to it
|
|
305 bcs Crash crash if not found...
|
|
306 L01D0 jmp ,y ...else do OS9p2...
|
|
307 Crash jmp D.Crash report boot failed
|
|
308
|
|
309 * Setup system memory map.
|
|
310
|
|
311 L01D2 ldx D.SysMem point to map ++
|
|
312 leax $ED00/256,x kernel offset in map ++
|
|
313 lda #NotRam mark IOPage ++
|
|
314 sta 18,x as Not RAM ++
|
|
315 ldb #$12 18 pages in kernel ++
|
|
316
|
|
317 L01DF lda #RAMinUse mark kernel ++
|
|
318
|
|
319 L01E1 sta ,x+ RAM as in use ++
|
|
320 decb all done ++
|
|
321 bne L01E1 no, continue
|
|
322 ldx D.BlkMap+2 end of map++
|
|
323 sta -1,x mark block #3F ++
|
|
324 rts exit ++
|
|
325
|
|
326 * Link to Module (X = ptr to mod name):
|
|
327 LinkSys lda #Systm system module
|
|
328 os9 F$Link try to find it
|
|
329 rts
|
|
330
|
|
331 *------------------------------------------------*
|
|
332 * System Service Calls
|
|
333 *------------------------------------------------*
|
|
334 SysCalls fcb F$Link
|
|
335 fdb FLink-*-2
|
|
336 fcb F$PrsNam
|
|
337 fdb FPrsNam-*-2
|
|
338 fcb F$CmpNam
|
|
339 fdb FCmpNam-*-2
|
|
340 fcb F$CmpNam+$80 (sys)
|
|
341 fdb SCmpNam-*-2
|
|
342 fcb F$CRC
|
|
343 fdb FCRC-*-2
|
|
344 fcb F$SRqMem+$80
|
|
345 fdb FSRqMem-*-2
|
|
346 fcb F$SRtMem+$80
|
|
347 fdb FSRtMem-*-2
|
|
348 fcb F$AProc+$80
|
|
349 fdb FAProc-*-2
|
|
350 fcb F$NProc+$80
|
|
351 fdb FNProc-*-2
|
|
352 fcb F$VModul+$80
|
|
353 fdb FVModul-*-2
|
|
354 fcb F$SSvc
|
|
355 fdb FSSvc-*-2
|
|
356 fcb F$SLink+$80
|
|
357 fdb FSLink-*-2
|
|
358 fcb F$Boot+$80
|
|
359 fdb FBoot-*-2
|
|
360 fcb F$BtMem+$80
|
|
361 fdb FBtMem-*-2
|
|
362 fcb F$Move+$80
|
|
363 fdb FMove-*-2
|
|
364 fcb F$AllRam
|
|
365 fdb FAllRam-*-2
|
|
366 fcb F$AllImg+$80
|
|
367 fdb FAllImg-*-2
|
|
368 fcb F$SetImg+$80
|
|
369 fdb FSetImg-*-2
|
|
370 fcb F$FreeLB+$80
|
|
371 fdb FFreeLB-*-2
|
|
372 fcb F$FreeHB+$80
|
|
373 fdb FFreeHB-*-2
|
|
374 fcb F$AllTsk+$80
|
|
375 fdb FAllTsk-*-2
|
|
376 fcb F$DelTsk+$80
|
|
377 fdb FDelTsk-*-2
|
|
378 fcb F$SetTsk+$80
|
|
379 fdb FSetTsk-*-2
|
|
380 fcb F$ResTsk+$80
|
|
381 fdb FResTsk-*-2
|
|
382 fcb F$RelTsk+$80
|
|
383 fdb FRelTsk-*-2
|
|
384 fcb F$DATLog+$80
|
|
385 fdb FDATLog-*-2
|
|
386 fcb F$LDAXY+$80
|
|
387 fdb FLDAXY-*-2
|
|
388 fcb F$LDDDXY+$80
|
|
389 fdb FLDDDXY-*-2
|
|
390 fcb F$LDABX+$80
|
|
391 fdb FLDABX-*-2
|
|
392 fcb F$STABX+$80
|
|
393 fdb FSTABX-*-2
|
|
394 fcb F$ELink+$80
|
|
395 fdb FELink-*-2
|
|
396 fcb F$FModul+$80
|
|
397 fdb FFModul-*-2
|
|
398 fcb F$AlHRam+$80 new call ++
|
|
399 fdb FAlHRam-*-2 for CoCo3 ++
|
|
400 fcb $80 End of Table
|
|
401
|
|
402 *------------------------------------------------*
|
|
403 InitMod fcs "Init"
|
|
404 OS9p2Nm fcs "OS9p2"
|
|
405 BootMod fcs "Boot"
|
|
406
|
|
407 *------------------------------------------------*
|
|
408 Vectors jmp [-16,x] goto irq routine
|
|
409
|
|
410 *------------------------------------------------*
|
|
411 * User State SWI Vectors:
|
|
412 *------------------------------------------------*
|
|
413
|
|
414 XSWI3 ldx D.Proc proc desc
|
|
415 ldu P$SWI3,x diff swi3 vector?
|
|
416 beq L028E ..no, do normal
|
|
417
|
|
418 L027B lbra L0E5E else do usr call.
|
|
419
|
|
420 XSWI2 ldx D.Proc X=proc desc
|
|
421 ldu P$SWI2,x swi2 svc ptr
|
|
422 beq L028E ..zero, do normal
|
|
423 bra L027B else do usr map
|
|
424
|
|
425 XSWI ldx D.Proc proc desc
|
|
426 ldu P$SWI,x swi ptr
|
|
427 bne L027B ..do user, else:
|
|
428
|
|
429 *------------------------------------------------*
|
|
430 * System SWI calls: (X=pd, U=svc)
|
|
431
|
|
432 L028E ldd D.SysSvc set system state:
|
|
433 std D.XSWI2
|
|
434 ldd D.SysIRQ
|
|
435 std D.XIRQ
|
|
436 lda P$State,x
|
|
437 ora #SysState
|
|
438 sta P$State,x
|
|
439
|
|
440 sts P$SP,x and save user stack
|
|
441 leas P$Stack-R$Size,x get local sys stack
|
|
442 andcc #^IntMasks okay interrupts
|
|
443 leau ,s U=sys reg stack
|
|
444 bsr L02CB copy user stack here
|
|
445
|
|
446 ldb P$Task,x B=task#
|
|
447 ldx R$PC,u X=PC ptr
|
|
448 lbsr FLDBBX get call byte from user map ++
|
|
449 leax 1,x increment PC
|
|
450 stx R$PC,u past call
|
|
451
|
|
452 ldy D.UsrDis Y=user dispatch table
|
|
453 lbsr L033B do the call
|
|
454 ldb R$CC,u okay interrupts
|
|
455 andb #^IntMasks on return
|
|
456 stb R$CC,u to user map
|
|
457
|
|
458 ldx D.Proc
|
|
459 bsr L02DA copy back new user stack
|
|
460 lda P$State,x drop sys state
|
|
461 anda #^SysState
|
|
462 lbra L0D7C and return to user.
|
|
463
|
|
464 *------------------------------------------------*
|
|
465 * Get Caller's Regs:
|
|
466
|
|
467 L02CB pshs cc,x,y,u ++
|
|
468 ldb P$Task,x A=user tsk# ++
|
|
469 ldx P$SP,x X=from user stack
|
|
470 lbsr L0BF5 get offset in 8k space ++
|
|
471 leax $A000,x +$A000 =logical address ++
|
|
472 bra L02E9 get regs & rts.
|
|
473
|
|
474 * Return Regs to Caller:
|
|
475
|
|
476 L02DA pshs cc,x,y,u save state ++
|
|
477 ldb P$Task,x B=user tsk#
|
|
478 ldx P$SP,x X=to user stack
|
|
479 lbsr L0BF5 get offset in 8k space ++
|
|
480 leax $A000,x +$A000 =logical address ++
|
|
481 exg x,u U=user, X=sys
|
|
482
|
|
483 * move caller stack -->
|
|
484
|
|
485 L02E9 pshs u save U ++
|
|
486 lbsr L0C09 get DAT image pointer in U ++
|
|
487 leau a,u point to block # in image ++
|
|
488 leau 1,u point to LSB ++
|
|
489 * lda ,u++ first block # in A ++ --BGP
|
|
490 * ldb ,u second block # in B ++ --BGP
|
|
491 lda ,u first block # in A ++ ++BGP
|
|
492 ldb 2,u second block # in B ++ ++BGP
|
|
493 ldu #DAT.Regs+5 $A000 logical ++
|
|
494 orcc #IntMasks mask interrupts ++
|
|
495 std ,u set DAT ++
|
|
496 puls u recover U ++
|
|
497 ldy #R$SIZE register stack size ++
|
|
498
|
|
499 L0303 ldd ,x++ move them ++
|
|
500 std ,u++ ++
|
|
501 leay -2,y done yet? ++
|
|
502 bne L0303 no, continue ++
|
|
503 ldx D.SysDAT system DAT image ++
|
|
504 lda 11,x get real ++
|
|
505 ldb 13,x system blocks ++
|
|
506 std DAT.Regs+5 and restore system map ++
|
|
507 puls cc,x,y,u,pc clean up and rts ++
|
|
508
|
|
509 *------------------------------------------------*
|
|
510 * Sys State OS Call:
|
|
511 *------------------------------------------------*
|
|
512 SysCall leau ,s U=reg stack
|
|
513 lda D.SSTskN get task image ++
|
|
514 clr D.SSTskN set to system ++
|
|
515 pshs a save old task # ++
|
|
516 lda R$CC,u
|
|
517 tfr a,cc set CC=user CC
|
|
518 ldx R$PC,u get call
|
|
519 ldb ,s is task sys? ++
|
|
520 beq L032F yes ++
|
|
521 lbsr FLDBBX get call from user space ++
|
|
522 leax 1,x point past it ++
|
|
523 bra L0331 set as PC ++
|
|
524
|
|
525 L032F ldb ,x+ and increment PC
|
|
526
|
|
527 L0331 stx R$PC,u past it
|
|
528 ldy D.SysDis Y=system dispatch table
|
|
529 bsr L033B do the call
|
|
530 lbra L0E2B end
|
|
531
|
|
532 *------------------------------------------------*
|
|
533 * Do Svc Call(B), Y=table:
|
|
534
|
|
535 L033B aslb index
|
|
536 bcc L0345 ..okay if not I/O
|
|
537
|
|
538 * count I$ calls for current process (D.Proc)
|
|
539 pshs b save index into table
|
|
540 ldb #P$ICalls set up I$ counter
|
|
541 bsr IncCount go do it... (X is altered)
|
|
542 puls b recover index
|
|
543
|
|
544 rorb else reset B
|
|
545 ldx $00FE,y else X=IOMan vector
|
|
546 bra L034F and do it.
|
|
547
|
|
548 * count User Ticks, System Ticks, F$ calls, or I$ calls
|
|
549 * for current process (D.Proc) BRI
|
|
550 IncCount ldx <D.Proc get pointer to current proc desc
|
|
551 beq IncExit no current proc, go return
|
|
552 abx add offset to appropriate counter
|
|
553 inc 3,x 4 byte counter LSB
|
|
554 bne IncExit no overflow, go return
|
|
555 inc 2,x 4 byte counter lower middle byte
|
|
556 bne IncExit no overflow, go return
|
|
557 inc 1,x 4 byte counter upper middle byte
|
|
558 bne IncExit no overflow, go return
|
|
559 inc ,x 4 byte counter MSB (ignore overflow)
|
|
560 IncExit rts
|
|
561
|
|
562 * (not I/O call)
|
|
563
|
|
564 L0345 pshs b save index into table
|
|
565 ldb #P$FCalls set up F$ counter
|
|
566 bsr IncCount go do it... (X is altered)
|
|
567 puls b recover index
|
|
568
|
|
569 clra A=00
|
|
570 ldx d,y X=vector from table
|
|
571 bne L034F ..ok if one
|
|
572 comb else
|
|
573 ldb #E$UnkSvc 'Unknown Service Call'
|
|
574 bra L0355 bad end: return err
|
|
575
|
|
576 *------------------------------------------------*
|
|
577 * Do Call Vector (X)
|
|
578
|
|
579 L034F pshs u save reg ptr
|
|
580 jsr ,x do the call
|
|
581 puls u retrieve reg ptr
|
|
582
|
|
583 L0355 tfr cc,a A=svc call CC
|
|
584 bcc L035B ..skip if no err
|
|
585 stb R$B,u else return err in reg.B
|
|
586 L035B ldb R$CC,u drop lsb nibble
|
|
587 andb #(Entire!IntMasks)
|
|
588 stb R$CC,u
|
|
589 anda #^(Entire!IntMasks) put in call's CC lsnibble
|
|
590 ora R$CC,u
|
|
591 sta R$CC,u
|
|
592 rts end service call.
|
|
593
|
|
594
|
|
595 *------------------------------------------------*
|
|
596 * F$SSvc
|
|
597 *------------------------------------------------*
|
|
598 FSSvc ldy R$Y,u Y=table address
|
|
599 bra InstSSvc do check first...
|
|
600
|
|
601 * SSvc Loop:
|
|
602
|
|
603 L036D clra A=00
|
|
604 aslb B=table index (set C if >=$80)
|
|
605 tfr d,u U=index
|
|
606 ldd ,y++ D=new call vector offset
|
|
607 leax d,y X=actual vector
|
|
608 ldd D.SysDis D=sys dispatch table
|
|
609 stx d,u store new call vector
|
|
610 bcs InstSSvc ..skip if sys only
|
|
611 ldd D.UsrDis else put in user
|
|
612 stx d,u dispatch table also.
|
|
613
|
|
614 * End of Table Check:
|
|
615
|
|
616 InstSSvc ldb ,y+ get next call
|
|
617 cmpb #$80 is it end-of-table?
|
|
618 bne L036D ..no
|
|
619 rts yes, end.
|
|
620
|
|
621
|
|
622 *------------------------------------------------*
|
|
623 * F$SLink
|
|
624 *------------------------------------------------*
|
|
625 * Link modules into map.
|
|
626 * A=type,X=name,Y=DAT image ptr
|
|
627 FSLink ldy R$Y,u get DAT image ptr
|
|
628 bra SLink
|
|
629
|
|
630
|
|
631 *------------------------------------------------*
|
|
632 * F$ELink
|
|
633 *------------------------------------------------*
|
|
634 FELink pshs u
|
|
635 ldb R$B,u type
|
|
636 ldx R$X,u name of module
|
|
637 bra L03AF go link it
|
|
638
|
|
639
|
|
640 *------------------------------------------------*
|
|
641 * F$Link
|
|
642 *------------------------------------------------*
|
|
643 FLink ldx D.Proc proc desc
|
|
644 leay P$DATImg,x Y=DAT image ptr
|
|
645
|
|
646 *------------------------------------------------*
|
|
647 SLink pshs u save reg ptr
|
|
648 ldx R$X,u X=module name
|
|
649 lda R$A,u A=module type
|
|
650 lbsr L068D search moddir
|
|
651
|
|
652 bcs L041E ..err
|
|
653
|
|
654 leay ,u Y=moddir entry
|
|
655 ldu ,s get back reg ptr
|
|
656 stx R$X,u return X
|
|
657 std R$D,u return type/lang
|
|
658 leax ,y X=moddir entry
|
|
659
|
|
660 L03AF bitb #ReEnt is it shareable?
|
|
661 bne L03BB ..yes
|
|
662 ldd MD$Link,x any links?
|
|
663 beq L03BB ..no:ok, else
|
|
664 ldb #E$ModBsy 'Module Busy' err
|
|
665 bra L041E bad end.
|
|
666
|
|
667 L03BB ldd MD$MPtr,x D=module ptr
|
|
668 pshs a,b,x save ptr,entry
|
|
669 ldy MD$MPDAT,x Y=DAT img for module
|
|
670 ldd MD$MBSiz,x D=mem block size
|
|
671 addd #$1FFF round up A ++
|
|
672 tfr a,b to 8K block ++
|
|
673 lsrb B/32
|
|
674 lsrb
|
|
675 lsrb
|
|
676 lsrb
|
|
677 lsrb ++
|
|
678 adda #2 (A+2)/32 ++
|
|
679 lsra
|
|
680 lsra
|
|
681 lsra
|
|
682 lsra
|
|
683 lsra ++
|
|
684 pshs a save blocks needed
|
|
685 leau ,y U=moddir entry
|
|
686 bsr L0422 find it in callers map?
|
|
687 bcc L03EB ..yes
|
|
688
|
|
689 lda ,s blocks needed
|
|
690 lbsr L0A33 room to map in?
|
|
691 bcc L03E8 ..okay
|
|
692 leas 5,s else drop junk
|
|
693 bra L041E bad end.
|
|
694
|
|
695 L03E8 lbsr L0A8C set DAT image
|
|
696 L03EB leax P$Links,x link cnt tble
|
|
697 sta ,s save block #
|
|
698 asla index
|
|
699 leau a,x U=link ptr
|
|
700 ldx ,u increment link cnt:
|
|
701 leax 1,x
|
|
702 beq L03FC
|
|
703 stx ,u
|
|
704 L03FC ldu 3,s U=moddir entry
|
|
705 ldx MD$Link,u increment link cnt:
|
|
706 leax 1,x
|
|
707 beq L0406
|
|
708 stx MD$Link,u
|
|
709 L0406 puls b,x,y,u
|
|
710 lbsr L0AB0 dattolog
|
|
711 stx R$U,u return module addrss
|
|
712 ldx MD$MPtr,y mod ptr
|
|
713 ldy MD$MPDAT,y DAT image ptr
|
|
714 ldd #M$Exec get exec offset
|
|
715 lbsr LDDXY
|
|
716 addd R$U,u plus mod addrss
|
|
717 std R$Y,u = exec address
|
|
718 clrb okay
|
|
719 rts end.
|
|
720
|
|
721 L041E orcc #Carry set error
|
|
722 puls u,pc
|
|
723
|
|
724 *------------------------------------------------*
|
|
725 * See if moddir image in proc map already:
|
|
726 *------------------------------------------------*
|
|
727
|
|
728 * B=block img #, U=moddir ptr
|
|
729
|
|
730 L0422 ldx D.Proc proc desc
|
|
731 leay P$DATImg,x Y=DAT image ptr
|
|
732 clra A=00
|
|
733 pshs a,b,x,y save #,proc,img
|
|
734 subb #DAT.BlCt
|
|
735 negb
|
|
736 aslb index
|
|
737 leay b,y
|
|
738
|
|
739 * Image Compare Loop:
|
|
740
|
|
741 L0430 ldx ,s X=block cnt
|
|
742 pshs y,u
|
|
743 L0434 ldd ,y++ does proc img
|
|
744 cmpd ,u++ match mod image?
|
|
745 bne L0449 ..no
|
|
746 leax -1,x yes, cnt-1
|
|
747 bne L0434 ..done?
|
|
748
|
|
749 puls a,b,u D=start ptr
|
|
750 subd 4,s -block cnt = offset
|
|
751 lsrb B/2 index
|
|
752 stb ,s save block #
|
|
753 clrb okay
|
|
754 puls a,b,x,y,pc rts.
|
|
755
|
|
756 L0449 puls y,u Y=start ptr
|
|
757 leay -2,y back up one img
|
|
758 cmpy 4,s too far?
|
|
759 bcc L0430 ..no, try again
|
|
760 puls a,b,x,y,pc error end.
|
|
761
|
|
762
|
|
763 *------------------------------------------------*
|
|
764 * F$VModul
|
|
765 *------------------------------------------------*
|
|
766 FVModul pshs u
|
|
767 ldx R$X,u X=mod offset
|
|
768 ldy R$D,u Y=DAT img ptr
|
|
769 bsr L0463 do the verify
|
|
770 ldx ,s
|
|
771 stu R$U,x return moddir ptr
|
|
772 puls u,pc
|
|
773
|
|
774 L0463 pshs x,y
|
|
775 lbsr L0586 check module crc
|
|
776 bcs L0493 ..err
|
|
777
|
|
778 ldd #M$Type
|
|
779 lbsr LDDXY get type/rev bytes
|
|
780 andb #$0F save rev
|
|
781 pshs a,b
|
|
782
|
|
783 ldd #M$Name get name offset
|
|
784 lbsr LDDXY
|
|
785 leax d,x X points to mod name
|
|
786 puls a
|
|
787 lbsr L068D
|
|
788 puls a
|
|
789 bcs L0497
|
|
790
|
|
791 pshs a
|
|
792 andb #$0F
|
|
793 subb ,s+
|
|
794 bcs L0497
|
|
795 ldb #E$KwnMod 'Known Module'
|
|
796 bra L0493
|
|
797
|
|
798 L0491 ldb #E$DirFul 'Module Dir Full'
|
|
799 L0493 orcc #Carry
|
|
800 puls x,y,pc
|
|
801
|
|
802 *------------------------------------------------*
|
|
803 L0497 ldx ,s X=module addrss
|
|
804 lbsr L0524
|
|
805 bcs L0491
|
|
806 sty MD$MPDAT,u insert DAT image ptr
|
|
807 stx MD$MPtr,u and module ptr
|
|
808 clra
|
|
809 clrb
|
|
810 std MD$Link,u link count=00
|
|
811 ldd #M$Size
|
|
812 lbsr LDDXY get module size
|
|
813 pshs x mod addrss
|
|
814 addd ,s++ plus size
|
|
815 std MD$MBSiz,u
|
|
816 ldy [MD$MPDAT,u] Y=mod images
|
|
817 ldx D.ModDir X=mod dir strt
|
|
818 pshs u save entry
|
|
819 bra L04BE
|
|
820
|
|
821 L04BC leax MD$ESize,x next moddir entry
|
|
822 L04BE cmpx D.ModEnd last one?
|
|
823 bcc L04CD ..yes, end
|
|
824 cmpx ,s same entry?
|
|
825 beq L04BC ..yes, try again
|
|
826 cmpy [,x] same image ptr?
|
|
827 bne L04BC ..no, try again
|
|
828 bsr L04F2
|
|
829
|
|
830 *------------------------------------------------*
|
|
831 * Mark BlockMaps as Modules:
|
|
832
|
|
833 L04CD puls u U=dir entry
|
|
834 ldx D.BlkMap X=mem block map
|
|
835 ldd MD$MBSiz,u D=mod block size
|
|
836 addd #$1FFF round up size ++
|
|
837 lsra A/32 = number of blocks
|
|
838 lsra (8K)
|
|
839 lsra
|
|
840 lsra
|
|
841 lsra ++
|
|
842 ldy MD$MPDAT,u Y=mod dat image
|
|
843
|
|
844 L04DE pshs a,x save block size, blkmap
|
|
845 ldd ,y++ D=image block#
|
|
846 leax d,x X=blkmap ptr
|
|
847 ldb ,x get block marker
|
|
848 orb #ModBlock set module in block
|
|
849 stb ,x marker
|
|
850 puls a,x ..
|
|
851 deca count-1
|
|
852 bne L04DE ..mark all blocks
|
|
853
|
|
854 clrb okay
|
|
855 puls x,y,pc end.
|
|
856
|
|
857 *------------------------------------------------*
|
|
858 * Clear entries:
|
|
859
|
|
860 L04F2 pshs a,b,x,y,u
|
|
861 ldx ,x
|
|
862 pshs x
|
|
863 clra D=0000
|
|
864 clrb
|
|
865 L04FA ldy ,x last entry?
|
|
866 beq L0503 ..yes
|
|
867 std ,x++ no, clear
|
|
868 bra L04FA and loop
|
|
869
|
|
870 L0503 puls x
|
|
871 ldy 2,s
|
|
872 ldu MD$MPDAT,u U=mod images
|
|
873 puls a,b
|
|
874
|
|
875 L050C cmpx ,y same image?
|
|
876 bne L051B ..no, try next
|
|
877 stu MD$MPDAT,y yes, set new image
|
|
878 cmpd MD$MBSiz,y new size bigger?
|
|
879 bcc L0519 ..yes, use it
|
|
880 ldd MD$MBSiz,y else use old size
|
|
881 L0519 std MD$MBSiz,y set modblock size
|
|
882 L051B leay MD$ESize,y next entry
|
|
883 cmpy D.ModEnd last?
|
|
884 bne L050C ..no
|
|
885 puls x,y,u,pc end.
|
|
886
|
|
887 *------------------------------------------------*
|
|
888 L0524 pshs x,y,u save mod adrs,img,
|
|
889 ldd #M$Size get module size
|
|
890 lbsr LDDXY
|
|
891 addd ,s end = begin+size
|
|
892 addd #$1FFF round to block ++
|
|
893 lsra A/32
|
|
894 lsra
|
|
895 lsra
|
|
896 lsra
|
|
897 lsra ++,
|
|
898 tfr a,b A,B=number of blocks
|
|
899 pshs b save num
|
|
900 incb
|
|
901 aslb
|
|
902 negb
|
|
903 sex sign extend into D
|
|
904 bsr L054E make new dir entry
|
|
905 bcc L054C ..okay rts
|
|
906
|
|
907 os9 F$GCMDir else get task#
|
|
908 ldu #$0000 set flag
|
|
909 stu 5,s
|
|
910 bsr L054E make new dir entry
|
|
911 L054C puls b,x,y,u,pc rts.
|
|
912
|
|
913 *------------------------------------------------*
|
|
914 * Allocate module dir image:
|
|
915
|
|
916 L054E ldx D.ModDAT X+D = mod DAT img pointer
|
|
917 leax d,x
|
|
918 cmpx D.ModEnd would it be below last dir?
|
|
919 bcs L0583 ..yes, err
|
|
920
|
|
921 ldu 7,s get back old U
|
|
922 bne L056E ..
|
|
923 pshs x save new moddat ptr
|
|
924 ldy D.ModEnd Y=end of dir
|
|
925 leay MD$ESize,y plus new entry
|
|
926 cmpy ,s++ collide with moddat?
|
|
927 bhi L0583 ..yes, err
|
|
928
|
|
929 sty D.ModEnd store new dir end
|
|
930 leay -MD$ESize,y Y=new dir entry ptr
|
|
931 sty 7,s return it to caller
|
|
932 L056E stx D.ModDAT store new moddat ptr
|
|
933 ldy 5,s
|
|
934 ldb 2,s B=block count
|
|
935 stx 5,s return dir datimg ptr
|
|
936
|
|
937 L0577 ldu ,y++ copy images
|
|
938 stu ,x++ to new mod dat entry
|
|
939 decb
|
|
940 bne L0577
|
|
941
|
|
942 clr ,x zero flag
|
|
943 clr 1,x
|
|
944 rts end.
|
|
945
|
|
946 L0583 orcc #Carry set err flag
|
|
947 rts end.
|
|
948
|
|
949
|
|
950 *------------------------------------------------*
|
|
951 * Calculate CRC of Module:
|
|
952 *------------------------------------------------*
|
|
953
|
|
954 L0586 pshs x,y
|
|
955 clra D=offset of zero
|
|
956 clrb
|
|
957 lbsr LDDXY get 2 bytes
|
|
958 cmpd #M$ID12 is it module?
|
|
959 beq L0597 ..yes
|
|
960 ldb #E$BMID 'Bad Module Header'
|
|
961 bra L05F3 ..err end.
|
|
962
|
|
963 * Check Module Header:
|
|
964
|
|
965 L0597 leas -1,s make var
|
|
966 leax 2,x X=past sync bytes
|
|
967 lbsr L0AF0 set Y for X offset
|
|
968 ldb #$07 seven bytes
|
|
969 lda #$4A header crc
|
|
970 L05A2 sta ,s save crc
|
|
971 lbsr LDAXY get next byte
|
|
972 eora ,s do crc
|
|
973 decb more?
|
|
974 bne L05A2 ..loop
|
|
975
|
|
976 leas 1,s drop var
|
|
977 inca $FF+1 = 00
|
|
978 beq L05B5 ..okay header
|
|
979 ldb #E$BMHP 'Bad Module Header'
|
|
980 bra L05F3 err end.
|
|
981
|
|
982 *------------------------------------------------*
|
|
983 * Do CRC across module:
|
|
984 *
|
|
985 * Added code to check init module for CRC check flag
|
460
|
986 L05B5 lda <D.CRC get D.CRC flag ++BGP
|
0
|
987 bne L05CX if set, check CRC ++BGP
|
460
|
988 NOCRC clrb else clrb (A already zero) ++BGP
|
0
|
989 bra L05F5 branch to end of routine ++BGP
|
|
990 L05CX puls x,y
|
|
991 ldd #$0002
|
|
992 lbsr LDDXY
|
|
993 pshs a,b,x,y
|
|
994 ldd #$FFFF set temp CRC register
|
|
995 pshs a,b
|
|
996 pshs b
|
|
997 lbsr L0AF0 set up Y for X offset
|
|
998 leau ,s
|
|
999 L05CB tstb
|
|
1000 bne L05D8
|
|
1001 pshs x
|
|
1002 ldx #$0001
|
|
1003 os9 F$Sleep
|
|
1004 puls x
|
|
1005 L05D8 lbsr LDAXY get a byte
|
|
1006 bsr CRCCalc pass it through the CRC calculator
|
|
1007 ldd 3,s
|
|
1008 subd #$0001
|
|
1009 std 3,s
|
|
1010 bne L05CB
|
|
1011 puls b,x,y
|
|
1012 cmpb #$80
|
|
1013 bne L05F1
|
|
1014 cmpx #$0FE3
|
|
1015 beq L05F5
|
|
1016 L05F1 ldb #E$BMCRC 'Bad Module CRC'
|
|
1017 L05F3 orcc #Carry
|
|
1018 L05F5 puls x,y,pc
|
|
1019
|
|
1020 *------------------------------------------------*
|
|
1021 * CRC Calculator:
|
|
1022 *------------------------------------------------*
|
|
1023
|
|
1024 * A = byte to be passed through accumulator
|
|
1025 CRCCalc eora ,u
|
|
1026 pshs a
|
|
1027 ldd 1,u
|
|
1028 std ,u
|
|
1029 clra
|
|
1030 ldb ,s
|
|
1031 aslb
|
|
1032 rola
|
|
1033 eora 1,u
|
|
1034 std 1,u
|
|
1035 clrb
|
|
1036 lda ,s
|
|
1037 lsra
|
|
1038 rorb
|
|
1039 lsra
|
|
1040 rorb
|
|
1041 eora 1,u
|
|
1042 eorb 2,u
|
|
1043 std 1,u
|
|
1044 lda ,s
|
|
1045 asla
|
|
1046 eora ,s
|
|
1047 sta ,s
|
|
1048 asla
|
|
1049 asla
|
|
1050 eora ,s
|
|
1051 sta ,s
|
|
1052 asla
|
|
1053 asla
|
|
1054 asla
|
|
1055 asla
|
|
1056 eora ,s+
|
|
1057 bpl L0635
|
|
1058 ldd #$8021
|
|
1059 eora ,u
|
|
1060 sta ,u
|
|
1061 eorb 2,u
|
|
1062 stb 2,u
|
|
1063 L0635 rts
|
|
1064
|
|
1065 *------------------------------------------------*
|
|
1066 * F$CRC
|
|
1067 *------------------------------------------------*
|
|
1068 FCRC ldd R$Y,u get byte count
|
|
1069 beq L0677 ..zero
|
|
1070 ldx R$X,u begin ptr
|
|
1071 pshs a,b,x
|
|
1072 leas -3,s
|
|
1073 ldx D.Proc
|
|
1074 lda P$Task,x
|
|
1075 ldb D.SysTsk
|
|
1076 ldx R$U,u
|
|
1077 ldy #$0003
|
|
1078 leau ,s
|
|
1079 pshs a,b,x,y
|
|
1080 lbsr L0B2C
|
|
1081 ldx D.Proc
|
|
1082 leay P$DATImg,x
|
|
1083 ldx 11,s
|
|
1084 lbsr L0AF0
|
|
1085 L065D lbsr LDAXY
|
|
1086 bsr CRCCalc pass byte through CRC calculator
|
|
1087 ldd 9,s
|
|
1088 subd #$0001
|
|
1089 std 9,s
|
|
1090 bne L065D
|
|
1091 puls a,b,x,y
|
|
1092 exg a,b
|
|
1093 exg x,u
|
|
1094 lbsr L0B2C
|
|
1095 leas 7,s
|
|
1096 L0677 clrb
|
|
1097 rts
|
|
1098
|
|
1099 *------------------------------------------------*
|
|
1100 * F$FModul
|
|
1101 *------------------------------------------------*
|
|
1102 * Find the Module named (X) with type (A) in Y
|
|
1103 FFModul pshs u
|
|
1104 lda R$A,u A=type request
|
|
1105 ldx R$X,u X=name
|
|
1106 ldy R$Y,u Y=DAT image ptr
|
|
1107 bsr L068D find it
|
|
1108 puls y
|
|
1109 std R$D,y return type/attr
|
|
1110 stx R$X,y updated name ptr
|
|
1111 stu R$U,y module offset
|
|
1112 rts
|
|
1113
|
|
1114 L068D ldu #$0000 address flag
|
|
1115 pshs a,b,u
|
|
1116 bsr L0712 get first char
|
|
1117 cmpa #PDELIM start with pathlist delimiter?
|
|
1118 beq L070B ..bad name error
|
|
1119 lbsr L0741
|
|
1120 bcs L070E
|
|
1121 ldu D.ModEnd U=mod end ++
|
|
1122 bra L0700
|
|
1123
|
|
1124 *------------------------------------------------*
|
|
1125 * Main Loop:
|
|
1126
|
|
1127 L06A1 pshs a,b,x,y
|
|
1128 pshs x,y
|
|
1129 ldy MD$MPDAT,u Y=mod images
|
|
1130 beq L06F6
|
|
1131 ldx MD$MPtr,u X=mod ptr
|
|
1132 pshs x,y
|
|
1133 ldd #M$Name get mod name
|
|
1134 lbsr LDDXY offset
|
|
1135 leax d,x X=name address
|
|
1136 pshs x,y save add,images
|
|
1137 leax 8,s
|
|
1138 ldb 13,s
|
|
1139 leay ,s
|
|
1140 lbsr L07DE
|
|
1141 leas 4,s
|
|
1142 puls x,y
|
|
1143 leas 4,s
|
|
1144 bcs L06FE
|
|
1145 ldd #M$Type get mod type/lang
|
|
1146 lbsr LDDXY
|
|
1147 sta ,s
|
|
1148 stb 7,s
|
|
1149 lda 6,s
|
|
1150 beq L06ED
|
|
1151 anda #$F0
|
|
1152 beq L06E1
|
|
1153 eora ,s
|
|
1154 anda #$F0
|
|
1155 bne L06FE
|
|
1156 L06E1 lda 6,s
|
|
1157 anda #$0F
|
|
1158 beq L06ED
|
|
1159 eora ,s
|
|
1160 anda #$0F
|
|
1161 bne L06FE
|
|
1162 L06ED puls a,b,x,y
|
|
1163 abx
|
|
1164 clrb
|
|
1165 ldb 1,s
|
|
1166 leas 4,s
|
|
1167 rts
|
|
1168
|
|
1169 *------------------------------------------------*
|
|
1170 L06F6 leas 4,s
|
|
1171 ldd 8,s
|
|
1172 bne L06FE
|
|
1173 stu 8,s
|
|
1174 L06FE puls a,b,x,y
|
|
1175
|
|
1176 * Moved back one ++
|
|
1177
|
|
1178 L0700 leau -MD$ESize,u next dir entry ++
|
|
1179 cmpu D.ModDir last one? ++
|
|
1180 bcc L06A1 ..no, loop ++
|
|
1181
|
|
1182 *------------------------------------------------*
|
|
1183 ldb #E$MNF 'Module Not Found'
|
|
1184 bra L070E
|
|
1185
|
|
1186 L070B comb
|
|
1187 ldb #E$BNam 'Bad Name' error
|
|
1188 L070E stb 1,s return err code
|
|
1189 puls a,b,u,pc
|
|
1190
|
|
1191 *------------------------------------------------*
|
|
1192 * Get Module Name:
|
|
1193
|
|
1194 L0712 pshs y save image strt
|
|
1195 L0714 lbsr L0AF0 point X to name in img(Y)
|
|
1196 lbsr L0AC8 get char
|
|
1197 leax 1,x ptr+1
|
|
1198 cmpa #C$SPAC was char space?
|
|
1199 beq L0714 ..yes, skip
|
|
1200
|
|
1201 leax -1,x ptr-1
|
|
1202 pshs a save char
|
|
1203 tfr y,d D=image ptr
|
|
1204 subd 1,s -images start
|
|
1205 asrb block#=image/2
|
|
1206 lbsr L0AB0 ??
|
|
1207 puls a,y,pc rts.
|
|
1208
|
|
1209
|
|
1210 *------------------------------------------------*
|
|
1211 * F$PrsNam
|
|
1212 *------------------------------------------------*
|
|
1213 FPrsNam ldx D.Proc proc desc
|
|
1214 leay P$DATImg,x Y=DAT image ptr
|
|
1215 ldx R$X,u X=name string
|
|
1216 bsr L0741 get it and length
|
|
1217 std R$D,u return length in D
|
|
1218 bcs L073E ..err
|
|
1219 stx R$X,u and X at name begin
|
|
1220 abx plus len
|
|
1221 L073E stx R$Y,u return Y=end of name ptr
|
|
1222 rts end.
|
|
1223
|
|
1224 * Parse Name:
|
|
1225
|
|
1226 L0741 pshs y save image ptr
|
|
1227 lbsr L0AF0 find map block
|
|
1228 pshs x,y save X offset within block and Y block pointer
|
|
1229 lbsr LDAXY get A=byte(X)
|
|
1230 cmpa #PDELIM is it a pathlist delimiter?
|
|
1231 bne L0756 ..no, go keep X offset and block Y
|
|
1232 leas 4,s
|
|
1233 pshs x,y
|
|
1234 lbsr LDAXY get next char
|
|
1235 L0756 bsr L07A1 go check if valid first character...
|
|
1236 bcs L076A not valid, go get next name start offset in X...
|
|
1237 clrb initialize character counter
|
|
1238 L075B incb incb add one character
|
|
1239 tsta last character in name string?
|
|
1240 bmi L0766 yes, go return valid...
|
|
1241 lbsr LDAXY go get next character...
|
|
1242 bsr L078A go check if valid character...
|
|
1243 bcc L075B valid, go check if last character...
|
|
1244 L0766 andcc #^Carry
|
|
1245 bra L077C
|
|
1246
|
|
1247 *------------------------------------------------*
|
|
1248 L076A cmpa #C$COMA comma?
|
|
1249 bne L0775 no, check for next character
|
|
1250 L076E leas 4,s
|
|
1251 pshs x,y
|
|
1252 lbsr LDAXY
|
|
1253 L0775 cmpa #C$SPAC is it a space?
|
|
1254 beq L076E ..yes, go get next character
|
|
1255 comb error, set Carry
|
|
1256 ldb #E$BNam 'Bad Name' error
|
|
1257 L077C puls x,y recover offset and pointer
|
|
1258 pshs cc,a,b save Carry, character and count or error code
|
|
1259 tfr y,d copy DAT image block pointer
|
|
1260 subd 3,s subtract original DAT image pointer
|
|
1261 asrb convert 2 byte/block count to block number
|
|
1262 lbsr L0AB0 go get true map offset in X...
|
|
1263 puls cc,a,b,y,pc recover registers and return...
|
|
1264
|
|
1265 L078A pshs a save character
|
|
1266 anda #$7F drop msbit
|
|
1267 cmpa #PDIR period?
|
|
1268 beq ValidChr yes, go return valid character...
|
|
1269 cmpa #'0 is it control?
|
|
1270 bcs InvalChr ..yes
|
|
1271 cmpa #'9 is it number?
|
|
1272 bls ValidChr ..yes
|
|
1273 cmpa #'_ is it '_'?
|
|
1274 bne L07A5 ..no
|
|
1275 ValidChr clra clear carry
|
|
1276 puls a,pc recover original character and return
|
|
1277
|
|
1278 *----------------------------------------------
|
|
1279 L07A1 pshs a
|
|
1280 anda #$7F drop msbit
|
|
1281 L07A5 cmpa #'A less than "A"?
|
|
1282 bcs InvalChr yes, go return invalid character...
|
|
1283 cmpa #'Z less than or equal to "Z"?
|
|
1284 bls ValidChr yes, go return valid character
|
|
1285 cmpa #'a less than "a"?
|
|
1286 bcs InvalChr yes, go return invalid character
|
|
1287 cmpa #'z less than or equal to "z"?
|
|
1288 bls ValidChr yes, go return valid character
|
|
1289 InvalChr coma
|
|
1290 puls a,pc
|
|
1291
|
|
1292
|
|
1293 *------------------------------------------------*
|
|
1294 * F$CmpNam
|
|
1295 *------------------------------------------------*
|
|
1296 FCmpNam ldx D.Proc proc desc
|
|
1297 leay P$DATImg,x Y=caller DAT image ptr
|
|
1298 ldx R$X,u X=first name
|
|
1299 pshs x,y save name,img
|
|
1300 bra L07CF do it
|
|
1301
|
|
1302
|
|
1303 *------------------------------------------------*
|
|
1304 * F$CmpNam (sys)
|
|
1305 *------------------------------------------------*
|
|
1306 SCmpNam ldx D.Proc proc desc
|
|
1307 leay P$DATImg,x Y=images
|
|
1308 ldx R$X,u X=first name
|
|
1309 pshs x,y save name,imgs
|
|
1310 ldy D.SysDAT Y=system DAT image ptr
|
|
1311
|
|
1312 L07CF ldx R$Y,u X=second name
|
|
1313 pshs x,y save name2,sysimg
|
|
1314 ldd R$D,u D=match length
|
|
1315 leax 4,s [X]=name1
|
|
1316 leay ,s [Y]=name2
|
|
1317 bsr L07DE compare them
|
|
1318 leas 8,s drop vars
|
|
1319 rts end.
|
|
1320
|
|
1321 * Compare two strings:
|
|
1322
|
|
1323 L07DE pshs a,b,x,y,u length,name1,name2,regs
|
|
1324 ldu 2,s U=name1 ptr
|
|
1325 pulu x,y get name,images
|
|
1326 lbsr L0AF0 set X for img(Y)
|
|
1327 pshu x,y save name1 offsets
|
|
1328 ldu 4,s
|
|
1329 pulu x,y
|
|
1330 lbsr L0AF0
|
|
1331 bra L07F6
|
|
1332
|
|
1333 L07F2 ldu 4,s
|
|
1334 pulu x,y
|
|
1335 L07F6 lbsr LDAXY get name2 char
|
|
1336 pshu x,y
|
|
1337 pshs a save char
|
|
1338 ldu 3,s
|
|
1339 pulu x,y
|
|
1340 lbsr LDAXY get name1 char
|
|
1341 pshu x,y
|
|
1342 eora ,s compare chars
|
|
1343 tst ,s+ check result
|
|
1344 bmi L0816 ..msb diff
|
|
1345 decb len-1
|
|
1346 beq L0813 last?
|
|
1347 anda #$DF
|
|
1348 beq L07F2 do next char
|
|
1349
|
|
1350 L0813 comb err
|
|
1351 puls a,b,x,y,u,pc end.
|
|
1352
|
|
1353 L0816 decb len-1
|
|
1354 bne L0813 ..err if >0
|
|
1355 anda #$5F
|
|
1356 bne L0813
|
|
1357 clrb okay
|
|
1358 puls a,b,x,y,u,pc end.
|
|
1359
|
|
1360
|
|
1361 *------------------------------------------------*
|
|
1362 * F$SRqMem / F$BtMem
|
|
1363 *------------------------------------------------*
|
|
1364 FSRqMem
|
|
1365 FBtMem ldd R$D,u get # bytes wanted
|
|
1366 addd #$00FF round up
|
|
1367 clrb to page
|
|
1368 std R$D,u return it
|
|
1369 ldy D.SysMem Y=system mem map
|
|
1370 leas -2,s
|
|
1371 stb ,s
|
|
1372 L082F ldx D.SysDAT X=system DAT image
|
|
1373 aslb index block
|
|
1374 ldd b,x D=DAT marker
|
|
1375 cmpd #DAT.Free is it free?
|
|
1376 beq L0847 ..yes
|
|
1377 ldx D.BlkMap else look
|
|
1378 lda d,x at block map byte
|
|
1379 cmpa #RAMinUse is it in use?
|
|
1380 bne L0848 ..yes
|
|
1381 leay 32,y leave map ++
|
|
1382 bra L084F
|
|
1383
|
|
1384 * Free Ram:
|
|
1385
|
|
1386 L0847 clra
|
|
1387
|
|
1388 * Ram Not in Use:
|
|
1389
|
|
1390 L0848 ldb #32 count=32 pages ++
|
|
1391 L084A sta ,y+ mark the ram
|
|
1392 decb
|
|
1393 bne L084A
|
|
1394
|
|
1395 L084F inc ,s
|
|
1396 ldb ,s
|
|
1397 cmpb #DAT.BlCt all blocks done?
|
|
1398 bcs L082F
|
|
1399 L0857 ldb R$A,u page count
|
|
1400 L0859 cmpy D.SysMem back to map start?
|
|
1401 bhi L0863 ..not yet
|
|
1402 comb
|
|
1403 ldb #E$NoRam was MemFul ++
|
|
1404 bra L0894
|
|
1405
|
|
1406 L0863 lda ,-y free page?
|
|
1407 bne L0857 ..no,try again
|
|
1408 decb else got page+1
|
|
1409 bne L0859
|
|
1410 sty ,s
|
|
1411 lda 1,s
|
|
1412 lsra
|
|
1413 lsra
|
|
1414 lsra
|
|
1415 lsra
|
|
1416 lsra ++
|
|
1417 ldb 1,s
|
|
1418 andb #$1F ++
|
|
1419 addb R$A,u
|
|
1420 addb #$1F ++
|
|
1421 lsrb
|
|
1422 lsrb
|
|
1423 lsrb
|
|
1424 lsrb
|
|
1425 lsrb ++
|
|
1426 ldx D.SysPrc
|
|
1427 lbsr L09BE allocate ram images
|
|
1428 bcs L0894
|
|
1429 ldb R$A,u
|
|
1430 L088A inc ,y+
|
|
1431 decb
|
|
1432 bne L088A
|
|
1433 lda 1,s
|
|
1434 std R$U,u return ptr to mem
|
|
1435 clrb
|
|
1436 L0894 leas 2,s
|
|
1437 rts
|
|
1438
|
|
1439
|
|
1440 *------------------------------------------------*
|
|
1441 * F$SRtMem
|
|
1442 *------------------------------------------------*
|
|
1443 FSRtMem ldd R$D,u
|
|
1444 beq L08F2
|
|
1445 addd #$00FF
|
|
1446 ldb R$U+1,u
|
|
1447 beq L08A6
|
|
1448 comb
|
|
1449 ldb #E$BPAddr 'Boundary Error'
|
|
1450 rts
|
|
1451
|
|
1452 L08A6 ldb R$U,u
|
|
1453 beq L08F2
|
|
1454 ldx D.SysMem
|
|
1455 abx
|
|
1456 L08AD ldb ,x
|
|
1457 andb #^RAMinUse
|
|
1458 stb ,x+
|
|
1459 deca
|
|
1460 bne L08AD
|
|
1461 ldx D.SysDAT
|
|
1462 ldy #DAT.BlCt 16 blocks/space
|
|
1463 L08BC ldd ,x
|
|
1464 cmpd #DAT.Free free block?
|
|
1465 beq L08EC ..yes
|
|
1466 ldu D.BlkMap
|
|
1467 lda d,u
|
|
1468 cmpa #$01
|
|
1469 bne L08EC
|
|
1470 tfr x,d
|
|
1471 subd D.SysDAT
|
|
1472 aslb
|
|
1473 aslb
|
|
1474 aslb
|
|
1475 aslb ++
|
|
1476 ldu D.SysMem
|
|
1477 leau d,u
|
|
1478 ldb #32 16 blocks in sys space ++
|
|
1479 L08DA lda ,u+
|
|
1480 bne L08EC
|
|
1481 decb
|
|
1482 bne L08DA
|
|
1483 ldd ,x
|
|
1484 ldu D.BlkMap
|
|
1485 clr d,u
|
|
1486 ldd #DAT.Free
|
|
1487 std ,x
|
|
1488 L08EC leax 2,x
|
|
1489 leay -1,y
|
|
1490 bne L08BC
|
|
1491 L08F2 clrb
|
|
1492 rts
|
|
1493
|
|
1494
|
|
1495 *------------------------------------------------*
|
|
1496 * F$Boot
|
|
1497 *------------------------------------------------*
|
|
1498 FBoot comb
|
|
1499 lda D.Boot booted already?
|
|
1500 bne L0966 ..yes,rts.
|
|
1501 inc D.Boot flag it
|
|
1502 * ldx D.Init X=init module
|
|
1503 * beq L0908 ..use default if no Init
|
|
1504 * ldd BootStr,x offset to Boot name
|
|
1505 * beq L0908 ..none
|
|
1506 * leax d,x X=Init BootStrap name
|
|
1507 * bra L090C use it
|
|
1508
|
|
1509 L0908 leax BootMod,pcr default 'Boot' name
|
|
1510 L090C lbsr LinkSys link to module
|
|
1511 bcs L0966 ..err rts
|
|
1512 jsr ,y do the boot
|
|
1513 bcs L0966 ..err
|
|
1514 std D.BtSz Bootfile size ++
|
|
1515 stx D.BtPtr Boot start address ++
|
|
1516 leau d,x
|
|
1517 tfr x,d
|
|
1518 anda #$E0 ++
|
|
1519 clrb
|
|
1520 pshs a,b,u
|
|
1521 lsra
|
|
1522 lsra
|
|
1523 lsra
|
|
1524 lsra ++
|
|
1525 ldy D.SysDAT
|
|
1526 leay a,y
|
|
1527 *------------------------------------------------*
|
|
1528 * Find & Verify Boot Modules:
|
|
1529
|
|
1530 L092D ldd ,x get header
|
|
1531 cmpd #M$ID12 (87CD) is it a module?
|
|
1532 bne L0954 ..no
|
|
1533 tfr x,d
|
|
1534 subd ,s
|
|
1535 tfr d,x
|
|
1536 tfr y,d
|
|
1537 os9 F$VModul
|
|
1538 pshs b
|
|
1539 ldd 1,s
|
|
1540 leax d,x
|
|
1541 puls b
|
|
1542 bcc L094E
|
|
1543 cmpb #E$KwnMod 'Known Module'?
|
|
1544 bne L0954 ..no
|
|
1545 L094E ldd 2,x
|
|
1546 leax d,x
|
|
1547 bra L0956
|
|
1548
|
|
1549 L0954 leax 1,x
|
|
1550 L0956 cmpx 2,s end of boot mem?
|
|
1551 bcs L092D ..no, try more
|
|
1552 leas 4,s
|
|
1553 ldx D.SysDAT ++
|
|
1554 ldb 13,x ++
|
|
1555 incb ++
|
|
1556 ldx D.BlkMap ++
|
|
1557 lbra L01DF ++
|
|
1558
|
|
1559 L0966 rts
|
|
1560
|
|
1561
|
|
1562 *------------------------------------------------*
|
|
1563 * F$AllRam
|
|
1564 *------------------------------------------------*
|
|
1565 FAllRam ldb R$B,u get # ram blocks desired
|
|
1566 bsr L0970
|
|
1567 bcs L096F
|
|
1568 std R$D,u
|
|
1569 L096F rts
|
|
1570
|
|
1571 *------------------------------------------------*
|
|
1572 L0970 pshs a,b,x,y
|
|
1573 ldx D.BlkMap X=block map start
|
|
1574
|
|
1575 * Start at new block begin:
|
|
1576
|
|
1577 L0974 leay ,x Y=start
|
|
1578 ldb 1,s B=count
|
|
1579 L0978 cmpx D.BlkMap+2 at end of block map?
|
|
1580 bcc L0995 ..yes,end.
|
|
1581 lda ,x+ is block free?
|
|
1582 bne L0974 ..no, try new start
|
|
1583 decb yes, count-1
|
|
1584 bne L0978 keep trying
|
|
1585
|
|
1586 L0983 tfr y,d D=begin block ptr ++
|
|
1587 subd D.BlkMap D=begin block number
|
|
1588 sta R$A-1,s return number on ,S
|
|
1589 lda R$B-1,s A=count
|
|
1590 stb R$B-1,s
|
|
1591
|
|
1592 * mark off blocks
|
|
1593
|
|
1594 L098D inc ,y+ mark as ram in use
|
|
1595 deca
|
|
1596 bne L098D
|
|
1597 clrb
|
|
1598 puls a,b,x,y,pc okay end.
|
|
1599
|
|
1600 L0995 comb
|
|
1601 ldb #E$NoRam 'Sys Ram Full'
|
|
1602 stb 1,s return err
|
|
1603 puls a,b,x,y,pc bad end.
|
|
1604
|
|
1605 *------------------------------------------------*
|
|
1606 * F$AlHRam
|
|
1607 *------------------------------------------------*
|
|
1608
|
|
1609 FALHRAM ldb R$B,u get block count ++
|
|
1610 bsr L09A5 find blocks ++
|
|
1611 bcs L09A4 error ++
|
|
1612 std R$D,u return count in D ++
|
|
1613
|
|
1614 L09A4 rts ++
|
|
1615
|
|
1616 L09A5 pshs a,b,x,y match up stack ++
|
|
1617 ldx D.BlkMap+2 point to end of map ++
|
|
1618
|
|
1619 L09A9 ldb R$B-1,s get block count ++
|
|
1620
|
|
1621 L09AB cmpx D.BlkMap at bottom of map? ++
|
|
1622 bls L0995 yes, error ++
|
|
1623 lda ,-x block free? ++
|
|
1624 bne L09A9 no ++
|
|
1625 decb found them all? ++
|
|
1626 bne L09AB no, continue ++
|
|
1627 tfr x,y match up registers ++
|
|
1628 bra L0983 allocate blocks ++
|
|
1629
|
|
1630 *------------------------------------------------*
|
|
1631 * F$AllImg
|
|
1632 *------------------------------------------------*
|
|
1633 FAllImg ldd R$D,u A=begin blk#, B=# of blocks
|
|
1634 ldx R$X,u X=proc desc
|
|
1635 L09BE pshs a,b,x,y,u
|
|
1636 asla
|
|
1637 leay P$DATImg,x Y=DAT image ptr
|
|
1638 leay a,y Y=image ptr
|
|
1639 clra
|
|
1640 tfr d,x
|
|
1641 ldu D.BlkMap
|
|
1642 pshs a,b,x,y,u
|
|
1643 L09CD ldd ,y++ D=image
|
|
1644 cmpd #DAT.Free unused?
|
|
1645 beq L09E2 ..yes
|
|
1646 lda d,u else what is it?
|
|
1647 cmpa #RAMinUse ram?
|
|
1648 puls a,b
|
|
1649 bne L09F7 ..no
|
|
1650
|
|
1651 subd #$0001
|
|
1652 pshs a,b
|
|
1653 L09E2 leax -1,x
|
|
1654 bne L09CD
|
|
1655 ldx ,s++
|
|
1656 beq L0A00
|
|
1657 L09EA lda ,u+
|
|
1658 bne L09F2
|
|
1659 leax -1,x
|
|
1660 beq L0A00
|
|
1661 L09F2 cmpu D.BlkMap+2
|
|
1662 bcs L09EA
|
|
1663
|
|
1664 L09F7 ldb #E$MemFul 'Proc Memory Full' (207)
|
|
1665 leas 6,s
|
|
1666 stb R$B-1,s
|
|
1667 comb
|
|
1668 puls a,b,x,y,u,pc
|
|
1669
|
|
1670 *------------------------------------------------*
|
|
1671 L0A00 puls x,y,u
|
|
1672 L0A02 ldd ,y++
|
|
1673 cmpd #DAT.Free
|
|
1674 bne L0A16
|
|
1675 L0A0A lda ,u+
|
|
1676 bne L0A0A
|
|
1677 inc ,-u
|
|
1678 tfr u,d
|
|
1679 subd D.BlkMap
|
|
1680 std -2,y
|
|
1681
|
|
1682 L0A16 leax -1,x
|
|
1683 bne L0A02
|
|
1684 ldx 2,s
|
|
1685 lda P$State,x get proc state &
|
|
1686 ora #ImgChg flag image change
|
|
1687 sta P$State,x .
|
|
1688 clrb
|
|
1689 puls a,b,x,y,u,pc
|
|
1690
|
|
1691
|
|
1692 *------------------------------------------------*
|
|
1693 * F$FreeHB
|
|
1694 *------------------------------------------------*
|
|
1695 FFreeHB ldb R$B,u B=block count
|
|
1696 ldy R$Y,u
|
|
1697 bsr L0A31
|
|
1698 bcs L0A30
|
|
1699 sta R$A,u
|
|
1700 L0A30 rts
|
|
1701
|
|
1702 L0A31 tfr b,a
|
|
1703 L0A33 suba #$09
|
|
1704 nega
|
|
1705 pshs x,b,a
|
|
1706 ldd #$FFFF
|
|
1707 pshs b,a
|
|
1708 bra L0A58
|
|
1709
|
|
1710 FFreeLB ldb R$B,u
|
|
1711 ldy R$Y,u
|
|
1712 bsr L0A4B
|
|
1713 bcs L0A4A
|
|
1714 sta R$A,u
|
|
1715 L0A4A rts
|
|
1716
|
|
1717 L0A4B lda #$FF
|
|
1718 pshs x,b,a
|
|
1719 lda #$01
|
|
1720 subb #$09
|
|
1721 negb
|
|
1722 pshs b,a
|
|
1723 bra L0A58
|
|
1724
|
|
1725 L0A58 clra
|
|
1726 ldb $02,s
|
|
1727 addb ,s
|
|
1728 stb $02,s
|
|
1729 cmpb $01,s
|
|
1730 bne L0A75
|
|
1731 ldb #$CF
|
|
1732 cmpy <D.SysDAT
|
|
1733 bne L0A6C
|
|
1734 ldb #$ED
|
|
1735 L0A6C stb $03,s
|
|
1736 comb
|
|
1737 bra L0A82
|
|
1738
|
|
1739 L0A71 tfr a,b
|
|
1740 addb $02,s
|
|
1741 L0A75 lslb
|
|
1742 ldx b,y
|
|
1743 cmpx #DAT.Free
|
|
1744 bne L0A58
|
|
1745 inca
|
|
1746 cmpa $03,s
|
|
1747 bne L0A71
|
|
1748 L0A82 leas $02,s
|
|
1749 puls pc,x,b,a
|
|
1750
|
|
1751 FSetImg ldd R$A,u
|
|
1752 ldx R$X,u
|
|
1753 ldu R$U,u
|
|
1754 L0A8C pshs u,y,x,b,a
|
|
1755 leay P$DATImg,x
|
|
1756 lsla
|
|
1757 leay a,y
|
|
1758 L0A94 ldx ,u++
|
|
1759 stx ,y++
|
|
1760 decb
|
|
1761 bne L0A94
|
|
1762 ldx $02,s get proc desc ptr
|
|
1763 lda P$State,x
|
|
1764 ora #ImgChg
|
|
1765 sta P$State,x
|
|
1766 clrb
|
|
1767 puls pc,u,y,x,b,a
|
|
1768
|
|
1769 FDATLog ldb R$B,u
|
|
1770 ldx R$X,u
|
|
1771 bsr L0AB0
|
|
1772 stx R$X,u
|
|
1773 clrb
|
|
1774 rts
|
|
1775
|
|
1776 *L0AB0 pshs x,b,a --BGP
|
|
1777 L0AB0 pshs x,b ++BGP
|
|
1778 lslb
|
|
1779 lslb
|
|
1780 lslb
|
|
1781 lslb
|
|
1782 lslb
|
|
1783 * addb $02,s --BGP
|
|
1784 * stb $02,s --BGP
|
|
1785 addb 1,s ++BGP
|
|
1786 stb 1,s ++BGP
|
|
1787 * puls pc,x,b,a --BGP
|
|
1788 puls pc,x,b ++BGP
|
|
1789
|
|
1790 FLDAXY ldx R$X,u
|
|
1791 ldy R$Y,u
|
|
1792 bsr L0AC8
|
|
1793 sta R$A,u
|
|
1794 clrb
|
|
1795 rts
|
|
1796
|
|
1797 L0AC8 pshs cc
|
|
1798 lda $01,y
|
|
1799 orcc #IntMasks
|
|
1800 sta >DAT.Regs
|
|
1801 lda ,x
|
|
1802 clr >DAT.Regs
|
|
1803 puls pc,cc
|
|
1804
|
|
1805 LDAXY bsr L0AC8
|
|
1806 leax $01,x
|
|
1807 bra L0AF0
|
|
1808
|
|
1809 L0AEA leax >-$2000,x
|
|
1810 leay $02,y
|
|
1811 L0AF0 cmpx #$2000
|
|
1812 bcc L0AEA
|
|
1813 rts
|
|
1814
|
|
1815 FLDDDXY ldd R$D,u
|
|
1816 leau R$X,u
|
|
1817 pulu y,x
|
|
1818 bsr LDDXY
|
|
1819 std -$07,u
|
|
1820 clrb
|
|
1821 rts
|
|
1822 LDDXY pshs y,x
|
|
1823 leax d,x
|
|
1824 bsr L0AF0
|
|
1825 bsr LDAXY
|
|
1826 pshs a
|
|
1827 bsr L0AC8
|
|
1828 tfr a,b
|
|
1829 puls pc,y,x,a
|
|
1830
|
|
1831 FLDABX ldb R$B,u
|
|
1832 ldx R$X,u
|
|
1833 lbsr L0C12
|
|
1834 sta R$A,u
|
|
1835 rts
|
|
1836
|
|
1837 FSTABX ldd R$D,u
|
|
1838 ldx R$X,u
|
|
1839 lbra L0C28
|
|
1840
|
|
1841 FMove ldd R$D,u
|
|
1842 ldx R$X,u
|
|
1843 ldy R$Y,u
|
|
1844 ldu R$U,u
|
|
1845 L0B2C pshs u,y,x,b,a
|
|
1846 leay ,y
|
|
1847 lbeq L0BF2
|
|
1848 pshs y,b,a
|
|
1849 tfr a,b
|
|
1850 lbsr L0C0F
|
|
1851 leay a,u
|
|
1852 pshs y,x
|
|
1853 ldb $09,s
|
|
1854 ldx $0E,s
|
|
1855 lbsr L0C0F
|
|
1856 leay a,u
|
|
1857 pshs y,x
|
|
1858 ldd #$2000
|
|
1859 subd ,s
|
|
1860 pshs b,a
|
|
1861 ldd #$2000
|
|
1862 subd $06,s
|
|
1863 pshs b,a
|
|
1864 ldx $08,s
|
|
1865 leax >-$6000,x
|
|
1866 ldu $04,s
|
|
1867 leau >-$4000,u
|
|
1868 L0B6A pshs cc
|
|
1869 ldd [<$07,s]
|
|
1870 pshs b
|
|
1871 ldd [<$0C,s]
|
|
1872 pshs b
|
|
1873 ldd <$11,s
|
|
1874 cmpd $03,s
|
|
1875 bls L0B82
|
|
1876 ldd $03,s
|
|
1877 L0B82 cmpd $05,s
|
|
1878 bls L0B89
|
|
1879 ldd $05,s
|
|
1880 L0B89 cmpd #$0040
|
|
1881 bls L0B84
|
|
1882 ldd #$0040
|
|
1883 L0B84 std $0F,s
|
|
1884 puls y
|
|
1885 orcc #IntMasks
|
|
1886 sty >$FFA5
|
|
1887 andb #$07
|
|
1888 beq L0B99
|
|
1889 L0B92 lda ,x+
|
|
1890 sta ,u+
|
|
1891 decb
|
|
1892 bne L0B92
|
|
1893 L0B99 ldb $0E,s
|
|
1894 lsrb
|
|
1895 lsrb
|
|
1896 lsrb
|
|
1897 beq L0BBC
|
|
1898 pshs b
|
|
1899 exg x,u
|
|
1900 L0BA4 pulu y,b,a
|
|
1901 std ,x
|
|
1902 sty $02,x
|
|
1903 pulu y,b,a
|
|
1904 std $04,x
|
|
1905 sty $06,x
|
|
1906 leax $08,x
|
|
1907 dec ,s
|
|
1908 bne L0BA4
|
|
1909 leas $01,s
|
|
1910 exg x,u
|
|
1911 L0BBC ldy <D.SysDAT
|
|
1912 lda $0B,y
|
|
1913 ldb $0D,y
|
|
1914 std >$FFA5
|
|
1915 puls cc
|
|
1916 ldd $0E,s
|
|
1917 subd $0C,s
|
|
1918 beq L0BEF
|
|
1919 std $0E,s
|
|
1920 ldd ,s
|
|
1921 subd $0C,s
|
|
1922 bne L0BD7
|
|
1923 ldd #$2000
|
|
1924 leax >-$2000,x
|
|
1925 inc $0B,s
|
|
1926 inc $0B,s
|
|
1927 L0BD7 std ,s
|
|
1928 ldd $02,s
|
|
1929 subd $0C,s
|
|
1930 bne L0BEA
|
|
1931 ldd #$2000
|
|
1932 leau >-$2000,u
|
|
1933 inc $07,s
|
|
1934 inc $07,s
|
|
1935 L0BEA std $02,s
|
|
1936 lbra L0B6A
|
|
1937 L0BEF leas <$10,s
|
|
1938 L0BF2 clrb
|
|
1939 puls pc,u,y,x,b,a
|
|
1940
|
|
1941 L0BF5 pshs b
|
|
1942 tfr x,d
|
|
1943 anda #$1F
|
|
1944 exg d,x
|
|
1945 anda #$E0
|
|
1946 lsra
|
|
1947 lsra
|
|
1948 lsra
|
|
1949 lsra
|
|
1950 L0C07 puls pc,b
|
|
1951 L0C0F bsr L0BF5
|
|
1952 *L0C09 pshs b --BGP
|
|
1953 L0C09
|
|
1954 ldu <D.TskIPt
|
|
1955 lslb
|
|
1956 ldu b,u
|
|
1957 rorb ++BGP
|
|
1958 * puls pc,b --BGP
|
|
1959 rts ++BGP
|
|
1960
|
|
1961 L0C12 andcc #^Carry
|
|
1962 pshs u,x,b,cc
|
|
1963 bsr L0C0F
|
|
1964 ldd a,u
|
|
1965 orcc #IntMasks
|
|
1966 stb >DAT.Regs
|
|
1967 lda ,x
|
|
1968 clr >DAT.Regs
|
|
1969 puls pc,u,x,b,cc
|
|
1970
|
|
1971 L0C28 andcc #^Carry
|
|
1972 pshs u,x,b,a,cc
|
|
1973 bsr L0C0F
|
|
1974 ldd a,u
|
|
1975 lda $01,s
|
|
1976 orcc #IntMasks
|
|
1977 stb >DAT.Regs
|
|
1978 sta ,x
|
|
1979 clr >DAT.Regs
|
|
1980 puls pc,u,x,b,a,cc
|
|
1981
|
|
1982 FLDBBX andcc #^Carry
|
|
1983 pshs u,x,a,cc
|
|
1984 bsr L0C0F
|
|
1985 ldd a,u
|
|
1986 orcc #IntMasks
|
|
1987 stb >DAT.Regs
|
|
1988 ldb ,x
|
|
1989 clr >DAT.Regs
|
|
1990 puls pc,u,x,a,cc
|
|
1991
|
|
1992 FAllTsk ldx R$X,u
|
|
1993 L0C58 ldb P$Task,x
|
|
1994 bne L0C64
|
|
1995 cmpx <$004A
|
|
1996 beq L0C64
|
|
1997 bsr L0CA6
|
|
1998 bcs L0C65
|
|
1999 stb P$Task,x
|
|
2000 bsr L0C79
|
|
2001 L0C64 clrb
|
|
2002 L0C65 rts
|
|
2003
|
|
2004 FDelTsk ldx R$X,u get proc desc ptr
|
|
2005 L0C68 ldb P$Task,x
|
|
2006 beq L0C65
|
|
2007 clr P$Task,x
|
|
2008 bra L0CC3
|
|
2009 L0C70 lda P$State,x
|
|
2010 bita #ImgChg
|
|
2011 bne L0C79
|
|
2012 rts
|
|
2013
|
|
2014 FSetTsk ldx R$X,u
|
|
2015 L0C79 lda P$State,x
|
|
2016 anda #^ImgChg
|
|
2017 sta P$State,x
|
|
2018 andcc #^Carry
|
|
2019 pshs u,y,x,b,a,cc
|
|
2020 ldb P$Task,x
|
|
2021 leax P$DATImg,x
|
|
2022 ldu <D.TskIPt
|
|
2023 lslb
|
|
2024 stx b,u
|
|
2025 cmpb #$02
|
|
2026 bgt L0C9F
|
|
2027 ldu #DAT.Regs
|
|
2028 leax 1,x
|
|
2029 ldb #$08
|
|
2030 L0C98 lda ,x++
|
|
2031 sta ,u+
|
|
2032 decb
|
|
2033 bne L0C98
|
|
2034 L0C9F puls pc,u,y,x,b,a,cc
|
|
2035
|
|
2036 FResTsk bsr L0CA6
|
|
2037 stb R$B,u
|
|
2038 rts
|
|
2039
|
|
2040 L0CA6 pshs x
|
|
2041 ldb #$02
|
|
2042 ldx <D.Tasks
|
|
2043 L0CAC lda b,x
|
|
2044 beq L0CBA
|
|
2045 incb
|
|
2046 cmpb #$20
|
|
2047 bne L0CAC
|
|
2048 comb
|
|
2049 ldb #$EF
|
|
2050 bra L0CBF
|
|
2051
|
|
2052 L0CBA inc b,x
|
|
2053 clra
|
|
2054 L0CBF puls pc,x
|
|
2055
|
|
2056 FRelTsk ldb R$B,u
|
|
2057 L0CC3 pshs x,b
|
|
2058 tstb
|
|
2059 beq L0CD0
|
|
2060 ldx <D.Tasks
|
|
2061 clr b,x
|
|
2062 L0CD0 puls pc,x,b
|
|
2063
|
|
2064 * Control goes here when a tick interrupt comes in
|
|
2065 Clock ldb #P$STicks assume system state
|
|
2066 ldx <D.Proc get curr process
|
|
2067 lda P$State,x get process state
|
|
2068 bmi L0CDC branch if SysState
|
|
2069 ldb #P$UTicks otherwise user state
|
|
2070 L0CDC lbsr IncCount count ticks
|
|
2071 ldx <D.SProcQ point to sleep queue
|
|
2072 beq L0CFD branch if no process sleeping
|
|
2073 * Process sleep queue here!
|
|
2074 * Sleep queue is sorted by process closest to wake first, all the way
|
|
2075 * to processes that are sleeping forever.
|
|
2076 lda P$State,x get process' state
|
|
2077 bita #TimSleep sleeping forever?
|
|
2078 beq L0CFD yep, finished
|
|
2079 ldu P$SP,x else get process' stack pointer
|
|
2080 ldd R$X,u and get process' sleep tick counter
|
|
2081 subd #$0001 subtract 1 from tick counter
|
|
2082 std R$X,u save back to process' X
|
|
2083 bne L0CFD branch if not ready to wake
|
|
2084 L0CE7 ldu P$Queue,x else time to wake up! so...
|
|
2085 bsr L0D11 activate this process
|
|
2086 leax ,u point to next process
|
|
2087 beq L0CFB
|
|
2088 lda P$State,x
|
|
2089 bita #TimSleep
|
|
2090 beq L0CFB
|
|
2091 ldu P$SP,x
|
|
2092 ldd R$X,u
|
|
2093 beq L0CE7
|
|
2094 L0CFB stx <D.SProcQ store new process pointer
|
|
2095 L0CFD dec <D.Slice decrement slice
|
|
2096 bne L0D0D branch if not at end of timeslice
|
|
2097 inc <D.Slice
|
|
2098 ldx <D.Proc get current process
|
|
2099 beq L0D0D branch if none
|
|
2100 lda P$State,x ...else get state
|
|
2101 ora #TimOut and indicate it's out of time
|
|
2102 sta P$State,x then restore it
|
|
2103 L0D0D clrb
|
|
2104 rts
|
|
2105
|
|
2106 * X = address of process descriptor to put in active queue
|
|
2107 FAProc ldx R$X,u
|
|
2108 L0D11 clrb
|
|
2109 pshs u,y,x,b,cc
|
|
2110 lda P$Prior,x get priority of process
|
|
2111 sta P$Age,x reset age to priority
|
|
2112 orcc #IntMasks mask interrupts
|
|
2113 ldu #$0045
|
|
2114 bra L0D29
|
|
2115 L0D1F inc $0B,u
|
|
2116 bne L0D25
|
|
2117 dec $0B,u
|
|
2118 L0D25 cmpa $0B,u
|
|
2119 bhi L0D2B
|
|
2120 L0D29 leay ,u
|
|
2121 L0D2B ldu $0D,u
|
|
2122 bne L0D1F
|
|
2123 ldd $0D,y
|
|
2124 stx $0D,y
|
|
2125 std $0D,x
|
|
2126 puls pc,u,y,x,b,cc
|
|
2127
|
|
2128 * System IRQ service routine
|
|
2129
|
|
2130 XIRQ ldx <D.Proc
|
|
2131 sts P$SP,x
|
|
2132 lds <D.SysStk
|
|
2133 ldd <D.SysSvc
|
|
2134 std <D.XSWI2
|
|
2135 ldd <D.SysIRQ
|
|
2136 std <D.XIRQ
|
|
2137 jsr [>D.SvcIRQ]
|
|
2138 bcc L0D5B
|
|
2139 ldx <D.Proc
|
|
2140 ldb P$Task,x
|
|
2141 ldx P$SP,x
|
|
2142 lbsr L0C12
|
|
2143 ora #IntMasks
|
|
2144 lbsr L0C28
|
|
2145 L0D5B orcc #IntMasks
|
|
2146 ldx <D.Proc
|
|
2147 lda P$State,x
|
|
2148 bita #TimOut
|
|
2149 bne L0D7C
|
|
2150 L0D78 ldu $04,x
|
|
2151 bra L0DB9
|
|
2152 L0D7C anda #$DF
|
|
2153 sta $0C,x
|
|
2154 lbsr L0C68
|
|
2155 L0D83 bsr L0D11
|
|
2156
|
|
2157 FNProc ldx <D.SysPrc
|
|
2158 stx <D.Proc
|
|
2159 lds <D.SysStk
|
|
2160 andcc #^(IntMasks)
|
|
2161 bra L0D93
|
|
2162
|
|
2163 L0D91 cwai #^(IntMasks)
|
|
2164 L0D93 orcc #IntMasks
|
|
2165 lda #Suspend
|
|
2166 ldx #$0045
|
|
2167 L0D9A leay ,x
|
|
2168 ldx $0D,y
|
|
2169 beq L0D91
|
|
2170 bita P$State,x
|
|
2171 bne L0D9A
|
|
2172 ldd P$Queue,x
|
|
2173 std $0D,y
|
|
2174 stx <D.Proc
|
|
2175 lbsr L0C58
|
|
2176 bcs L0D83
|
|
2177 lda <D.TSlice
|
|
2178 sta <D.Slice
|
|
2179 ldu P$SP,x
|
|
2180 lda P$State,x
|
|
2181 bmi L0E29
|
|
2182 L0DB9 bita #Condem
|
|
2183 bne L0DFD
|
|
2184 lbsr L0C70
|
|
2185 ldb P$Signal,x
|
|
2186 beq L0DF2
|
|
2187 decb
|
|
2188 beq L0DEF
|
|
2189 leas -$0C,s
|
|
2190 leau ,s
|
|
2191 lbsr L02CB
|
|
2192 lda P$Signal,x
|
|
2193 sta $02,u
|
|
2194 ldd P$SigVec,x
|
|
2195 beq L0DFD
|
|
2196 std $0A,u
|
|
2197 ldd P$SigDat,x
|
|
2198 std $08,u
|
|
2199 ldd P$SP,x
|
|
2200 subd #$000C
|
|
2201 std P$SP,x
|
|
2202 lbsr L02DA
|
|
2203 leas $0C,s
|
|
2204 ldu P$SP,x
|
|
2205 clrb
|
|
2206 L0DEF stb P$Signal,x
|
|
2207 L0DF2 ldd <D.UsrSvc
|
|
2208 std <D.XSWI2
|
|
2209 ldd <D.UsrIRQ
|
|
2210 std <D.XIRQ
|
|
2211 bra L0E4C
|
|
2212 L0DFD lda P$State,x
|
|
2213 ora #SysState
|
|
2214 sta P$State,x
|
|
2215 leas $0200,x
|
|
2216 andcc #^(IntMasks)
|
|
2217 ldb P$Signal,x
|
|
2218 clr P$Signal,x
|
|
2219 os9 F$Exit
|
|
2220
|
|
2221 * Interrupts come through here when in system state
|
|
2222 S.SysIRQ lda <D.SSTskN get system task number
|
|
2223 clr <D.SSTskN clear system task number in globs
|
|
2224 pshs a save on stack
|
|
2225 jsr [>D.SvcIRQ]
|
|
2226 puls a
|
|
2227 bsr L0E39
|
|
2228 bcc XFIRQ
|
|
2229 ldb R$CC,s
|
|
2230 orb #IntMasks
|
|
2231 stb R$CC,s
|
|
2232 XFIRQ rti
|
|
2233
|
|
2234 L0E29 clr ,-s
|
|
2235 L0E2B ldx <D.SysPrc
|
|
2236 lbsr L0C70
|
|
2237 orcc #IntMasks
|
|
2238 puls a
|
|
2239 bsr L0E39
|
|
2240 leas ,u
|
|
2241 rti
|
|
2242
|
|
2243 * A = task number
|
|
2244 L0E39 sta <D.SSTskN
|
|
2245 beq S.AltIRQ
|
|
2246 ora <D.TINIT
|
|
2247 sta <D.TINIT
|
|
2248 sta DAT.Task
|
|
2249 S.AltIRQ rts
|
|
2250
|
|
2251 S.SvcIRQ jmp [>D.Poll]
|
|
2252 S.POLL orcc #Carry
|
|
2253 rts
|
|
2254
|
|
2255 L0E4C ldb $06,x
|
|
2256 orcc #IntMasks
|
|
2257 bsr L0E8D
|
|
2258 lda <D.TINIT
|
|
2259 ora #$01
|
|
2260 sta <D.TINIT
|
|
2261 sta DAT.Task
|
|
2262 leas ,u
|
|
2263 rti
|
|
2264
|
|
2265 L0E5E ldb <D.TINIT
|
|
2266 orb #$01
|
|
2267 stb <D.TINIT
|
|
2268 stb DAT.Task
|
|
2269 jmp ,u
|
|
2270
|
|
2271 S.Flip0 pshs b,a
|
|
2272 lda <D.TINIT
|
|
2273 anda #$FE
|
|
2274 sta <D.TINIT
|
|
2275 sta DAT.Task
|
|
2276 clr <D.SSTskN
|
|
2277 puls b,a
|
|
2278 tfr x,s
|
|
2279 tfr a,cc
|
|
2280 rts
|
|
2281
|
|
2282 S.Flip1 ldb #$01 get task image entry number
|
|
2283 bsr L0E8D copy over the DAT image
|
|
2284 lda <D.TINIT get copy of GIME Task side
|
|
2285 ora #$01 switch it to task one
|
|
2286 sta <D.TINIT save it to image
|
|
2287 sta DAT.Task save it to GIME register
|
|
2288 inc <D.SSTskN increment system tstae task number
|
|
2289 rti return
|
|
2290
|
|
2291 L0E8D pshs u,x,b,a
|
|
2292 ldx #$FFA8 get MMU start register for process
|
|
2293 ldu <D.TskIPt get task image pointer table
|
|
2294 lslb account for 2 bytes per entry
|
|
2295 ldu b,u get address of MMU entry
|
|
2296 leau $01,u
|
|
2297 ldb #$08
|
|
2298 L0E9B lda ,u++
|
|
2299 sta ,x+
|
|
2300 decb
|
|
2301 bne L0E9B
|
|
2302 puls pc,u,x,b,a
|
|
2303
|
|
2304 * SWI3.V - Control comes here upon a SWI3 interrupt
|
|
2305 SWI3.V orcc #IntMasks mask interrupts
|
|
2306 ldb #D.SWI3 get direct page global vector
|
|
2307 bra IRQCntrl
|
|
2308
|
|
2309 * SWI2.V - Control comes here upon a SWI2 interrupt
|
|
2310 SWI2.V orcc #IntMasks mask interrupts
|
|
2311 ldb #D.SWI2 get direct page global vector
|
|
2312 bra IRQCntrl
|
|
2313
|
|
2314 * FIRQ.V - Control comes here upon a FIRQ interrupt
|
|
2315 FIRQ.V tst ,s
|
|
2316 bmi L0EB0
|
|
2317 leas -$01,s
|
|
2318 pshs y,x,dp,b,a
|
|
2319 lda $08,s
|
|
2320 stu $07,s
|
|
2321 ora #$80
|
|
2322 pshs a
|
|
2323 L0EB0 ldb #D.FIRQ
|
|
2324 bra IRQCntrl
|
|
2325
|
|
2326 * IRQ.V - Control comes here upon a IRQ interrupt
|
|
2327 IRQ.V orcc #IntMasks mask interrupts
|
|
2328 ldb #D.IRQ get direct page global vector
|
|
2329 * B = address of vector from direct page
|
|
2330 IRQCntrl clra clear A
|
|
2331 tfr a,dp make DP point to 0
|
|
2332 sta DAT.Task redundancy???
|
|
2333 lda <D.TINIT get task register shadow
|
|
2334 anda #$FE clear bit to use $FFA0-$FFA7
|
|
2335 sta <D.TINIT save in shadow
|
|
2336 sta DAT.Task save in hardware (do it!)
|
|
2337 clra clear A
|
|
2338 tfr d,x D = addr of direct page vector
|
|
2339 jmp [,x] transfer control to addr in passed vector
|
|
2340
|
|
2341 * SWI.V - Control comes here upon a SWI interrupt
|
|
2342 SWI.V ldb #D.SWI get direct page global vector
|
|
2343 bra IRQCntrl
|
|
2344
|
|
2345 * NMI.V - Control comes here upon a NMI interrupt
|
|
2346 NMI.V ldb #D.NMI get direct page global vector
|
|
2347 bra IRQCntrl
|
|
2348
|
460
|
2349 * Filler to get $ED9
|
|
2350 Filler fill $39,$EDC-*
|
0
|
2351
|
|
2352 emod
|
|
2353 eom equ *
|
|
2354
|
|
2355 * Direct Page vectors
|
|
2356 D.VECTRS fdb $F100+Clock goes in D.Clock
|
|
2357 fdb $F100+XSWI3 goes in D.XSWI3
|
|
2358 fdb $F100+XSWI2 goes in D.XSWI2
|
|
2359 fdb $F100+XFIRQ goes in D.XFIRQ
|
|
2360 fdb $F100+XIRQ goes in D.XIRQ
|
|
2361 fdb $F100+XSWI goes in D.XSWI
|
|
2362 fdb $F100 goes in D.NMI
|
|
2363 fcb $55
|
|
2364 * 6809 vectors
|
|
2365 * This table starts at $FEEE. Each address is pointed to by the 6809
|
|
2366 * vectors at $FFF0 (defined in the CoCo 3 ROM).
|
|
2367 lbra SWI3.V SWI3
|
|
2368 lbra SWI2.V SWI2
|
|
2369 lbra FIRQ.V FIRQ
|
|
2370 lbra IRQ.V IRQ
|
|
2371 lbra SWI.V SWI
|
|
2372 lbra NMI.V NMI
|
|
2373
|
|
2374 eo equ *
|
|
2375 end
|