annotate level2/modules/kernel/ffreehb.asm @ 1250:1e1377bd37c1

Several fixes as per Rodney H's suggestions.
author boisy
date Sat, 16 Aug 2003 22:43:12 +0000
parents 90bad6d8388c
children 1aae5bde55a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
1 * F$FreeHB entry point (Called from F$MapBlk - called from SS.MpGPB)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
2 FFreeHB ldb R$B,u Get # blocks requested
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
3 ldy R$Y,u Get DAT Img ptr
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
4 bsr L0A31 Go find free blocks in high part of DAT
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
5 L0A2C bcs L0A30 Couldn't find any, exit with error
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
6 sta R$A,u Save starting block #
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
7 L0A30 rts Return
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
8
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
9 L0A31 tfr b,a Copy # blocks requested to A
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
10 * This gets called directly from within F$Link
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
11 L0A33 suba #$09 Invert within 8
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
12 nega
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
13 pshs x,d Save X, block # & block count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
14 ldd #$FFFF -1'
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
15 L0A56 pshs d
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
16
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
17 * Move to next block - SHOULD OPTOMIZE WITH W
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
18 L0A58 clra # free blocks found so far=0
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
19 ldb 2,s Get block #
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
20 addb ,s Add block increment (point to next block)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
21 stb 2,s Save new block # to check
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
22 cmpb 1,s Same as block count?
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
23 bne L0A75 No, skip ahead
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
24 ldb #E$MemFul Preset error for 207 (Process mem full)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
25 cmpy <D.SysDAT Is it the system process?
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
26 bne L0A6C No, exit with error 207
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
27 ldb #E$NoRam System Mem full (237)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
28 L0A6C stb 3,s Save error code
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
29 comb set carry
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
30 bra L0A82 Exit with error
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
31
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
32 L0A71 tfr a,b Copy # blocks to B
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
33 addb 2,s Add to current start block #
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
34 L0A75 lslb Multiply block # by 2
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
35 ldx b,y Get DAT marker for that block
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
36 cmpx #DAT.Free Empty block?
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
37 bne L0A58 No, move to next block
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
38 inca Bump up # blocks free counter
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
39 cmpa 3,s Have we got enough?
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
40 bne L0A71 No, keep looking
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
41 L0A82 leas 2,s Eat temporary stack
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
42 puls d,x,pc Restore reg, error code & return
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
43
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
44 * F$FreeLB entry point (WHERE DOES THIS EVER GET CALLED FROM???)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
45 FSFreeLB ldb R$B,u Get block count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
46 ldy R$Y,u Get ptr to DAT Image
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
47 bsr L0A4B Go find block #'s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
48 bra L0A2C Do error checking & exit (since never called,
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
49 * not worried about speed)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
50
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
51 L0A4B lda #$FF Value to start loop at block 0
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
52 pshs x,d Preserve X,flag & block count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
53 * lda #$01 # to add to go to next block (positive here)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
54 nega -(-1)=+1
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
55 subb #9 Drop block count to -8 to -1 (invert within 8)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
56 negb Negate so it is a positive # again
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
57 bra L0A56 Go into main find loop
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
58
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
59 * F$FreLB entry point
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
60 FFreeLB ldd R$D,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
61 ldx R$X,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
62 ldu R$U,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
63 L0A8C pshs d,x,y,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
64 leay <P$DATImg,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
65 lsla
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
66 leay a,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
67 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
68 clra
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
69 lslb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
70 tfr d,w
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
71 tfm u+,y+
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
72 oim #ImgChg,P$State,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
73 ELSE
1250
1e1377bd37c1 Several fixes as per Rodney H's suggestions.
boisy
parents: 1239
diff changeset
74 lslb
1e1377bd37c1 Several fixes as per Rodney H's suggestions.
boisy
parents: 1239
diff changeset
75 L0ALoop lda ,u+
1e1377bd37c1 Several fixes as per Rodney H's suggestions.
boisy
parents: 1239
diff changeset
76 sta ,y+
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
77 decb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
78 bne L0ALoop
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
79 lda P$State,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
80 ora #ImgChg
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
81 sta P$State,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
82 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
83 clrb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
84 puls d,x,y,u,pc