You are on page 1of 32

Simple Calculator

to Microprocessor
• Performs only arithmetic
operations.
• Input should be data and
operation.
• Stores only two data and one
operation.
• Does not has memory to store
sequence of operations
Simple Calculator to
Microprocessor (Cont.)

• Performs arithmetic and logical


operation.
• Has memory and can store data
and sequence of operation.
• Does not require human
intervention between operation
• The operations are stored in
program/code memory and data
in data memory
8086-Microprocessor Architecture
• In 1978, Intel released its first 16-bit microprocessor-8086.
• Widths of the Data bus and Registers are 16-bits.
• It executes the instructions at 2.5MIPS
• Execution time for one instruction is 400ns.
• What is a instruction? (Add AL BL, Mov BX AX)
• 8086 can address 1MB(1MB=220 bytes) of memory-20 bit
address bus.
• Does 8086 has memory?
8086-Microprocessor Architecture
• Functional block diagram of 8086, subdivided into the following
two units:
1. Bus interface unit (BIU)
2. Execution unit (EU)

Bus Interface unit: Fetches instruction. It includes an adder for


address calculations, four-16 bit segment registers (CS,DS,SS,ES),
a 16-bit instruction pointer(IP), a six-byte instruction queue, and
bus control logic.
Execution unit: Executes instructions. It includes the ALU, 16-bit
general purpose registers, a 16-bit flag register and a control unit.
General Purpose Registers

15 8 7 0
AX AH AL Accumulator

BX BH BL Base
Data Group
CX CH CL Counter

DX DH DL Data

SP Stack Pointer

BP Base Pointer
Pointer and
Index Group
SI Source Index

DI Destination Index
General Purpose Registers
• General Purpose registers can be used to store 8-bit or 16-bit data during
program execution. In addition each register has the following function:
• AX/AL:
• It is used as a accumulator.
• It is used in the multiply,divide, and input/output operations, and in
some decimal and ASCII adjustment instructions.
• BX:
• It holds the offset address of a location in the memory.
General Purpose Registers
• CX/CL:
• CX is used to hold the count value while executing the
repeated string instruction and the LOOP instruction.
(REP/REPE/REPNE).
• CL- Used to hold the count value while executing the
shift/rotate instructions.
• DX:
• Used to hold a part of the result during a multiplication
operation and a part of the dividend before a division
operation.
• Used to hold the I/O device address while executing the IN
and OUT instructions.
Segment registers and default offset registers in the 8086

Segment registers Default offset registers

CS IP

DS BX,SI,DI, 8-or 16-bit


displacement
SS SP and BP

ES DI for string instruction


Offset Registers
SP:
• Stack Pointer is used to hold the offset address of the data stored at the top
of the stack segment.
• SP is used along with the SS register to decide the address at which the data
is to be pushed or popped, during the execution of the PUSH or POP
instruction, respectively.
BP:
• BP register is called base pointer
• Used to hold the offset address of the data to be read from or written into
the stack segment.
SI:
• Source index register
• Used to hold the offset address of the source data in the data segment,
while executing string instructions.
DI:
• Destination index register
• Used to hold the offset address of the Destination data in the extra segment,
while executing string instructions.
Segmented Memory
Address Calculation
Address Calculation
Address Calculation
Address Calculation
Flag Register
Flag Register
Flag Register
• Examples
Sign Flag:
+13=00001101
+9 =00001001
+22=00010110 (Sign bit is 0; so result is positive)

+13=00001101
-9 =11110111 (2’s complement for -9 with sign bit
+4=100000100(Ignore Carry; Sign bit is 0 so result is positive)

+9 =00001001
-13=11110011 (2’s complement for -13 with sign bit
-4 = 11111100 sign bit is 1; negative)
00000011 Invert each bit
1( add 1)
00000100( -4; magnitude)
Flag Register
• If register AL=7FH and the instruction ADD AL,1
• Result:
• AL = 80H ; 7FH+1=80H
• CF = 0 ; No carry out of bit 7
• PF = 0 ; 80H has an odd no of logic 1’s
• AF = 1 ; Carry out of bit 3 into bit 4
• ZF = 0 ; Result is not 0
• SF = 1 ; Bit 7 is set
• OF = 1 ; Result(+128) exceeds the capacity of register AL
Immediate

mov al, 5
mov bl, 3

add bl, al

sub bl, 1
Register & Direct
Register
mov dh, bl

Direct
mov [5000h], al

mov ch, [5000h]

10H*DS+5000H
Register Indirect

mov bx, 5000h

mov ah, [bx]

10H*DS+[bx]
Indexed
mov si, bx

mov cl, [si]

10H*DS+[si]
Register Relative
mov 50h[bx], 2000h

mov ax, 50h[bx]

10H*DS+[bx]+50
Base Index
mov [bx] [si], 9000h

mov ax, [bx] [si]

10H*DS+[bx]+[si]
Relative Based Index

mov 50h [bx][si], 1500h

mov ax, 50h [bx][si]

10H*DS+[bx]+[si]
Add
add ax, 1000h

add ax, bx

add ax, [si]

add ax, [1000h]

add [1000h], 5h

mov ax, [1000h]


Sub
sub ax, bx

Increment

inc ax
inc [1000h]

Decrement
dec ax

You might also like