It's also that x86 segments memory into code, data, and stack, so you can have

        .code
                OR EAX, EAX // produces less binary than CMP EAX, 0; JE X
                JZ X
                JMP Y
        Y:
        .data
                str DB 'less\z'
        .code
                // ...
        .data
        .code
        .stack
        .code
        .data

On Feb 11, 2008, at 2:41 PM, Jon Snader wrote:

On Mon, Feb 11, 2008 at 11:43:08AM -0500, erik quanstrom wrote:
I've always thought variables and such went at the bottom... or
is that just m68k asm?

you can put them anywhere.  there's no typechecking in assembly
and the linker doesn't care.


When I started programming (so long ago that assembly and Fortran
were basically the only games in town) we always put the data at
the end--it just seemed fitting somehow.  Later, the best
practice became to put them at the beginning on the grounds that
the data wouldn't move as changes where made to the program; in
those days, all manner of strange things happened like programs
that knew where the data portion of other programs lived.  If
nothing else, it made the (very crude) dumps easier to work with.

jcs

Reply via email to