Microprocessor and Assembly Language Lecture 1
Microprocessor and Assembly Language Lecture 1
Language
8086 Microprocessor
• 8086 Microprocessor is an enhanced version of
8085Microprocessor that was designed by Intel in 1976.
• It consists of powerful instruction set, which provides
operations like multiplication and division easily.
• It has 40 pins divide in:
Input pins
Output pins
In Output pins
• It provides 14, 16 -bit registers.
Register Organization of 8086 General
• The 8086 microprocessor has a total of 14 registers
that are accessible to the programmer.
• It is divided into four groups. They are:
• Four General purpose registers
• Four Index/Pointer registers
• Four Segment registers
• Two Other registers
Register Structure of the 8086
8 Bits 8 Bits
AH AL AX Accumulator
BH BL BX Base General
Purpose
CH CL CX Count Register
DH DL DX Data
SP Stack Pointer
BP Base Pointer Pointer and
SI Source Index Index
DI Destination Index Registers
IP Instruction Pointer
CS Code Segment
DS Data Segment Segment
SS Stack Segment Registers
ES Extra Segment
Flags
16 Bits
General Purpose Register
• AX (Accumulator Register )
Arithmetic operations, I/O operations and string manipulation
• BX (Base Register )
Pointer to base address (data)
• CX (Counter Register )
Loop, shift/rotate instructions and as a counter in string manipulation
• DX (Data Register )
Arithmetic operations and I/O operations
AX (Accumulator Register )
• Accumulator register consists of two 8-bit registers AL and AH,
which can be combined together and used as a 16-bit register
AX.
• AL in this case contains the low order byte of the word, and AH
contains the high-order byte.
BP (Base Pointer )
• Base Pointer (BP) is a 16-bit register pointing to data in stack segment.
• It is usually used by subroutines to locate variables that were passed
on the stack by a calling program.
SI (Source Index) & DI (Destination Index )
• Source Index (SI) is a 16-bit register.
• Destination Index (DI) is a 16-bit register.
• Flag Register
A flag can only take on the values 0 and 1.
Flag Register contains a group of status bits called flags that indicate the
status of the CPU or the result of arithmetic operations.
INSTRUCTION SET OF 8086
• The Instruction set of 8086 microprocessor is
classified into 7, they are:
1. Data transfer instructions.
2. Arithmetic& logical instructions.
3. Program control transfer instructions.
4. Machine Control Instructions.
5. Shift / rotate instructions.
6. Flag manipulation instructions.
7. String instructions.
Data Transfer instructions
• Data transfer instruction, as the name suggests is for the
transfer of data.
• from memory to internal register,
• from internal register to memory,
• from one register to another register,
• from input port to internal register,
• from internal register to output port,
• Examples:
MOV, PUSH, POP, IN , OUT, XCHG
MOV instruction
• It is a general purpose instruction to transfer byte or word
from:
• register to register.
• memory to register.
• register to memory.
• with immediate addressing.
• General Form:
MOV destination, source
MOV instruction
MOV destination, source
Destination and source may be as followed
1) From memory location to register
2) From register to memory location
3) From register to register
4) From intermediate value to memory location
5) From intermediate value to register
• The source and destination needs to be of the same size, that is both 8 bit or both
16 bit.
• MOV instruction does not affect any flags.
• MOV instruction must have 2 operands.
MOV instruction
Example :
• PUSH DS
• Decrement SP by 2 and copy DS to stack .
• POP CX
• Copy a word from the top of the stack to CX and increment SP by 2.
XCHG instruction
• The XCHG instruction exchanges contents of the destination and source.
• Here destination and source can be:
• register and register.
• register and memory location.
• XCHG cannot interchange the value of 2 memory locations.
• General Form:
XCHG register, register
XCHG register, memory location
XCHG memory location, register
• XCHG AL, CL
• exchange byte in CL with the byte in AL
Program Structure Example
.MODEL SMALL
.STACK 100H
.DATA
; Here we define all the variables and constants.
.CODE
MAIN PROC
; Here we put the main procedure statements
MAIN ENDP
; here we put the other procedures
END MAIN
Data Types
• We use data allocation directives to allocate storage, based on several
predefined types.
DB: Define Byte (8-bits)
DW: Define Word (2-bytes)
DD: Define Doubleword (2-words)
DQ: Define Quadword (4-words)
Simple Program
.model small .code
main proc
.data
mov ax,@data
x1 db 254D mov ds,ax
x2 db 3D mov ax,0000h
.stack 100h mov al,x1
mov bl,x2
add al,bl
add al,2D
main endp
end main