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