Hi serge1,
Welcome to the Forum! I edited your post to put "code tags" around your code. Just the word "code" in square brackets at the beginning of your code amd "/code" in square brackets at the end. This supposedly makes your code easier to read, and definitely makes it easier to cut-and-paste.
Don't worry about that too much, because it's the "wrong code" anyway. That code is for Linux and won't work for Windows. Despite the fact that Linux is a less "popular" OS, a lot of people get ahold of that example - the "dear string" comment identifies it as a very old example. I don't know why Windows programmers find it, but you're not the first one it has happened to!
Your command line to Nasm is good, and your command line to ld may be okay. Golink is more popular, but ld should also work fine. You will need different code! I haven't run Windows since win98 was in use, so I'm badly out-of-date. I hope we can get a current Windows user in here to help you. Meanwhile...
There is some valid Windows code here:
http://forum.nasm.us/index.php?topic=1918.0Code more like what you've got for Linux - something that will write to the console - would involve "WriteFile"... and you'll need to call "GetStdHandle" to find out what STDOUT is (it's always 1 for Linux). I strongly suggest you end with "ExitProcess" rather than just "ret", although it may work.
This is untested code, and almost certainly has errors, but the code you want will look "something like this"...
; nasm -f win32 myprog.asm
; ld -o myprog.exe myprog.obj
; might be myprog.o and you might need a .lib file
extern GetStdHandle
extern WriteFile
extern ExitProcess
section .data
msg db "hello windows!", 0
msglen equ $ - msg ; note: a constant not a variable
section .bss
; Linux returns this in eax
; Windows needs a "place to put it"
bytes_written resd 1
section .text
global start ; or perhaps winmain
start:
; find out what STDOUT is
push -11
call GetStdHandle
; now the handle for STDOUT is in eax
push 0
push bytes_written
push msglen
push msg
push eax
call WriteFile
push 0
call ExitProcess
;----------------------------
One of the things that could be wrong with that is the "true names" of the APIs. It might be "_GetStdHandle@4", "_WriteFile@20" and "_exitprocess@4". Maybe "_winmain@16", too? The number after the '@' is the number of bytes of parameters (not the number of parameters). I think the linker you use (or the library?) "simplifies" the names for you and some don't.
I hope a Windows user will provide you with some tested code, but give it a shot. You'll never learn assembly language if you give up easy.
Good luck!
Best,
Frank