Re: Buffers in Assembly (NASM)
- From: "bwaichu@xxxxxxxxx" <spamtrap@xxxxxxxxxx>
- Date: Sat, 19 Jul 2008 11:16:14 -0700 (PDT)
On Jul 19, 1:18 am, ArarghMail807NOSPAM <spamt...@xxxxxxxxxx> wrote:
But how do I zero out the buffer on the stack? In C, I would just do
something like:
char buffer[64] = {0};
Which does what I show below.
What's the equivalent in assembly using NASM?
This will work for either the stack, or bss: (baring typos)
xor al,al
mov ecx,64
lea edi,buffer ; may need [] ?
rep stosb
OR:
xor eax,eax
mov ecx,16
lea edi,buffer ; may need [] ?
rep stosd
That works well. I just did this:
sub esp, 64
mov dword edi, esp ;store the location of the beginning of the buffer
in edi
xor eax, eax ; make sure al is zero for the call to stosb
mov dword ecx, 64 ; set counter to 64
rep stosb ; repeat stosb 64 times -- this could be done faster with
stosd 16?
Does stosb move up the stack by default or do I need to explicitly
specify the direction with cld?
Thanks,
Brian
.
- Follow-Ups:
- Re: Buffers in Assembly (NASM)
- From: ArarghMail807NOSPAM
- Re: Buffers in Assembly (NASM)
- References:
- Buffers in Assembly (NASM)
- From: bwaichu@xxxxxxxxx
- Re: Buffers in Assembly (NASM)
- From: ArarghMail807NOSPAM
- Buffers in Assembly (NASM)
- Prev by Date: Re: Buffers in Assembly (NASM)
- Next by Date: Re: [Clax86list] Atomic operations in 32 and 64 bit platforms
- Previous by thread: Re: Buffers in Assembly (NASM)
- Next by thread: Re: Buffers in Assembly (NASM)
- Index(es):
Relevant Pages
|