allocate memory in dos .exe
spamtrap_at_crayne.org
Date: 03/29/05
- Next message: hutch--: "Re: BIOS Assembly"
- Previous message: Benjamin David Lunt: "multiple posts"
- Next in thread: IIJIMA Hiromitsu : "Re: allocate memory in dos .exe"
- Reply: IIJIMA Hiromitsu : "Re: allocate memory in dos .exe"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 29 Mar 2005 04:08:17 +0000 (UTC)
I am writing an MS-DOS .exe program.
1. If I allocate memory using int 21 fct 48, after resizing the
program's memory (with int 21 fct 4a), need I free the block with int
21 fct 49 before exiting the program? If I do not, is there a danger of
a memory leak?
2. I prefer to calculate the size of the running program on the fly
rather than changing the .exe header. On entry to my program, is SS -
DS (or ES) + size of stack (in paragraphs) going to be a reliable way
to do this? I'm using old versions of MASM and LINK.
.model small
.stack
.code
;free memory above program so we can alloc some
mov bx,ss
mov ax,ds
sub bx,ax ; ss - ds = para psp + code + data
add bx,40h ; = para stack (400h)
mov ah,4ah ;resize block es = psp bx = size in para
int 21h ;dos fct
;cf set = error
;ask for 64K
mov ah,48h ;allocate block bx = size in para
mov bx,1000h ;ask for 64K
int 21h ;dos fct
;ax = segment of block
;cf set = error
.... more code
mov ax,4C00h ; terminate program
int 21h
.data
.... some data
end
Looking at my .exe under debug, first comes the PSP, then code, then
data, then the stack.
3. From the point of view of an ASM programmer (in DOS) where do memory
leaks come from if the program does not TSR?
- Next message: hutch--: "Re: BIOS Assembly"
- Previous message: Benjamin David Lunt: "multiple posts"
- Next in thread: IIJIMA Hiromitsu : "Re: allocate memory in dos .exe"
- Reply: IIJIMA Hiromitsu : "Re: allocate memory in dos .exe"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|