NASM help

This is a discussion on NASM help within the Tech Board forums, part of the Community Boards category; So I wanted to dive into Linux Nasm. I am running a 64 bit system. From the google results I ...

  1. #1
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302

    NASM help

    So I wanted to dive into Linux Nasm. I am running a 64 bit system. From the google results I found, all the tutorials i see on Linux Nasm are 32bit. All of the 64bit Linux tutorials use AT&T syntax. Which I DO NOT want to use! Can I use Nasm on a 64bit Linux machine? I mean I installed it through the terminal but I assume that's for use with 32bit. Anyone know a little something? Perhaps a tutorial/PDF if Nasm on a 64bit system is possible?

    Thanks.

    EDIT: I went to a NASM forum and am seeking help there. If someone is still willing to post and help I'd appreciate it.
    Last edited by Annonymous; 12-19-2011 at 02:32 PM.

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    2,564
    Did you read the NASM manual? It does mention NASM style assembly.

    Jim

  3. #3
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    Yes i have Jim. The trouble is, its not sitting well with me. I find it far from beginner friendly! I look at it and can't help but feel overwhelmed!

    I actually have decided to download myself a copy of Ubuntu 10.10. The 32 bit version and install that in replace of my 64 bit version of Ubuntu. Coding in 64 bit ASM will be so much harder for a beginner like myself than it's 32 bit counterpart.

    Thanks Jim.

    Looking for beginner friendly tutorials/PDF's/suggestions. So if anyone has any, please feel free to reply. Thanks.
    Last edited by Annonymous; 12-19-2011 at 03:48 PM.

  4. #4
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,255
    I don't see your boggle. If you think you're going to have trouble learning 64 bit assembly, create a 32-bit virtual machine and start with 32 bit assembly instead.

    But don't try 16 bit assembly - I still have nightmares. Segment, offset, segment, offset... (starts shaking violently)

  5. #5
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    Quote Originally Posted by SMurf
    I don't see your boggle. If you think you're going to have trouble learning 64 bit assembly, create a 32-bit virtual machine and start with 32 bit assembly instead.
    This might help.
    Quote Originally Posted by Annonymous
    I actually have decided to download myself a copy of Ubuntu 10.10. The 32 bit version and install that in replace of my 64 bit version of Ubuntu. Coding in 64 bit ASM will be so much harder for a beginner like myself than it's 32 bit counterpart.

  6. #6
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,255
    Yeeeees but I feel you're missing something obvious here.
    Tell me - can you run 32-bit user mode programs in a 64-bit OS?

  7. #7
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    yeah sure. Not vice versa tho.

    If your going to suggest that i
    create a 32-bit virtual machine and start with 32 bit assembly instead.
    Instead of re-format and install a fresh copy of Ubuntu; I would like you to know that this is the way i prefer to do things. Sometimes i prefer the latter<shrugs shoulders>.

    If that is not what you intended on saying...Then i spoke to soon lol
    Last edited by Annonymous; 12-19-2011 at 05:11 PM.

  8. #8
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,255
    Right, so there's nothing stopping you from writing 32-bit assembly on your current 64-bit OS.

  9. #9
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    Quote Originally Posted by SMurf View Post
    Right, so there's nothing stopping you from writing 32-bit assembly on your current 64-bit OS.
    No there is not. This is what i can not figure out how to do. So that is why i said i am just going to switch to a 32 bit version of Ubuntu. Unless you can school me on how i go about doing the suggest.

    I know reformatting and installing a fresh copy of Ubuntu may seem crazy just to program in 32 bit mode. I actually have nothing on my computer. Its all on my usb. The only reason i use my laptop is to watch a movie or program anyway. So i wont lose any data. Its just the hassle of re installing i would be dealing with.
    Last edited by Annonymous; 12-19-2011 at 05:21 PM.

  10. #10
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,160
    Quote Originally Posted by SMurf View Post
    Yeeeees but I feel you're missing something obvious here.
    Tell me - can you run 32-bit user mode programs in a 64-bit OS?
    The *CPU* supports it. Whether you can actually do it is up to the OS. On Windows, it works transparently. On Linux you have to do all kinds of awful crap to make it work and even then it's flaky.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  11. #11
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    Wow all i had to do was add 2 numbers to the compile process to make it work lol I cant believe it was that easy.

    So it wouldnt work when i try:
    Code:
    root@ubuntu:/home/ubuntu/Documents# nasm -f elf pause.asm
    root@ubuntu:/home/ubuntu/Documents# ld pause.o -o pause
    which produces this error:
    Code:
    ld: i386 architecture of input file `pause.o' is incompatible with i386:x86-64 output
    That is actually for 32 bit mode. Now all you have to do for 64 bit mode is add th number 64 after the word elf.
    Code:
    nasm -f elf64 pause.asm
    "AND IT WORKS"

  12. #12
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Read up on the BITS directive for NASM - NASM Manual

    Then, you need to tell "ld" that you want 32 bit. I think this was the "-m32" flag that does this.

    I cant check as I burned the power unit out my 64 bit laptop last week and the postman still hasn't delivered my new one

  13. #13
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    It shouldn't be too hard -- you don't need to link to any libraries, right? 64-bit linux kernels generally have 32-bit support built into them because grub requires it.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  14. #14
    Registered User Annonymous's Avatar
    Join Date
    Apr 2011
    Location
    Jackson, New Jersey, United States
    Posts
    302
    Yeah all I needed to do was add 2 numbers to the compile process MK27.

    I was using
    nasm -f elf pause.asm When creating the object file.

    But needed to use
    nasm -f elf64 pause.asm

    Only a slight difference, but it is whats needed for the 64 bit Code to run. It surprisingly had nothing to do with the linker Fordy. It was the incompatable 32 bit obj file I was creating. Thanks yall

  15. #15
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Hmm, but then aren't you creating a 64-bit executable? I dunno if that matters, but try it without the "64" using the ld flag Fordy recommends and see what happens.

    Actually I think that flag should be "-m elf_i386" but if you put -m in there and it doesn't recognized the arg it will say:

    root~»ld -m satan
    ld: unrecognised emulation mode: satan
    Supported emulations: elf_x86_64 elf_i386 i386linux elf_l1om
    Last edited by MK27; 12-20-2011 at 04:33 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. compiling assembly in linux with nasm
    By nano78 in forum Linux Programming
    Replies: 1
    Last Post: 10-09-2009, 09:10 PM
  2. Replies: 3
    Last Post: 04-26-2009, 05:59 AM
  3. Nasm
    By audinue in forum Tech Board
    Replies: 3
    Last Post: 01-13-2009, 01:07 PM
  4. Help getting NASM-IDE working
    By curlious in forum Tech Board
    Replies: 2
    Last Post: 11-17-2003, 07:15 AM
  5. More with NASM
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 11-13-2003, 04:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21