0
|
1 ********************************************************************
|
|
2 * OS9p1 - OS-9 Level One V2 P1 module
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Ed. Comments Who YY/MM/DD
|
|
7 * ------------------------------------------------------------------
|
201
|
8 * 14 From Tandy OS-9 Level One VR 02.00.00
|
0
|
9
|
|
10
|
|
11 nam OS9
|
|
12 ttl OS-9 Level One V2 P1 module
|
|
13
|
|
14 ifp1
|
|
15 use defsfile
|
|
16 use scfdefs
|
|
17 endc
|
|
18
|
|
19 tylg set Systm+Objct
|
|
20 atrv set ReEnt+rev
|
|
21 rev set $01
|
201
|
22 edition set 14
|
0
|
23
|
|
24 L0000 mod eom,name,tylg,atrv,OS9Cold,size
|
|
25
|
|
26 size equ .
|
|
27
|
|
28 name fcs /OS9/
|
|
29 fcb edition
|
|
30
|
|
31 fcc /CC/
|
|
32
|
|
33 InitNam fcs /INIT/
|
|
34
|
|
35 P2Nam fcs /OS9P2/
|
|
36
|
|
37 VectCode bra SWI3Jmp
|
|
38 nop
|
|
39 bra SWI2Jmp
|
|
40 nop
|
|
41 bra SWIJmp
|
|
42 nop
|
|
43 bra NMIJmp
|
|
44 nop
|
|
45 bra IRQJmp
|
|
46 nop
|
|
47 bra FIRQJmp
|
|
48
|
|
49 SWI3Jmp jmp [>D.SWI3]
|
|
50 SWI2Jmp jmp [>D.SWI2]
|
|
51 SWIJmp jmp [>D.SWI]
|
|
52 NMIJmp jmp [>D.NMI]
|
|
53 IRQJmp jmp [>D.IRQ]
|
|
54 FIRQJmp jmp [>D.FIRQ]
|
|
55 VectCSz equ *-VectCode
|
|
56
|
|
57
|
|
58 SysTbl fcb F$Link
|
|
59 fdb FLink-*-2
|
|
60
|
|
61 fcb F$Fork
|
|
62 fdb FFork-*-2
|
|
63
|
|
64 fcb F$Chain
|
|
65 fdb FChain-*-2
|
|
66
|
|
67 fcb F$Chain+$80
|
|
68 fdb SFChain-*-2
|
|
69
|
|
70 fcb F$PrsNam
|
|
71 fdb FPrsNam-*-2
|
|
72
|
|
73 fcb F$CmpNam
|
|
74 fdb FCmpNam-*-2
|
|
75
|
|
76 fcb F$SchBit
|
|
77 fdb FSchBit-*-2
|
|
78
|
|
79 fcb F$AllBit
|
|
80 fdb FAllBit-*-2
|
|
81
|
|
82 fcb F$DelBit
|
|
83 fdb FDelBit-*-2
|
|
84
|
|
85 fcb F$CRC
|
|
86 fdb FCRC-*-2
|
|
87
|
|
88 fcb F$SRqMem+$80
|
|
89 fdb FSRqMem-*-2
|
|
90
|
|
91 fcb F$SRtMem+$80
|
|
92 fdb FSRtMem-*-2
|
|
93
|
|
94 fcb F$AProc+$80
|
|
95 fdb FAProc-*-2
|
|
96
|
|
97 fcb F$NProc+$80
|
|
98 fdb FNProc-*-2
|
|
99
|
|
100 fcb F$VModul+$80
|
|
101 fdb FVModul-*-2
|
|
102
|
|
103 fcb F$SSvc
|
|
104 fdb FSSvc-*-2
|
|
105
|
|
106 fcb $80
|
|
107
|
|
108 *
|
|
109 * OS-9 Genesis!
|
|
110 OS9Cold equ *
|
|
111 * clear out system globals from $0020-$0400
|
|
112 ldx #D.FMBM
|
|
113 ldy #$400-D.FMBM
|
|
114 clra
|
|
115 clrb
|
|
116 L007F std ,x++
|
|
117 leay -2,y
|
|
118 bne L007F
|
|
119 * set up system globals
|
|
120 inca
|
|
121 inca D = $200
|
|
122 std <D.FMBM $200 = start of free memory bitmap
|
|
123 addb #$20
|
|
124 std <D.FMBM+2 $220 = end of free memory bitmap
|
|
125 addb #$02
|
|
126 std <D.SysDis $222 = addr of sys dispatch tbl
|
|
127 addb #$70
|
296
|
128 std <D.UsrDis $292 = addr of usr dispatch tbl
|
0
|
129 clrb
|
|
130 inca D = $300
|
|
131 std <D.ModDir $300 = mod dir start
|
|
132 stx <D.ModDir+2 X = $400 = mod dir end
|
|
133 leas >$0100,x S = $500 (system stack?)
|
|
134
|
|
135 * Check for valid RAM starting at $400
|
|
136 ChkRAM leay ,x
|
|
137 ldd ,y store org contents in D
|
|
138 ldx #$00FF
|
|
139 stx ,y write pattern to ,Y
|
|
140 cmpx ,y same as what we wrote?
|
|
141 bne L00C2 nope, not RAM here!
|
|
142 ldx #$FF00 try different pattern
|
|
143 stx ,y write it to ,Y
|
|
144 cmpx ,y same as what we wrote?
|
|
145 bne L00C2 nope, not RAM here!
|
|
146 std ,y else restore org contents
|
|
147 leax >$0100,y check top of next 256 block
|
|
148 cmpx #$EF00 stop short of boot track mem
|
|
149 bcs ChkRAM
|
|
150 leay ,x
|
|
151 * Here, Y = end of RAM
|
|
152 L00C2 leax ,y X = end of RAM
|
|
153 stx <D.MLIM save off memory limit
|
|
154
|
|
155 * Copy vector code over to address $100
|
|
156 pshs y,x
|
|
157 leax >VectCode,pcr
|
247
|
158 ldy #D.XSWI3
|
0
|
159 ldb #VectCSz
|
|
160 L00D2 lda ,x+
|
|
161 sta ,y+
|
|
162 decb
|
|
163 bne L00D2
|
|
164 puls y,x
|
|
165 * validate modules at top of RAM (kernel, etc.)
|
|
166 L00DB lbsr ValMod
|
|
167 bcs L00E6
|
|
168 ldd M$Size,x
|
|
169 leax d,x go past module
|
|
170 bra L00EC
|
|
171 L00E6 cmpb #E$KwnMod
|
|
172 beq L00EE
|
|
173 leax 1,x
|
|
174 L00EC bne L00DB
|
|
175
|
|
176 * copy vectors to system globals
|
|
177 L00EE leay >Vectors,pcr
|
|
178 leax >L0000,pcr
|
|
179 pshs x
|
|
180 ldx #D.SWI3
|
|
181 L00FB ldd ,y++
|
|
182 addd ,s
|
|
183 std ,x++
|
|
184 cmpx #$0036
|
|
185 bls L00FB
|
|
186 leas 2,s restore stack
|
|
187
|
|
188 * fill in more system globals
|
|
189 leax >URtoSs,pcr
|
|
190 stx <D.URtoSs
|
|
191 leax >UsrIRQ,pcr
|
|
192 stx <D.UsrIRQ
|
|
193 leax >UsrSvc,pcr
|
|
194 stx <D.UsrSvc
|
|
195 leax >SysIRQ,pcr
|
|
196 stx <D.SysIRQ
|
|
197 stx <D.SvcIRQ
|
|
198 leax >SysSvc,pcr
|
|
199 stx <D.SysSvc
|
|
200 stx <D.SWI2
|
|
201 leax >Poll,pcr
|
|
202 stx <D.Poll
|
|
203 leax >Clock,pcr
|
|
204 stx <D.Clock
|
|
205 stx <D.AltIRQ
|
|
206
|
|
207 * install system calls
|
|
208 leay >SysTbl,pcr
|
|
209 lbsr InstSSvc
|
|
210
|
|
211 * link to init module
|
|
212 lda #Systm+0
|
|
213 leax >InitNam,pcr
|
|
214 os9 F$Link
|
|
215 lbcs OS9Cold
|
|
216 stu <D.Init
|
|
217 ldd MaxMem+1,u
|
|
218 clrb
|
|
219 cmpd <D.MLIM
|
|
220 bcc L0158
|
|
221 std <D.MLIM
|
|
222 L0158 ldx <D.FMBM
|
|
223 ldb #$F8
|
|
224 stb ,x
|
|
225 clra
|
|
226 ldb <D.MLIM
|
|
227 negb
|
|
228 tfr d,y
|
|
229 negb
|
|
230 lbsr L065A
|
|
231
|
|
232 * jump into OS9p2 here
|
|
233 leax >P2Nam,pcr
|
|
234 lda #Systm+Objct
|
|
235 os9 F$Link
|
|
236 lbcs OS9Cold
|
|
237 jmp ,y
|
165
|
238 SWI3 pshs pc,x,b
|
0
|
239 ldb #P$SWI3
|
|
240 bra L018C
|
165
|
241 SWI2 pshs pc,x,b
|
0
|
242 ldb #P$SWI2
|
|
243 bra L018C
|
247
|
244 DUMMY rti
|
165
|
245 SVCIRQ jmp [>D.SvcIRQ]
|
|
246 SWI pshs pc,x,b
|
0
|
247 ldb #P$SWI
|
|
248 L018C ldx >D.Proc
|
|
249 ldx b,x get SWI entry
|
|
250 stx 3,s put in PC on stack
|
|
251 puls pc,x,b
|
|
252
|
|
253 UsrIRQ leay <L01B1,pcr
|
|
254 * transition from user to system state
|
|
255 URtoSs clra
|
|
256 tfr a,dp clear direct page
|
|
257 ldx <D.Proc
|
|
258 ldd <D.SysSvc
|
|
259 std <D.SWI2
|
|
260 ldd <D.SysIRQ
|
|
261 std <D.SvcIRQ
|
|
262 leau ,s
|
|
263 stu P$SP,x
|
|
264 lda P$State,x
|
|
265 ora #SysState
|
|
266 sta P$State,x
|
|
267 jmp ,y
|
|
268
|
|
269 L01B1 jsr [>D.Poll]
|
|
270 bcc L01BD
|
|
271 ldb ,s
|
|
272 orb #$10
|
|
273 stb ,s
|
|
274 L01BD lbra L0255
|
|
275
|
|
276 SysIRQ clra
|
|
277 tfr a,dp
|
|
278 jsr [>D.Poll]
|
|
279 bcc L01CF
|
|
280 ldb ,s
|
|
281 orb #$10
|
|
282 stb ,s
|
|
283 L01CF rti
|
|
284 Poll comb
|
|
285 rts
|
|
286
|
|
287 Clock ldx <D.SProcQ
|
|
288 beq L01FD
|
|
289 lda P$State,x
|
|
290 bita #TimSleep
|
|
291 beq L01FD
|
|
292 ldu P$SP,x
|
|
293 ldd P$SP,u
|
|
294 subd #$0001
|
|
295 std P$SP,u
|
|
296 bne L01FD
|
|
297 L01E7 ldu P$Queue,x
|
|
298 bsr L021A
|
|
299 leax ,u
|
|
300 beq L01FB
|
|
301 lda P$State,x
|
|
302 bita #TimSleep
|
|
303 beq L01FB
|
|
304 ldu P$SP,x
|
|
305 ldd P$SP,u
|
|
306 beq L01E7
|
|
307 L01FB stx <D.SProcQ
|
|
308 L01FD dec <D.Slice
|
|
309 bne ClockRTI
|
|
310 lda <D.TSlice
|
|
311 sta <D.Slice
|
|
312 ldx <D.Proc
|
|
313 beq ClockRTI
|
|
314 lda P$State,x
|
|
315 ora #TimOut
|
|
316 sta P$State,x
|
|
317 bpl L0212 branch if not system state
|
|
318 ClockRTI rti
|
|
319
|
|
320 L0212 leay >L0255,pcr
|
|
321 bra URtoSs
|
|
322
|
|
323 * X = proc desc
|
|
324 FAProc ldx R$X,u
|
|
325 L021A pshs u,y
|
|
326 ldu #$003F
|
|
327 bra L0228
|
|
328 L0221 ldb P$Age,u
|
|
329 incb
|
|
330 beq L0228
|
|
331 stb P$Age,u
|
|
332 L0228 ldu P$Queue,u U = proc desc
|
|
333 bne L0221
|
|
334 ldu #$003F
|
|
335 lda P$Prior,x
|
|
336 sta P$Age,x
|
|
337 orcc #IntMasks
|
|
338 L0235 leay ,u
|
|
339 ldu P$Queue,u
|
|
340 beq L023F
|
|
341 cmpa P$Age,u
|
|
342 bls L0235
|
|
343 L023F stu P$Queue,x
|
|
344 stx P$Queue,y
|
|
345 clrb
|
|
346 puls pc,u,y
|
|
347
|
|
348 UsrSvc leay <L024E,pcr
|
|
349 orcc #IntMasks
|
|
350 lbra URtoSs
|
|
351
|
|
352 L024E andcc #^IntMasks
|
|
353 ldy <D.UsrDis
|
|
354 bsr L0278
|
|
355 L0255 ldx <D.Proc get current proc desc
|
|
356 beq FNProc branch to FNProc if none
|
|
357 orcc #IntMasks
|
|
358 ldb P$State,x
|
|
359 andb #^SysState
|
|
360 stb P$State,x
|
|
361 bitb #TimOut
|
|
362 beq L02D1
|
|
363 andb #^TimOut
|
|
364 stb P$State,x
|
|
365 bsr L021A
|
|
366 bra FNProc
|
|
367
|
|
368 * system call entry
|
|
369 SysSvc clra
|
|
370 tfr a,dp set direct page to 0
|
|
371 leau ,s
|
|
372 ldy <D.SysDis
|
|
373 bsr L0278
|
|
374 rti
|
|
375
|
|
376 L0278 pshs u
|
|
377 ldx R$PC,u point X to PC
|
|
378 ldb ,x+ get func code at X
|
|
379 stx R$PC,u restore updated PC
|
|
380 lslb multiply by 2
|
|
381 bcc L0288 branch if user call
|
|
382 rorb
|
|
383 ldx -2,y
|
|
384 bra L0290
|
|
385 L0288 cmpb #$6E
|
|
386 bcc L02A7
|
|
387 ldx b,y X = addr of system call
|
|
388 beq L02A7
|
|
389 L0290 jsr ,x jsr into system call
|
|
390 L0292 puls u
|
|
391 tfr cc,a
|
|
392 bcc FixCC branch if no error
|
|
393 stb R$B,u store error code
|
|
394 FixCC ldb R$CC,u get caller's CC
|
|
395 andb #^(Negative+Zero+TwosOvfl+Carry)
|
|
396 stb R$CC,u
|
|
397 anda #Negative+Zero+TwosOvfl+Carry
|
|
398 ora R$CC,u
|
|
399 sta R$CC,u
|
|
400 rts
|
|
401 L02A7 comb
|
|
402 ldb #E$UnkSvc
|
|
403 bra L0292
|
|
404
|
|
405 * no signal handler, exit with signal value as exit code
|
|
406 L02AC ldb P$State,x
|
|
407 orb #SysState
|
|
408 stb P$State,x
|
|
409 ldb <P$Signal,x
|
|
410 andcc #^(IntMasks)
|
|
411 os9 F$Exit
|
|
412
|
|
413 FNProc clra
|
|
414 clrb
|
|
415 std <D.Proc
|
|
416 bra L02C2
|
|
417 * execution goes here when there are no active processes
|
|
418 L02C0 cwai #^(IntMasks)
|
|
419 L02C2 orcc #IntMasks
|
|
420 ldx <D.AProcQ get next active process
|
|
421 beq L02C0 CWAI if none
|
|
422 ldd P$Queue,x get queue ptr
|
|
423 std <D.AProcQ store in Active Q
|
|
424 stx <D.Proc store in current process
|
|
425 lds P$SP,x get process' stack ptr
|
|
426 L02D1 ldb P$State,x get state
|
|
427 bmi L0308 branch if system state
|
|
428 bitb #Condem process condemned?
|
|
429 bne L02AC branch if so...
|
|
430 ldb <P$Signal,x get signal no
|
|
431 beq L02FF branch if none
|
|
432 decb decrement
|
|
433 beq L02FC branch if wake up
|
|
434 ldu <P$SigVec,x get signal handler addr
|
|
435 beq L02AC branch if none
|
|
436 ldy <P$SigDat,x get data addr
|
|
437 ldd $06,s
|
|
438 pshs u,y,b,a
|
|
439 ldu $0A,s
|
|
440 lda <P$Signal,x
|
|
441 ldb $09,s
|
|
442 tfr d,y
|
|
443 ldd $06,s
|
|
444 pshs u,y,b,a
|
|
445 clrb
|
|
446 L02FC stb <P$Signal,x
|
|
447 L02FF ldd <P$SWI2,x
|
|
448 std <D.SWI2
|
|
449 ldd <D.UsrIRQ
|
|
450 std <D.SvcIRQ
|
|
451 L0308 rti
|
|
452
|
|
453 FLink pshs u save caller regs
|
|
454 ldd R$A,u
|
|
455 ldx R$X,u
|
|
456 lbsr L0443
|
|
457 bcc FLinkOK
|
|
458 ldb #E$MNF
|
|
459 bra L033D
|
|
460 * U = module dir entry
|
|
461 FLinkOK ldy ,u get module ptr
|
|
462 ldb M$Revs,y
|
|
463 bitb #ReEnt reentrant?
|
|
464 bne L032A branch if so
|
|
465 tst $02,u link count zero?
|
|
466 beq L032A yep, ok to link to nonreent
|
|
467 comb else module is busy
|
|
468 ldb #E$ModBsy
|
|
469 bra L033D
|
|
470 L032A inc $02,u increment link count
|
|
471 ldu ,s get caller regs from stack
|
|
472 stx R$X,u
|
|
473 sty R$U,u
|
|
474 ldd M$Type,y
|
|
475 std R$D,u
|
|
476 ldd M$IDSize,y
|
|
477 leax d,y
|
|
478 stx R$Y,u
|
|
479 L033D puls pc,u
|
|
480
|
|
481 FVModul pshs u
|
|
482 ldx R$X,u
|
|
483 bsr ValMod
|
|
484 puls y
|
|
485 stu R$U,y
|
|
486 rts
|
|
487 * X = address of module to validate
|
|
488 ValMod bsr ChkMHCRC
|
|
489 bcs L039A
|
|
490 lda M$Type,x
|
|
491 pshs x,a
|
|
492 ldd M$Name,x
|
|
493 leax d,x X = addr of name in mod
|
|
494 puls a
|
|
495 lbsr L0443
|
|
496 puls x
|
|
497 bcs L039B
|
|
498 ldb #E$KwnMod
|
|
499 cmpx ,u
|
|
500 beq L03A1
|
|
501 lda M$Revs,x
|
|
502 anda #RevsMask
|
|
503 pshs a
|
|
504 ldy ,u
|
|
505 lda M$Revs,y
|
|
506 anda #RevsMask
|
|
507 cmpa ,s+ same revision as other mod?
|
|
508 bcc L03A1
|
|
509 pshs y,x
|
|
510 ldb M$Size,u
|
|
511 bne L0395
|
|
512 ldx ,u
|
|
513 cmpx <D.BTLO
|
|
514 bcc L0395
|
|
515 ldd $02,x
|
|
516 addd #$00FF
|
|
517 tfr a,b
|
|
518 clra
|
|
519 tfr d,y
|
|
520 ldb ,u
|
|
521 ldx <D.FMBM
|
|
522 os9 F$DelBit
|
|
523 clr $02,u
|
|
524 L0395 puls y,x
|
|
525 L0397 stx ,u
|
|
526 clrb
|
|
527 L039A rts
|
|
528 L039B leay ,u
|
|
529 bne L0397
|
|
530 ldb #E$DirFul
|
|
531 L03A1 coma
|
|
532 rts
|
|
533
|
|
534 * check module header and CRC
|
|
535 * X = address of potential module
|
|
536 ChkMHCRC ldd ,x
|
|
537 cmpd #M$ID12 sync bytes?
|
|
538 bne L03B1 nope, not a module here
|
|
539 leay M$Parity,x
|
|
540 bsr ChkMHPar check header parity
|
|
541 bcc L03B5 branch if ok
|
|
542 L03B1 comb
|
|
543 ldb #E$BMID
|
|
544 rts
|
|
545 L03B5 pshs x
|
|
546 ldy M$Size,x
|
|
547 bsr ChkMCRC checkm module CRC
|
|
548 puls pc,x
|
|
549 * check module header parity
|
|
550 * Y = pointer to parity byte
|
|
551 ChkMHPar pshs y,x
|
|
552 clra
|
|
553 ChkM010 eora ,x+
|
|
554 cmpx 2,s compare to addr of M$Parity
|
|
555 bls ChkM010
|
|
556 cmpa #$FF
|
|
557 puls pc,y,x
|
|
558 * X = address of potential module
|
|
559 * Y = size of module
|
|
560 ChkMCRC ldd #$FFFF
|
|
561 pshs b,a
|
|
562 pshs b,a
|
|
563 leau 1,s
|
|
564 L03D4 lda ,x+
|
|
565 bsr CRCAlgo
|
|
566 leay -1,y dec Y (size of module)
|
|
567 bne L03D4 continue
|
|
568 clr -1,u
|
|
569 lda ,u
|
|
570 cmpa #CRCCon1
|
|
571 bne L03EC
|
|
572 ldd 1,u
|
|
573 cmpd #CRCCon23
|
|
574 beq L03EF
|
|
575 L03EC comb
|
|
576 ldb #E$BMCRC
|
|
577 L03EF puls pc,y,x
|
|
578
|
|
579 * F$CRC
|
|
580 FCRC ldx R$X,u
|
|
581 ldy R$Y,u
|
|
582 beq L0402
|
|
583 ldu R$U,u
|
|
584 L03FA lda ,x+
|
|
585 bsr CRCAlgo
|
|
586 leay -1,y
|
|
587 bne L03FA
|
|
588 L0402 clrb
|
|
589 rts
|
|
590
|
|
591 CRCAlgo eora ,u
|
|
592 pshs a
|
|
593 ldd $01,u
|
|
594 std ,u
|
|
595 clra
|
|
596 ldb ,s
|
|
597 lslb
|
|
598 rola
|
|
599 eora 1,u
|
|
600 std 1,u
|
|
601 clrb
|
|
602 lda ,s
|
|
603 lsra
|
|
604 rorb
|
|
605 lsra
|
|
606 rorb
|
|
607 eora 1,u
|
|
608 eorb 2,u
|
|
609 std 1,u
|
|
610 lda ,s
|
|
611 lsla
|
|
612 eora ,s
|
|
613 sta ,s
|
|
614 lsla
|
|
615 lsla
|
|
616 eora ,s
|
|
617 sta ,s
|
|
618 lsla
|
|
619 lsla
|
|
620 lsla
|
|
621 lsla
|
|
622 eora ,s+
|
|
623 bpl L0442
|
|
624 ldd #$8021
|
|
625 eora ,u
|
|
626 sta ,u
|
|
627 eorb 2,u
|
|
628 stb 2,u
|
|
629 L0442 rts
|
|
630
|
|
631 L0443 ldu #$0000
|
|
632 tfr a,b
|
|
633 anda #TypeMask
|
|
634 andb #LangMask
|
|
635 pshs u,y,x,b,a
|
|
636 bsr EatSpace
|
|
637 cmpa #PDELIM pathlist char?
|
|
638 beq L049C branch if so
|
|
639 lbsr L074D parse name
|
|
640 bcs L049D return if error
|
|
641 ldu <D.ModDir
|
|
642 L045B pshs u,y,b
|
|
643 ldu ,u
|
|
644 beq L048B
|
|
645 ldd $04,u
|
|
646 leay d,u
|
|
647 ldb ,s
|
|
648 lbsr L07AB
|
|
649 bcs L0493
|
|
650 lda $05,s
|
|
651 beq L0476
|
|
652 eora $06,u
|
|
653 anda #$F0
|
|
654 bne L0493
|
|
655 L0476 lda $06,s
|
|
656 beq L0480
|
|
657 eora $06,u
|
|
658 anda #$0F
|
|
659 bne L0493
|
|
660 L0480 puls u,x,b
|
|
661 stu $06,s
|
|
662 bsr EatSpace
|
|
663 stx $02,s
|
|
664 clra
|
|
665 bra L049D
|
|
666 L048B ldd $0B,s
|
|
667 bne L0493
|
|
668 ldd $03,s
|
|
669 std $0B,s
|
|
670 L0493 puls u,y,b
|
|
671 leau $04,u
|
|
672 cmpu <D.ModDir+2
|
|
673 bcs L045B
|
|
674 L049C comb
|
|
675 L049D puls pc,u,y,x,b,a
|
|
676
|
|
677 EatSpace lda #C$SPAC
|
|
678 EatSpc10 cmpa ,x+
|
|
679 beq EatSpc10
|
|
680 lda ,-x
|
|
681 rts
|
|
682
|
|
683 FFork ldx <D.PrcDBT
|
|
684 os9 F$All64
|
|
685 bcs L0517
|
|
686 ldx <D.Proc
|
|
687 pshs x save calling proc desc on stack
|
|
688 ldd P$User,x
|
|
689 std P$User,y
|
|
690 lda P$Prior,x
|
|
691 clrb
|
|
692 std P$Prior,y
|
|
693 ldb #SysState
|
|
694 stb P$State,y
|
|
695 sty <D.Proc
|
|
696 ldd <P$NIO,x
|
|
697 std <P$NIO,y
|
|
698 ldd <P$NIO+2,x
|
|
699 std <P$NIO+2,y
|
|
700 leax <P$DIO,x
|
|
701 leay <P$DIO,y
|
|
702 ldb #DefIOSiz
|
|
703 * copy I/O stuff from parent to child
|
|
704 L04D7 lda ,x+
|
|
705 sta ,y+
|
|
706 decb
|
|
707 bne L04D7
|
|
708 * X/Y = address of path table in respective proc desc
|
|
709 * Dup stdin/stdout/stderr
|
|
710 ldb #$03
|
|
711 L04E0 lda ,x+
|
|
712 os9 I$Dup
|
|
713 bcc L04E8
|
|
714 clra
|
|
715 L04E8 sta ,y+
|
|
716 decb
|
|
717 bne L04E0
|
|
718 bsr L0553
|
|
719 bcs L050C
|
|
720 puls y get parent proc desc
|
|
721 sty <D.Proc
|
|
722 lda P$ID,x get ID of new process
|
|
723 sta R$A,u store in caller's A
|
|
724 ldb P$CID,y get child id of parent
|
|
725 sta P$CID,y store new proc in parent's CID
|
|
726 lda P$ID,y get ID of parent
|
|
727 std P$PID,x store in child proc desc
|
|
728 ldb P$State,x update state of child
|
|
729 andb #^SysState
|
|
730 stb P$State,x
|
|
731 os9 F$AProc insert child in active Q
|
|
732 rts
|
|
733 L050C pshs b
|
|
734 os9 F$Exit
|
|
735 comb
|
|
736 puls x,b
|
|
737 stx <D.Proc
|
|
738 rts
|
|
739 L0517 comb
|
|
740 ldb #E$PrcFul
|
|
741 rts
|
|
742
|
|
743 FChain bsr L0543
|
|
744 bcs L0531
|
|
745 orcc #IntMasks
|
|
746 ldb $0D,x
|
|
747 andb #$7F
|
|
748 stb $0D,x
|
|
749 L0527 os9 F$AProc
|
|
750 os9 F$NProc
|
|
751
|
|
752 SFChain bsr L0543
|
|
753 bcc L0527
|
|
754 L0531 pshs b
|
|
755 stb <P$Signal,x
|
|
756 ldb P$State,x
|
|
757 orb #Condem
|
|
758 stb P$State,x
|
|
759 ldb #$FF
|
|
760 stb P$Prior,x
|
|
761 comb
|
|
762 puls pc,b
|
|
763 L0543 pshs u
|
|
764 ldx <D.Proc
|
|
765 ldu <P$PModul,x
|
|
766 os9 F$UnLink
|
|
767 ldu ,s
|
|
768 bsr L0553
|
|
769 puls pc,u
|
|
770 L0553 ldx <D.Proc
|
|
771 pshs u,x
|
|
772 ldd <D.UsrSvc
|
|
773 std <P$SWI,x
|
|
774 std <P$SWI2,x
|
|
775 std <P$SWI3,x
|
|
776 clra
|
|
777 clrb
|
|
778 sta <P$Signal,x
|
|
779 std <P$SigVec,x
|
|
780 lda R$A,u
|
|
781 ldx R$X,u
|
|
782 os9 F$Link
|
|
783 bcc L0578
|
|
784 os9 F$Load
|
|
785 bcs L05E7
|
|
786 L0578 ldy <D.Proc
|
|
787 stu <P$PModul,y
|
|
788 cmpa #Prgrm+Objct
|
|
789 beq L058B
|
|
790 cmpa #Systm+Objct
|
|
791 beq L058B
|
|
792 comb
|
|
793 ldb #E$NEMod
|
|
794 bra L05E7
|
|
795 L058B leay ,u Y = addr of module
|
|
796 ldu 2,s get U off stack (caller regs)
|
|
797 stx R$X,u
|
|
798 lda R$B,u
|
|
799 clrb
|
|
800 cmpd M$Mem,y compare passed mem to module's
|
|
801 bcc L059B branch if less than
|
|
802 ldd M$Mem,y
|
|
803 L059B addd #$0000
|
|
804 bne L05A0
|
|
805 L05A0 os9 F$Mem
|
|
806 bcs L05E7
|
|
807 subd #R$Size subtract registers
|
|
808 subd R$Y,u subtract parameter area
|
|
809 bcs L05E5
|
|
810 ldx R$U,u get parameter area
|
|
811 ldd R$Y,u get parameter size
|
|
812 pshs b,a
|
|
813 beq L05BE
|
|
814 leax d,x point to end of param area
|
|
815 L05B6 lda ,-x get byte, dec X
|
|
816 sta ,-y save byte in data area, dec X
|
|
817 cmpx R$U,u at top of param area?
|
|
818 bhi L05B6
|
|
819 * set up registers for return of F$Fork/F$Chain
|
|
820 L05BE ldx <D.Proc
|
|
821 sty -$08,y put in X on caller stack
|
|
822 leay -R$Size,y back up register size
|
|
823 sty P$SP,x
|
|
824 lda P$ADDR,x
|
|
825 clrb
|
|
826 std R$U,y lowest address
|
|
827 sta R$DP,y set direct page
|
|
828 adda P$PagCnt,x
|
|
829 std R$Y,y
|
|
830 puls b,a
|
|
831 std R$D,y size of param area
|
|
832 ldb #Entire
|
|
833 stb R$CC,y
|
|
834 ldu <P$PModul,x get addr of prim. mod
|
|
835 ldd M$Exec,u
|
|
836 leau d,u
|
|
837 stu R$PC,y put in PC on caller reg
|
|
838 clrb
|
|
839 L05E5 ldb #E$IForkP
|
|
840 L05E7 puls pc,u,x
|
|
841
|
|
842 FSRqMem ldd R$D,u
|
|
843 addd #$00FF
|
|
844 clrb
|
|
845 std R$D,u
|
|
846 ldx <D.FMBM+2
|
|
847 ldd #$01FF
|
|
848 pshs b,a
|
|
849 bra L0604
|
|
850 L05FA dec $01,s
|
|
851 ldb $01,s
|
|
852 L05FE lsl ,s
|
|
853 bcc L060A
|
|
854 rol ,s
|
|
855 L0604 leax -1,x
|
|
856 cmpx <D.FMBM
|
|
857 bcs L0620
|
|
858 L060A lda ,x
|
|
859 anda ,s
|
|
860 bne L05FA
|
|
861 dec 1,s
|
|
862 subb 1,s
|
|
863 cmpb 1,u
|
|
864 rora
|
|
865 addb 1,s
|
|
866 rola
|
|
867 bcs L05FE
|
|
868 ldb 1,s
|
|
869 clra
|
|
870 incb
|
|
871 L0620 leas 2,s
|
|
872 bcs L0635
|
|
873 ldx <D.FMBM
|
|
874 tfr d,y
|
|
875 ldb 1,u
|
|
876 clra
|
|
877 exg d,y
|
|
878 bsr L065A
|
|
879 exg a,b
|
|
880 std 8,u
|
|
881 L0633 clra
|
|
882 rts
|
|
883 L0635 comb
|
|
884 ldb #E$MemFul
|
|
885 rts
|
|
886
|
|
887 FSRtMem ldd R$D,u
|
|
888 addd #$00FF
|
|
889 tfr a,b
|
|
890 clra
|
|
891 tfr d,y
|
|
892 ldd R$U,u
|
|
893 beq L0633
|
|
894 tstb
|
|
895 beq L064E
|
|
896 comb
|
|
897 ldb #E$BPAddr
|
|
898 rts
|
|
899 L064E exg a,b
|
|
900 ldx <D.FMBM
|
|
901 bra L06AD
|
|
902
|
|
903 FAllBit ldd R$D,u
|
|
904 leau R$X,u
|
|
905 pulu y,x
|
|
906 L065A pshs y,x,b,a
|
|
907 bsr L0690
|
|
908 tsta
|
|
909 pshs a
|
|
910 bmi L0671
|
|
911 lda ,x
|
|
912 L0665 ora ,s
|
|
913 leay -1,y
|
|
914 beq L0689
|
|
915 lsr ,s
|
|
916 bcc L0665
|
|
917 sta ,x+
|
|
918 L0671 tfr y,d
|
|
919 sta ,s
|
|
920 lda #$FF
|
|
921 bra L067B
|
|
922 L0679 sta ,x+
|
|
923 L067B subb #$08
|
|
924 bcc L0679
|
|
925 dec ,s
|
|
926 bpl L0679
|
|
927 L0683 lsla
|
|
928 incb
|
|
929 bne L0683
|
|
930 ora ,x
|
|
931 L0689 sta ,x
|
|
932 clra
|
|
933 leas 1,s
|
|
934 puls pc,y,x,b,a
|
|
935 L0690 pshs b
|
|
936 lsra
|
|
937 rorb
|
|
938 lsra
|
|
939 rorb
|
|
940 lsra
|
|
941 rorb
|
|
942 leax d,x
|
|
943 puls b
|
|
944 lda #$80
|
|
945 andb #$07
|
|
946 beq L06A6
|
|
947 L06A2 lsra
|
|
948 decb
|
|
949 bne L06A2
|
|
950 L06A6 rts
|
|
951
|
|
952 FDelBit ldd R$D,u
|
|
953 leau R$X,u
|
|
954 pulu y,x
|
|
955 L06AD pshs y,x,b,a
|
|
956 bsr L0690
|
|
957 coma
|
|
958 pshs a
|
|
959 bpl L06C4
|
|
960 lda ,x
|
|
961 L06B8 anda ,s
|
|
962 leay -1,y
|
|
963 beq L06D8
|
|
964 asr ,s
|
|
965 bcs L06B8
|
|
966 sta ,x+
|
|
967 L06C4 tfr y,d
|
|
968 bra L06CA
|
|
969 L06C8 clr ,x+
|
|
970 L06CA subd #$0008
|
|
971 bhi L06C8
|
|
972 beq L06D8
|
|
973 L06D1 lsla
|
|
974 incb
|
|
975 bne L06D1
|
|
976 coma
|
|
977 anda ,x
|
|
978 L06D8 sta ,x
|
|
979 clr ,s+
|
|
980 puls pc,y,x,b,a
|
|
981
|
|
982 FSchBit pshs u
|
|
983 ldd R$D,u
|
|
984 ldx R$X,u
|
|
985 ldy R$Y,u
|
|
986 ldu R$U,u
|
|
987 bsr L06F3
|
|
988 puls u
|
|
989 std R$D,u
|
|
990 sty R$Y,u
|
|
991 rts
|
|
992 L06F3 pshs u,y,x,b,a
|
|
993 pshs y,b,a
|
|
994 clr 8,s
|
|
995 clr 9,s
|
|
996 tfr d,y
|
|
997 bsr L0690
|
|
998 pshs a
|
|
999 bra L0710
|
|
1000 L0703 leay $01,y
|
|
1001 sty $05,s
|
|
1002 L0708 lsr ,s
|
|
1003 bcc L0714
|
|
1004 ror ,s
|
|
1005 leax $01,x
|
|
1006 L0710 cmpx $0B,s
|
|
1007 bcc L0732
|
|
1008 L0714 lda ,x
|
|
1009 anda ,s
|
|
1010 bne L0703
|
|
1011 leay $01,y
|
|
1012 tfr y,d
|
|
1013 subd $05,s
|
|
1014 cmpd $03,s
|
|
1015 bcc L0739
|
|
1016 cmpd $09,s
|
|
1017 bls L0708
|
|
1018 std $09,s
|
|
1019 ldd $05,s
|
|
1020 std $01,s
|
|
1021 bra L0708
|
|
1022 L0732 ldd $01,s
|
|
1023 std $05,s
|
|
1024 coma
|
|
1025 bra L073B
|
|
1026 L0739 std $09,s
|
|
1027 L073B leas $05,s
|
|
1028 puls pc,u,y,x,b,a
|
|
1029
|
|
1030 FPrsNam ldx R$X,u
|
|
1031 bsr L074D
|
|
1032 std R$D,u
|
|
1033 bcs L0749
|
|
1034 stx R$X,u
|
|
1035 L0749 sty R$Y,u
|
|
1036 rts
|
|
1037 L074D lda ,x
|
|
1038 cmpa #PDELIM pathlist char?
|
|
1039 bne L0755 branch if not
|
|
1040 leax 1,x go past pathlist char
|
|
1041 L0755 leay ,x
|
|
1042 clrb
|
|
1043 lda ,y+
|
|
1044 anda #$7F
|
|
1045 bsr L0792
|
|
1046 bcs L0772
|
|
1047 L0760 incb
|
|
1048 lda -1,y
|
|
1049 bmi L076F hi bit set on this char, done
|
|
1050 lda ,y+
|
|
1051 anda #$7F
|
|
1052 bsr IllChar
|
|
1053 bcc L0760
|
|
1054 lda ,-y
|
|
1055 L076F andcc #^Carry
|
|
1056 rts
|
|
1057 L0772 cmpa #C$COMA comma?
|
|
1058 bne L0778
|
|
1059 L0776 lda ,y+
|
|
1060 L0778 cmpa #C$SPAC space?
|
|
1061 beq L0776
|
|
1062 lda ,-y
|
|
1063 comb
|
|
1064 ldb #E$BNam
|
|
1065 rts
|
|
1066
|
|
1067 * check for illegal characters in a pathlist
|
|
1068 IllChar cmpa #C$PERD period?
|
|
1069 beq L07C9 branch if so
|
|
1070 cmpa #'0 zero?
|
|
1071 bcs L07A2 branch if less than
|
|
1072 cmpa #'9 number?
|
|
1073 bls L07C9 branch if lower/same
|
|
1074 cmpa #'_ underscore?
|
|
1075 beq L07C9 branch if so
|
|
1076 L0792 cmpa #'A A?
|
|
1077 bcs L07A2 branch if less than
|
|
1078 cmpa #'Z Z?
|
|
1079 bls L07C9 branch if less or equal
|
|
1080 cmpa #'a a?
|
|
1081 bcs L07A2 branch if lower
|
|
1082 cmpa #'z z?
|
|
1083 bls L07C9 branch if less or equal
|
|
1084 L07A2 orcc #Carry
|
|
1085 rts
|
|
1086
|
|
1087 FCmpNam ldb R$B,u
|
|
1088 leau R$X,u
|
|
1089 pulu y,x
|
|
1090 L07AB pshs y,x,b,a
|
|
1091 L07AD lda ,y+
|
|
1092 bmi L07BE
|
|
1093 decb
|
|
1094 beq L07BA
|
|
1095 eora ,x+
|
|
1096 anda #$DF
|
|
1097 beq L07AD
|
|
1098 L07BA orcc #Carry
|
|
1099 puls pc,y,x,b,a
|
|
1100 L07BE decb
|
|
1101 bne L07BA
|
|
1102 eora ,x
|
|
1103 anda #$5F
|
|
1104 bne L07BA
|
|
1105 puls y,x,b,a
|
|
1106 L07C9 andcc #^Carry
|
|
1107 rts
|
|
1108
|
|
1109 FSSvc ldy R$Y,u
|
|
1110 bra InstSSvc
|
|
1111 SSvcLoop tfr b,a put syscall code in A
|
|
1112 anda #$7F kill hi bit
|
|
1113 cmpa #$7F is code $7F?
|
|
1114 beq SSvcOK
|
|
1115 cmpa #$37
|
|
1116 bcs SSvcOK branch if A less than $37
|
|
1117 comb
|
|
1118 ldb #E$ISWI
|
|
1119 rts
|
|
1120 SSvcOK lslb
|
|
1121 ldu <D.SysDis
|
|
1122 leau b,u U points to entry in table
|
|
1123 ldd ,y++ get addr of func
|
|
1124 leax d,y get absolute addr
|
|
1125 stx ,u store in system table
|
|
1126 bcs InstSSvc branch if system only
|
|
1127 stx <$70,u else store in user table too
|
|
1128 InstSSvc ldb ,y+ get system call code in B
|
|
1129 cmpb #$80 end of table?
|
|
1130 bne SSvcLoop branch if not
|
|
1131 rts
|
|
1132
|
|
1133 emod
|
|
1134 eom equ *
|
|
1135
|
165
|
1136 fdb Clock
|
247
|
1137 Vectors fdb SWI3 SWI3
|
|
1138 fdb SWI2 SWI2
|
|
1139 fdb DUMMY FIRQ
|
|
1140 fdb SVCIRQ IRQ
|
|
1141 fdb SWI SWI
|
|
1142 fdb DUMMY NMI
|
0
|
1143
|
|
1144 end
|
|
1145
|