Introduction
Introduction
as analog device and the electronic device that works with discrete
Processor (CPU)
Memory Input-Output
Control Unit
ALU
Store Data & Program Communicate with
"outside world", e.g.
Execute program • Screen
• Keyboard
• Storage devices
Do arithmetic/logic operations • ...
requested by program
Operations on Memory
• Fetch (address):
• Fetch a copy of the content of memory cell with the specified address.
• Non-destructive, copies value in memory cell.
• Store(address, value)
– Load the address into MAR.
– Load the value into MDR.
– Decode the address in MAR
– Copy the content of MDR into
memory cell with the specified
address.
Von Neumann
Architecture
Input / Output Subsystem
• Handles devices that allow the computer system to:
1. Communicate and interact with the outside world
– Screen, keyboard, printer, ...
• SystemInterconnection – some
mechanism that provides for
communication among CPU, main
memory, and I/O
ALU-Arithmetic & Logical Unit
binary numbers.
1. Hardwired Control
2. Microprogrammed Control
Programming language
1. Machine language
2. Assembly language
3. It is prone to errors
4. It is difficult to modify
Assembly level programming
• The 8085 provides two instructions: PUSH and POP for storing
subroutine.
routine.
The CALL Instruction
• CALL 4000H (3 byte instruction)
– When CALL instruction is fetched, the MP knows that the
next two Memory location contains 16bit subroutine address in
the memory.
The CALL Instruction
• MP Reads the subroutine address from the next two memory
location and stores the higher order 8bit of the address in the W
register and stores the lower order 8bit of the address in the Z
register
• Push the address of the instruction immediately following the CALL
onto the stack [Return address]
• Loads the program counter with the 16-bit address supplied with
the CALL instruction from WZ register.
The RET Instruction
– Call by Reference:
• The data is stored in one of the registers by the calling program and
the subroutine uses the value from the register. The register values
get modified within the subroutine. Then these modifications will
be transferred back to the calling program upon returning from a
subroutine
Passing Data to a Subroutine
– Call by Value:
• The data is stored in one of the registers, but the subroutine first
PUSHES register values in the stack and after using the registers, it
POPS the previous values of the registers from the stack while
exiting the subroutine. i.e. the original values are restored before
execution returns to the calling program.
Cautions with PUSH and POP
from the top of the stack and the program will fail.
Types of Operands
• Addresses
• Numbers
• Characters
• Logical Data
Instruction Set
Types of Operations
1. Data Transfer
2. Arithmetic
3. Logical
4. Input Output [ I/O ]
5. System Control
6. Transfer Control
Data Transfer
• Move (Transfer) :Transfer word or block from source to destination
• Store: Transfer word from processor to memory
• Load (fetch): Transfer word from memory to processor
• Exchange: Swap contents of source and destination
• Clear (reset): Transfer word of 0s to destination
• Set: Transfer word of 1s to destination
• Push: Transfer word from source to top of stack
• Pop: Transfer word from top of stack to destination
Arithmetic
• Add: Compute sum of two operands
• Subtract: Compute difference of two operands
• Multiply: Compute product of two operands
• Divide: Compute quotient of two operands
• Absolute: Replace operand by its absolute value
• Negate: Change sign of operand
• Increment : Add 1 to operand
• Decrement: Subtract 1 from operand
Logical
• AND: Performs the logical operation AND bitwise
• OR: Performs the logical operation OR bitwise
• NOT: Performs the logical operation NOT bitwise
• Exclusive OR: Performs the specified logical operation Exclusive-OR
bitwise
• Test: Test specified condition; set flag(s) based on outcome
• Compare: Make logical or arithmetic comparison Set flag(s) based
on outcome
• Set Control Variables: Class of instructions to set controls for
protection purposes, interrupt handling, timer control etc.
• Shift: Left (right) shift operand, introducing constant at end
• Rotate: Left (right) shift operation, with wraparound end
Input/output
• Input (Read): Transfer data from specified I/O port or device to
destination (e.g., main memory or processor register)
• Output (Write): Transfer data from specified source to I/O port or
device.
• Start I/O: Transfer instructions to I/O processor to initiate I/O
operation.
• Test I/O: Transfer status information from I/O system to specified
destination
System Control
• System control instructions are those which are used for system
systems.
Transfer of Control
The most common transfer-of-control operations found in instruction
set are:
1. Branch
2. Skip
3. Procedure call.
• BRP X: Branch to location X if result is positive
• BRN X: Branch to location X if result is negative
• BRZ X: Branch to location X is result is zero
• BRO X: Branch to location X if overflow occurs
Instruction Format
LOAD A A C <- M [ A ]
ADD B A C <- A C + M [ B ]
STORE T M [ T ] <- A C
LOAD C A C <- M [ C ]
ADD D A C <- A C + M [ D ]
MUL T A C <- A C • M [ T ]
STORE X M [ X ] <- A C
Two address instructions
MOV R1 , A R 1 <--M [ A ]
ADD R1 , B R 1 <--R 1 + M [ B ]
MOV R2 , C R 2 <--M [ C ]
ADD R2 , D R 2 <--R 2 + M [ D ]
MUL R1 , R2 R 1 <--R 1 * R 2
MOV X , R1 M [ X ] <--R 1
Three address instructions
ADD R1 , A , B R 1 <--M [ A ] + M [ B ]
ADD R2 , C , D R 2 <--M [ C ] + M [ D ]
MUL X , R1 , R2 M [ X ] <--R 1 * R 2