I use NASM as an Assembler, I'm trying to learn Assembly Language after C++, and I'm facing too much problems like after generating .OBJ with the Command nasm -f win32 c:\asm\assembly.asm
this generates a assembly.obj file, and after using a command in CMD link c:\asm\assembly.obj /OUT:c:\asm\assembly.exe /SUBSYSTEM:CONSOLE /ENTRY:start
this generates a assembly.exe file.
But if I try to open it, Windows displays a box saying "The Program has stopped working" Whats it?? I'm very confused, and I'm aware of the IDEs in the Internet, but don't want to use any of them, I like the command prompt window, but never used it for linking any of my Applications(c++), And this is the Code copied from TutorialsPoint.com:
NOTE*: All Comments are Orignal as on the TutorialsPoint's Website, it is'nt mine...
section .text
global _start ;must be declared for linker (ld)
_start: ;tells linker entry point
mov edx,len ;message length
mov ecx,msg ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax,1 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db 'Hello, world!', 0xa ;our dear string
len equ $ - msg ;length of our dear string
I tried changing _start to _WinMain@16
as on a Website(Windows Programs uses _WinMain instead _start on linux) but it gives Linker error:Unresolved Externals, But this code Assembled and linked fine, the Only problem i faced is that the Applications get hanged or they Stoped working.
Thanx in Advance!!