Professional Documents
Culture Documents
APU CSLLT - 9 - Mathematical Commands
APU CSLLT - 9 - Mathematical Commands
CT073-3-2
Mathematical Commands
Topic & Structure of The Lesson
Mathematical commands
-ADD
- SUB
- MUL
- DIV
- INC
-DEC
ADD AL,CL
For example:-
mov al,5
mov cl,12
add al,cl
Answer:-
al = 17
cl = 12
For example:-
mov al,5
add al,12
Answer:-
al = 17
For example:-
mov al,250
mov cl,20
add al,cl
Answer:-
al = 14
cl = 20
ADD AX,CX
For example:-
mov ax,625
mov cx,489
add ax,cx
Answer:-
ax = 1114
cx = 489
For example:-
mov ax,625
add ax,489
Answer:-
ax = 1114
For example:-
mov ax,63821 (F94D)
mov cx,48260 (BC84)
add ax,cx
Answer:-
ax = 46545 (B5D1)
cx = 48260 (BC84)
SUB AL,CL
For example:-
mov al,10
mov cl,5
sub al,cl
Answer:-
al = 5
cl = 5
For example:-
mov al,10
sub al,5
Answer:-
al = 5
For example:-
mov al,10
mov cl,15
sub al,cl
Answer:-
al = 251
cl = 15
SUB AX,CX
For example:-
mov ax,10
mov cx,5
sub ax,cx
Answer:-
ax = 5
cx = 5
For example:-
mov ax,10
sub ax,5
Answer:-
ax = 5
For example:-
mov ax,10 (A)
mov cx,20 (14)
sub cx
Answer:-
ax = 65526 (FFF6)
cx = 20
Byte Multiplication
A multiplication which involves byte registers and
producing a result which is word (8bits) in size.
Word Multiplication
A multiplication which involves word registers and
producing a result which is double word (16bits) in
size.
CT073-2-3 and CSLLT Mathematical Command slide <22> of 47
Byte Multiplication
MUL BL
MUL CL
For example:-
mov al,5
mov bl,30
mul bl
Answer:-
al = 150
ah = 0
ax = 150
CT073-2-3 and CSLLT Mathematical Command slide <25> of 47
Byte Multiplication - Example
For example:-
mov al,30 (1E)
mov bl,10 (A)
mul bl
Answer:-
al = 44 (2C)
ah = 1
ax = 300 (12C)
CT073-2-3 and CSLLT Mathematical Command slide <26> of 47
Word Multiplication
MUL BX
MUL CX
For example:-
mov ax,300
mov bx,129
mul bx
Answer:-
ax = 38700
dx = 0
dx:ax = 38700
CT073-2-3 and CSLLT Mathematical Command slide <29> of 47
Word Multiplication - Example
For example:-
mov ax,329
mov bx,1030
mul bx
Answer:-
ax = 11190
dx = 5
dx:ax = 338870
CT073-2-3 and CSLLT Mathematical Command slide <30> of 47
Division
In assembly language there are generally two kinds of
division:-
• byte division
• word division
Byte Division
A division which involves dividing a word register
(16bits) with a byte register (8bits) and producing a
result which is byte in size.
Word Division
A division which involves dividing a double word
(32bits) register with a word (16bits) register and
producing a result which is word in size.
CT073-2-3 and CSLLT Mathematical Command slide <31> of 47
Byte Division
DIV BL
DIV CL
For example:-
mov ax,100
mov bl,25
div bl
Answer:-
al = 4
ah = 0
For example:-
mov ax,6239
mov bl,45
div bl
Answer:-
al = 138
ah = 29
For example:-
mov ax,2560
mov bl,10
div bl
Answer:-
al = ?
ah = ?
DIV BX
DIV CX
For example:-
mov dx,0
mov ax, 61287
mov bx,14
div bx
Answer:-
ax = 4377
dx = 9
CT073-2-3 and CSLLT Mathematical Command slide <39> of 47
Word Division - Example
For example:-
This is a 32bit
mov dx,5
number, 389625
mov ax, 61945
mov bx,23
div bx
Answer:-
ax = 16940
dx = 5
CT073-2-3 and CSLLT Mathematical Command slide <40> of 47
Increment Commands
INC CX
This is interpreted as:-
CX = CX + 1
INC AL
This is interpreted as:-
AL = AL + 1
MOV AH,198
INC AH
DEC CX
DEC AL
MOV AH,198
DEC AH
Q&A