Re: NASM on WINXP x64 creating EXE
- From: oraclerob <rob.mascaro@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: 22 Dec 2009 14:14:31 GMT
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
.
- Follow-Ups:
- Re: NASM on WINXP x64 creating EXE
- From: James Harris
- Re: NASM on WINXP x64 creating EXE
- From: BGB / cr88192
- Re: NASM on WINXP x64 creating EXE
- From: James Van Buskirk
- Re: NASM on WINXP x64 creating EXE
- References:
- NASM on WINXP x64 creating EXE
- From: oraclerob
- Re: NASM on WINXP x64 creating EXE
- From: Frank Kotler
- Re: NASM on WINXP x64 creating EXE
- From: oraclerob
- NASM on WINXP x64 creating EXE
- Prev by Date: Re: Howto Push
- Next by Date: Re: NASM on WINXP x64 creating EXE
- Previous by thread: Re: NASM on WINXP x64 creating EXE
- Next by thread: Re: NASM on WINXP x64 creating EXE
- Index(es):
Relevant Pages
|