fasm: dynamic memory allocation
git-svn-id: svn://kolibrios.org@635 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
51662272ac
commit
01d88ae246
@ -27,8 +27,8 @@ use32
|
||||
dd 0x01 ; header version
|
||||
dd START ; program start
|
||||
dd program_end ; program image size
|
||||
dd APP_MEMORY ; required amount of memory
|
||||
dd 0xDFFF0 ; stack
|
||||
dd stacktop ; required amount of memory
|
||||
dd stacktop ; stack
|
||||
dd params,0x0 ; parameters,icon
|
||||
|
||||
include 'lang.inc'
|
||||
@ -593,3 +593,7 @@ max_handles = 8
|
||||
fileinfos rb (4+20+MAX_PATH)*max_handles
|
||||
fileinfos_end:
|
||||
pinfo process_information
|
||||
|
||||
align 1000h
|
||||
rb 1000h
|
||||
stacktop:
|
||||
|
@ -58,15 +58,29 @@ filepos dd 0x0
|
||||
; ~3/8 - additional memory
|
||||
; ~5/8 - main memory
|
||||
init_memory:
|
||||
mov [memory_start],0x100000
|
||||
mov [memory_end],0x100000+(APP_MEMORY-0x100000)/8*5
|
||||
mov [additional_memory],0x100000+(APP_MEMORY-0x100000)/8*5
|
||||
mov [additional_memory_end],APP_MEMORY
|
||||
mcall 18, 16
|
||||
cmp eax, 0xFFFFFFFF shr 9
|
||||
jbe @f
|
||||
mov eax, 0xFFFFFFFF shr 9
|
||||
@@:
|
||||
shl eax, 9
|
||||
lea ecx, [eax+stacktop]
|
||||
mcall 64, 1
|
||||
mov [memory_start], stacktop
|
||||
mov [additional_memory_end], ecx
|
||||
sub ecx, stacktop
|
||||
shr ecx, 3
|
||||
lea ecx, [ecx*5+stacktop]
|
||||
mov [memory_end],ecx
|
||||
mov [additional_memory],ecx
|
||||
ret
|
||||
|
||||
exit_program:
|
||||
cmp [_mode],NORMAL_MODE
|
||||
je still
|
||||
jne @f
|
||||
mcall 64, 1, stacktop
|
||||
jmp still
|
||||
@@:
|
||||
or eax,-1
|
||||
mcall
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user