Lab Manual - Mid-Sem
Lab Manual - Mid-Sem
THEORY
Intel 8086 was the first 16-bit microprocessor introduced by Intel in 1978.
Segment Registers:
The 8086 architecture uses the concept of segmented memory. 8086 able to address to
address a memory capacity of 1 megabyte and it is byte organized. This 1 megabyte memory
is divided into 16 logical segments. Each segment contains 64 Kbytes of memory.
Code segment register (CS): is used from addressing memory location in the code segment of
the memory, where the executable program is stored.
Data segment register (DS): points to the data segment of the memory where the data is
stored.
Extra Segment Register (ES): also refers to a segment in the memory which is another data
segment in the memory.
Stack Segment Register (SS): is used for addressing stack segment of the memory. The stack
segment is that segment of memory which is used to store stack data.
While addressing any location in the memory bank, the physical address is calculated from
two parts:
- The first is segment address, the segment registers contain 16-bit segment base addresses,
related to different segment.
- The second part is the offset value in that segment.
The advantage of this scheme is that in place of maintaining a 20-bit register for a physical
address, the processor just maintains two 16-bit registers which is within the memory
capacity of the machine.
Flag register
Arithmetic Instructions
ADD, SUB Add, subtract byte or word
ADC, SBB Add, subtract byte or word and carry (borrow)
INC, DEC Increment, decrement byte or word
NEG Negate byte or word (two's complement)
CMP Compare byte or word (subtract without storing)
MUL, DIV Multiply, divide byte or word (unsigned)
IMUL, IDIV Integer multiply, divide byte or word (signed)
CBW, CWD Convert byte to word, word to double word (useful before
multiply/divide)
AAA, AAS,
AAM, AAD ASCII adjust for addition, subtraction, multiplication, division (ASCII
codes 30-39)
DAA, DAS Decimal adjust for addition, subtraction (binary coded decimal
numbers)
Transfer Instructions
JMP Unconditional jump (short 127/8, near 32K, far between segments)
Conditional jumps:
JA (JNBE) Jump if above (not below or equal) +127, -128 range only
JAE (JNB) Jump if above or equal (not below) +127, -128 range only
JB (JNAE) Jump if below (not above or equal) +127, -128 range only
JBE (JNA) Jump if below or equal (not above) +127, -128 range only
JE (JZ) Jump if equal (zero) +127, -128 range only
JG (JNLE) Jump if greater (not less or equal) +127, -128 range only
IEC 213 MICROPROCESSORS AND MICROCONTROLLERS DR. DELLA THOMAS
LAB MANUAL
8
JGE (JNL) Jump if greater or equal (not less) +127, -128 range only
JL (JNGE) Jump if less (not greater nor equal) +127, -128 range only
JLE (JNG) Jump if less or equal (not greater) +127, -128 range only
JC, JNC Jump if carry set, carry not set +127, -128 range only
JO, JNO Jump if overflow, no overflow +127, -128 range only
JS, JNS Jump if sign, no sign +127, -128 range only
JNP (JPO) Jump if no parity (parity odd) +127, -128 range only
JP (JPE) Jump if parity (parity even) +127, -128 range only
Loop control:
LOOP Loop unconditional, count in CX, short jump to target address
LOOPE (LOOPZ) Loop if equal (zero), count in CX, short jump to target address
LOOPNE (LOOPNZ) Loop if not equal (not zero), count in CX, short jump to target
address
JCXZ Jump if CX equals zero (used to skip code in loop)
String Instructions
MOVS Move byte or word string
MOVSB, MOVSW Move byte, word string
CMPS Compare byte or word string
SCAS Scan byte or word string (comparing to A or AX)
LODS, STOS Load, store byte or word string to AL or AX
Repeat instructions (placed in front of other string operations):
REP Repeat
REPE, REPZ Repeat while equal, zero
REPNE, REPNZ Repeat while not equal (zero)
Inactive states:
NOP No operation
WAIT Wait for TEST pin activity
HLT Halt processor
2. MULTIBYTE ADDITION
MOV SI,3000
MOV DI,4000
MOV BX,2000
MOV CL,04
MOV DL,00
MOV AL, [BX]
ADD AL,[SI]
MOV [DI],AL
INC BX
INC SI
INC DI
LOOP BACK
JNC LABEL
ADC DL,00
LABEL: MOV [DI],DL
3. MULTIBYTE SUBTRACTION
MOV SI,3000
MOV DI,4000
MOV BX,2000
MOV CL,04
MOV DL,00
MOV AL, [BX]
SUB AL,[SI]
MOV [DI],AL
INC BX
INC SI
INC DI
LOOP BACK
JNC LABEL
ADC DL,00
LABEL: MOV [DI],DL
4. 8 BIT MULTIPLICATION
5. 16 BIT MULTIPLICATION
6. 8 BIT DIVISION
MOV SI,2000
MOV AX,[SI]
MOV BL,[SI]02
DIV BL
MOV [SI]03,AX
INT 03
7. 32 BIT DIVISION
MOV SI,2000H
MOV AX,[SI]
MOV DX,[SI]02
MOV BX,[SI]04
DIV BX
MOV [SI]06,AX
MVI B, 00H
MVI C, 08H
MOV AL,DL
BACK: ROR AX,01
JNC SKIP
INC BL
SKIP: DEC CL
JNZ BACK
INT 03
CLC
MOV SI,2000H
MOV BX,3000H
MOV DI,4000H
MOV CX,02
L1:MOV AL,SI
ADC AL,{BX}
DAA
INC BX
INC SI
INC DI
DEC CX
JNX L1
INT 03
MOV SI,3000H
MOV CL,05
MOV AL,00H
MOV BL,00H
BACK: MOV DL,SI
ADD AL,DL
JNC LABEL
INC BL
LABEL: INC SI
JMP BACK
MOV SI,AL
MOV [SI]01,BL
INT 03H
MOV BX,3000
MOV AX,[BX]
MUL AX
MOV CX,AX
MOV AX,[BX]
MUL CX
INT 03
CLD
MOV DI, 3000
MOV CX, 0000
MOV AL,0FF
AGAIN:SCASB
JNZ COUNT
MOV BX, 5000
MOV [BX],CX
JMP EXIT
COUNT: INC CX
JMP AGAIN
EXIT: INT 03
CLD
MOV DI, 3000
MOV CX, 0000
MOV AX,0FFFF
AGAIN:SCASW
JNZ COUNT
MOV BX, 5000
MOV [BX],CX
JMP EXIT
COUNT: INC CX
JMP AGAIN
EXIT: INT 03
MOV DI,3000
MOV BX,8000
MOV CX,0005
MOV SI,2000
MOV AL,[SI]
CLD
L2:SCASB
JNE X
MOV DL,00
MOV [BX],DL
JMP Y
X: LOOP L2
MOV DL,FF
MOV [BX],DL
Y: INT 03
CLD
MOV SI,4000
MOV DI,5000
MOV CL,05
REP
MOVSB
INT 03
MOV SI,2000
MOV DI,3000
MOV CX,0005H
ADD SI,CX
SUB SI,0001
BACK: STD
LODSB
CLD
STOSB
LOOP BACK
INT 03H