0% found this document useful (0 votes)
164 views

Microprocessor and Assembly Language Lecture 1

The document discusses the 8086 microprocessor and its assembly language. It provides details on the 8086's register organization, including general purpose registers like AX, BX, CX, and DX. It describes the different types of registers like segment registers, index/pointer registers, and other registers. The document also discusses the instruction set of the 8086, including data transfer instructions, arithmetic/logical instructions, and program control transfer instructions. Finally, it provides an example of a basic program structure in assembly language and data type definitions.

Uploaded by

Reem Abed Zeidan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
164 views

Microprocessor and Assembly Language Lecture 1

The document discusses the 8086 microprocessor and its assembly language. It provides details on the 8086's register organization, including general purpose registers like AX, BX, CX, and DX. It describes the different types of registers like segment registers, index/pointer registers, and other registers. The document also discusses the instruction set of the 8086, including data transfer instructions, arithmetic/logical instructions, and program control transfer instructions. Finally, it provides an example of a basic program structure in assembly language and data type definitions.

Uploaded by

Reem Abed Zeidan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Microprocessor and Assembly

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.

• Accumulator can be used for arithmetic operations, I/O


operations and string manipulation.
BX (Base Register )
• Base register consists of two 8-bit registers BL and BH, which
can be combined together and used as a 16-bit register BX.

• BL in this case contains the low-order byte of the word, and


BH contains the high-order byte.

• BX register usually contains a data pointer used for based,


based indexed or register indirect addressing.
CX (Counter Register )
• Count register consists of two 8-bit registers CL and CH, which
can be combined together and used as a 16-bit register CX.

• When combined, CL register contains the low order byte of the


word, and CH contains the high-order byte.

• Count register can be used in Loop, shift/rotate instructions


and as a counter in string manipulation.
DX (Data Register )

• Data register consists of two 8-bit registers DL and DH, which


can be combined together and used as a 16-bit register DX.
• When combined, DL register contains the low order byte of
the word, and DH contains the high-order byte.
• Data register can be used as a port number in I/O operations.
• In integer 32-bit multiply and divide instruction the DX
register contains high-order word of the initial or resulting
number.
Index or Pointer Registers
• SP (Stack Pointer)
Pointer to top of Stack
• BP (Base Pointer )
Pointer to base address (stack)
• SI (Source Index)
Source string /index pointer
• DI(Destination Index )
Destination string/ index pointer
SP (Stack Pointer)
• Stack Pointer (SP) is a 16-bit register pointing to program stack, i.e. it
is used to hold the address of the top of stack.
• The stack is maintained as a LIFO with its bottom at the start of the
stack segment (specified by the SS segment register).

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.

• In short, Destination Index and SI Source Index registers are


used to hold address
Segments Registers
• CS (Code segment )
• SS (Stack segment )
• DS (Data segment )
• ES (Extra segment)

• Segment registers cannot be used in arithmetic operations.


CS (Code segment )
• Code segment (CS) is a 16-bit register containing address of
64 KB segment with processor instructions.
• The processor uses CS segment for all accesses to
instructions referenced by instruction pointer (IP) register.
• CS register cannot be changed directly.
• The CS register is automatically updated during far jump, far call
and far return instructions.
SS (Stack segment )
• Stack segment (SS) is a 16-bit register containing address of
64KB segment with program stack.

• By default, the processor assumes that all data referenced by


the stack pointer (SP) and base pointer (BP) registers is
located in the stack segment.
DS (Data segment )
• Data segment (DS) is a 16-bit register containing address of 64KB
segment with program data.

• By default, the processor assumes that all data referenced by


general registers (AX, BX, CX, DX) and index register (SI, DI) is
located in the data segment.

• DS register can be changed directly using POP and LDS


instructions.
ES (Extra segment)
• Extra segment (ES) used to hold the starting address of Extra
segment.

• Extra segment is provided for programs that need to access a


second data segment.
Other registers
• IP (Instruction Pointer)
Is a 16-bit register.
Is used to store the memory location of the next instruction to be
executed.

• 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 :

MOV CL, [207H]


MOV [546H], BX
MOV DS, CX
MOV [0011H], 00F3H
MOV AX, 00F3H
PUSH instruction
• The PUSH instruction decrements the stack pointer by two and copies the word
from source to the location where stack pointer now points.
• The data will be stored SS.
• General Form:
PUSH source
• The source data must be word.
• Source can be:
• General Purpose Register(Ax ,Bx ,CX ,Dx ).
• Segments Register( ES,DS,CS).
• Memory Location.
• Push instruction does not affect any flags.
• Push instruction has one operand.
POP instruction
• The POP instruction copies a word from the stack location pointed by the
stack pointer to the destination.
• Here after the content is copied the stack pointer is automatically
incremented by two.
• General Form:
POP destination
• Destination can be:
• General Purpose Register(Ax ,Bx ,CX ,Dx ).
• Segments Register( ES,DS,CS).
• Memory Location.
PUSH and POP instruction Example
• PUSH CX
• Decrements SP by 2, copy content of CX to the stack.

• 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

• Data transfer instructions does not affect any flags.


XCHG instruction
Example:
• XCHG BX, CX
• exchange word in CX with the word in BX

• 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

You might also like