Re: NASM on WINXP x64 creating EXE




Ok, so I figured out how to create an win32 exe but still having
problems linking x64. Code as such for win32
; tiny.asm
BITS 32
GLOBAL main
SECTION .text
main:
mov eax, 42
ret

nasm -fwin32 -o tiny.o tiny.asm

Then used cygwin ld as such (I also used alink which also works)
d:\cygwin\bin\ld -o tiny.exe tiny.o


Ok, so now have a properly linked runnable exe but only 32bit. I have
tried changing the BITS 64 directive and creating an object file
successfully but I'm not sure which linker I could use to produce a
pure 64 bit executable. Anyone know if there is a directive to the
linker or another linker I could use as alink and cygwin ld seem to be
only 32 bit?




On Dec 22, 7:16 pm, oraclerob <rob.masc...@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
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

  • Re: NASM on WINXP x64 creating EXE
    ... This should have produced a runnable exe I would have thought, but no, ...   GLOBAL main ... attempt to execute under win32?? ... If executing the COFF header ...
    (comp.lang.asm.x86)
  • Re: BWFParser
    ... It doesn't install, it just runs from the exe but it has some issues. ... Win32 Version: 2.0.50727.832 ... CodeBase: ...
    (rec.arts.movies.production.sound)
  • Re: Delphi 2006 VCL for .NET 100% Managed Code ?
    ... Win32 at the end. ... But VCL.net is not just a wrapper around the Winforms layer... ... The MONO one or the Portable.net one will work with your Winforms exe. ...
    (borland.public.delphi.non-technical)
  • Re: NASM on WINXP x64 creating EXE
    ...   GLOBAL main ... attempt to execute under win32?? ... which need to be linked into an .exe. ... linking need for assembled objects. ...
    (comp.lang.asm.x86)
  • Exports from CF Assembly to Win32
    ... I have successfully exported functions from a .Net assembly for use by a Win32 .exe, but I am having problems using the same assembly compiled for CF. ... Does the Compact Framework support this feature, or is there some implementation problem I need to be aware of? ...
    (microsoft.public.pocketpc.developer)