Mercurial > hg > Members > kono > nitros9-code
annotate level2/modules/kernel/fmem.asm @ 3195:6eb2edad80d8
L2: Introduce symbol KrnBlk to define kernel block number
This is the block number that the kernel is loaded into. This is
platform-specific, a function of the behaviour of the platform MMU/DAT.
CRCs are unaffected by this change.
author | Neal Crook <foofoobedoo@gmail.com> |
---|---|
date | Thu, 01 Jun 2017 22:13:49 +0100 |
parents | 039ddb7c8ad7 |
children |
rev | line source |
---|---|
1145 | 1 ************************************************** |
2 * System Call: F$Mem | |
3 * | |
4 * Function: Resize data memory area | |
5 * | |
6 * Input: D = Desired memory area (in bytes) | |
7 * | |
8 * Output: Y = Address of new memory area upper bound | |
9 * D = New memory area size in bytes | |
10 * | |
11 * Error: CC = C bit set; B = error code | |
12 * | |
13 FMem ldx <D.Proc get current process pointer | |
14 ldd R$D,u get requested memory size | |
15 beq L0638 he wants current size, return it | |
16 addd #$00FF round up to nearest page | |
17 bcc L05EE no overflow, skip ahead | |
18 ldb #E$MemFul get mem full error | |
19 rts return | |
20 | |
21 L05EE cmpa P$PagCnt,x match current page count? | |
22 beq L0638 yes, return it | |
23 pshs a save page count | |
24 bhs L0602 he's requesting more, skip ahead | |
25 deca subtract a page | |
26 ldb #($100-R$Size) get size of default stack - R$Size | |
27 cmpd P$SP,x shrinking it into stack? | |
28 bhs L0602 no, skip ahead | |
29 ldb #E$DelSP get error code (223) | |
30 bra L0627 return error | |
31 L0602 lda P$PagCnt,x get page count | |
32 adda #$1F round it up | |
33 lsra divide by 32 to get block count | |
34 lsra | |
35 lsra | |
36 lsra | |
37 lsra | |
38 ldb ,s | |
39 addb #$1F | |
40 bcc L0615 still have room, skip ahead | |
41 ldb #E$MemFul | |
42 bra L0627 | |
43 L0615 lsrb divide by 32 to get block count | |
44 lsrb | |
45 lsrb | |
46 lsrb | |
47 lsrb | |
48 IFNE H6309 | |
49 subr a,b same count? | |
50 ELSE | |
1239 | 51 pshs a |
52 subb ,s+ | |
1145 | 53 ENDC |
54 beq L0634 yes, save it | |
55 bcs L062C overflow, delete the ram we just got | |
56 os9 F$AllImg allocate the image in DAT | |
57 bcc L0634 no error, skip ahead | |
58 L0627 leas 1,s purge stack | |
59 L0629 orcc #Carry set carry for error | |
60 rts return | |
61 | |
62 L062C equ * | |
63 IFNE H6309 | |
64 addr b,a | |
65 ELSE | |
1239 | 66 pshs b |
67 adda ,s+ | |
1145 | 68 ENDC |
3123
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
69 negb |
039ddb7c8ad7
l2 kernel: Remove tabs and trailing whitespace, align comments
Neal Crook <foofoobedoo@gmail.com>
parents:
1239
diff
changeset
|
70 os9 F$DelImg |
1145 | 71 L0634 puls a restore requested page count |
72 sta P$PagCnt,x save it into process descriptor | |
73 L0638 lda P$PagCnt,x get page count | |
74 clrb clear LSB | |
75 std R$D,u save mem byte count to caller | |
76 std R$Y,u save memory upper limit to caller | |
77 rts return |