Re: NASM on WINXP x64 creating EXE




Sorry guys I haven't done this since 16 bit MASM under DOS so am very
rusty on the specifics of producing an EXE,
As I said in my first post, that is exactly what I did. I produced an
obj file and did try to link using gcc-3 like this:
nasm -f win64 -o tiny.o tiny.asm
d:\cygwin\bin\gcc-3 tiny.o -o tiny.exe

This should have produced a runnable exe I would have thought, but no,
the same error occurs. I know I'm missing a lot of stuff here so
please be kind and lead me in the write direction.



On Dec 22, 11:13 am, Frank Kotler <fbkot...@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
oraclerob wrote:
I'm hoping that someone can help me with this simple problem.

I'm using NASM 2.07 on winxp x64 trying to create a 64 bit ASM exe and
I am getting this message:
"Thie program or feature" "xxxxx" cannot run or start due to
incompatibility with 64-bit versions or Windows....."

I have tried 32 bit and 64 bit mode and linking with gcc, but whatever
I do i get this message.

Here is the helloworld code:

; tiny.asm
  BITS 64
  GLOBAL main
  SECTION .text
  main:
                mov     eax, 42   ;; this has also been tried with mov
rax, 42 the equiv 64 bit instr
                ret

Compiled with
nasm -f win64 -o tiny.exe tiny.asm

Please tell me what simple mistake I'm making

You don't want "-o tiny.exe" here. You want Nasm to produce "tiny.obj"
(which it will do by default, you don't need the "-o" switch unless you
want a different name). Then, you should be able to link this with "gcc
-o tiny.exe tiny.obj". I'm not familiar with win64, so there *may* be
more to it, but I think that'll solve it.

as the program does
attempt to execute under win32??

Win32 probably thinks it's a .com file. If executing the COFF header
doesn't crash it, it might even work!

Also Windows7 x64 produces the same error?

Yeah, "-f win32" and "-f win64" both produce linkable object files...
which need to be linked into an .exe. It is possible to produce an .exe
directly by writing your own executable header and assembling with "-f
bin", but you don't want to do it (probably).

Best,
Frank

.



Relevant Pages