Re: Buffers in Assembly (NASM)
- From: ArarghMail807NOSPAM <spamtrap@xxxxxxxxxx>
- Date: Sat, 19 Jul 2008 02:18:33 -0500
On Fri, 18 Jul 2008 19:34:08 -0700 (PDT), "bwaichu@xxxxxxxxx"
<spamtrap@xxxxxxxxxx> wrote:
I'm trying to better understand data structures in assembly. I know I
can create a zero filled buffer in the bss section in NASM with this:
The bss section is by definition not initialized by the program, so
you have to clear it yourself.
buffer: times 64 db 0This should get an error in the bss section.
And I know I can create a buffer on the stack like this:Which does what I show below.
sub esp, 64
mov ebx, esp ;save the start point of the buffer
But how do I zero out the buffer on the stack? In C, I would just do
something like:
char buffer[64] = {0};
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
--
ArarghMail807 at [drop the 'http://www.' from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html
To reply by email, remove the extra stuff from the reply address.
.
- Follow-Ups:
- Re: Buffers in Assembly (NASM)
- From: bwaichu@xxxxxxxxx
- Re: Buffers in Assembly (NASM)
- From: Bob Masta
- Re: Buffers in Assembly (NASM)
- References:
- Buffers in Assembly (NASM)
- From: bwaichu@xxxxxxxxx
- Buffers in Assembly (NASM)
- Prev by Date: Re: Buffers in Assembly (NASM)
- Next by Date: Re: 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
|