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