Page 1 of 1
assembling a 64bit exe on windows?
Posted: Thu Aug 18, 2011 11:41 pm
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?
Re: assembling a 64bit exe on windows?
Posted: Fri Aug 19, 2011 12:52 am
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.
Re: assembling a 64bit exe on windows?
Posted: Fri Aug 19, 2011 1:42 am
by bonch
ahh. looks like i was reading the wrong documentation. thanks. and yes, lesson learnt.