The Registers (AX)

I've mentioned AX, AL, and AH before, and you're probably wondering what exactly they are. Well, I'm gonna go through one by one and explain what each register is and what it's most common uses are. Here goes:


AX (AH/AL):

AX is a 16 bit register which, as metioned before, is merely two bytes attached together. Well, for AX, BX, CX, & DX you can independantly access each part of the 16 bit register through the 8bit (or byte sized) registers. For AX, they are AL and AH, which are the Low and High parts of AX, respectivly. It should be noted that any change to AL or AH, will change AX. Similairly any changes to AX may or may not change AL and AH. For instance:

Let's suppose that AX = 00000h (AH and AL both = 0, too)

mov AX,0
mov AL,0
mov AH,0

Now we set AL = 0FFh.

mov AL,0FFh

:AX => 000FFh ;I'm just showing ya what's in the registers
:AL => 0FFh
:AH => 000h

Now we increase AX by one:

INC AX

:AX => 00100h (= 256.. 255+1= 256)
:AL => 000h (Notice that the change to AX changed AL and AH)
:AH => 001h

Now we set AH = 0ABh (=171)

mov AH,0ABh

:AX => 0AB00h
:AL => 000h
:AH => 0ABh

Notice that the first example was just redundant...
We could've set AX = 0 by just doing

mov ax,0

:AX => 00000h
:AL => 000h
:AH => 000h

I think ya got the idea...

SPECIAL USES OF AX:
Used as the destination of an IN (in port)
ex:
IN AL,DX
IN AX,DX

Source for the output for an OUT
ex:
OUT DX,AL
OUT DX,AX

Destination for LODS (grabs byte/word from [DS:SI] and INCreses SI)
ex:
lodsb (same as: mov al,[ds:si] ; inc si )
lodsw (same as: mov ax,[ds:si] ; inc si ; inc si )

Source for STOS (puts AX/AL into [ES:DI] and INCreses DI)
ex:
stosb (same as: mov [es:di],al ; inc di )
stosw (same as: mov [es:di],ax ; inc di ; inc di )

Used for MUL, IMUL, DIV, IDIV

As the next post I will get to you about the registers called BX. That's all for this post. You have to get it! :-)

No comments: