Programming
Workshop

Spring 2006
course
navigation
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.
Here's a chunk of code from http://docs.cs.up.ac.za/programming/asm/derick_tut/.
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:
for EBX (I/O stuff):
for EBX (sys_exit):

I guess this illustrates the importance of using the right registers.