gas & nasm syntaxes

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Adek336

gas & nasm syntaxes

Post by Adek336 »

I know that

db 0x12 -> .byte 0x12

How can I translate dw 0x1234 and dd 0x12345678 to gas syntax?

anyways, which do you reckon better: as or nasm?

Cheers,
Adrian.
VE3MTM

RE:gas & nasm syntaxes

Post by VE3MTM »

dw => .word
dd => .dword

Thus,
dw 0x1234 => .word 0x1234
dd 0x12345678 => .dword 0x12345678

As for which is better, that's totally a matter of choice. NASM seems to be the most popular, probably because the syntax is simpler, but you should be familiar with both (GCC uses as's syntax for inline assembly, for example). You'll also find that most code examples use NASM syntax
mikeleany

RE:gas & nasm syntaxes

Post by mikeleany »

dw 0x1234 -> .short 0x1234 OR .word 0x1234
dd 0x12345678 -> .long 0x12345678 OR .int 0x12345678

Most people will tell you that nasm is better and it's what I prefer, but gcc uses gas (of course) for its inline asm. So you won't really be able to get away from it completely if you use gcc.
Post Reply