1

I want to create a valid Win32 executable, that can be run as standalone application.

For example, this simple program:

bits 32
mov eax,1
ret

I compiled it using NASM with

nasm test.asm -o test.exe

Then I ran that program. It started NTVDM and it told me "The NTVDM CPU encountered illegal instruction" and some technical details, probably dump, and registers.

So, I want to create a standalone Win32 application in assembly language. I don't want to create COM file, like in DOS.

rkhb
  • 14,159
  • 7
  • 32
  • 60
Smax Smaxović
  • 550
  • 2
  • 7
  • 17
  • You probably need to read [Iczelion's Win32 Assembly](http://win32assembly.programminghorizon.com/tutorials.html) tutorials. To solve you specific problem you need a linker that is capable of producing a PE image. – IInspectable Sep 12 '13 at 17:48
  • 1
    See http://stackoverflow.com/questions/1023593/how-to-write-hello-world-in-assembler-under-windows – Michael Sep 12 '13 at 17:49
  • 2
    Have you tried to select an output format, suitable for your operating system ? eg. `-f win32` switch to create a linkable object file for Windows. – boleto Sep 12 '13 at 18:56
  • And yet another example: http://cs.lmu.edu/~ray/notes/nasmexamples/ – lurker Sep 12 '13 at 20:11
  • possible duplicate of [cannot run executable made by nasm in windows 7](http://stackoverflow.com/questions/10477818/cannot-run-executable-made-by-nasm-in-windows-7) – Raymond Chen Sep 12 '13 at 20:37

2 Answers2

2
[section] .text
    global _start
_start:
    mov eax, 1
    ret

can be assembled like this:

 nasm -fwin32 file.asm              (this should give you file.obj)

and

 link /subsystem:windows /entry:start file.obj       

(or)

 ld -e _start file.obj      

whatever linker you choose should give you your .exe

James
  • 1,009
  • 10
  • 11
0

At least Windows XP refuses to load an application that does not use any DLL files. I didn't test with Windows 7 up to now!

The reason is that there are no official interfaces but the DLLs that come with Windows and that a program that has neither inputs nor outputs makes no sense.

Martin Rosenau
  • 17,897
  • 3
  • 19
  • 38