Unit 2 Instruction Set and Addressing Modes
Unit 2 Instruction Set and Addressing Modes
52
8085 Programming register and
programming model
➢ The register which are programmable and available for the use are six general
❑ Execute cycle
➢ The actual actions which occur during the execute cycle of an
instruction.
➢ Depend on both the instruction itself and the addressing mode
specified to be used to access the data that may be required.
38
Fetching an instruction
Step 1: Instruction pointer (program counter) hold the
address of the next instruction to befetch.
4
Fetching an instruction….Cont….
Step 2
5
Fetching an instruction….Cont….
Step 3
6
Fetching an instruction….Cont….
Step 4
7
Fetching an instruction….Cont….
Step 5
8
Fetching an instruction….Cont….
Step 6
44
Data flow from memory toMPU
Steps and data flow, when the
instruction code 01001111 (4FH
– MOV C, A) stored in the
location 2005H, is being fetch.
Step 1: MPU places the 16 bit memory address from PC on the address bus
Step 2: Control unit send the signal RD to enable memory chip
Step 3: The byte from the memory location is placed on the data bus.
Step 4: The byte is placed on the instruction decoder of the MPU and task is carried
out according to the instruction.
8085 Instruction
❑Since the 8085 is an 8-bit device it can have up to 28 (256)
instructions.
➢ However, the 8085 only uses 246 combinations that represent a total of 74
instructions.
➢ Most of the instructions have more than one format.
❑Operand - The second part is the data to be operated on. Data can be
given in variousform.
➢ It can specify in various ways: may include 8 bit/16 bit data, aninternal register,
memory location or 8 bit /16 bitaddress.
Opcode Operand
Instruction word Size
➢An instruction is assembled in binary form(0,1) known as machine code or opcode.
Due to different ways of specifying data or operand the machine code are not same for all
the instruction
➢ The size of an instruction signifies how much memory space is required to load an
instruction in the memory.8085 instructions are of following sizes:
✓ One-byte or oneword Instructions: opcode and operand in 8 bits
only i.e. one byte. Operand(s) are internal register and are coded into the
instruction.
e.g. MOV, ADD, ANA, SUB, ORA etc.
MOV A,B Move the content of B inA
01 111 000 = 78H 01 for MOV operation, 111 binary code for
register A and last 000 binary code for register B
Register Code
B 000 Register Code
pair
C 001
D 010 BC 00
E 011 DE 01
H 100 HL 10
L 101 A, F, SP 11
M 110
A 111
Addressing Modes
The various formats for specifying operands/data are called the ADDRESSING MODES. 8085
instructions can be classified in following addressing modes
Rotate- Each bit in the accumulator can be shifted either left or right to the next
position.
Compare- Any 8-bit number, or the contents of a register, or a memory location can be
compared for equality, greater than, or less than, with the contents of the accumulator.
25
Write the Assemble Program..cont..
Start
Add Numbers
Block 2: ADD B Add two bytes and save sum inA
2
27
Storing in Memory and converting from Hex
code to binary Code
To store the program in R/W memory, assume the
memory ranges from 2000 H to 20FFH. Now to enter
the Program
1. Reset the system by pushing the RESET key.
2. Enter the first memory address using the HEX keys, where the program
should be written.(2000H)
3. Enter each machine code by pushing Hex keys. For Ex, to enter the first
machine code, push 3E and store keys. Store key, store the program in
memory location 2000H and upgrade the memory address t0 2001.
4. Repeat step 3 until the last machine code 76H. Check the keys and convert
5. Reset the system. Hex code into binarycode
Flowchart
8085 Manual Monitor Binary ToMemory
Hex Code
Mnemonics lookup Program Code for Storage
28
Program Stored in memory as
Mnemonics Hex Code Memory Content Memory Address
Eight Machine code, require eight memory location. MPU can only understand
binary code; everything else(Mnemonics, Hex code, comments) for the convenience
of human being.
29
Executing the Program
To execute the program, we need to tell the MPU
where the program begins by entering the memory
address 2000H.
➢ Push the execute Key, soMPU loads 2000H in PC.
➢ PC is transferred from the monitor program to our program.
➢ MPU begin to read the one machine cycle at a time, when it
fetches the complete instruction, it execute that instruction.
➢ For Eg. When it fetches the machine code stored in 2000 and
2001H and execute the instruction MVI A, 32H , thus load 32H in
register A.
➢ Continue to execute the instruction until it fetches the HLT
instruction.
30
How Does a MPU differentiatebetween data
and instruction code
MPU is a sequential machine. When the system is turns on, it
begins the execution of the code in memory. Now the question
is that how does the MPU differentiate between code and
data when both are binarynumbers.
➢ MPU interprets the first byte , it fetches as an opcode.
➢ When the MPU is reset its PC is reset to 0000H. fetches the first
code from the location 0000H but in our example the memory
location is 2000H.
➢ From the previous program it fetches the 3EH .when it decode that
code it know that it is a two byte instruction. so it assume that
second code 32H isdata.
➢ But if we forget to enter 32H and enter the next code 06H, instead
it , so MPU load 06H in the accumulator and interpret the next
code 48H as an opcode. And continue the execution in sequence.
We may get a totallyunexpected result.
31
END OF LECTURE