
PROGRAMMING CONCEPTS–III 4-35
L DB -9
QUO DB?
.CODE
.STARTUP
MOV AL, X ;copy X to AL
MOV BL, Y ;copy Y to BL
CALL MULT ;call the procedure to multiply X and Y
MOV CX, AX ;copy the product to CX
MOV AL, Z ;copy Z to AL
MOV BL, AL ;copy Z to BL as well
CALL MULT ;call the procedure to get Z
2
SUB CX, AX ;compute XY—Z
2
XCHG CX, AX ;exchange CX and AX, to get dividend in AX
IDIV L ;signed division by L
MOV QUO, AL ;copy the quotient to memory
.EXIT
MULT PROC NEAR ;define the MULT procedure
IMUL BL ;multiply AL by BL, product in AX
RET ;return to calling program
MULT ENDP ;end the procedure
END
In this program, the operands are positive as w ...