From 01d88ae2460b23750966d550e51e6e9a1943a618 Mon Sep 17 00:00:00 2001 From: "Evgeny Grechnikov (Diamond)" Date: Thu, 20 Sep 2007 17:07:33 +0000 Subject: [PATCH] fasm: dynamic memory allocation git-svn-id: svn://kolibrios.org@635 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/develop/fasm/trunk/fasm.asm | 8 ++++++-- programs/develop/fasm/trunk/system.inc | 24 +++++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/programs/develop/fasm/trunk/fasm.asm b/programs/develop/fasm/trunk/fasm.asm index 1de571123e..ae9137cd22 100644 --- a/programs/develop/fasm/trunk/fasm.asm +++ b/programs/develop/fasm/trunk/fasm.asm @@ -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: diff --git a/programs/develop/fasm/trunk/system.inc b/programs/develop/fasm/trunk/system.inc index 9c0f0ba002..17b6199c90 100644 --- a/programs/develop/fasm/trunk/system.inc +++ b/programs/develop/fasm/trunk/system.inc @@ -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