Something Wrong with 64 Bit Code Segments

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
Fear
Member
Member
Posts: 39
Joined: Wed May 24, 2006 11:00 pm

Something Wrong with 64 Bit Code Segments

Post by Fear »

NASM doesn't really like when I used [BITS 64], but I couldn't find a replacement for me. It gives me an error saying "Bits must be used with 16 or 32.", or something along those lines. Is it because I'm doing straight binary, or because I'm not using the right directive or what?
Mike
Member
Member
Posts: 25
Joined: Tue Oct 17, 2006 7:57 pm

Post by Mike »

I don't think NASM supports 64-bit mode.

Try FASM or YASM instead. I have used FASM ever since I ran into this hurdle.

Mike
Fear
Member
Member
Posts: 39
Joined: Wed May 24, 2006 11:00 pm

Post by Fear »

Well, thats a kick to the face.... I just figured out how to code the whole thing in NASM, and now I have to make it FASM. Eh, I'll get started. Anyway, why does the NASM manual say it supports [BITS 64]? Thanks.

Do you know if theres a way to check if I'm in Long Mode (not if my computer supports it)? Because I'm not 100% positive I did it right...
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Fear, I think YASM is what your looking for... ([BITS 64] actually works.. 8))

Here is a quote from the site:
Yasm is a complete rewrite of the NASM assembler under the "new" BSD License (some portions are under other licenses, see COPYING for details). Yasm currently supports the x86 and AMD64 instruction sets, accepts NASM and GAS assembler syntaxes, outputs binary, ELF32, ELF64, COFF, Win32, and Win64 object formats, and generates source debugging information in STABS, DWARF 2, and CodeView? 8 formats...
Sadly they didn't include NASM's support for OpenBSD&NetBSD's a.out format so I don't use it personally.

http://www.tortall.net/projects/yasm/
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
spix
Member
Member
Posts: 128
Joined: Mon Jun 26, 2006 8:41 am
Location: Millicent, South Australia
Contact:

Post by spix »

Sadly they didn't include NASM's support for OpenBSD&NetBSD's a.out format so I don't use it personally.
Can I ask why you would want a.out on OpenBSD? They haven't been using a.out for quite a few releases, I can't remember which upgrade it was they switched to elf, but it was at least three or four ago (and quite an interesting upgrade).

NetBSD uses elf as well, since about 1999.

Andrew
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

spix wrote:
Sadly they didn't include NASM's support for OpenBSD&NetBSD's a.out format so I don't use it personally.
Can I ask why you would want a.out on OpenBSD? They haven't been using a.out for quite a few releases, I can't remember which upgrade it was they switched to elf, but it was at least three or four ago (and quite an interesting upgrade).

NetBSD uses elf as well, since about 1999.

Andrew
I only use NASM for OSDev, not for userland applications.. (I used a.out for my old kernel). I do everything else in C. :wink:
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Post Reply