1345
|
1 **************************************************
|
|
2 * System Call: F$AllRAM
|
|
3 *
|
|
4 * Function: Allocate RAM blocks
|
|
5 *
|
|
6 * Input: B = Desired block count
|
|
7 *
|
|
8 * Output: D = Beginning RAM block number
|
|
9 *
|
|
10 * Error: CC = C bit set; B = error code
|
|
11 *
|
1145
|
12 FAllRam ldb R$B,u Get # blocks requested
|
|
13 pshs b,x,y Save regs
|
|
14 ldx <D.BlkMap Get ptr to start of block map
|
|
15 L0974 leay ,x Point Y to current block
|
|
16 ldb ,s Get # blocks requested
|
|
17 L0978 cmpx <D.BlkMap+2 Hit end of map yet?
|
|
18 bhs L0995 Yes, exit with No RAM error
|
|
19 lda ,x+ Get block marker
|
|
20 bne L0974 Already used, start over with next block up
|
|
21 decb Dec # blocks still needed
|
|
22 bne L0978 Still more, keep checking
|
|
23 * Entry: Y=ptr to start of memory found
|
|
24 * Note: Due to fact that block map always starts @ $200 (up to $2FF), we
|
|
25 * don't need to calc A
|
|
26 L0983 tfr y,d Copy start of requested block mem ptr to D (B)
|
|
27 lda ,s Get # blocks requested
|
|
28 stb ,s Save start block #
|
|
29 L098D inc ,y+ Flag blocks as used
|
|
30 deca (for all blocks allocated)
|
|
31 bne L098D Do until done
|
|
32 puls b Get start block #
|
|
33 clra (allow for D as per original calls)
|
|
34 std R$D,u Save for caller
|
|
35 puls x,y,pc Restore regs & return
|
|
36
|
|
37 L0995 comb Exit with No RAM error
|
|
38 ldb #E$NoRam
|
|
39 stb ,s
|
|
40 puls b,x,y,pc
|
|
41
|
1345
|
42
|
|
43 **************************************************
|
|
44 * System Call: F$AlHRAM
|
|
45 *
|
|
46 * Function: Allocate RAM blocks from top of RAM
|
|
47 *
|
|
48 * Input: B = Desired block count
|
|
49 *
|
|
50 * Output: D = Beginning RAM block number
|
|
51 *
|
|
52 * Error: CC = C bit set; B = error code
|
|
53 *
|
1145
|
54 FAlHRam ldb R$B,u Get # blocks to allocate
|
|
55 pshs b,x,y Preserve regs
|
|
56 ldx <D.BlkMap+2 Get ptr to end of block map
|
|
57 L09A9 ldb ,s Get # blocks requested
|
|
58 L09AB cmpx <D.BlkMap Are we at beginning of RAM yet?
|
|
59 bls L0995 Yes, exit with No RAM error
|
|
60 lda ,-x Get RAM block marker
|
|
61 bne L09A9 If not free, start checking next one down
|
|
62 decb Free block, dec # blocks left to find count
|
|
63 bne L09AB Still more needed, keep checking
|
|
64 tfr x,y Found enough contigous blocks, move ptr to Y
|
|
65 bra L0983 Go mark blocks as used, & return info to caller
|
|
66
|