clearing heap in djgpp
clearing heap in djgpp
hi all, i know thers some built in varables that define heap position but i can't seem to figure out how to zero out the heap???
Re:clearing heap in djgpp
Do you mean the .bss Section or the actual heap? The compiler shouldn't have any concept of what the heap even is, you will have to manually zero the memory once it's been allocated.
To zero the .bss, you'll need to modify your linker script so that you have something like:Then in your opening Assembly code you would have something like:You can also optimize by dividing by 4 in the link script (bsslength = (bssend - bss) / 4;) and then using stosd to set 4bytes at a time instead of 1.
@Solar: My GAS (Cygwin i686-pc-elf 2.16.1) won't assemble STOSD, it accepts STOSB and STOSW but won't take STOSD [.code32], what have I done now?
To zero the .bss, you'll need to modify your linker script so that you have something like:
Code: Select all
{
bss = .;
*(.bss)
bssend = .;
}
bsslength = bssend - bss;
Code: Select all
.extern bss
.extern bsslength
mov $bss, %edi /* I don't have my code or compiler on hand but this should be close enough to figure out */
mov $bsslength, %ecx
xor %eax, %eax
rep
stosb
@Solar: My GAS (Cygwin i686-pc-elf 2.16.1) won't assemble STOSD, it accepts STOSB and STOSW but won't take STOSD [.code32], what have I done now?
Re:clearing heap in djgpp
thx that helped, stosd doesn't work for me ether??? stosw works so i used it
Re:clearing heap in djgpp
Don't you mean 'STOSL' instead?AR wrote:@Solar: My GAS (Cygwin i686-pc-elf 2.16.1) won't assemble STOSD, it accepts STOSB and STOSW but won't take STOSD [.code32], what have I done now?
mkr
Re:clearing heap in djgpp
That helps, bloody obvious solution again, comes from knowing both Intel and GAS Syntax assembly and being reasonably fluent in both.