Re: Buffers in Assembly (NASM)



On Sat, 19 Jul 2008 11:53:43 GMT, NoSpam@xxxxxxxxxxx (Bob Masta)
wrote:

On Sat, 19 Jul 2008 02:18:33 -0500, ArarghMail807NOSPAM
<spamtrap@xxxxxxxxxx> wrote:

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.

Not familiar with NASM or its linker, but with MASM32 and the standard
PE linker the BSS section (called .data? in MASM) is automatically
zeroed. In this section you can not specify a fill value, you must
use ? or MASM reports an error, but when the app runs that section is
always filled with zeros.

I did a little digging, and found that for DOS type programs written
in C, the bss is cleared by the C runtime startup code. For windows
programs written in C, there is no clearing routine in the startup
code, so windows must have zeroed it out. (Assumption, not necessarily
a good one!)

So for an assembler program, for DOS, you have to clear bss yourself,
for windows, you can try assuming that windows did it.

But I clear it out, anyway. It's only done once at the beginning of
the program, and that way I *KNOW* it has been zeroed out.
--
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.

.



Relevant Pages

  • Re: Buffers in Assembly (NASM)
    ... 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, ... Not familiar with NASM or its linker, but with MASM32 and the standard ... Scope, Spectrum, Spectrogram, Sound Level Meter ...
    (comp.lang.asm.x86)
  • Re: Buffers in Assembly (NASM)
    ... 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, ... Not familiar with NASM or its linker, but with MASM32 and the standard ... PE linker the BSS section (called .data? ...
    (comp.lang.asm.x86)
  • Re: Blueflops ate my X
    ... .bss section. ... dos, or of a "dos box" started raising an "illegal operation" in ... I suspect that this may affect some of the "asmutils" utilities, ... But marking the ".text" section "write" (which the friendly Nasm manual says works) still segfaults! ...
    (alt.lang.asm)
  • Re: NASM pe segfaults, RosAsm dissassembles the PE and runs it without segfaulting
    ... I see no .BSS sections in the PEView. ... Now suddenly I have a segfault in rosasm as well, ... The funny thing is that this particular code sequence executes correctly in the NASM version. ...
    (alt.lang.asm)
  • Re: Buffers in Assembly (NASM)
    ... it doesn't know what ".bss" means. ... In other formats, this will ... Nasm to zero it. ... I'm basically just creating a buffer to write strings for functions ...
    (comp.lang.asm.x86)