8086 Instructions
8086 Instructions
8086 Instructions
INSTRUCTIONS AND
PROGRAMMING
8088/8086 MICROPROCESSOR
PROGRAMMING INTEGER
INSTRUCTIONS AND COMPUTATIONS
5.1 Data-Transfer Instructions
5.2 Arithmetic Instructions
5.3 Logic Instructions
5.4 Shift Instructions
5.5 Rotate Instructions
Data-Transfer Instructions
The data-transfer functions provide the ability to move data
e.g.
MOV DX, CS
MOV [SUM], AX
e.g.
XCHG AX, DX
((DS)0+SUM)
(BX)
PA = 1200016 + 123416=1323416
Execution of the instruction performs the following 16-bit swap:
(1323416)
(BL)
(1323516)
(BH)
So we get (BX) = 00FF16, (SUM) = 11AA16
e.g.
e.g.
memory
Solution:
Arithmetic Instructions
The arithmetic instructions include
Addition
Subtraction
Multiplication
Division
Data formats
Unsigned binary bytes
Signed binary bytes
Unsigned binary words
Signed binary words
Unpacked decimal bytes
Packed decimal bytes
ASCII numbers
Allowed operands
for INC instruction
Allowed operands for ADD and
ADC instructions
(AX) = 1BBC16
SUM, and carry flag (CF) are 123416, AB16, 00CD16, and 016,
respectively. Describe the results of executing the following
sequence of instruction?
ADD AX, [SUM]
ADC BL, 05H
INC WORD PTR [SUM]
Solution:
(AX)
(BL)
(SUM)
(AL)
(AL)+(BL)= 3216 + 3416=6616
The result after the AAA instruction is
(AL) = 0616
(AH) = 0016
with both AF and CF remain cleared
processors register.
Solution:
(DX,CX)
(DX,CX)+(BX,AX)
(DX,CX) = FEDCBA9816
(BX,AX) = 0123456716
MOV DX, 0FEDCH
MOV CX, 0BA98H
MOV BX, 01234H
MOV AX, 04567H
ADD CX, AX
ADC DX, BX ;
NEG
NEG
(BX)-(CX)-(CF) (BX)
We get
(BX) = 123416 012316 016
= 111116
the carry flag remains cleared
Solution:
Logic Instructions
The logic instructions include
AND
OR
XOR (Exclusive-OR)
NOT
Allowed operands
for NOT instruction
Solution:
(AL)=010101012 000111112= 000101012=1516
Solution:
Shift Instructions
Shift instructions: SHL, SHR, SAL, SAR
SHL AX, 1
SHR AX, CL
(CL)=2
SAR AX, CL
(CL)=2
CONTROL_FLAGS.
Solution:
Rotate Instructions
Rotate instructions: ROL, ROR, RCL, RCR
ROL AX, 1
ROR AX, CL
(CL)=4
For RCL, RCR, the bits are rotate through the carry flag
following instructions?
RCR BX, CL
Assume that, prior to execution of the instruction,
(CL)=0416, (BX)=123416, and (CF)=0
Solution:
byte in memory.
Solution:
MOV AL, [HEX_DIGITS]
MOV BL, AL
MOV CL, 04H
ROR BL, CL
AND AL, 0FH
AND BL, 0FH
ADD AL, BL