943,917 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 579
  • Assembly RSS
May 3rd, 2009
0

assembly language help

Expand Post »
Assembly Syntax (Toggle Plain Text)
  1. GNU nano 2.0.7 File: hello.asm
  2.  
  3. section .data
  4. hello: db 'Hello World!', 10
  5. helloLen: equ $-hello
  6.  
  7. section .bss
  8.  
  9. section .text
  10. global _start
  11.  
  12. _start:
  13. mov eax, 4
  14. mov ebx, 1
  15. mov ecx, hello
  16. mov edx, helloLen
  17.  
  18. int 80h
  19.  
  20. mov eax, 1
  21. mov ebx, 0
  22. 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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
unregistered is offline Offline
4 posts
since May 2009
May 3rd, 2009
0

Re: assembly language help

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.
Reputation Points: 57
Solved Threads: 5
Light Poster
sysop_fb is offline Offline
42 posts
since Apr 2009
May 4th, 2009
0

Re: assembly language help

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
unregistered is offline Offline
4 posts
since May 2009
May 4th, 2009
0

Re: assembly language help

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?
Not that I know of but you could check the man pages. I'm about 4 months out of date
Alternatively there are programs out there to convert your code back and forth.
Reputation Points: 57
Solved Threads: 5
Light Poster
sysop_fb is offline Offline
42 posts
since Apr 2009
May 4th, 2009
0

Re: assembly language help

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
unregistered is offline Offline
4 posts
since May 2009
May 4th, 2009
0

Re: assembly language help

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
It depends, on unix systems and code from people who've used unix for eons(better to say in the unix world?) you'll find a lot of AT&T syntax. As well if you do inline asm in C you'll be doing AT&T. GDB also while letting you do lines of asm code directly only recognizes AT&T.
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'.
Reputation Points: 57
Solved Threads: 5
Light Poster
sysop_fb is offline Offline
42 posts
since Apr 2009
May 4th, 2009
0

Re: assembly language help

can intel syntax be inlined into c code too?

btw, which is better to pick up to learn about computer security, understanding exploits like buffer overflow, etc?

and thanks for the input so far
Last edited by unregistered; May 4th, 2009 at 3:12 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
unregistered is offline Offline
4 posts
since May 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Please Correct My Code ( Small Model )
Next Thread in Assembly Forum Timeline: Conditional assambly doesn't work! :(





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC