annotate level2/modules/kernel/ffreehb.asm @ 1624:bb75784a1ec5

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