flat assembler
Message board for the users of flat assembler.

flat assembler > DOS > Question about using segments for dynamic memory allocation

Author
Thread Post new topic Reply to topic
adroit



Joined: 21 Feb 2010
Posts: 252
Can someone explain how segments work? I want to be able to create a malloc() function, where 4 segments will be allocated as the heap. What I want to know is, for COM files, what are the default values for the code segment and data segment? And are the remaining segments uncommitted for the programmer's use?

_________________
meshnix
Post 13 Oct 2013, 16:16
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1388
Location: Toronto, Canada
When COM program is loaded - the default values for all segments decided by DOS or whatever is emulating DOS (DOSBOX, NTVDM, etc).

If you take the DS register and add 1000h to it - segments starting at that adress are free to use for COM program.
However, you have to plan the allocation in your code and you cannot use DOS services to allocate memory.
Post 13 Oct 2013, 16:48
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.