8

I want to program 64 bit windows assembly (preferably using NASM). I have looked quite a but on google but it seems that I cannot find a 64 bit windows compiler. Some site mentioned ml64 but it seems like it is no longer included in VC++. I have tried with 32 bit assembly, but obviously it just crashes on my 64 bit machine. Is it possible to write, compile and run 32 bit assembly applications on a 64 bit windows machine? Or should it be written and compiled for 64 bits?

Thanks.

Jayson Kane
  • 173
  • 2
  • 3
  • 7
  • For the record, ml64.exe is included in my installation of VS2010. I'm not sure if it's included in the Express version though... – PinnyM May 22 '12 at 19:26
  • 1
    VS2010 Express user here, ml64.exe is present in Visual Studio/VC/bin/amd64 and bin/x86_amd64 folders. – DCoder May 22 '12 at 19:59
  • If you want to use NASM, then just go to http://nasm.us and download the Win32 version of NASM. It will run on a 64-bit system and it will create 64-bit applications. – Jim Mischel May 23 '12 at 03:53
  • @PinnyM and DCoder - Thanks I never checked my own dir *doh*. I found it on mine as well. – Jayson Kane May 23 '12 at 07:24
  • @JimMischel - I tried that but my program just crashes.. Maybe I have some bad code. I will try to find a better tutorial than the one I was following. – Jayson Kane May 23 '12 at 07:25

2 Answers2

6

Yasm(*) is a modern, multi-platform NASM-rewritten assembler which is capable of assembling for both x86 and AMD64/x86-64 instruction sets.

However... What you probably mean is that you need a linker to link the assembled object code/file(s) to create an executable file. At least the completely free MinGW(Minimal GNU for Windows) project package ships with a linker(called ld) capable of assembling both 32- and 64-bit Windows executables from object files(ELF and PE object format, at least).

You can definitely cross-compile/build 32-bit projects in a 64-bit environment and vice versa, given that you supply correct command-line parameters to the assembler and the linker. Please refer to the documentation of the tools of your choise for more precise details.

*) http://yasm.tortall.net/

zxcdw
  • 1,629
  • 1
  • 10
  • 18
  • That's correct. Thanks for pointing it out, I completely misunderstood the context in a hurry and mixed the terminology. I've edited and enhanced the answer for more detail. – zxcdw May 23 '12 at 07:49
  • Thanks alot for your post. I am using ld to link it but it seems to be still crashing. Is it possible for you to supply me with a snippet of assembly code that can compile with yasm and be linked on a 64-bit system, but written in 32-bit assembly? It doesn't have to do anything. Just compile and run without crashing. That would be great. – Jayson Kane May 23 '12 at 08:22
  • I don't have Windows machine available but on a Linux machine all you really have to do is to use the yasm '-f' flag(\f in windows?) with 'elf32'('win32' for Windows) as a parameter. Then, for ld you use '-m' (again, use \ instead of -) flag with 'elf_i386' parameter to produce a 32-bit executable. However, on Windows you need different flags. You can see the available emulation flags by using '-V'(\V ..?) flag, then pick the best candidate and try out. So all in all, it looks like this: 'yasm some.asm -o some.o -f elf32' and 'ld some.o -o some.bin -m elf_i386'. So just change elf32 & elf_i386 – zxcdw May 23 '12 at 10:17
3

It is possible to write, assemble, and run 32-bit assembly on 64-bit Windows. I've written a few utilities in masm32 on my Windows 7 x64 machine. If you want to assemble 64-bit code, I believe that FASM supports 64-bit object code.

Brian Knoblauch
  • 20,639
  • 15
  • 57
  • 92