Search code examples
if-statementx8664-bitfasm

FASM - x64 vs x86


I made a simple application in FASM while using windows vista x86. The application compiled and ran fine with no errors what-so-ever.

I then, moved the same exact source code (literally the same files) to my other PC running windows vista x64. Upon compiling the source code I received errors.

When on x86 I could simply start off with:

include "win32a.inc"
entry start

When compiling on x64 I had to use something similar to the following:

format PE GUI 4.0
include "win32a.inc"
entry start

Another issue (my main concern) is when on x86 I could use:

.if dword [var] = "1234"
    ;Do something here
.endif

But while compiling the same code on x64 I get "Illegal Instruction" with the following line highlighted:

.if dword [var] = "1234"

Is there a different way to go about doing this on x64?

Also, how can I code to where it will be compatible on both? I figure, if I compile on x86, then the resulting output will run fine on x64?

Finally, is it possible this could have something other to do with than the architecture?


Solution

  • I dug up some old MASM code to use with the latest version of FASM. I had to add this to use the .if macro:

    include 'MACRO/IF.INC'
    

    as well as:

    include "win32a.inc"
    

    for it to compile. Note I get an Illegal Instruction error without including macro/if.inc.

    Maybe the version of win32a.inc on your old 32-bit system includes the .if macro?