3. 3
Basic Processor Operation
All instructions (program steps) are stored in memory.
To run a program, the individual instructions must
be read from the memory in sequence, and executed.
Detailed sequence:
Instruction fetch (read from memory)
Decode instruction
Get operands
Execute operation
Save result
get
next
instruction
4. 4
Basic Processor Operation
We will first demonstrate the main steps of execution
using a very simple processor “model” :
Few instructions (commands)
Simple memory access
Easy to understand
Then, we will start examining the actual 8085
processor instruction set and operations.
5. The OTC (Our Tiny Computer)
• Only 4 Instructions
– Add
• sets condition of result: negative, zero, positive
– Load, Store
• Absolute Reference
– Branch
• PC Relative branch
• 4 Registers (r0, r1, r2, r3)
• 16 Storage (Memory) Locations
6. Example OTC Instructions
load r1,12 // r1 = M[12]
add r1,r2,r2 // r1 = r2 + r2
br pos,-3 // if (result > 0) PC = PC – 3
st r0,3 // M[3] = r0
Illegal instructions
load r4,17 // no register 4, no location 17
add r1,19 // add requires register references
18. 18
Example: Instruction Fetch Operation
Instruction
(opcode)
reaches the
instruction
decoder now !
It takes four
clock cycles
to get one
instruction
into the CPU.
19. 19
Execution of an Instruction
Now consider the execution of a simple instruction:
Instruction 3E (hex) means: Load a data byte into
the accumulator
The instruction is followed by the data byte 32 (hex)
Two-byte instruction !
21. 21
Execution of an Instruction
Put the first
memory
location on
the address
bus (2000 h)
22. 22
Execution of an Instruction
Get the
instruction
(opcode)
byte from
memory
23. 23
Execution of an Instruction
Interpret the
instruction:
Wait for the
data byte !
24. 24
Execution of an Instruction
Put the next
memory
location on
the address
bus (2001 h)
25. 25
Execution of an Instruction
Get the data
byte from the
memory
Put into
accumulator
26. 26
Execution of an Instruction
How long does it take to execute this two-byte
instruction (op-code) ?
It is quite possible to accurately predict the time
that is required to run each instruction, and to
run the entire program !
27. 27
8085 Instruction Set
The 8085 instructions can be classified as follows:
Data transfer operations
Arithmetic operations (ADD, SUB, INR, DCR)
Logic operations
Branching operations (JMP, CALL, RET)
• Between registers
• Between memory location and a register
• Direct write to a register / memory
• Between I/O device and accumulator
31. 31
A VERY Simple Program
Add two hexadecimal numbers:
Load register A (accumulator) with 32 (hex)
Load register B with 48 (hex)
Add the two numbers and save the sum in A
Display accumulator (A) contents at port (01)
End