using malloc in c, I need to cast the return value. shall I handle it in assembly as well?
how about brk? what should be done before calling it in assembly?
How can I use these
functions in assembly? 1.malloc 2. brk?
You don't need to cast, as in assembly theren't any types basically (not quite true, but you know).
You simply need to follow the calling conventions of your architecture. So for intel architectures, it should be something like:
// Save Caller-saved register
push reg1;
push reg2;
....
...
// Pass argument
push $512 // need array of 512 bytes
// Call
call malloc
// Save Value: Address is in eax
mov %eax, dest
// Rescue Caller-saved Registers
...
pop reg2
pop reg1
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment