annotate level2/modules/kernel/ffreehb.asm @ 1258:1aae5bde55a0

Fixed bugs as per Rodney's suggestion
author boisy
date Sun, 17 Aug 2003 19:30:01 +0000
parents 1e1377bd37c1
children 436443bd9b8e
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
1258
1aae5bde55a0 Fixed bugs as per Rodney's suggestion
boisy
parents: 1250
diff changeset
17 * Move to next block - SHOULD OPTIMIZE WITH W
1145
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???)
1258
1aae5bde55a0 Fixed bugs as per Rodney's suggestion
boisy
parents: 1250
diff changeset
45 * Rodney says: "it's called via os9p1 syscall vector in line 393"
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
46 FSFreeLB ldb R$B,u Get block count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
47 ldy R$Y,u Get ptr to DAT Image
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
48 bsr L0A4B Go find block #'s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
49 bra L0A2C Do error checking & exit (since never called,
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
50 * not worried about speed)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
51
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
52 L0A4B lda #$FF Value to start loop at block 0
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
53 pshs x,d Preserve X,flag & block count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
54 * lda #$01 # to add to go to next block (positive here)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
55 nega -(-1)=+1
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
56 subb #9 Drop block count to -8 to -1 (invert within 8)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
57 negb Negate so it is a positive # again
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
58 bra L0A56 Go into main find loop
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
59
1258
1aae5bde55a0 Fixed bugs as per Rodney's suggestion
boisy
parents: 1250
diff changeset
60 * F$FreeLB entry point
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
61 FFreeLB ldd R$D,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
62 ldx R$X,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
63 ldu R$U,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
64 L0A8C pshs d,x,y,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
65 leay <P$DATImg,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
66 lsla
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
67 leay a,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
68 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
69 clra
1258
1aae5bde55a0 Fixed bugs as per Rodney's suggestion
boisy
parents: 1250
diff changeset
70 * Rodney claims this is a bug...
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
71 lslb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
72 tfr d,w
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
73 tfm u+,y+
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
74 oim #ImgChg,P$State,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
75 ELSE
1250
1e1377bd37c1 Several fixes as per Rodney H's suggestions.
boisy
parents: 1239
diff changeset
76 lslb
1e1377bd37c1 Several fixes as per Rodney H's suggestions.
boisy
parents: 1239
diff changeset
77 L0ALoop lda ,u+
1e1377bd37c1 Several fixes as per Rodney H's suggestions.
boisy
parents: 1239
diff changeset
78 sta ,y+
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
79 decb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
80 bne L0ALoop
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
81 lda P$State,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
82 ora #ImgChg
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
83 sta P$State,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
84 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
85 clrb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
86 puls d,x,y,u,pc