Re: how to align instructions?




"Herbert Kleebauer" <klee@xxxxxxxxx> wrote in message
news:47BBF2F0.F58F0A6@xxxxxxxxxxxx
Dirk Wolfgang Glomp wrote:

Alignment is usually done with an assembler directive such as:

ALIGN 8, db 0 ; NASM syntax for mod 8, pad with 0

.p2align 3, 0 ; GAS AT&T syntax for mod 8, pad with 0

org START + ((($-START)/8)*8)+8

I don't think it works if you only change the current location counter
without outputting appropriate bytes to the binary file. And what is
((($-START)/8)*8)+8 supposed to do? Is START >$ or <$ ? For START=$
you get 8?

You meant: "you get START+8?" For C, he'd be computing the next multiple of
8 above the value of START. That assumes the value of START is below $,
that the assembler supports multiple ORG's (MASM only?, not for NASM...),
and /8 is an integer divide or truncates the division. Any other problems?


RP

.



Relevant Pages

  • Re: how to align instructions?
    ... Dirk Wolfgang Glomp wrote: ... I don't think it works if you only change the current location counter ... without outputting appropriate bytes to the binary file. ...
    (alt.lang.asm)
  • Re: how to align instructions?
    ... without outputting appropriate bytes to the binary file. ... If I want to round the current location counter to the next multiple of 8, ...
    (alt.lang.asm)
  • Re: how to align instructions?
    ... I don't think it works if you only change the current location counter ... without outputting appropriate bytes to the binary file. ... align a destination for a jmp/call, when the few bytes before those ...
    (alt.lang.asm)