Mercurial > hg > Members > kono > os9 > sbc09
comparison CoCoOS9/level2v3/MODULES/os9p2.asm @ 31:bd2b07db8917 cocoos9lv2v3
CoCoOS9 version
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 14 Jul 2018 15:16:13 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
30:7b1b25ff010a | 31:bd2b07db8917 |
---|---|
1 ******************************************************************** | |
2 * OS9p2 - OS-9 Level Two V3 P2 module | |
3 * | |
4 * $Id: os9p2.asm,v 1.1.1.1 2001/02/21 23:30:55 boisy Exp $ | |
5 * | |
6 * Ed. Comments Who YY/MM/DD | |
7 * ------------------------------------------------------------------ | |
8 * 18d Removed bogus assumptions regarding init BGP 98/10/05 | |
9 * module in order to shrink code size, added | |
10 * check for CRC bit in compabibility byte of | |
11 * init module. | |
12 * 18e Made minor optimizations as per Curtis Boyle's BGP 98/10/10 | |
13 * optimization document | |
14 | |
15 nam OS9p2 | |
16 ttl OS-9 Level Two V3 P2 module | |
17 | |
18 ifp1 | |
19 use defsfile | |
20 endc | |
21 | |
22 msiz equ 256 | |
23 | |
24 F$IOMan equ $7F | |
25 | |
26 rev set $05 | |
27 edition set 18 | |
28 | |
29 mod endmod,name,Systm,Reent+rev,entry,msiz | |
30 | |
31 name fcs "OS9p2" | |
32 fcb edition | |
33 | |
34 *------------------------------------------------* | |
35 * OS9p2 Inits Here: | |
36 *------------------------------------------------* | |
37 | |
38 entry leay SysCalls,pcr insert OS9p2 sys calls | |
39 os9 F$SSvc | |
40 ldu <D.Init | |
41 ldd Maxmem,u D=top of free mem | |
42 lsra D/16 (16 blocks/map) | |
43 rorb | |
44 lsra | |
45 rorb | |
46 lsra | |
47 rorb | |
48 lsra | |
49 rorb | |
50 lsra | |
51 rorb | |
52 addd <D.BlkMap D+block map start | |
53 tfr d,x X=D | |
54 ldb #NotRAM get flag | |
55 bra L0036 | |
56 | |
57 L0030 lda ,x+ get block marker | |
58 bne L0036 ..skip if used | |
59 stb -1,x else set as none | |
60 L0036 cmpx <D.BlkMap+2 end of map? | |
61 bcs L0030 ..no,loop | |
62 | |
63 L003A ldu <D.Init U=init module | |
64 ldd SysStr,u point to '/D0' offset | |
65 beq L004F ..none | |
66 leax d,u X=name ptr | |
67 lda #READ.+EXEC. | |
68 os9 I$ChgDir 'CHD /D0',CHX /D0 | |
69 * bcc L004F ..okay | |
70 * os9 F$Boot else boot | |
71 * bcc L003A ..okay | |
72 | |
73 L004F ldu <D.Init init data | |
74 ldd StdStr,u point to '/TERM' | |
75 beq L0077 | |
76 leax d,u | |
77 lda #READ.+WRITE. | |
78 os9 I$Open try to open /Term | |
79 * bcc L0066 ..okay | |
80 * os9 F$Boot else boot and | |
81 * bcc L004F ..try again | |
82 bcs Crash crash! | |
83 | |
84 L0066 ldx <D.Proc X=proc desc | |
85 sta P$Path,x std in | |
86 os9 I$Dup | |
87 sta P$Path+1,x std out | |
88 os9 I$Dup | |
89 sta P$Path+2,x std err | |
90 | |
91 L0077 leax OS9p3Nam,pcr try to find OS9p3 | |
92 lbsr SysLink | |
93 bcs L0083 | |
94 jsr ,y do it's init if it exists | |
95 | |
96 L0083 ldu <D.Init | |
97 ldd InitStr,u point to 'Sysgo' | |
98 leax d,u | |
99 lda #Objct mod type | |
100 clrb mem ok | |
101 ldy #$0000 no parms | |
102 os9 F$Fork start up sysgo | |
103 os9 F$NProc and do it. | |
104 | |
105 OS9p3Nam fcs "OS9p3" | |
106 | |
107 * NEW CODE FOR BAD BOOT: | |
108 | |
109 Crash jmp <D.Crash reset vector | |
110 | |
111 *------------------------------------------------* | |
112 * Service Calls: | |
113 *------------------------------------------------* | |
114 | |
115 SysCalls fcb F$Unlink | |
116 fdb FUnlink-*-2 | |
117 fcb F$Fork | |
118 fdb FFork-*-2 | |
119 fcb F$Wait | |
120 fdb FWait-*-2 | |
121 fcb F$Chain | |
122 fdb FChain-*-2 | |
123 fcb F$Exit | |
124 fdb FExit-*-2 | |
125 fcb F$Mem | |
126 fdb FMem-*-2 | |
127 fcb F$Send | |
128 fdb FSend-*-2 | |
129 fcb F$Icpt | |
130 fdb FIcpt-*-2 | |
131 fcb F$Sleep | |
132 fdb FSleep-*-2 | |
133 fcb F$SPrior | |
134 fdb FSPrior-*-2 | |
135 fcb F$ID | |
136 fdb FID-*-2 | |
137 fcb F$SSWI | |
138 fdb FSSWI-*-2 | |
139 fcb F$STime | |
140 fdb FSTime-*-2 | |
141 fcb F$SchBit | |
142 fdb FSchBit-*-2 | |
143 fcb F$SchBit+$80 (sys) | |
144 fdb SSchBit-*-2 | |
145 fcb F$AllBit | |
146 fdb FAllBit-*-2 | |
147 fcb F$AllBit+$80 (sys) | |
148 fdb SAllBit-*-2 | |
149 fcb F$DelBit | |
150 fdb FDelBit-*-2 | |
151 fcb F$DelBit+$80 | |
152 fdb SDelBit-*-2 | |
153 fcb F$GPrDsc | |
154 fdb FGPrDsc-*-2 | |
155 fcb F$GBlkMp | |
156 fdb FGBlkMp-*-2 | |
157 fcb F$GModDr | |
158 fdb FGModDr-*-2 | |
159 fcb F$CpyMem | |
160 fdb FCpyMem-*-2 | |
161 fcb F$SUser | |
162 fdb FSUser-*-2 | |
163 fcb F$Unload | |
164 fdb FUnload-*-2 | |
165 fcb F$Find64+$80 | |
166 fdb FFind64-*-2 | |
167 fcb F$All64+$80 | |
168 fdb FAll64-*-2 | |
169 fcb F$Ret64+$80 | |
170 fdb FRet64-*-2 | |
171 fcb F$GProcP+$80 | |
172 fdb FGProcP-*-2 | |
173 fcb F$DelImg+$80 | |
174 fdb FDelImg-*-2 | |
175 fcb F$AllPrc+$80 | |
176 fdb FAllPrc-*-2 | |
177 fcb F$DelPrc+$80 | |
178 fdb FDelPrc-*-2 | |
179 fcb F$MapBlk | |
180 fdb FMapBlk-*-2 | |
181 fcb F$ClrBlk | |
182 fdb FClrBlk-*-2 | |
183 fcb F$DelRam | |
184 fdb FDelRam-*-2 | |
185 fcb F$GCMDir+$80 | |
186 fdb FGCMdir-*-2 | |
187 fcb F$IOMan | |
188 fdb IOCall-*-2 | |
189 fcb $80 End of Calls | |
190 | |
191 * Link to a Systm module | |
192 SysLink lda #Systm | |
193 os9 F$Link | |
194 rts | |
195 | |
196 *------------------------------------------------* | |
197 * The first I$Call will come here: | |
198 | |
199 IOMgrNam fcs "IOMan" | |
200 | |
201 IOCall pshs a,b,x,y,u | |
202 leax IOMgrNam,pcr | |
203 bsr SysLink try to find IOMan | |
204 * The following assumes os9p2 may be in the boot track and | |
205 * requires a call to F$Boot to get to IOMan. This is | |
206 * not the case for the CoCo 3. | |
207 * bcc L0121 ..okay | |
208 * os9 F$Boot else boot | |
209 * bcs L012B ..return err | |
210 * bsr SysLink try again | |
211 bcs L012B | |
212 L0121 jsr ,y initialize IOMan | |
213 puls a,b,x,y,u | |
214 ldx $00FE,y then do the call | |
215 jmp ,x | |
216 | |
217 *------------------------------------------------* | |
218 * Error, No IOMan: | |
219 | |
220 L012B stb 1,s return err code | |
221 puls a,b,x,y,u,pc | |
222 | |
223 *------------------------------------------------* | |
224 * F$Unlink | |
225 *------------------------------------------------* | |
226 FUnlink pshs a,b,u | |
227 ldd R$U,u D=module address | |
228 ldx R$U,u X=module address | |
229 lsra img block # = A/16 | |
230 lsra | |
231 lsra | |
232 lsra | |
233 lsra | |
234 sta ,s save usr map img num | |
235 beq L0183 ..ignore if zero | |
236 | |
237 ldu <D.Proc proc desc | |
238 leay P$DATImg,u map images | |
239 asla index by block# | |
240 ldd a,y D= DAT image number | |
241 ldu <D.BlkMap look it up | |
242 ldb d,u in the block map | |
243 bitb #ModBlock module in block? | |
244 beq L0183 ..no, okay | |
245 leau P$DATImg,y else see if done | |
246 bra L0161 with this block... | |
247 | |
248 L015D dec ,s at mod block? | |
249 beq L0183 ..yes, ignore. | |
250 L0161 ldb ,s usr block # | |
251 aslb index | |
252 ldd b,u D=real number | |
253 beq L015D skip if zero | |
254 | |
255 lda ,s else get usr blk # | |
256 asla *16 is module start | |
257 asla | |
258 asla | |
259 asla | |
260 asla | |
261 clrb B=00 | |
262 nega A=-A | |
263 leax d,x X=block begin | |
264 ldb ,s usr blk # | |
265 aslb index | |
266 ldd b,y D=img block | |
267 ldu <D.ModDir U=mod dir | |
268 bra L0185 ..check mods in block | |
269 | |
270 *------------------------------------------------* | |
271 * Check Block for Mods: | |
272 | |
273 L017C leau MD$ESize,u next entry | |
274 cmpu <D.ModEnd end of dir? | |
275 bcs L0185 ..no, try more | |
276 L0183 bra L01D0 ..yes,end. | |
277 | |
278 L0185 cmpx MD$MPtr,u is it dir entry? | |
279 bne L017C ..no, loop | |
280 cmpd [MD$MPDAT,u] image block same? | |
281 bne L017C ..no, loop | |
282 ldx MD$Link,u link count=0? | |
283 beq L0198 ..yes | |
284 leax -1,x else link-1 | |
285 stx MD$Link,u | |
286 bne L01B5 ..skip if not zero | |
287 | |
288 L0198 ldx 2,s X=reg stack | |
289 ldx R$U,x X=mod ptr | |
290 ldd #M$Type D=offset to type byte | |
291 os9 F$LDDDXY get module type/lang | |
292 cmpa #FlMgr is it mgr,driver, or desc? | |
293 bcs L01B3 ..no | |
294 os9 F$IODel yes, delete it properly | |
295 bcc L01B3 ..ok | |
296 ldx MD$Link,u else inc link count | |
297 leax 1,x | |
298 stx MD$Link,u | |
299 bra L01D1 ..bad end. | |
300 | |
301 L01B3 bsr L01D5 delete moddir entry | |
302 L01B5 ldb ,s block dat | |
303 aslb index | |
304 leay b,y Y=image ptr | |
305 ldx P$Links-P$DATImg,y link count | |
306 leax -1,x -1 | |
307 stx P$Links-P$DATImg,y | |
308 bne L01D0 ..skip if not zero | |
309 | |
310 ldd MD$MBSiz,u block size | |
311 bsr L0226 change to #blocks | |
312 ldx #DAT.Free free flag | |
313 L01CB stx ,y++ mark images free | |
314 deca | |
315 bne L01CB | |
316 | |
317 L01D0 clrb okay | |
318 L01D1 leas 2,s drop | |
319 puls u,pc end unlink. | |
320 | |
321 *------------------------------------------------* | |
322 * Clear ModDir Entry: | |
323 | |
324 L01D5 ldx <D.BlkMap X=ram map | |
325 ldd [MD$MPDAT,u] D=DAT img blk | |
326 lda d,x A=map marker | |
327 bmi L0225 ..bra if not ram | |
328 ldx <D.ModDir point to module dir | |
329 | |
330 L01DF ldd [MD$MPDAT,x] get block # | |
331 cmpd [MD$MPDAT,u] same as this? | |
332 bne L01EA ..no | |
333 | |
334 ldd MD$Link,x link cnt zero? | |
335 bne L0225 ..no | |
336 L01EA leax MD$ESize,x skip to next entry | |
337 cmpx <D.ModEnd last? | |
338 bcs L01DF ..no, keep looking | |
339 | |
340 ldx <D.BlkMap block map ptr | |
341 ldd MD$MBSiz,u module block size | |
342 bsr L0226 convert to #blocks | |
343 pshs y save y | |
344 ldy MD$MPDAT,u module image ptr | |
345 L01FB pshs a,x save #blocks, ptr | |
346 ldd ,y get block number | |
347 clr ,y+ clear the image | |
348 clr ,y+ | |
349 leax d,x point to blkmap entry | |
350 ldb ,x | |
351 andb #^(RAMinUse+ModBlock) free block | |
352 stb ,x | |
353 puls a,x | |
354 deca last block done? | |
355 bne L01FB ..no, loop | |
356 | |
357 puls y | |
358 ldx <D.ModDir module dir ptr | |
359 ldd MD$MPDAT,u image ptr | |
360 | |
361 L0216 cmpd ,x was module here? | |
362 bne L021F ..no | |
363 clr MD$MPDAT,x clear entry | |
364 clr MD$MPDAT+1,x | |
365 L021F leax MD$ESize,x next dir entry | |
366 cmpx <D.ModEnd last? | |
367 bcs L0216 ..no, keep looking | |
368 | |
369 L0225 rts end clear moddir entry. | |
370 | |
371 *------------------------------------------------* | |
372 * Convert BlockSize to #Blocks: | |
373 | |
374 L0226 addd #$1FFF round up | |
375 lsra | |
376 lsra | |
377 lsra | |
378 lsra | |
379 lsra | |
380 rts | |
381 | |
382 *------------------------------------------------* | |
383 * F$Fork | |
384 *------------------------------------------------* | |
385 FFork pshs u | |
386 lbsr L02EA get proc desc | |
387 bcc L0238 ..ok, fork | |
388 puls u,pc else err. | |
389 | |
390 *------------------------------------------------* | |
391 L0238 pshs u save child proc desc ptr | |
392 ldx <D.Proc get parent's | |
393 ldd P$User,x copy user index | |
394 std P$User,u | |
395 lda P$Prior,x priority & age | |
396 sta P$Prior,u | |
397 | |
398 pshs x,u save proc. desc. addresses | |
399 | |
400 leax P$NIO,x copy Net IO ptrs <NEW> | |
401 leau P$NIO,u <NEW> | |
402 ldb #NefIOSiz Net table size <NEW> | |
403 | |
404 L0250 lda ,x+ | |
405 sta ,u+ | |
406 decb | |
407 bne L0250 | |
408 | |
409 puls x,u recover proc. desc. addresses | |
410 leax P$DIO,x copy default data/exec dirs: | |
411 leau P$DIO,u | |
412 ldb #DefIOSiz | |
413 L0261 lda ,x+ | |
414 sta ,u+ | |
415 decb | |
416 bne L0261 | |
417 | |
418 ldy #3 | |
419 | |
420 * dup 1st 3 paths: | |
421 | |
422 L026C lda ,x+ | |
423 beq L0276 skip if not open | |
424 os9 I$Dup | |
425 bcc L0276 | |
426 clra | |
427 | |
428 * as std in/out/err: | |
429 | |
430 L0276 sta ,u+ | |
431 leay -1,y count-1 | |
432 bne L026C | |
433 | |
434 ldx ,s X=child proc desc | |
435 ldu 2,s U=caller regs | |
436 lbsr L04B1 link/load mod, set proc desc | |
437 bcs L02CF ..err | |
438 pshs a,b save size | |
439 os9 F$AllTsk get task# for child | |
440 bcs L02CF | |
441 | |
442 L028C lda P$PagCnt,x D=mem amt | |
443 clrb | |
444 subd ,s D-mod size | |
445 tfr d,u U=dest | |
446 ldb P$Task,x B=child task# for parm copy | |
447 ldx <D.Proc parent's proc desc | |
448 lda P$Task,x and task | |
449 leax ,y X=parameter ptr | |
450 puls y Y=count | |
451 os9 F$Move X(A)-->U(B) *Y copy over data | |
452 | |
453 ldx ,s copy over child's stack | |
454 lda <D.SysTsk | |
455 ldu P$SP,x | |
456 leax P$Stack-R$Size,x | |
457 ldy #R$Size | |
458 os9 F$Move X(A)-->U(B) *Y | |
459 | |
460 puls x,u | |
461 os9 F$DelTsk release child task# | |
462 ldy <D.Proc Y=parents proc desc | |
463 lda P$ID,x X=childs proc desc | |
464 sta R$A,u return it | |
465 ldb P$CID,y B=sibling | |
466 sta P$CID,y let parent have child | |
467 lda P$ID,y parents ID | |
468 std P$PID,x set child's parent/sibling | |
469 lda P$State,x | |
470 anda #^SysState take child out of sys | |
471 sta P$State,x state and | |
472 os9 F$AProc activate it | |
473 rts end. | |
474 | |
475 *------------------------------------------------* | |
476 * Error - couldn't link/load pgm: | |
477 | |
478 L02CF puls x bad proc desc | |
479 pshs b save error | |
480 lbsr L05A5 close paths & unlink mem | |
481 lda P$ID,x get bad id | |
482 lbsr L0386 delete proc desc & task# | |
483 comb set err | |
484 puls b,u,pc bad end. | |
485 | |
486 *------------------------------------------------* | |
487 * F$AllPrc | |
488 *------------------------------------------------* | |
489 FAllPrc pshs u save reg ptr | |
490 bsr L02EA allocate process desc | |
491 bcs L02E8 ..err | |
492 ldx ,s get reg ptr | |
493 stu R$U,x return proc desc ptr | |
494 L02E8 puls u,pc end. | |
495 | |
496 *------------------------------------------------* | |
497 * Allocate a Proc Desc: | |
498 | |
499 L02EA ldx <D.PrcDBT X=proc table | |
500 L02EC lda ,x+ search 'til empty | |
501 bne L02EC is found | |
502 | |
503 leax -1,x back up to it | |
504 tfr x,d D=addrss | |
505 subd <D.PrcDBT D=index | |
506 tsta >256? | |
507 beq L02FE ..no, ok | |
508 comb else | |
509 ldb #E$PrcFul 'Process Table Full' | |
510 bra L032F | |
511 | |
512 L02FE pshs b save index | |
513 ldd #P$Size get 512 bytes | |
514 os9 F$SRqMem for proc desc | |
515 puls a A=index | |
516 bcs L032F ..err | |
517 sta P$ID,u set proc ID | |
518 tfr u,d D=proc desc addrss | |
519 sta ,x set proc desc msb in table | |
520 | |
521 clra D=0000 | |
522 leax P$PID,u start after ID | |
523 ldy #$80 256 byte count | |
524 L0317 std ,x++ clear proc desc | |
525 leay -1,y | |
526 bne L0317 | |
527 | |
528 ldy <D.Proc get current proc desc address | |
529 ldx <D.SysPrc get system proc desc address | |
530 stx <D.Proc make system current proc | |
531 leax P$DatBeg,u new proc desc creation date/time tag | |
532 os9 F$Time ignore any error... | |
533 sty <D.Proc restore current proc desc address | |
534 | |
535 lda #SysState set system state | |
536 sta P$State,u | |
537 ldb #DAT.BlCt mark all blocks as unused | |
538 ldx #DAT.Free | |
539 leay P$DATImg,u in the proc images | |
540 L0329 stx ,y++ | |
541 decb | |
542 bne L0329 | |
543 clrb okay | |
544 L032F rts | |
545 | |
546 *------------------------------------------------* | |
547 * F$DelPrc | |
548 *------------------------------------------------* | |
549 FDelPrc lda R$A,u get proc id | |
550 bra L0386 delete it | |
551 | |
552 *------------------------------------------------* | |
553 * F$Wait | |
554 *------------------------------------------------* | |
555 FWait ldx <D.Proc proc desc | |
556 lda P$CID,x any children? | |
557 beq L0368 ..no, quick return | |
558 | |
559 L033A lbsr L0B2E find child proc desc | |
560 lda P$State,y | |
561 bita #Dead has it died? | |
562 bne L036C ..yes | |
563 lda P$SID,y else does it have sibling? | |
564 bne L033A ..yes, check it | |
565 | |
566 sta R$A,u return child's id | |
567 | |
568 sta R$B,U | |
569 | |
570 pshs cc save CC | |
571 orcc #IntMasks stop interrupts | |
572 | |
573 lda P$SIGNAL,X | |
574 beq N035D | |
575 deca | |
576 bne N035A | |
577 sta P$SIGNAL,X | |
578 N035A lbra L071B | |
579 | |
580 N035D ldd <D.WProcQ insert caller | |
581 std P$Queue,x into waiting proc | |
582 stx <D.WProcQ queue | |
583 puls cc restore CC | |
584 lbra L0780 and go wait. | |
585 | |
586 L0368 comb | |
587 ldb #E$NoChld 'No Child Error' | |
588 rts | |
589 | |
590 *------------------------------------------------* | |
591 L036C lda P$ID,y get child id | |
592 ldb P$Signal,y and its death signal | |
593 std R$A,u return to caller | |
594 leau ,y child proc desc | |
595 leay P$CID-P$SID,x | |
596 bra L037C go bury child | |
597 | |
598 *------------------------------------------------* | |
599 L0379 lbsr L0B2E find proc desc | |
600 L037C lda P$SID,y is sibling the link? | |
601 cmpa P$ID,u | |
602 bne L0379 ..no, try next | |
603 ldb P$SID,u link in other | |
604 stb P$SID,y siblings | |
605 | |
606 * Delete Proc Desc & Task#: | |
607 | |
608 L0386 pshs a,b,x,u | |
609 | |
610 cmpa WGlobal+G.AlPID is alarm call for this task? | |
611 bne NEWLABEL no .... | |
612 clr WGlobal+G.AlPID clear task # | |
613 clr WGlobal+G.AlSig clear signal | |
614 | |
615 NEWLABEL ldb ,s <NEW LABEL> | |
616 ldx <D.PrcDBT X=proc desc table | |
617 abx index task | |
618 lda ,x get pointer | |
619 beq L03AC ..quick ok if none | |
620 clrb else clear ptr | |
621 stb ,x | |
622 tfr d,x X=proc desc | |
623 os9 F$DelTsk release task flag | |
624 leau ,x U=proc desc | |
625 ldd #P$Size return 512 byte | |
626 os9 F$SRtMem proc desc mem | |
627 L03AC puls a,b,x,u,pc end. | |
628 | |
629 *------------------------------------------------* | |
630 * F$Chain | |
631 *------------------------------------------------* | |
632 FChain pshs u save U | |
633 lbsr L02EA allocate proc desc | |
634 bcc L03B7 ..go chain | |
635 puls u,pc | |
636 | |
637 *------------------------------------------------* | |
638 * Copy Proc Desc Data: | |
639 | |
640 L03B7 ldx <D.Proc save proc | |
641 pshs x,u | |
642 leax P$SP,x copy from P$SP--> | |
643 leau P$SP,u | |
644 ldy #$007E 252 byte count | |
645 | |
646 L03C3 ldd ,x++ copy bytes | |
647 std ,u++ | |
648 leay -1,y | |
649 bne L03C3 | |
650 | |
651 ldu 2,S get new proc desc address | |
652 leau P$DATImg,u point to DAT image | |
653 ldx ,S get old proc desc | |
654 lda P$Task,x get old task # | |
655 asla task # x2 is index | |
656 ldx <D.TskIPt point to DAT image table | |
657 stu A,X put image address into table | |
658 | |
659 ldx <D.Proc proc desc | |
660 clra D=0000 | |
661 clrb | |
662 stb P$Task,x set no task# | |
663 std P$SWI,x sys swi's | |
664 std P$SWI2,x | |
665 std P$SWI3,x | |
666 sta P$Signal,x no signal/vecs | |
667 std P$SigVec,x | |
668 ldu P$PModul,x unlink primary module | |
669 os9 F$Unlink | |
670 ldb P$PagCnt,x mem page count | |
671 addb #$1F round up | |
672 lsrb B/16 (pages-->blocks) | |
673 lsrb | |
674 lsrb | |
675 lsrb | |
676 lsrb | |
677 lda #DAT.BlCt max count=16 | |
678 pshs b -num used | |
679 suba ,s+ =number to release: | |
680 leay P$DATImg,x Y=images | |
681 aslb index | |
682 leay b,y first block | |
683 ldu #DAT.Free not used flag | |
684 L040C stu ,y++ clear proc images | |
685 deca | |
686 bne L040C | |
687 | |
688 ldu 2,s set new proc desc | |
689 stu <D.Proc | |
690 ldu P$SP,s | |
691 lbsr L04B1 link/load module | |
692 | |
693 bcs L04A1 ..err | |
694 | |
695 pshs a,b save size | |
696 os9 F$AllTsk get task# for new proc (if possible) | |
697 bcc L0425 | |
698 | |
699 *------------------------------------------------* | |
700 * Chain Error: | |
701 | |
702 leas 2,s dump parm size | |
703 | |
704 L04A1 | |
705 puls x,u | |
706 stx <D.Proc reset proc | |
707 pshs cc,b save error status/info | |
708 lda P$ID,u get temp proc id | |
709 lbsr L0386 and delete proc desc | |
710 puls cc,b recover error status/info | |
711 os9 F$Exit and exit gracefully | |
712 | |
713 L0425 ldu <D.Proc U=new proc | |
714 lda P$Task,u A=source tsk# | |
715 ldb P$Task,x B=dest tsk# | |
716 leau P$Stack-R$Size,x ($01F4) | |
717 leax ,y source ptr | |
718 ldu R$X,u dest ptr | |
719 pshs u source ptr > | |
720 cmpx ,s++ dest ptr? | |
721 puls y size | |
722 bhi L0471 ..yes | |
723 beq L0474 same place | |
724 leay ,y size=zero? | |
725 beq L0474 ..yes | |
726 | |
727 pshs a,b,x | |
728 tfr y,d size | |
729 leax d,x source end ptr | |
730 pshs u save dest | |
731 cmpx ,s++ source within dest? | |
732 puls a,b,x | |
733 bls L0471 ..no | |
734 | |
735 pshs a,b,x,y,u | |
736 tfr y,d size | |
737 leax d,x source end ptr | |
738 leau d,u dest end ptr | |
739 | |
740 * Copy Parms: | |
741 | |
742 L0457 ldb ,s source task# | |
743 leax -1,x back up fm end | |
744 os9 F$LDABX get byte | |
745 exg x,u src <--> dest | |
746 ldb 1,s task# | |
747 leax -1,x back up dest ptr | |
748 os9 F$STABX store byte | |
749 exg x,u | |
750 leay -1,y cnt-1 | |
751 bne L0457 | |
752 | |
753 puls a,b,x,y,u | |
754 bra L0474 | |
755 | |
756 *------------------------------------------------* | |
757 L0471 os9 F$Move X(A)-->U(B) *Y | |
758 L0474 lda <D.SysTsk from sys map | |
759 ldx ,s get proc desc | |
760 ldu P$SP,x and stack pointer | |
761 leax P$Stack-R$Size,x point to proc stack | |
762 ldy #R$Size stack count | |
763 os9 F$Move X(A)-->U(B) *Y copy from proc desc | |
764 puls x,u stack to user reg stack | |
765 lda P$ID,u get id | |
766 lbsr L0386 delete temp proc desc & free task# | |
767 os9 F$DelTsk delete task# | |
768 orcc #IntMasks halt interrupts | |
769 ldd <D.SysPrc set system as proc | |
770 std <D.Proc | |
771 lda P$State,x drop system state | |
772 anda #^SysState | |
773 sta P$State,x | |
774 os9 F$AProc insert in active queue | |
775 os9 F$NProc and start next process. | |
776 * NOTE: F$NProc will NOT return control to caller. | |
777 * This routine ends here, no error possible. | |
778 | |
779 *------------------------------------------------* | |
780 * Init New Proc Desc: | |
781 * Link or Load Primary Module: | |
782 | |
783 L04B1 pshs a,b,x,y,u | |
784 ldd <D.Proc proc desc | |
785 pshs a,b save it | |
786 stx <D.Proc temp proc | |
787 lda R$A,u type | |
788 ldx R$X,u name | |
789 ldy ,s new proc desc | |
790 leay P$DATImg,y Y=new images | |
791 os9 F$SLink link in primary mod | |
792 bcc L04D7 ..ok | |
793 | |
794 ldd ,s else restore old proc | |
795 std <D.Proc | |
796 ldu 4,s get new proc desc | |
797 os9 F$Load use sys f$load | |
798 bcc L04D7 ..ok | |
799 leas 4,s else drop junk | |
800 puls x,y,u,pc return err. | |
801 | |
802 *------------------------------------------------* | |
803 L04D7 stu 2,s save mod address | |
804 pshs a,y save mod type,entry | |
805 ldu $0B,s U=usr regs (old P$SP) | |
806 stx R$X,u update name ptr | |
807 ldx 7,s set new process desc | |
808 stx <D.Proc | |
809 ldd 5,s set primary module addrss | |
810 std P$PModul,x | |
811 puls a module type | |
812 cmpa #Prgrm+Objct is it program module? | |
813 beq L04FB ..yes | |
814 cmpa #Systm+Objct is it system module? | |
815 beq L04FB ..yes | |
816 | |
817 ldb #E$NEMod 'Non-Executable Module' | |
818 L04F4 leas 2,s drop return | |
819 stb 3,s return err code | |
820 comb set err | |
821 bra L053E restore proc desc & rts. | |
822 | |
823 *------------------------------------------------* | |
824 * Allocate data memory and set child regs: | |
825 | |
826 L04FB ldd #M$Mem offset to mem size | |
827 leay P$DATImg,x image | |
828 ldx P$PModul,x mod address | |
829 os9 F$LDDDXY get mem size | |
830 cmpa R$B,u greater than user request? | |
831 bcc L050E ..yes | |
832 lda R$B,u no, use request | |
833 clrb to page boundary | |
834 L050E os9 F$Mem get U=data memory | |
835 bcs L04F4 ..err | |
836 | |
837 ldx 6,s parent proc desc | |
838 leay P$Stack-R$Size,x | |
839 pshs a,b save mem size | |
840 subd R$Y,u -parm size | |
841 std R$X,y is new parm pointer | |
842 subd #R$Size memsize-reg stack | |
843 std P$SP,x is new stack pointer | |
844 | |
845 ldd R$Y,u get parm size | |
846 std R$D,y D is parm size | |
847 std 6,s return to caller | |
848 puls a,b,x mem and entry | |
849 std R$Y,y Y is end of data mem | |
850 ldd R$U,u parm ptr | |
851 std 6,s return | |
852 lda #Entire CC register is full rti | |
853 sta R$CC,y set cc reg | |
854 clra | |
855 sta R$DP,y DP is 00 | |
856 clrb | |
857 std R$U,y U is data address | |
858 stx R$PC,y PC is module exec address | |
859 | |
860 L053E puls a,b restore proc desc | |
861 std <D.Proc | |
862 puls a,b,x,y,u,pc return. | |
863 | |
864 *------------------------------------------------* | |
865 * F$Exit | |
866 *------------------------------------------------* | |
867 FExit ldx <D.Proc proc desc | |
868 bsr L05A5 close paths & return memory | |
869 ldb R$B,u get exit signal | |
870 stb P$Signal,x and save in proc desc | |
871 leay P$CID-P$SID,x parent id | |
872 bra L0563 go find kids... | |
873 | |
874 *------------------------------------------------* | |
875 L0551 clr P$SID,y clear sibling pointer | |
876 lbsr L0B2E find its proc desc | |
877 clr P$PID,y clear its parent ptr (us) | |
878 lda P$State,y get child's state | |
879 bita #Dead is it dead? | |
880 beq L0563 ..no | |
881 lda P$ID,y else get its id | |
882 lbsr L0386 and destroy its proc desc | |
883 L0563 lda P$SID,y did it have a sibling? | |
884 bne L0551 ..yes,loop | |
885 | |
886 leay ,x kid's proc desc | |
887 ldx #D.WProcQ-P$Queue | |
888 lds <D.SysStk use system stack | |
889 pshs cc save CC | |
890 orcc #IntMasks halt interrupts while queuing | |
891 lda P$PID,y get our parent id | |
892 bne L0584 ..and wake him up | |
893 | |
894 puls cc restore CC | |
895 lda P$ID,y our id | |
896 lbsr L0386 give up our proc desc | |
897 bra L05A2 and start next active process. | |
898 | |
899 *------------------------------------------------* | |
900 * Search For Waiting Parent: | |
901 | |
902 L0580 cmpa P$ID,x is proc desc our parent's? | |
903 beq L0592 ..yes! | |
904 | |
905 L0584 leau ,x U is base desc | |
906 ldx P$Queue,x X is next waiter | |
907 bne L0580 see if parent | |
908 puls cc restore CC | |
909 lda #SysState+Dead set us to system state | |
910 sta P$State,y and mark us as dead | |
911 bra L05A2 so F$Wait will find us; next proc. | |
912 | |
913 * Found Parent (X): | |
914 | |
915 L0592 ldd P$Queue,x take parent out of wait queue | |
916 std P$Queue,u | |
917 puls cc restore CC | |
918 ldu P$SP,x get parents reg stack | |
919 ldu R$U,u | |
920 lbsr L036C get child's death signal to parent | |
921 os9 F$AProc move parent to active queue | |
922 L05A2 os9 F$NProc start next proc in active queue. | |
923 | |
924 *------------------------------------------------* | |
925 * Close Proc I/O Paths & Unlink Mem: | |
926 | |
927 L05A5 pshs u save | |
928 ldb #NumPaths B=up to 16 paths | |
929 leay P$Path,x point to proc desc paths | |
930 L05AC lda ,y+ get path desc# | |
931 beq L05B9 ..skip if not used | |
932 clr -1,y else clr it | |
933 pshs b save cnt | |
934 os9 I$Close close path | |
935 puls b | |
936 L05B9 decb count-1 | |
937 bne L05AC ..loop | |
938 | |
939 clra begin block=00 | |
940 ldb P$PagCnt,x any memory used? | |
941 beq L05CB ..no | |
942 addb #$1F round up mem | |
943 lsrb mem/16 = blocks used | |
944 lsrb | |
945 lsrb | |
946 lsrb | |
947 lsrb | |
948 os9 F$DelImg return mem | |
949 L05CB ldd <D.Proc save current proc | |
950 pshs a,b | |
951 stx <D.Proc set bad proc | |
952 ldu P$PModul,x pgrm ptr | |
953 os9 F$Unlink unlink aborted pgrm | |
954 puls a,b,u | |
955 std <D.Proc reset parent proc | |
956 os9 F$DelTsk release X's task# | |
957 rts . | |
958 | |
959 *------------------------------------------------* | |
960 * F$Mem | |
961 *------------------------------------------------* | |
962 FMem ldx <D.Proc proc | |
963 ldd R$D,u get mem request | |
964 beq L0638 ..return current size request | |
965 addd #$00FF else round up size | |
966 bcc L05EE ..okay if <64K | |
967 ldb #E$MemFul 'Memory Full' | |
968 bra L0629 ..err end | |
969 | |
970 L05EE cmpa P$PagCnt,x same as current? | |
971 beq L0638 ..yes | |
972 pshs a save amt | |
973 bcc L0602 ..go for more mem | |
974 | |
975 deca go for less mem | |
976 ldb #$F4 enuf room for SP? | |
977 cmpd P$SP,x | |
978 bcc L0602 ..yes | |
979 ldb #E$DelSP 'Suicide Attempt' | |
980 bra L0627 | |
981 | |
982 L0602 lda P$PagCnt,x get current size | |
983 adda #$1F round up | |
984 lsra A/16 = block cnt | |
985 lsra | |
986 lsra | |
987 lsra | |
988 lsra | |
989 ldb ,s B=pages wanted | |
990 addb #$1F round up | |
991 bcc L0615 ..ok | |
992 ldb #E$MemFul 'Memory Full' | |
993 bra L0627 | |
994 | |
995 L0615 lsrb B/16 = blocks wanted | |
996 lsrb | |
997 lsrb | |
998 lsrb | |
999 lsrb | |
1000 pshs a save #blocks now | |
1001 subb ,s+ B=# difference | |
1002 beq L0634 ..same | |
1003 bcs L062C ..less | |
1004 os9 F$AllImg else get mem | |
1005 bcc L0634 ..err | |
1006 | |
1007 * Error ends: | |
1008 | |
1009 L0627 leas 1,s | |
1010 L0629 orcc #Carry | |
1011 rts | |
1012 | |
1013 *------------------------------------------------* | |
1014 * Need Less Mem: | |
1015 | |
1016 L062C pshs b save amt less | |
1017 adda ,s+ + amt now | |
1018 negb | |
1019 os9 F$DelImg return mem blocks | |
1020 L0634 puls a get new amt | |
1021 sta P$PagCnt,x set in proc desc | |
1022 | |
1023 * Return Mem Size to user: | |
1024 | |
1025 L0638 lda P$PagCnt,x D=byte count | |
1026 clrb | |
1027 std R$D,u return size | |
1028 std R$Y,u and upper bound | |
1029 rts | |
1030 | |
1031 *------------------------------------------------* | |
1032 * F$Send | |
1033 *------------------------------------------------* | |
1034 FSend ldx <D.Proc proc desc | |
1035 lda R$A,u A=dest proc | |
1036 bne L0652 ..send if <> 00 | |
1037 inca else send to all ('cept zero) | |
1038 L0647 cmpa ,x our proc? | |
1039 beq L064D ..skip if is | |
1040 bsr L0652 else send signal | |
1041 L064D inca ID+1 | |
1042 bne L0647 done 255? | |
1043 clrb yep | |
1044 rts end. | |
1045 | |
1046 *------------------------------------------------* | |
1047 * Send signal to Proc A: | |
1048 | |
1049 L0652 lbsr L0B2E find proc desc | |
1050 pshs cc,a,y,u | |
1051 bcs L066A ..not found | |
1052 tst R$B,u is signal = zero? (Kill) | |
1053 bne L066D ..no | |
1054 ldd P$User,x are we superuser? | |
1055 beq L066D ..yes | |
1056 cmpd P$User,y else same user? | |
1057 beq L066D ..yes | |
1058 ldb #E$IPrcID 'Illegal Proc ID' | |
1059 inc ,s set carry bit | |
1060 L066A lbra L06F4 | |
1061 | |
1062 L066D orcc #IntMasks stop interrupts | |
1063 ldb R$B,u B=signal | |
1064 bne L067B skip if not Kill | |
1065 | |
1066 ldb #E$PrcAbt 'Keyboard Abort' (#2) | |
1067 lda P$State,y | |
1068 ora #Condem condemn process | |
1069 sta P$State,y | |
1070 | |
1071 * Wake Up Dest Process: | |
1072 | |
1073 L067B lda P$State,y | |
1074 anda #^Suspend (F7) drop suspend | |
1075 sta P$State,y state | |
1076 lda P$Signal,y have signal now? | |
1077 beq L068F ..no | |
1078 deca else was it wake? | |
1079 beq L068F ..yes | |
1080 inc ,s set carry | |
1081 ldb #E$USigP 'Signal Error' | |
1082 bra L06F4 | |
1083 | |
1084 L068F stb P$Signal,y save signal | |
1085 ldx #D.SProcQ-P$Queue search sleep queue | |
1086 clra ticks left=0000 | |
1087 clrb | |
1088 | |
1089 L0697 leay ,x Y is base desc | |
1090 ldx P$Queue,x X is next qproc | |
1091 beq L06D3 ..last | |
1092 ldu P$SP,x else get process | |
1093 addd R$X,u add ticks | |
1094 cmpx 2,s same as dest proc desc? | |
1095 bne L0697 ..no, loop | |
1096 | |
1097 pshs a,b save tick count | |
1098 lda P$State,x is process time sleeping? | |
1099 bita #TimSleep | |
1100 beq L06CF ..no it's not | |
1101 | |
1102 ldd ,s get tick count | |
1103 beq L06CF ..bra if none | |
1104 ldd R$X,u get time left | |
1105 pshs a,b save it | |
1106 ldd 2,s get ticks left | |
1107 std R$X,u make it new time left | |
1108 puls a,b tick count | |
1109 ldu P$Queue,x qproc after this one? | |
1110 beq L06CF ..no | |
1111 std ,s | |
1112 lda P$State,u time sleeping? | |
1113 bita #TimSleep | |
1114 beq L06CF ..no its not | |
1115 | |
1116 ldu P$SP,u next proc SP | |
1117 ldd ,s update tick count | |
1118 addd R$X,u | |
1119 std R$X,u | |
1120 | |
1121 L06CF leas 2,s drop | |
1122 bra L06E0 give signal... | |
1123 | |
1124 *------------------------------------------------* | |
1125 L06D3 ldx #D.WProcQ-P$Queue search wait queue | |
1126 L06D6 leay ,x base proc desc | |
1127 ldx P$Queue,x get next in queue | |
1128 beq L06F4 ..end if none | |
1129 cmpx 2,s signal dest proc? | |
1130 bne L06D6 ..no | |
1131 | |
1132 L06E0 ldd P$Queue,x take proc out of queue | |
1133 std P$Queue,y | |
1134 lda P$Signal,x has signal | |
1135 deca other than S$Wake? | |
1136 bne L06F1 ..yes | |
1137 sta P$Signal,x no, clear for wakeup | |
1138 lda ,s restore CC | |
1139 tfr a,cc | |
1140 L06F1 os9 F$AProc insert proc in active queue | |
1141 L06F4 puls cc,a,y,u,pc return. | |
1142 | |
1143 *------------------------------------------------* | |
1144 * F$Icpt | |
1145 *------------------------------------------------* | |
1146 FIcpt ldx <D.Proc proc desc | |
1147 ldd R$X,u set signal vector | |
1148 std P$SigVec,x | |
1149 ldd R$U,u and data area | |
1150 std P$SigDat,x | |
1151 clrb ok | |
1152 rts end. | |
1153 | |
1154 *------------------------------------------------* | |
1155 * F$Sleep | |
1156 *------------------------------------------------* | |
1157 FSleep pshs cc save int masks | |
1158 ldx <D.Proc proc desc | |
1159 orcc #IntMasks stop interrupts here | |
1160 lda P$Signal,x have unprocessed signal? | |
1161 beq L0722 ..no | |
1162 deca yes, was it Wake? | |
1163 bne L0715 ..no | |
1164 sta P$Signal,x yes, ignore it | |
1165 | |
1166 L0715 lda P$STATE,X | |
1167 anda #^SUSPEND DROP SUSPEND | |
1168 sta P$STATE,X | |
1169 | |
1170 L071B puls cc restore CC | |
1171 os9 F$AProc activate immediately | |
1172 bra L0780 | |
1173 | |
1174 * Do the Sleep: | |
1175 | |
1176 L0722 ldd R$X,u sleep forever? | |
1177 beq L076D ..yes | |
1178 subd #$0001 else -1 already | |
1179 std R$X,u save tick cnt | |
1180 | |
1181 beq L071B ..awake if was just 1 | |
1182 pshs x,y save | |
1183 ldx #D.SProcQ-P$Queue | |
1184 | |
1185 L0732 std R$X,u return tick count | |
1186 stx 2,s temp var | |
1187 ldx P$Queue,x X=next queue proc | |
1188 beq L074F ..end of line | |
1189 lda P$State,x is it still | |
1190 bita #TimSleep asleep? | |
1191 beq L074F ..no | |
1192 ldy P$SP,x yes, get its | |
1193 ldd R$X,u X register and | |
1194 subd R$X,y compare to ours | |
1195 bcc L0732 ..try next if we're more | |
1196 | |
1197 nega else negate count | |
1198 negb | |
1199 sbca #$00 | |
1200 std R$X,y and update proc sleep ticks | |
1201 L074F puls x,y queue proc ptrs | |
1202 lda P$State,x set proc as | |
1203 ora #TimSleep tick sleeping | |
1204 sta P$State,x | |
1205 ldd P$Queue,y insert us in queue | |
1206 stx P$Queue,y | |
1207 std P$Queue,x | |
1208 ldx R$X,u get ticks requested | |
1209 bsr L0780 go wait for wakeup | |
1210 | |
1211 stx R$X,u return ticks left | |
1212 ldx <D.Proc | |
1213 lda P$State,x drop sleep flag | |
1214 anda #^TimSleep | |
1215 sta P$State,x | |
1216 puls cc,pc return to caller. | |
1217 | |
1218 *------------------------------------------------* | |
1219 L076D ldx #D.SProcQ-P$Queue start at first asleep | |
1220 | |
1221 L0770 leay ,x Y is base proc | |
1222 ldx P$Queue,x X is next qproc | |
1223 bne L0770 ..not last yet | |
1224 ldx <D.Proc else get our proc | |
1225 clra D=0000 | |
1226 clrb | |
1227 stx P$Queue,y put us at end of queue | |
1228 std P$Queue,x and mark none after us now | |
1229 puls cc restore CC | |
1230 | |
1231 *------------------------------------------------* | |
1232 * Wait for Signal/Wakeup: | |
1233 | |
1234 L0780 pshs x,y,u,pc make vars | |
1235 leax <L079C,pcr point to wakeup code | |
1236 stx 6,s put as rts pcr | |
1237 ldx <D.Proc | |
1238 ldb P$Task,x are we sys proc? | |
1239 cmpb <D.SysTsk | |
1240 beq L0792 ..yes | |
1241 os9 F$DelTsk else release task# | |
1242 L0792 ldd P$SP,x save stack pointer | |
1243 pshs cc,a,b,dp | |
1244 sts P$SP,x and temp SP | |
1245 os9 F$NProc go do next proc. | |
1246 | |
1247 *------------------------------------------------* | |
1248 * Proc Wakes up here: | |
1249 | |
1250 L079C pshs x save tick count | |
1251 ldx <D.Proc | |
1252 std P$SP,x restore real SP | |
1253 clrb ok | |
1254 puls x,pc return from sleep. | |
1255 | |
1256 *------------------------------------------------* | |
1257 * F$SPrior | |
1258 *------------------------------------------------* | |
1259 FSprior lda R$A,u get id | |
1260 lbsr L0B2E find proc desc | |
1261 bcs L07C0 ..err | |
1262 ldx <D.Proc get our user index | |
1263 ldd P$User,x | |
1264 beq L07B7 ..zero is ok | |
1265 cmpd P$User,y same as id? | |
1266 bne L07BD ..no, err | |
1267 L07B7 lda R$B,u get desired priority | |
1268 sta P$Prior,y set it in id | |
1269 clrb ok | |
1270 rts end. | |
1271 | |
1272 L07BD comb | |
1273 ldb #E$IPrcID 'Illegal Process ID' | |
1274 L07C0 rts | |
1275 | |
1276 *------------------------------------------------* | |
1277 * F$ID | |
1278 *------------------------------------------------* | |
1279 FID ldx <D.Proc proc desc | |
1280 lda P$ID,x get id | |
1281 sta R$A,u return it | |
1282 ldd P$User,x and user | |
1283 std R$Y,u index to caller | |
1284 clrb ok | |
1285 rts end. | |
1286 | |
1287 *------------------------------------------------* | |
1288 * F$SSWI | |
1289 *------------------------------------------------* | |
1290 FSSWI ldx <D.Proc proc desc | |
1291 leay P$SWI,x point to SWI vectors | |
1292 ldb R$A,u B=swi to set | |
1293 decb B-1 | |
1294 cmpb #$03 0-2? | |
1295 bcc L07DF ..no, err | |
1296 aslb else index | |
1297 ldx R$X,u get new vector | |
1298 stx b,y and set it | |
1299 rts end. | |
1300 | |
1301 L07DF comb | |
1302 ldb #E$ISWI 'Illegal SWI code' | |
1303 rts | |
1304 | |
1305 *------------------------------------------------* | |
1306 * F$STime | |
1307 *------------------------------------------------* | |
1308 ClockNam fcs "Clock" | |
1309 | |
1310 FSTime ldx R$X,u X=time packet | |
1311 tfr dp,a A=DP | |
1312 ldb #D.Time B=sys time addrss | |
1313 tfr d,u U=sys time location | |
1314 ldy <D.Proc | |
1315 lda P$Task,y A=from tsk# | |
1316 ldb <D.SysTsk B=to (sys) tsk# | |
1317 ldy #$0006 copy over time data | |
1318 os9 F$Move X(A)-->U(B) *Y | |
1319 ldx <D.Proc save user proc | |
1320 pshs x | |
1321 ldx <D.SysPrc make sys for link | |
1322 stx <D.Proc | |
1323 leax ClockNam,pcr link to Clock | |
1324 lbsr SysLink | |
1325 puls x | |
1326 stx <D.Proc restore user proc | |
1327 bcs L0816 ..err end | |
1328 jmp ,y else go do Clock init. | |
1329 | |
1330 L0816 rts | |
1331 | |
1332 *------------------------------------------------* | |
1333 * F$AllBit | |
1334 *------------------------------------------------* | |
1335 FAllBit ldd R$D,u number of first bit | |
1336 ldx R$X,u map address | |
1337 bsr L086E get X=addrss, A=mask | |
1338 ldy <D.Proc proc desc | |
1339 ldb P$Task,y use usr map | |
1340 bra L082C | |
1341 | |
1342 SAllBit ldd R$D,u number of first bit | |
1343 ldx R$X,u map address | |
1344 bsr L086E get X=addrss, A=mask | |
1345 ldb <D.SysTsk use sys map | |
1346 | |
1347 L082C ldy R$Y,u Y=number of bits | |
1348 beq L086C ..none | |
1349 sta ,-s save mask | |
1350 bmi L0847 skip if no bit0 | |
1351 os9 F$LDABX get map byte | |
1352 L0838 ora ,s set bit | |
1353 leay -1,y count-1 | |
1354 beq L0867 ..quik end if last | |
1355 lsr ,s next bit | |
1356 bcc L0838 ..loop if not bit7 | |
1357 | |
1358 os9 F$STABX else store map byte | |
1359 leax 1,x map addrss+1 | |
1360 | |
1361 L0847 lda #$FF now quik set byte at a time | |
1362 bra L0852 | |
1363 | |
1364 *------------------------------------------------* | |
1365 * Byte at a Time: | |
1366 | |
1367 L084B os9 F$STABX store map byte | |
1368 leax 1,x map addrss+1 | |
1369 leay -8,y bit count-8/byte | |
1370 | |
1371 L0852 cmpy #$0008 under 8 bits to go? | |
1372 bhi L084B ..no, continue byte at a time | |
1373 beq L0867 ..exactly one byte left | |
1374 | |
1375 * Last byte: | |
1376 | |
1377 L085A lsra move mask into pos | |
1378 leay -1,y for last byte | |
1379 bne L085A .. | |
1380 | |
1381 coma fix mask | |
1382 sta ,s save it | |
1383 os9 F$LDABX get last map byte | |
1384 ora ,s set last bits | |
1385 L0867 os9 F$STABX update last map byte | |
1386 leas 1,s drop mask | |
1387 L086C clrb okay | |
1388 rts return. | |
1389 | |
1390 *------------------------------------------------* | |
1391 L086E pshs b,y save regs & low order 0-7 | |
1392 lsra | |
1393 rorb D/8 | |
1394 lsra | |
1395 rorb | |
1396 lsra | |
1397 rorb | |
1398 leax d,x X=byte address | |
1399 puls b B=low order | |
1400 leay <L0883,pcr table of A shifted | |
1401 andb #$07 B=bit count | |
1402 lda b,y get mask for A | |
1403 puls y,pc return. | |
1404 | |
1405 *------------------------------------------------* | |
1406 * Mask Table: | |
1407 | |
1408 L0883 fcb $80 | |
1409 fcb $40 | |
1410 fcb $20 | |
1411 fcb $10 | |
1412 fcb $08 | |
1413 fcb $04 | |
1414 fcb $02 | |
1415 fcb $01 | |
1416 | |
1417 *------------------------------------------------* | |
1418 * F$DelBit | |
1419 *------------------------------------------------* | |
1420 FDelBit ldd R$A,u | |
1421 ldx R$X,u | |
1422 bsr L086E | |
1423 ldy <D.Proc | |
1424 ldb P$Task,y | |
1425 bra L08A0 | |
1426 | |
1427 SDelBit ldd R$A,u | |
1428 ldx R$X,u | |
1429 bsr L086E | |
1430 ldb <D.SysTsk | |
1431 | |
1432 L08A0 ldy R$Y,u | |
1433 beq L08E0 | |
1434 coma | |
1435 sta ,-s | |
1436 bpl L08BC | |
1437 os9 F$LDABX | |
1438 L08AD anda ,s | |
1439 leay -1,y | |
1440 beq L08DB | |
1441 asr ,s | |
1442 bcs L08AD | |
1443 os9 F$STABX | |
1444 leax 1,x | |
1445 L08BC clra | |
1446 bra L08C6 | |
1447 | |
1448 *------------------------------------------------* | |
1449 L08BF os9 F$STABX | |
1450 leax 1,x | |
1451 leay -8,y | |
1452 L08C6 cmpy #8 | |
1453 bhi L08BF | |
1454 beq L08DB | |
1455 coma | |
1456 L08CF lsra | |
1457 leay -1,y | |
1458 bne L08CF | |
1459 sta ,s | |
1460 os9 F$LDABX | |
1461 anda ,s | |
1462 L08DB os9 F$STABX | |
1463 leas 1,s | |
1464 L08E0 clrb | |
1465 rts | |
1466 | |
1467 *------------------------------------------------* | |
1468 * F$SchBit | |
1469 *------------------------------------------------* | |
1470 FSchBit ldd R$D,u search start bit # | |
1471 ldx R$X,u map address | |
1472 bsr L086E set byte mask | |
1473 ldy <D.Proc use user map | |
1474 ldb P$Task,y | |
1475 bra L08F8 do it | |
1476 | |
1477 SSchBit ldd R$D,u search start bit # | |
1478 ldx R$X,u map address | |
1479 lbsr L086E set byte mask | |
1480 ldb <D.SysTsk use sys map | |
1481 | |
1482 L08F8 pshs cc,a,b,x,y,u | |
1483 clra D=0000 | |
1484 clrb | |
1485 std 3,s | |
1486 ldy R$D,u | |
1487 sty 7,s | |
1488 bra L0911 | |
1489 | |
1490 *------------------------------------------------* | |
1491 L0906 sty 7,s | |
1492 L0909 lsr 1,s | |
1493 bcc L091C | |
1494 ror 1,s | |
1495 leax 1,x | |
1496 L0911 cmpx R$U,u end of map? | |
1497 bcc L093A ..yes | |
1498 ldb 2,s | |
1499 os9 F$LDABX | |
1500 sta ,s | |
1501 L091C leay 1,y | |
1502 lda ,s | |
1503 anda 1,s | |
1504 bne L0906 | |
1505 | |
1506 tfr y,d | |
1507 subd 7,s | |
1508 cmpd R$Y,u | |
1509 bcc L0943 | |
1510 cmpd 3,s | |
1511 bls L0909 | |
1512 std 3,s | |
1513 ldd 7,s | |
1514 std 5,s | |
1515 bra L0909 | |
1516 | |
1517 L093A ldd 3,s | |
1518 std R$Y,u | |
1519 comb | |
1520 ldd 5,s | |
1521 bra L0945 | |
1522 | |
1523 L0943 ldd 7,s | |
1524 L0945 std R$D,u | |
1525 leas 9,s | |
1526 rts | |
1527 | |
1528 *------------------------------------------------* | |
1529 * F$GPrDsc | |
1530 *------------------------------------------------* | |
1531 FGprDsc ldx <D.Proc proc desc | |
1532 ldb P$Task,x B=dest task# | |
1533 lda R$A,u A=desired ID | |
1534 os9 F$GProcP get B=ptr to proc desc | |
1535 bcs L0962 | |
1536 lda <D.SysTsk A=from tsk# | |
1537 leax ,y X=proc desc | |
1538 ldy #P$Size 512 bytes | |
1539 ldu R$X,u U=dest buffer | |
1540 os9 F$Move X(A)-->U(B) *Y | |
1541 L0962 rts end. | |
1542 | |
1543 *------------------------------------------------* | |
1544 * F$GBlkMp | |
1545 *------------------------------------------------* | |
1546 FGblkMp ldd #$2000 RETURN 8K BLOCK SIZE | |
1547 std R$D,u | |
1548 ldd <D.BlkMap+2 return blk map size | |
1549 subd <D.BlkMap | |
1550 std R$Y,u | |
1551 tfr d,y Y=count | |
1552 lda <D.SysTsk A=from sys | |
1553 ldx <D.Proc | |
1554 ldb P$Task,x B=to user | |
1555 ldx <D.BlkMap X=block map | |
1556 ldu R$X,u U=dest buffer | |
1557 os9 F$Move X(A)-->U(B) *Y | |
1558 rts | |
1559 | |
1560 *------------------------------------------------* | |
1561 * F$GModDr | |
1562 *------------------------------------------------* | |
1563 FGModDr ldd <D.ModDir+2 D=end of moddir | |
1564 subd <D.ModDir -begin | |
1565 tfr d,y Y=size | |
1566 ldd <D.ModEnd D=top of dir stack | |
1567 subd <D.ModDir D=size | |
1568 ldx R$X,u X=dest buffer | |
1569 leax d,x plus size | |
1570 stx R$Y,u return size to user | |
1571 ldx <D.ModDir and moddir | |
1572 stx R$U,u address | |
1573 | |
1574 lda <D.SysTsk A=sys task | |
1575 ldx <D.Proc B=usr task | |
1576 ldb P$Task,x | |
1577 ldx <D.ModDir X=moddir | |
1578 ldu R$X,u U=dest buffer | |
1579 os9 F$Move X(A)-->U(B) *Y | |
1580 rts end. | |
1581 | |
1582 *------------------------------------------------* | |
1583 * F$SUser | |
1584 *------------------------------------------------* | |
1585 FSUser ldx <D.Proc proc desc | |
1586 ldd R$Y,u D=user num | |
1587 std P$User,x set it | |
1588 clrb ok | |
1589 rts end. | |
1590 | |
1591 *------------------------------------------------* | |
1592 * F$CpyMem | |
1593 *------------------------------------------------* | |
1594 FCpyMem ldd R$Y,u byte count | |
1595 beq L0A01 ..skip if none | |
1596 addd R$U,u plus dest buff | |
1597 bcs L0A01 | |
1598 leas -$10,s | |
1599 leay ,s | |
1600 pshs a,b,y save buff end,img ptr | |
1601 ldx <D.Proc | |
1602 ldb P$Task,X | |
1603 pshs b save caller task# | |
1604 leay P$DATImg,x | |
1605 ldx R$D,u X=caller DAT img ptr | |
1606 ldb #8 | |
1607 pshs b,u | |
1608 ldu P$Task,s U=tempdat ptr | |
1609 | |
1610 L09C7 clra D=0000 | |
1611 clrb | |
1612 os9 F$LDDDXY move user DAT image | |
1613 std ,u++ to sys tempDAT img | |
1614 leax 2,x | |
1615 dec ,s | |
1616 bne L09C7 ..loop | |
1617 | |
1618 puls b,u | |
1619 ldx R$X,u X=offset | |
1620 ldu R$U,u U=dest buffer | |
1621 ldy 3,s Y=tmpDAT | |
1622 | |
1623 puls b | |
1624 bra L09E7 | |
1625 | |
1626 N09D6 leax $E000,x | |
1627 leay 2,y | |
1628 | |
1629 *------------------------------------------------* | |
1630 * Copy Loop: | |
1631 | |
1632 L09E7 cmpx #$2000 | |
1633 bcc N09D6 | |
1634 | |
1635 L09EC os9 F$LDAXY get byte | |
1636 leax 1,x | |
1637 exg x,u | |
1638 | |
1639 os9 F$STABX store byte | |
1640 leax 1,x plus one | |
1641 cmpx ,s | |
1642 exg x,u | |
1643 bcs L09E7 | |
1644 leas $14,s | |
1645 | |
1646 L0A01 clrb ok | |
1647 rts end. | |
1648 | |
1649 *------------------------------------------------* | |
1650 * F$UnLoad | |
1651 *------------------------------------------------* | |
1652 FUnload pshs u | |
1653 lda R$A,u A=type | |
1654 ldx <D.Proc proc desc | |
1655 leay P$DATImg,x images ptr | |
1656 ldx R$X,u X=name | |
1657 os9 F$FModul find the module | |
1658 puls y reg stack | |
1659 bcs L0A4F ..err | |
1660 | |
1661 stx R$X,y update name ptr | |
1662 ldx MD$Link,u get module link cnt | |
1663 beq L0A21 ..zero | |
1664 leax -1,x else decrement it | |
1665 stx MD$Link,u | |
1666 bne L0A4E ..skip if still in use | |
1667 | |
1668 L0A21 cmpa #FlMgr system module? | |
1669 bcs L0A4B ..no | |
1670 | |
1671 clra | |
1672 ldx [MD$MPDAT,u] get module block | |
1673 ldy <D.SysDAT check against sys map | |
1674 L0A2B adda #$02 next offset | |
1675 cmpa #DAT.ImSz last? | |
1676 bcc L0A4B ..yes | |
1677 cmpx a,y else found right img? | |
1678 bne L0A2B ..no, loop | |
1679 | |
1680 asla A/8 block# -->address | |
1681 asla | |
1682 asla | |
1683 asla | |
1684 clrb | |
1685 addd MD$MPtr,u point to module | |
1686 tfr d,x | |
1687 os9 F$IODel delete I/O module | |
1688 bcc L0A4B ..ok | |
1689 | |
1690 ldx MD$Link,u else if error, | |
1691 leax 1,x | |
1692 stx MD$Link,u increment link cnt | |
1693 bra L0A4F | |
1694 | |
1695 L0A4B lbsr L01D5 clear moddir entry | |
1696 L0A4E clrb ok | |
1697 L0A4F rts end. | |
1698 | |
1699 *------------------------------------------------* | |
1700 * F$Find64 | |
1701 *------------------------------------------------* | |
1702 FFind64 lda R$A,u get pd block number | |
1703 ldx R$X,u get block address | |
1704 bsr L0A5C find it | |
1705 bcs L0A5B ..err | |
1706 sty R$Y,u return address | |
1707 L0A5B rts end. | |
1708 | |
1709 * Find Path/Process Descriptor: | |
1710 | |
1711 L0A5C pshs a,b save number, make space | |
1712 tsta number=zero? | |
1713 beq L0A70 ..yes,bad | |
1714 clrb else... | |
1715 lsra number/4 | |
1716 rorb (point to block ptr) | |
1717 lsra | |
1718 rorb | |
1719 lda a,x use index to get | |
1720 tfr d,y block address | |
1721 beq L0A70 ..none | |
1722 tst ,y is block in use? | |
1723 bne L0A71 ..yes, okay! | |
1724 L0A70 coma set error | |
1725 L0A71 puls a,b,pc return. | |
1726 | |
1727 *------------------------------------------------* | |
1728 * F$All64 | |
1729 *------------------------------------------------* | |
1730 FAll64 ldx R$X,u get base page | |
1731 bne L0A7F ..okay if have one | |
1732 bsr L0A89 else allocate page | |
1733 bcs L0A88 ..err | |
1734 stx ,x insert first page flag | |
1735 stx R$X,u return base page | |
1736 L0A7F bsr L0A9F get one 64-byte block | |
1737 bcs L0A88 ..err | |
1738 sta R$A,u return block number | |
1739 sty R$Y,u return block address | |
1740 L0A88 rts end. | |
1741 | |
1742 *------------------------------------------------* | |
1743 * Allocate Base Block: | |
1744 | |
1745 L0A89 pshs u save U | |
1746 ldd #$0100 get 256-byte page | |
1747 os9 F$SRqMem | |
1748 leax ,u X=page address | |
1749 puls u | |
1750 bcs L0A9E ..err | |
1751 clra A=00 | |
1752 clrb 256 byte count | |
1753 L0A99 sta d,x clear block | |
1754 incb | |
1755 bne L0A99 | |
1756 L0A9E rts | |
1757 | |
1758 *------------------------------------------------* | |
1759 * Find & Set Block In Use: | |
1760 | |
1761 L0A9F pshs x,u | |
1762 clra | |
1763 L0AA2 pshs a | |
1764 clrb | |
1765 lda a,x | |
1766 beq L0AB4 | |
1767 tfr d,y | |
1768 clra | |
1769 L0AAC tst d,y | |
1770 beq L0AB6 | |
1771 addb #64 | |
1772 bcc L0AAC | |
1773 L0AB4 orcc #Carry | |
1774 L0AB6 leay d,y | |
1775 puls a | |
1776 bcc L0AE1 | |
1777 inca try all pages | |
1778 cmpa #64 until 64th page | |
1779 bcs L0AA2 | |
1780 | |
1781 clra | |
1782 L0AC2 tst a,x | |
1783 beq L0AD0 | |
1784 inca | |
1785 cmpa #64 | |
1786 bcs L0AC2 | |
1787 | |
1788 comb | |
1789 ldb #E$PthFul 'Path Table Full' | |
1790 bra L0AEE | |
1791 | |
1792 *------------------------------------------------* | |
1793 L0AD0 pshs a,x | |
1794 bsr L0A89 | |
1795 bcs L0AF0 | |
1796 leay ,x | |
1797 tfr x,d | |
1798 tfr a,b | |
1799 puls a,x | |
1800 stb a,x | |
1801 clrb | |
1802 | |
1803 * D=Block Address: | |
1804 | |
1805 L0AE1 aslb | |
1806 rola | |
1807 aslb | |
1808 rola | |
1809 | |
1810 ldb #$3F | |
1811 | |
1812 * Clear Block: | |
1813 | |
1814 L0AE7 clr b,y | |
1815 decb | |
1816 bne L0AE7 | |
1817 sta ,y | |
1818 L0AEE puls x,u,pc okay rts. | |
1819 | |
1820 L0AF0 leas 3,s drop vars | |
1821 puls x,u,pc return. | |
1822 | |
1823 *------------------------------------------------* | |
1824 * F$Ret64 | |
1825 *------------------------------------------------* | |
1826 FRet64 lda R$A,u | |
1827 ldx R$X,u | |
1828 pshs a,b,x,y,u | |
1829 clrb | |
1830 tsta | |
1831 beq L0B22 | |
1832 lsra | |
1833 rorb | |
1834 lsra | |
1835 rorb | |
1836 pshs a | |
1837 lda a,x | |
1838 beq L0B20 | |
1839 tfr d,y | |
1840 clr ,y | |
1841 clrb | |
1842 tfr d,u | |
1843 clra | |
1844 L0B10 tst d,u | |
1845 bne L0B20 | |
1846 addb #64 | |
1847 bne L0B10 | |
1848 inca | |
1849 os9 F$SRtMem | |
1850 lda ,s | |
1851 clr a,x | |
1852 L0B20 clr ,s+ | |
1853 L0B22 puls a,b,x,y,u,pc | |
1854 | |
1855 *------------------------------------------------* | |
1856 * F$GProcP | |
1857 *------------------------------------------------* | |
1858 FGProcP lda R$A,u get id | |
1859 bsr L0B2E find proc esc | |
1860 bcs L0B2D ..err | |
1861 sty R$Y,u return pointer | |
1862 L0B2D rts end. | |
1863 | |
1864 *------------------------------------------------* | |
1865 * Find Process Descriptor A, address --> Y: | |
1866 | |
1867 L0B2E pshs a,b,x save id, etc | |
1868 ldb ,s B=id | |
1869 beq L0B40 ..can't be zero | |
1870 ldx <D.PrcDBT proc desc table | |
1871 abx index | |
1872 lda ,x get pointer | |
1873 beq L0B40 ..err if none by that id | |
1874 clrb else make address | |
1875 tfr d,y return in Y | |
1876 puls a,b,x,pc end. | |
1877 | |
1878 L0B40 puls a,b,x | |
1879 comb | |
1880 ldb #E$IPrcId | |
1881 rts | |
1882 | |
1883 *------------------------------------------------* | |
1884 * F$DelImg | |
1885 *------------------------------------------------* | |
1886 FDelImg ldx R$X,u X=proc desc | |
1887 ldd R$D,u A=start, B=count | |
1888 leau P$DATImg,x U=image table | |
1889 asla index first | |
1890 leau a,u point to it | |
1891 clra | |
1892 tfr d,y Y=count | |
1893 pshs x save desc | |
1894 | |
1895 L0B55 ldd 0,u D=block number | |
1896 addd <D.BlkMap plus map begin | |
1897 tfr d,x X=map address | |
1898 lda ,x get marker | |
1899 anda #^RAMinUse release mem | |
1900 sta ,x | |
1901 ldd #DAT.Free flag image | |
1902 std ,u++ as free | |
1903 leay -1,y count-1 | |
1904 bne L0B55 ..loop | |
1905 | |
1906 puls x proc desc | |
1907 lda P$State,x | |
1908 ora #ImgChg flag image change | |
1909 sta P$State,x | |
1910 clrb okay | |
1911 rts end. | |
1912 | |
1913 *------------------------------------------------* | |
1914 * F$MapBlk | |
1915 *------------------------------------------------* | |
1916 FMapBlk lda R$B,u get number of blocks | |
1917 | |
1918 beq L0BAA <NEW> | |
1919 | |
1920 cmpa #DAT.BlCt over 16? (8 ON COCO) | |
1921 bhi L0BAA ..err WAS BCC | |
1922 | |
1923 leas -$10,s | |
1924 ldx R$X,u beginning block# desired | |
1925 leay ,s point to local vars | |
1926 ldb #1 ++BGP | |
1927 L0B82 stx ,y++ put images | |
1928 * leax 1,x desired on | |
1929 abx ++BGP | |
1930 deca the local stack | |
1931 bne L0B82 | |
1932 | |
1933 ldb R$B,u number of blocks | |
1934 ldx <D.Proc point to process's | |
1935 leay P$DATImg,x image map | |
1936 os9 F$FreeHB find contiguous blocks free | |
1937 bcs L0BA6 ..err | |
1938 pshs a,b save begin free#,amt | |
1939 asla first free*16 = mem address | |
1940 asla | |
1941 asla | |
1942 asla | |
1943 asla | |
1944 clrb | |
1945 std R$U,u return addrss of first block | |
1946 puls a,b drop | |
1947 leau ,s point to images wanted | |
1948 os9 F$SetImg map them into callers space | |
1949 L0BA6 leas $10,S | |
1950 rts return. | |
1951 | |
1952 L0BAA comb set err | |
1953 ldb #E$IBA 'Illegal Block Address' | |
1954 rts return. | |
1955 | |
1956 *------------------------------------------------* | |
1957 * F$ClrBlk | |
1958 *------------------------------------------------* | |
1959 FClrBlk ldb R$B,u B=block count | |
1960 beq L0BE9 ..zero | |
1961 ldd R$U,u D=first block addrss | |
1962 tstb | |
1963 bne L0BAA ..must be even page | |
1964 bita #$1F | |
1965 bne L0BAA ..and on 4k boundary | |
1966 ldx <D.Proc get proc desc | |
1967 lda P$SP,x and it's SP | |
1968 anda #$E0 | |
1969 suba R$U,u -mem | |
1970 bcs L0BCE ..err if sp mem | |
1971 lsra address -> block# | |
1972 lsra | |
1973 lsra | |
1974 lsra | |
1975 lsra | |
1976 cmpa R$B,u end of mem? | |
1977 bcs L0BAA ..error | |
1978 L0BCE lda P$State,x mark image change | |
1979 ora #ImgChg | |
1980 sta P$State,x | |
1981 lda R$U,u get mem ptr | |
1982 lsra index as image ptr | |
1983 lsra | |
1984 lsra | |
1985 lsra | |
1986 leay P$DATImg,x proc images | |
1987 leay a,y point to block image | |
1988 ldb R$B,u get block count | |
1989 ldx #DAT.Free free flag | |
1990 L0BE4 stx ,y++ clear image(s) | |
1991 decb | |
1992 bne L0BE4 | |
1993 L0BE9 clrb okay | |
1994 rts end. | |
1995 | |
1996 *------------------------------------------------* | |
1997 * F$DelRam | |
1998 *------------------------------------------------* | |
1999 FDelRam ldb R$B,u get block count | |
2000 beq L0C11 ..zero | |
2001 ldd <D.BlkMap+2 end of block map | |
2002 subd <D.BlkMap D=max block# | |
2003 subd R$X,u cmp to desired block# | |
2004 bls L0C11 ..bad number | |
2005 | |
2006 tsta close to end of map? | |
2007 bne L0C00 ..no | |
2008 cmpb R$B,u block cnt easy? | |
2009 bcc L0C00 ..no | |
2010 stb R$B,u save block cnt lsb | |
2011 L0C00 ldx <D.BlkMap point to block map | |
2012 ldd R$X,u get start block# | |
2013 leax d,x index into map | |
2014 ldb R$B,u get count | |
2015 L0C08 lda ,x get block flag | |
2016 anda #^RAMinUse release for use | |
2017 sta ,x+ | |
2018 decb count-1 | |
2019 bne L0C08 ..'til done. | |
2020 | |
2021 L0C11 clrb okay | |
2022 rts end. | |
2023 | |
2024 *------------------------------------------------* | |
2025 * F$GCMDir | |
2026 *------------------------------------------------* | |
2027 FGCMDir ldx <D.ModDir module dir ptr | |
2028 bra L0C1D ..do garbage collect | |
2029 | |
2030 L0C17 ldu ,x get DAT entry | |
2031 beq L0C23 ..empty | |
2032 leax MD$ESize,x else point to next | |
2033 | |
2034 L0C1D cmpx <D.ModEnd end of dir? | |
2035 bne L0C17 ..no, loop | |
2036 bra L0C4B yes, do it | |
2037 | |
2038 L0C23 tfr x,y Y=entry | |
2039 bra L0C2B ..do it | |
2040 | |
2041 L0C27 ldu ,y get DAT entry | |
2042 bne L0C34 ..in use | |
2043 L0C2B leay MD$ESize,y point to next entry | |
2044 cmpy <D.ModEnd last? | |
2045 bne L0C27 ..no | |
2046 bra L0C49 do it. | |
2047 | |
2048 * Move Entries Up: | |
2049 | |
2050 L0C34 ldu ,y++ 2 | |
2051 stu ,x++ | |
2052 ldu ,y++ 4 | |
2053 stu ,x++ | |
2054 ldu ,y++ 6 | |
2055 stu ,x++ | |
2056 ldu ,y++ 8 bytes | |
2057 stu ,x++ | |
2058 cmpy <D.ModEnd end of dir? | |
2059 bne L0C27 ..no | |
2060 | |
2061 L0C49 stx <D.ModEnd set new dir end | |
2062 L0C4B ldx <D.ModDir+2 end of dir | |
2063 bra L0C53 | |
2064 | |
2065 L0C4F ldu ,x get entry | |
2066 beq L0C5B ..not used | |
2067 L0C53 leax -2,x back up in entry | |
2068 cmpx <D.ModDAT end? | |
2069 bne L0C4F ..no | |
2070 bra L0C93 else end if all done. | |
2071 | |
2072 L0C5B ldu -2,x | |
2073 bne L0C53 | |
2074 tfr x,y | |
2075 bra L0C67 | |
2076 | |
2077 L0C63 ldu ,y get entry | |
2078 bne L0C70 | |
2079 L0C67 leay -2,y | |
2080 L0C69 cmpy <D.ModDAT | |
2081 bcc L0C63 | |
2082 bra L0C81 | |
2083 | |
2084 L0C70 leay 2,y go back | |
2085 ldu ,y do last entry | |
2086 stu ,x | |
2087 L0C76 ldu ,--y | |
2088 stu ,--x | |
2089 beq L0C87 | |
2090 cmpy <D.ModDAT end? | |
2091 bne L0C76 ..no | |
2092 L0C81 | |
2093 stx <D.ModDAT set new end | |
2094 bsr L0C95 change images | |
2095 bra L0C93 end. | |
2096 | |
2097 L0C87 leay 2,y | |
2098 leax 2,x | |
2099 bsr L0C95 | |
2100 leay -4,y | |
2101 leax -2,x | |
2102 bra L0C69 | |
2103 L0C93 clrb okay | |
2104 rts end. | |
2105 | |
2106 *------------------------------------------------* | |
2107 * Update Module Dir Image Ptrs: | |
2108 | |
2109 L0C95 pshs u | |
2110 ldu <D.ModDir module dir start | |
2111 bra L0CA4 | |
2112 | |
2113 L0C9B cmpy MD$MPDAT,u same DAT ptrs? | |
2114 bne L0CA2 ..no, skip | |
2115 stx MD$MPDAT,u else update ptr | |
2116 L0CA2 leau MD$ESize,u next entry | |
2117 L0CA4 cmpu <D.ModEnd last entry? | |
2118 bne L0C9B ..no | |
2119 puls u,pc yes, return. | |
2120 | |
2121 emod | |
2122 endmod equ * | |
2123 end | |
2124 |