Hi starca,
The source code you show is suitable for only one output format: "-f obj". Give Nasm a command line like:
nasm -f obj hello.asm
That should get Nasm to "shut up and assemble", producing "hello.obj" (assuming you named your source file "hello.asm" - otherwise change it to whatever you named it, of course).
Now you'll need to link it, to produce an executable. The command line to the linker will differ slightly, depending on which linker you're using. Something like:
alink -oEXE hello.obj
You can leave out the "-oEXE" if you want - it is the default for Alink. No space after the "-o" - Alink's funny that way: with a space after it, "-o" specifies the output file name, with no space after it "-oEXE", "-oCOM" or "-oPE" specify the type of executable. You want "-oEXE" (for this source code). You could even leave out the ".obj" and just type:
alink hello
This will produce "hello.exe". It will also produce a warning about "no stack", but it should run okay anyway. To get rid of the warning, you need a slight change to your source code:
segment stack stack
The first "stack" is just a name, and could be anything. The second "stack" tells Nasm the type of segment, so Nasm can tell Alink. IF you do this, you can leave out part of your code...
mov ax, stack
mov ss, ax
mov sp, 100
I know, I know, it shows that in the example in the manual, but IF we do it right, DOS will load your file with ss and sp all set up. Won't hurt to leave it in, but DOS does it for us. You still need to set up ds, as you've done.
Another option would be to create a ".com" file (different type of executable). Nasm will do this without the asssistance of a linker, but needs slightly different source code:
org 100h ; tell Nasm where DOS will load us
segment .data
msg db 'hello word$'
segment .text
mov dx,msg
mov ah,09
int 21h
mov ax,4c00h
int 21h
Notice the spelling of the segment names! Nasm knows ".data" and ".text" (and ".bss" if you have uninitialized data - you don't). These have to have the '.', and have to be lowercase! There's no entrypoint ("..start" is only for "-f obj") specified - a .com file always starts at the beginning of the file. Nasm will move ".data" after ".text" (we don't want to execute the ".data" segment!)... IF we spell 'em right.
You'll need a slightly different command line for Nasm:
nasm -f bin hello.asm -o hello.com
That should produce "hello.com", all ready to run (if I haven't typo'ed anything). Somewhat simpler than using a linker (IMO), but less flexible when you get to more advanced code.
If you're running a 64-bit version of Windows, DOS isn't supported and this won't run (neither the .exe or the .com versions). In this case, get "dosbox" or find an example suitable for Windows. Otherwise it should work - post again if it doesn't... (you might want to spell "world" with an "l" in it
)
If you put the word "code" inside of square brackets, "[]" (like a Nasm memory reference) at the beginning of your code, and "/code" in "[]"s at the end of your code, it'll make "code blocks". I don't care, myself, but some of the moderators request that you use 'em!
Best,
Frank