views:

223

answers:

3

I'm looking for some good code examples of dynamic memory allocation using an assembly language under Linux and using system calls, not malloc and friends.

What are some of the simplest but effective ways to do this?

On Intel 386+ computers.

+1  A: 

Use the brk system call to change the end of your data segment.

Take a look here: http://www.linuxjournal.com/article/6390 to understand what you're doing.

WhirlWind
Thanks. I started reading that article. It's awesome.
mudge
+2  A: 

brk(2). And take a look at ELF.

Nikolai N Fetissov
What is the "data segment" the man page refers to?
mudge
See ELF link above.
Nikolai N Fetissov
A: 

An alternative to brk() is to use the mmap() system call, with MAP_ANONYMOUS | MAP_PRIVATE.

caf