assembly language help

Reply

Join Date: May 2009
Posts: 4
Reputation: unregistered is an unknown quantity at this point 
Solved Threads: 0
unregistered unregistered is offline Offline
Newbie Poster

assembly language help

 
0
  #1
May 3rd, 2009
  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?
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 39
Reputation: sysop_fb is an unknown quantity at this point 
Solved Threads: 5
sysop_fb sysop_fb is offline Offline
Light Poster

Re: assembly language help

 
0
  #2
May 3rd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 4
Reputation: unregistered is an unknown quantity at this point 
Solved Threads: 0
unregistered unregistered is offline Offline
Newbie Poster

Re: assembly language help

 
0
  #3
May 4th, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 39
Reputation: sysop_fb is an unknown quantity at this point 
Solved Threads: 5
sysop_fb sysop_fb is offline Offline
Light Poster

Re: assembly language help

 
0
  #4
May 4th, 2009
Originally Posted by unregistered View Post
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.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 4
Reputation: unregistered is an unknown quantity at this point 
Solved Threads: 0
unregistered unregistered is offline Offline
Newbie Poster

Re: assembly language help

 
0
  #5
May 4th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 39
Reputation: sysop_fb is an unknown quantity at this point 
Solved Threads: 5
sysop_fb sysop_fb is offline Offline
Light Poster

Re: assembly language help

 
0
  #6
May 4th, 2009
Originally Posted by unregistered View Post
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'.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 4
Reputation: unregistered is an unknown quantity at this point 
Solved Threads: 0
unregistered unregistered is offline Offline
Newbie Poster

Re: assembly language help

 
0
  #7
May 4th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC