Mercurial > hg > Members > kono > nitros9-code
annotate level2/modules/kernel/ffreehb.asm @ 3295:6b7a7b233925 default tip
makefile: Allow PORTS with level1/2 mix
https://sourceforge.net/p/nitros9/feature-requests/10/
author | Tormod Volden <debian.tormod@gmail.com> |
---|---|
date | Tue, 19 Apr 2022 18:12:17 +0200 |
parents | 039ddb7c8ad7 |
children |
rev | line source |
---|---|
1345 | 1 ************************************************** |
2 * System Call: F$FreeHB | |
3 * | |
4 * Function: Get free high block | |
5 * | |
6 * Called from F$MapBlk and from SS.MpGPB) | |
7 * | |
8 * Input: B = Block count | |
9 * Y = DAT image pointer | |
10 * | |
11 * Output: A = High block number | |
12 * | |
13 * Error: CC = C bit set; B = error code | |
14 * | |
1145 | 15 FFreeHB ldb R$B,u Get # blocks requested |
16 ldy R$Y,u Get DAT Img ptr | |
17 bsr L0A31 Go find free blocks in high part of DAT | |
18 L0A2C bcs L0A30 Couldn't find any, exit with error | |
19 sta R$A,u Save starting block # | |
20 L0A30 rts Return | |
21 | |
22 L0A31 tfr b,a Copy # blocks requested to A | |
23 * This gets called directly from within F$Link | |
24 L0A33 suba #$09 Invert within 8 | |
3123
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1387
diff
changeset
|
25 nega |
1145 | 26 pshs x,d Save X, block # & block count |
27 ldd #$FFFF -1' | |
28 L0A56 pshs d | |
29 | |
1258 | 30 * Move to next block - SHOULD OPTIMIZE WITH W |
1145 | 31 L0A58 clra # free blocks found so far=0 |
32 ldb 2,s Get block # | |
33 addb ,s Add block increment (point to next block) | |
34 stb 2,s Save new block # to check | |
35 cmpb 1,s Same as block count? | |
36 bne L0A75 No, skip ahead | |
37 ldb #E$MemFul Preset error for 207 (Process mem full) | |
38 cmpy <D.SysDAT Is it the system process? | |
39 bne L0A6C No, exit with error 207 | |
1387 | 40 ldb #E$NoRAM System Mem full (237) |
1145 | 41 L0A6C stb 3,s Save error code |
42 comb set carry | |
43 bra L0A82 Exit with error | |
44 | |
45 L0A71 tfr a,b Copy # blocks to B | |
46 addb 2,s Add to current start block # | |
47 L0A75 lslb Multiply block # by 2 | |
48 ldx b,y Get DAT marker for that block | |
49 cmpx #DAT.Free Empty block? | |
50 bne L0A58 No, move to next block | |
51 inca Bump up # blocks free counter | |
52 cmpa 3,s Have we got enough? | |
53 bne L0A71 No, keep looking | |
54 L0A82 leas 2,s Eat temporary stack | |
55 puls d,x,pc Restore reg, error code & return | |
56 | |
1345 | 57 |
58 * WHERE DOES THIS EVER GET CALLED FROM??? | |
59 * Rodney says: "It's called via os9p1 syscall vector in line 393" | |
1145 | 60 FSFreeLB ldb R$B,u Get block count |
61 ldy R$Y,u Get ptr to DAT Image | |
62 bsr L0A4B Go find block #'s | |
63 bra L0A2C Do error checking & exit (since never called, | |
3123
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1387
diff
changeset
|
64 * not worried about speed) |
1145 | 65 |
66 L0A4B lda #$FF Value to start loop at block 0 | |
67 pshs x,d Preserve X,flag & block count | |
68 * lda #$01 # to add to go to next block (positive here) | |
3123
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1387
diff
changeset
|
69 nega -(-1)=+1 |
1145 | 70 subb #9 Drop block count to -8 to -1 (invert within 8) |
71 negb Negate so it is a positive # again | |
72 bra L0A56 Go into main find loop | |
73 | |
1345 | 74 |
75 ************************************************** | |
76 * System Call: F$FreeLB | |
77 * | |
78 * Function: Get free low block | |
79 * | |
80 * Input: B = Block count | |
81 * Y = DAT image pointer | |
82 * | |
83 * Output: A = Low block number | |
84 * | |
85 * Error: CC = C bit set; B = error code | |
86 * | |
1145 | 87 FFreeLB ldd R$D,u |
88 ldx R$X,u | |
89 ldu R$U,u | |
90 L0A8C pshs d,x,y,u | |
91 leay <P$DATImg,x | |
3123
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1387
diff
changeset
|
92 lsla |
1145 | 93 leay a,y |
94 IFNE H6309 | |
95 clra | |
96 lslb | |
97 tfr d,w | |
98 tfm u+,y+ | |
99 oim #ImgChg,P$State,x | |
100 ELSE | |
1250 | 101 lslb |
102 L0ALoop lda ,u+ | |
103 sta ,y+ | |
1145 | 104 decb |
105 bne L0ALoop | |
106 lda P$State,x | |
107 ora #ImgChg | |
108 sta P$State,x | |
109 ENDC | |
3123
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1387
diff
changeset
|
110 clrb |
1145 | 111 puls d,x,y,u,pc |