| | |
assembly language help
![]() |
•
•
Join Date: May 2009
Posts: 4
Reputation:
Solved Threads: 0
Assembly Syntax (Toggle Plain Text)
GNU nano 2.0.7 File: hello.asm section .data hello: db 'Hello World!', 10 helloLen: equ $-hello section .bss section .text global _start _start: mov eax, 4 mov ebx, 1 mov ecx, hello mov edx, helloLen int 80h mov eax, 1 mov ebx, 0 int 80h
why does this compile in nasm but not in gas? using linux btw
and when i add rubbish inside the code the code compiles just fine as well, what gives?
•
•
Join Date: Apr 2009
Posts: 39
Reputation:
Solved Threads: 5
Because they're different syntaxs and not even a little bit different...
NASM syntax is based on intel syntax while gas syntax is based on AT&T syntax.
If you write a simple hello world program in C and compile it using
gcc -S mycode.c
It'll leave you with a mycode.s that you can read and see what AT&T asm syntax looks like. You should of learned the difference when you were learning assembly as any good teacher/book should make you familiar with the concepts enough to show you different syntaxs so you can see that even if you don't know the syntax then you can still read the code.
NASM syntax is based on intel syntax while gas syntax is based on AT&T syntax.
If you write a simple hello world program in C and compile it using
gcc -S mycode.c
It'll leave you with a mycode.s that you can read and see what AT&T asm syntax looks like. You should of learned the difference when you were learning assembly as any good teacher/book should make you familiar with the concepts enough to show you different syntaxs so you can see that even if you don't know the syntax then you can still read the code.
•
•
Join Date: Apr 2009
Posts: 39
Reputation:
Solved Threads: 5
•
•
•
•
yea but isnt there an option in gas to enable it to read intel syntax now? .intel_syntax or something like that, how do I enable it?

Alternatively there are programs out there to convert your code back and forth.
•
•
Join Date: Apr 2009
Posts: 39
Reputation:
Solved Threads: 5
•
•
•
•
i c, but intel syntax is more portable am i correct to say that? since i read that many more assemblers support intel than at&t
another question is why is it that nasm compiles my code just fine even when i add rubbish inside like random "fsfgssdgvsdgsdf"?
i exprected errors and such
That's why when you're learning ASM you're not learning the 'language' per se but you're learning how things work. mnemonics and the differences between tasm/masm/nasm/gas and whatever else are easy to pick up on if you know how things work.
And it depends where you're throwing this 'rubbish' as nasm could potentially just optimize out pieces of 'code' that it finds 'useless'.
![]() |
Similar Threads
- Assembly Language Resources (Assembly)
- Where can i learn about assembly language (Assembly)
- OOPic Microcontroller - Assembly Language Programming (Assembly)
- Using Assembly Language in .NET? (ASP.NET)
- Introduction to 80 x 86 Assembly Language and Computer Architecture - no CD - help (Assembly)
- machine/assembly language, syntax error (C++)
Other Threads in the Assembly Forum
- Previous Thread: Please Correct My Code ( Small Model )
- Next Thread: Conditional assambly doesn't work! :(
| Thread Tools | Search this Thread |





