Page 1 of 1

Something Wrong with 64 Bit Code Segments

Posted: Thu Nov 16, 2006 7:35 pm
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?

Posted: Thu Nov 16, 2006 7:39 pm
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

Posted: Thu Nov 16, 2006 7:41 pm
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...

Posted: Thu Nov 16, 2006 9:01 pm
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/

Posted: Fri Nov 17, 2006 1:06 am
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

Posted: Fri Nov 17, 2006 8:02 am
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: