gas

Frequently used directives

  • .byte, .2byte, .4byte, .8byte to define a N byte value

    .byte 0xaa
    .2byte 0xaabb
    .2byte 0xaa, 0xbb
    .4byte 0xaabbccdd
    .8byte 0xaabbccdd11223344
    
  • .ascii to define an ascii string

    .ascii "foo"   ; allocates 3 bytes
    
  • .asciz to define an ascii string with '\0' terminator

    .asciz "foo"   ; allocates 4 bytes (str + \0)
    
  • .macro to define assembler macros. Arguments are accessed with the \arg syntax.

    .macro defstr name str
    \name:
        .ascii "\str"
    \name\()_len:
        .8byte . - \name
    .endm
    
    ; use as
    defstr foo, "foobar"
    

    Use \() to concatenate macro argument and literal.

  • GNU Assembler

  • GNU Assembler Directives

  • GNU Assembler x86_64 dependent features