annotate level2/modules/kernel/fallbit.asm @ 1904:fd159d660df5

Changes for cobber
author afra
date Thu, 03 Nov 2005 01:37:41 +0000
parents bc14d533f4c9
children 039ddb7c8ad7
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 **************************************************
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
2 * System Call: F$AllBit
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
3 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
4 * Function: Sets bits in an allocation bitmap
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
5 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
6 * Input: X = Address of allocation bitmap
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
7 * D = Number of first bit to set
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
8 * Y = Bit count (number of bits to set)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
9 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
10 * Output: None
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
11 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
12 * Error: CC = C bit set; B = error code
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
13 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
14 FAllBit ldd R$D,u get bit # to start with
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
15 ldx R$X,u get address of allocation bit map
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
16 bsr CalcBit calculate byte & position & get first bit mask
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
17 IFGT Level-1
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
18 ldy <D.Proc get current task #
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
19 ldb P$Task,y get task number
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
20 bra DoAllBit go do it
1145
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 * F$AllBit (System State)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
23 FSAllBit ldd R$D,u get bit # to start with
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
24 ldx R$X,u get address of allocation bit map
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
25 bsr CalcBit calculate byte & pos & get first bit mask
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
26 ldb <D.SysTsk Get system task #
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
27 ENDC
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
28
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
29 * Main bit setting loop
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
30 DoAllBit equ *
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
31 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
32 ldw R$Y,u get # bits to set
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
33 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
34 ldy R$Y,u get # bits to set
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
35 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
36 beq BitEx nothing to set, return
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
37 sta ,-s preserve current mask
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
38 bmi SkpBit If high bit set, skip ahead
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
39 IFGT Level-1
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
40 os9 F$LDABX go get original value from bit map
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
41 ELSE
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
42 lda ,x
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
43 ENDC
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
44 NxtBitLp ora ,s OR it with the current mask
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
45 IFNE H6309
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
46 decw dec the bit counter
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
47 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
48 leay -1,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
49 ENDC
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
50 beq BitStEx done, go put the byte back into the task's map
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
51 lsr ,s shift out the lowest bit of original
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
52 bcc NxtBitLp if it is a 0, do next bit
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
53 IFGT Level-1
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
54 os9 F$STABX if it was a 1 (which means whole byte done),
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
55 ELSE
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
56 sta ,x
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
57 ENDC
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
58 leax 1,x store finished byte and bump ptr
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
59 SkpBit lda #$FF preload a finished byte
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
60 bra SkpBit2 skip ahead
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
61
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
62 StFulByt equ *
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
63 IFGT Level-1
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
64 os9 F$STABX store full byte
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
65 ELSE
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
66 sta ,x
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
67 ENDC
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
68 leax 1,x bump ptr up 1
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
69 IFNE H6309
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
70 subw #8 bump counter down by 8
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
71 SkpBit2 cmpw #8 is there at least 8 more (a full byte) to do?
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
72 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
73 leay -8,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
74 SkpBit2 cmpy #$0008
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
75 ENDC
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
76 bhi StFulByt more than 1, go do current
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
77 beq BitStEx exactly 1 byte left, do final store & exit
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
78
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
79 * Last byte: Not a full byte left loop
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
80 L085A lsra bump out least sig. bit
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
81 IFNE H6309
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
82 decw dec the bit counter
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
83 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
84 leay -1,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
85 ENDC
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
86 bne L085A keep going until last one is shifted out
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
87 coma invert byte to get proper result
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
88 sta ,s preserve a sec
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
89 IFGT Level-1
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
90 os9 F$LDABX get byte for original map
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
91 ELSE
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
92 lda ,x
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
93 ENDC
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
94 ora ,s merge with new mask
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
95 BitStEx equ *
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
96 IFGT Level-1
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
97 os9 F$STABX store finished byte into task
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
98 ELSE
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
99 sta ,x
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
100 ENDC
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
101 leas 1,s eat the working copy of the mask
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
102 BitEx clrb no error & return
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
103 rts
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
104
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
105 * Calculate address of first byte we want, and which bit in that byte, from
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
106 * a bit allocation map given the address of the map & the bit # we want to
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
107 * point to
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
108 * Entry: D=Bit #
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
109 * X=Ptr to bit mask table
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
110 * Exit: A=Mask to point to bit # within byte we are starting on
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
111 * X=Ptr in allocation map to first byte we are starting on
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
112 CalcBit pshs b,y preserve registers
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
113 IFNE H6309
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
114 lsrd divide bit # by 8 to calculate byte # to start
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
115 lsrd allocating at
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
116 lsrd
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
117 addr d,x offset that far into the map
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
118 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
119 lsra
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
120 rorb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
121 lsra
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
122 rorb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
123 lsra
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
124 rorb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
125 leax d,x
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
126 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
127 puls b restore bit position LSB
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
128 leay <MaskTbl,pc point to mask table
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
129 andb #7 round it down to nearest bit
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
130 lda b,y get bit mask
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
131 puls y,pc restore & return
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
132
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
133 * Bit position table (NOTE that bit #'s are done by left to right)
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
134 MaskTbl fcb $80,$40,$20,$10,$08,$04,$02,$01
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
135
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
136
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
137 **************************************************
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
138 * System Call: F$DelBit
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
139 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
140 * Function: Clears bits in an allocation bitmap
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
141 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
142 * Input: X = Address of allocation bitmap
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
143 * D = Number of first bit to clear
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
144 * Y = Bit count (number of bits to clear)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
145 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
146 * Output: None
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
147 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
148 * Error: CC = C bit set; B = error code
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
149 *
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
150 FDelBit ldd R$D,u get bit # to start with
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
151 ldx R$X,u get addr. of bit allocation map
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
152 bsr CalcBit point to starting bit
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
153 IFGT Level-1
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
154 ldy <D.Proc get current Task #
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
155 ldb P$Task,y get task #
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
156 bra DoDelBit do rest of 0 bits
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
157
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
158 * F$DelBit entry point for system state
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
159 FSDelBit ldd R$D,u get bit # to start with
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
160 ldx R$X,u get addr. of bit allocation map
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
161 bsr CalcBit point to starting bit
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
162 ldb <D.SysTsk get system task #
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
163 ENDC
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
164
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
165 DoDelBit equ *
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
166 IFNE H6309
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
167 ldw R$Y,u get # bits to clear
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
168 ELSE
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
169 ldy R$Y,u get # bits to clear
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
170 ENDC
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
171 beq L08E0 none, return
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
172 coma invert current bit mask
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
173 sta ,-s preserve on stack
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
174 bpl L08BC if high bit clear, skip ahead
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
175 IFGT Level-1
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
176 os9 F$LDABX go get byte from user's map
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
177 ELSE
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
178 lda ,x
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
179 ENDC
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
180 L08AD anda ,s AND it with current mask
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
181 IFNE H6309
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
182 decw dec the bits left counter
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
183 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
184 leay -1,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
185 ENDC
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
186 beq BitDone done, store finished byte back in task's map
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
187 asr ,s shift out lowest bit, leaving highest alone
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
188 bcs L08AD if it is a 1, do next bit
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
189 IFGT Level-1
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
190 os9 F$STABX if it was a 0 (which means whole byte done),
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
191 ELSE
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
192 sta ,x
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
193 ENDC
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
194 leax 1,x store finished byte & inc. ptr
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
195 L08BC clra preload a cleared byte
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
196 bra ChkFull skip ahead
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
197 L08BF equ *
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
198 IFGT Level-1
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
199 os9 F$STABX store full byte
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
200 ELSE
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
201 sta ,x
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
202 ENDC
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
203 leax 1,x bump ptr up by 1
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
204 IFNE H6309
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
205 subw #8 dec bits left counter by 8
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
206 ChkFull cmpw #8 at least 1 full byte left?
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
207 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
208 leay -8,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
209 ChkFull cmpy #8
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
210 ENDC
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
211 bhi L08BF yes, do a whole byte in 1 shot
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
212 beq BitDone exactly 1, store byte & exit
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
213 coma < full byte left, invert bits
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
214 L08CF lsra shift out rightmost bit
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
215 IFNE H6309
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
216 decw dec bits left counter
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
217 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
218 leay -1,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
219 ENDC
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
220 bne L08CF keep doing till done
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
221 sta ,s save finished mask
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
222 IFGT Level-1
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
223 os9 F$LDABX get original byte from task
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
224 ELSE
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
225 lda ,x
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
226 ENDC
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
227 anda ,s merge cleared bits with it
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
228 BitDone equ *
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
229 IFGT Level-1
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
230 os9 F$STABX store finished byte into task
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
231 ELSE
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
232 sta ,x
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
233 ENDC
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
234 leas 1,s eat working copy of mask
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
235 L08E0 clrb eat error & return
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
236 rts
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
237
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
238
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
239 **************************************************
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
240 * System Call: F$SchBit
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
241 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
242 * Function: Search bitmap for a free area
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
243 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
244 * Input: X = Address of allocation bitmap
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
245 * D = Starting bit number
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
246 * Y = Bit count (free bit block size)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
247 * U = Address of end of allocation bitmap
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
248 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
249 * Output: D = Beginning bit number
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
250 * Y = Bit count
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
251 *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
252 * Error: CC = C bit set; B = error code
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
253 *
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
254 FSchBit ldd R$D,u get start bit #
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
255 ldx R$X,u get addr. of allocation bit map
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
256 bsr CalcBit point to starting bit
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
257 IFGT Level-1
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
258 ldy <D.Proc get task #
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
259 ldb P$Task,y
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
260 bra DoSchBit skip ahead
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
261
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
262 * F$SchBit entry point for system
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
263 FSSchBit ldd R$D,u get start bit #
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
264 ldx R$X,u get addr. of allocation bit map
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
265 lbsr CalcBit point to starting bit
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
266 ldb <D.SysTsk get task #
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
267 * Stack: 0,s : byte we are working on (from original map)
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
268 * 1,s : Mask of which bit in current byte to start on
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
269 * 2,s : Task number the allocation bit map is in
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
270 * 3,s : Largest block found so far
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
271 * 5,s : Starting bit # of requested (or closest) size found
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
272 * 7,s : Starting bit # of current block being checked (2 bytes) (NOW IN Y)
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
273 ENDC
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
274 DoSchBit equ *
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
275 IFNE H6309
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
276 pshs cc,d,x,y preserve task # & bit mask & reserve stack space
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
277 clrd faster than 2 memory clears
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
278 ELSE
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
279 pshs cc,d,x,y,u preserve task # & bit mask & reserve stack space
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
280 clra
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
281 clrb
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
282 ENDC
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
283 std 3,s preserve it
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
284 IFNE H6309
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
285 ldw R$D,u get start bit #
1388
bc14d533f4c9 Fixed misplaced space.
boisy
parents: 1387
diff changeset
286 tfr w,y save as current block starting bit #
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
287 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
288 ldy R$D,u
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
289 sty 7,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
290 ENDC
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
291 bra Skipper skip ahead
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
292
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
293 * New start point for search at current location
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
294 RstSrch equ *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
295 IFNE H6309
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
296 tfr w,y preserve current block bit # start
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
297 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
298 sty 7,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
299 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
300 * Move to next bit position, and to next byte if current byte is done
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
301 MoveBit lsr 1,s move to next bit position
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
302 bcc CheckBit if not the last one, check it
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
303 ror 1,s move bit position marker to 1st bit again
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
304 leax 1,x move byte ptr (in map) to next byte
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
305
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
306 * Check if we are finished allocation map
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
307 Skipper cmpx R$U,u done entire map?
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
308 bhs BadNews yes, couldn't fit in 1 block, notify caller
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
309 ldb 2,s get task number
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
310 IFGT Level-1
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
311 os9 F$LDABX get byte from bit allocation map
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
312 ELSE
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
313 lda ,x
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
314 ENDC
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
315 sta ,s preserve in scratch area
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
316
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
317 * Main checking
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
318 CheckBit equ *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
319 IFNE H6309
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
320 incw increment current bit #
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
321 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
322 leay 1,y
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
323 ENDC
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
324 lda ,s get current byte
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
325 anda 1,s mask out all but current bit position
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
326 bne RstSrch if bit not free, restart search from next bit
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
327 IFNE H6309
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
328 tfr w,d dup current bit # into D
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
329 subr y,d calculate size we have free so far
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
330 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
331 tfr y,d
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
332 subd 7,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
333 ENDC
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
334 cmpd R$Y,u as big as user requested?
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
335 bhs WereDone yes, we are done
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
336 cmpd $03,s as big as the largest one we have found so far?
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
337 bls MoveBit no, move to next bit and keep going
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
338 std $03,s it is the largest, save current size
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
339 IFNE H6309
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
340 sty $05,s save as start bit # of largest block found so far
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
341 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
342 ldd 7,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
343 std 5,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
344 ENDC
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
345 bra MoveBit move to next bit and keep going
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
346
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
347 * Couldn't find requested size block; tell user where the closest was found
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
348 * and how big it was
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
349 BadNews ldd $03,s get size of largest block we found
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
350 std R$Y,u put into callers Y register
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
351 comb set carry to indicate we couldn't get full size
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
352 ldd 5,s get starting bit # of largest block we found
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
353 bra BadSkip skip ahead
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
354 * Found one, tell user where it is
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
355 WereDone equ *
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
356 IFNE H6309
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
357 tfr y,d get start bit # of the block we found
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
358 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
359 ldd 7,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
360 ENDC
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
361 BadSkip std R$D,u put starting bit # of block into callers D register
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
362 IFNE H6309
1387
1451bc7ef0b9 Updates source comments
boisy
parents: 1239
diff changeset
363 leas $07,s eat our temporary stack area & return
1145
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
364 ELSE
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
365 leas $09,s
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
366 ENDC
ca83286ded5b Start of new OS-9 L2 Kernel
boisy
parents:
diff changeset
367 rts