Professional Documents
Culture Documents
Micro - 7 Instruction (4) Arithmatic 30-10-2023
Micro - 7 Instruction (4) Arithmatic 30-10-2023
QUIZ #4
A. LOOPNE nxt
B. JS cont
Dr. Mazin H. Aziz 2nd-Class Microprocessor I 10/24/2023
1
10/24/2023
Instructions
for
INTEL 8086
Microprocessor
(4)
Arithmetic Group
3
10/24/2023 Dr. Mazin H. Aziz 2nd-Class Microprocessor I
2
10/24/2023
ARITHMATIC GROUP
SUB MUL
ADD IMUL
ADC SBB
AAM
DAA DAS
AAA AAS DIV
IDIV
CWD AAD
CBW
10/24/2023 Dr. Mazin H. Aziz 2nd-Class Microprocessor I
Dr. Mazin H. Aziz 2nd-Class Microprocessor 5
5
3
10/24/2023
Unsigned Integers
• Unsigned integers are easy – they use all 8 or 16 bits in the byte or
word to represent the number.
• If it is a byte, the total range is 0 to 255
(00000000 to 11111111).
• If it is a word, the total range is 0 to 65,535 (0000000000000000 to
1111111111111111).
Signed Integers
• Are slightly more complicated, as they can only use 7 (for the
byte) or 15 (for the word) of the bits to represent the number.
The highest bit is used to indicate the sign.
• A high bit of 0 → positive number
• A high bit of 1 → negative number
4
10/24/2023
Overflow Flag
The rules for turning on the overflow flag in binary/integer math
are two:
1) If the sum of two numbers with the sign bits “OFF” yields a result
number with the sign bit “ON”, the "overflow" flag is turned on.
0100 + 0100 = 1000 (overflow flag is turned “ON”)
2) If the sum of two numbers with the sign bits “ON” yields a result
number with the sign bit “OFF” , the "overflow" flag is turned on.
1000 + 1000 = 0000 (overflow flag is turned “ON”)
Otherwise, the overflow flag is turned “OFF”.
10/24/2023 Dr. Mazin H. Aziz 2nd-Class Microprocessor I 9
Example:
memory, REG MOV AL, 6
ADD AL, -3
REG, REG
FUNCTION:
ADC memory, immediate D.OPERAND = D.OPERAND + S.OPERAND + CF
Example:
REG, immediate
MOV AL, 6
ADC AL, -3
O, S, Z, A, C & P FLAGS are Affected
10/24/2023 Dr. Mazin H. Aziz 2nd-Class Microprocessor I
10
10
5
10/24/2023
Example
MOV BH, 26
ADD BH, 77 ; BH = 103
; CF = 0, ZF = 0
; OF = 0
(103 < 128, sign bit: 0→0)
11
Example:
REG, immediate
MOV AL, 6
SBB AL, 3
6
10/24/2023
Examples
MOV AL, 125
8-bit Addition ADD AL, 15 ; AL = 125 + 15 (= 8Ch)
7
10/24/2023
Examples
; AX = 14 * 29 = 406 (= 0196h)
MOV AL, 14 ; 0Eh
MOV BL, 29 ; 1Dh
MUL BL ; AX = 0Eh * 1Dh
16
8
10/24/2023
Algorithm:
if high bit of AL = 1 then:
AH = 255 (0FFh)
17
Algorithm:
if high bit of AX = 1 then:
DX = 65535 (FFFFh)
else DX = 0
9
10/24/2023
HOMEWORK #5
➢ Write A program to calculate the average of 5
numbers each consists of 8-bit.
19
A. AL = AL X BL
B. LOOP again
B. AL = AL / BL
20
10
10/24/2023
THE END
10/24/2023 Dr. Mazin H. Aziz 2nd-Class Microprocessor I 21
21
11