Okay, here are some things about registers, some "pointers" if you'll pardon the pun, that I'm trying to keep straight.
EDX - extended data register. When doing arithmetic or I/O operations, put stuff here.
EBX - extended base register. Points to some data.
EAX - extended accumulator register. Wikibooks says it's used for arithmetic, but it seems to be used for other things.
mov eax,4 ; The system call for write (sys_write)
mov ebx,1 ; File descriptor 1 - standard output
mov ecx,hello ; Put the offset of hello in ecx
mov edx,helloLen ; helloLen is a constant, so we don't need to say
; mov edx,[helloLen] to get it's actual value
int 80h ; Call the kernel
This takes the string variable hello and tells the kernel to output it to the screen. The 1 and 4 above are actual numbers, and I guess the kernel just interprets them (depending on what register they're in). Here are the ones I've seen so far:
for EAX:
- 1 is exit (use this at the end of your code).
- 3 is read (the "I" of I/O).
- 4 is write (the "O" of I/O).
- 6 is close, as in a file that you had opened for I/O stuff.
- 8 is create. Lets you make a new file (you can use ECX concurrently to set the permissions).
for EBX (I/O stuff):
- 1 is standard output (like the terminal)
- [filehandle] points to a file. Oh, the profundity.
for EBX (sys_exit):
- 0 means "return 0" (no errors), like you put in your C main function.
I guess this illustrates the importance of using the right registers.