
3-36
x86 MICROPROCESSORS
FIRST DB 89H
SECOND DB 0CAH
AVG DB ?
.CODE
.STARTUP
MOV AL, FIRST ;copy FIRST to AL
MOV AH, 0 ;zero-extend
MOV BL, SECOND ;copy SECOND to BL
MOV BH, 0 ;zero-extend
ADD AX, BX ;add the zero extended words
MOV CL, 02 ;load divisor to CL
DIV CL ;divide AX by CL
MOV AVG, AL ;save quotient to AVG
.EXIT
END
Example 3.21 gives a complete program for finding the average of two bytes stored in
memory locations labeled FIRST and SECOND. These are copied to registers AL and
BL and zero extended to convert them to words. Addition of the numbers is then done
as words. This sum, which is the di