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
|
|
51 pshs b
|
|
52 suba ,s+
|
|
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
|
|
66 pshs a
|
|
67 addb ,s+
|
|
68 ENDC
|
|
69 negb
|
|
70 os9 F$DelImg
|
|
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
|