NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: namespace on January 11, 2012, 10:22:27 PM

Title: Problem with x64 program
Post by: namespace on January 11, 2012, 10:22:27 PM
Hello!

I'm beginner in nasm.
I have a x86 program:
Code: [Select]
   
global main
extern printf

    section .data
fmt:  db "a=%e",10,0
a:    dq 0x1.1p+32

   section .text

main:
   push dword [a+4]
   push dword [a]
   push  dword fmt
   call printf
   add esp,12
   ret

When I tried to compile on x64 NASM i have got a problem:
Code: [Select]
prog.asm:11: error: instruction not supported in 64-bit mode
prog.asm:12: error: instruction not supported in 64-bit mode

Does anyone know what I have to change in this program to compile on x64?
Title: Re: Problem with x64 program
Post by: Frank Kotler on January 11, 2012, 11:09:58 PM
Well, "push qword"... but you probably don't want to do that. They've changed the game! Take a look here:

http://www.vikaskumar.org/amd64/index.htm

Or the NASMX package might help you out...

I'm still running 32-bit hardware, so I can't help you much...

Best,
Frank

Title: Re: Problem with x64 program
Post by: Keith Kanios on January 12, 2012, 12:18:39 AM
Jeremy Gordon, the author of GoAsm, has a pretty decent summary of Writing 64-bit programs (http://www.godevtool.com/GoasmHelp/64bits.htm) with emphasis on low-level details.

However, if you are merely trying to assemble/run a 32-bit program on 64-bit Windows, then use -f win32 instead of -f win64 and link accordingly.