Ralf Brown!!!
http://www.ctyme.com/rbrown.htmYour comments are pretty much right. int 21h is the main "dos services interrupt", and it does different things, depending on what's in ah. 9 prints a $-terminated string, with its offset in dx. 4Ch exits back to the command prompt.
That's for dos - should work under Windows - in a dos subsystem ("fake dos"). If it appears not to be working, it may be that the Window is closing instead of "exit to command prompt" (or Vista?). You could stick:
mov ah, 0
int 16h
Right after the first int 21h. That's a bios interrupt which waits for a key. Gives you time to admire your masterpiece. :) Very useful for graphics programs, where you want to "clean up" - switch back into text mode - but not until you've looked at your graphics...
But you don't want to spend *too* much time learning dos - not much "commercial potential" these days. For Windows, you "push" parameters on the stack, and "call" the API. I think there are some simple examples with Alink. For more on which APIs and what parameters - ask Micro$oft!
For Linux, int 80h is the "main OS services interrupt". Subfunctions go in eax, not al - other parameters in ebx, ecx, edx, esi, edi... and ebp in newer kernels. There's no real equivalent to int 21h/9 - print a '$'-terminated string - but eax=4 is "write to file". ebx takes the file handle - returned by "open"... or STDIN (0), STDOUT (1), STDERR (2) are open and available for us to use. ecx takes the address of the buffer to write from, and edx the number of bytes to write. We will, of course, need to exit (in *any* program - "push 0", "call ExitProcess" for 'doze). For Linux, eax=1 is "sys_exit". Like so:
; nasm -f elf hw.asm (makes hw.o)
; ld -o hw hw.o (makes hw)
; ./hw (say hi)
; we need to tell ld about our entrypoint!
; you'd need this in Windows, too
; for a dos .com file "org 100h"
global _start
section .text
_start:
mov eax, 4 ; __NR_write
mov ebx, 1 ; stdout
mov ecx, msg ; buffer
mov edx, msg_len ; length
int 80h ; ask the OS to do it
mov eax,1 ; __NR_exit
int 80h ; buh-bye!
section .data
msg db 'Hello, world',0Ah
msg_len equ $-msg
We can get into something more complicated if you tell us what you want to do...
Best,
Frank