Uploaded by Ron Ron Marquez

ARITHMETIC - MUL DIV AND LOOP

advertisement
ARITHMETIC
A.
B.
C.
D.
Addition
Subtraction
Multiplication
Division
ARITHMETIC
C. MULTIPLICATION
Instruction
Comment
MUL BL
The unsigned number in AL is multiplied by BL; the
product is found in AX.
Instruction
Solution
MOV CH, 44
CH =
MOV BH, 02
BH =
44
02
MOV AL, CH
AL =
44
MUL BH
AX =
AL * BH = 44 * 02 = 0088
MOV CX, AX
CX =
0088
Illustration
AX – PRODUCT
AL – MULTIPLICAND
BL - MULTIPLIER
ARITHMETIC
D.
DIVISION
Instruction
DIV CL
Instruction
Comment
The unsigned number in AX is divided by CL; the
quotient is in AL, and the remainder is in AH.
Solution
MOV AX, 0009
AX =
0009
MOV DL, 02
DL =
02
MOV BL, DL
BL =
02
DIV BL
AX =
AX/BL; 0009/02 = AL = 04 AH = 01
MOV DX, AX
DX =
0104
Illustration
AX – DIVIDEND
CL – DIVISOR
AL – QUOTIENT
AH - REMAINDER
LOOP’S
The LOOP instruction is a combination of the conditional jump and the decrement CX or CL instruction. It will decrement
the contents of register CX or CL and, if CX or CL is not 0, jump to the label associated with LOOP. If CX or CL becomes a
0, then the next sequential instruction in the program is executed.
1512
:
0100
MOV CX, 0003
CX=
0003
1512
:
0103
MOV BL, 10
BL=
10
1512
:
0105
MOV DL, 10
DL=
10
1512
:
0107
ADD BL, DL
BL=
20
30
40
1512
:
010A
MOV AL, BL
AL=
20
30
40
1512
:
010C
LOOP 107
CX=
02
01
00
AL=
0
1512
:
010E
SUB AL, 40
PROGRAM
OUTPUT
PROGRAM
OUTPUT
PROGRAM
OUTPUT
OUTPUT
PROGRAM
OUTPUT
PROGRAM
PROGRAM
OUTPUT
PROGRAM
OUTPUT
PROGRAM
OUTPUT
EVALUATION
Download