assembling a 64bit exe on windows?

Programming, for all ages and all languages.
Post Reply
bonch
Member
Member
Posts: 52
Joined: Thu Aug 18, 2011 11:19 pm

assembling a 64bit exe on windows?

Post by bonch »

hi all. im probably missing something really simple here but i cant seem to work out how to assemble a 64 bit exe file from asm source.
i have tried nasm and fasm so far and i cant find anything in the doc about outputting 64 bit. for example, nasm has the format option -fwin32 but i cant find and equivalent like fwin64. can anyone shed some light?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: assembling a 64bit exe on windows?

Post by Solar »

Have you tried the documentation?

I mean, I've never used NASM myself before, but it took me one google (to find the NASM homepage), three clicks and a Ctrl-F, "64" to find this (on the "bin" output format page):
Using the bin format puts NASM by default into 16-bit mode (see section 6.1). In order to use bin to write 32-bit or 64-bit code, such as an OS kernel, you need to explicitly issue the BITS 32 or BITS 64 directive.
Only a few seconds later I found -f win64 and -f elf64. Gosh, there's even a whole chapter on writing 64-bit code...



OK, enough of the mockery. Sorry, didn't mean to sound offensive. But the important lesson to be learned here: Do read the documentation of your toolchain. Personally, for OS development I'd even recommend reading it in full, not only the parts you think you need, as there are always surprising things to be found in TFM.
Every good solution is obvious once you've found it.
bonch
Member
Member
Posts: 52
Joined: Thu Aug 18, 2011 11:19 pm

Re: assembling a 64bit exe on windows?

Post by bonch »

ahh. looks like i was reading the wrong documentation. thanks. and yes, lesson learnt.
Post Reply