2 Instruction Set And Addressing Modes

Microprocessor and Computer Architecture · Unit 2

Instruction Set and Addressing Modes

Exam-focused notes for Instruction Set and Addressing Modes (Microprocessor and Computer Architecture, BIT151): what the TU syllabus asks and how it has actually been tested, with 9 solved past questions from this unit.

Instruction Set and Addressing Modes in short

The instruction set is the list of all operations the 8085 can perform. Every program for the 8085 is built from these instructions, so knowing their format, types and addressing modes is the base for all assembly programming.

Instruction Set and Addressing Modes: notes

Instruction format and structure

Every instruction has an opcode (operation code, the part that says what to do). Most also have an operand (the data or address to work on). Instructions are stored in memory as bytes, and the 8085 has three sizes.

SizeBytesExampleMeaning
One byte1MOV A,BOpcode only, register named in the opcode
Two byte2MVI A,08HOpcode, then 8-bit data
Three byte3STA 4000HOpcode, then low byte and high byte of a 16-bit address

In a three-byte instruction the low-order byte comes first. So STA 4000H is stored as 32H 00H 40H.

An assembly instruction is written as: label, mnemonic, operand, comment. For example, LOOP: DCR B ; reduce counter.

Instruction types and classification

The 8085 instructions fall into five groups.

  • Data transfer: copy data without changing the source. Examples: MOV, MVI, LDA, STA, LXI, XCHG.
  • Arithmetic: ADD, ADI, SUB, SUI, INR, DCR, INX, DCX, DAD, DAA.
  • Logical: ANA, ORA, XRA, CMP, CMA, RAL, RAR, RLC, RRC.
  • Branching: change the order of execution. Examples: JMP, JZ, JNC, CALL, RET.
  • Machine control: NOP, HLT, EI, DI, RIM, SIM. Stack and I/O instructions (PUSH, POP, IN, OUT) are often listed here too.

Branch instructions are of two kinds. An unconditional jump always happens. A conditional jump happens only if a flag has a given value, such as Zero (JZ) or Carry (JC).

Addressing modes in 8085

An addressing mode is the way an instruction tells the processor where its data is. The 8085 has five modes.

ModeWhere the data isExample
ImmediateIn the instruction itselfMVI B,32H, LXI H,2050H
RegisterIn a registerMOV A,B, ADD C
DirectAddress is given in the instructionLDA 2000H, STA 4000H
Register indirectAddress is held in a register pairMOV A,M, LDAX B
Implicit (implied)The data is fixed by the opcodeCMA, RAL, STC

Notes on each mode:

  • In immediate mode, MVI B,32H loads 32H straight into B.
  • In register mode, MOV A,B copies B into A.
  • In direct mode, LDA 2000H copies the byte at memory address 2000H into A.
  • In register indirect mode, M means the memory location whose address is in HL. If HL = 2050H, then MOV A,M loads the byte at 2050H.
  • In implicit mode, CMA complements the accumulator. No operand is written.

Instruction STA 4000H: it is a three-byte instruction in direct addressing mode. The address 4000H is part of the instruction, and the accumulator content is stored at that address.

What this unit covers

  • Instruction format and structure
  • Instruction types and classification
  • Addressing modes in 8085
  • Arithmetic instructions with examples
  • Instruction cycle and execution time

Addressing modes in 8085

2082 · 10 marks

Explain different addressing modes in 8085 microprocessor.Explain any five arithmetic instructions in 8085 microprocessor with suitable example.[5+5]

(a) Addressing Modes An addressing mode refers to the way in which the operand (data) is specified in an instruction. The 8085 microprocessor supports the following addressing modes: --- - The operand (data) is directly specified in the instruction itself. - The data follows the opcode in memory....

Open this answer on its own page →

2080 · 10 marks

What is Addressing Modes? Explain each with example. Explain the function and type of addressing mode with reason of instructions STA 4000H.[10]

Addressing Mode is the method by which the CPU identifies or specifies the location of the operand (data) to be used in an instruction. It defines how the processor accesses data during program execution. --- The operand (data) is directly included in the instruction itself as the 2nd or 3rd byte...

Open this answer on its own page →

2080.1 · 5 marks

What is addressing mode? Explain different addressing modes in 8085 microprocessor. [5]

Show solved answer

Addressing Modes in 8085 Microprocessor

Definition

Addressing mode refers to the way in which the operand (data) of an instruction is specified or accessed. It defines the method used by the CPU to identify the location of the data to be operated upon.


Types of Addressing Modes in 8085

The 8085 microprocessor supports the following addressing modes:


1. Immediate Addressing Mode

  • The operand (data) is directly specified in the instruction itself.
  • The data follows immediately after the opcode in memory.
  • Example:
    MVI A, 25H   ; Load 25H directly into accumulator
    LXI H, 2050H ; Load 2050H into HL pair
    

2. Register Addressing Mode

  • The operand is stored in a register, and the instruction specifies that register.
  • Data is transferred between registers.
  • Example:
    MOV A, B   ; Copy contents of register B to A
    ADD C      ; Add contents of register C to accumulator
    

3. Direct Addressing Mode

  • The 16-bit memory address of the operand is directly given in the instruction.
  • The CPU directly accesses that memory location.
  • Example:
    LDA 2050H   ; Load data from memory address 2050H into A
    STA 3000H   ; Store accumulator content at address 3000H
    

4. Indirect Addressing Mode (Register Indirect)

  • The address of the operand is stored in a register pair (usually HL, BC, or DE).
  • The register pair acts as a pointer to the memory location.
  • Example:
    MOV A, M   ; M refers to memory location pointed by HL pair
    LDAX B     ; Load accumulator with data at address in BC pair
    

5. Implicit (Implied) Addressing Mode

  • The operand is implicitly defined by the instruction itself; no address or data needs to be specified separately.
  • The instruction operates on a fixed, implied register (usually the accumulator).
  • Example:
    CMA    ; Complement the accumulator (A is implied)
    RAL    ; Rotate accumulator left (A is implied)
    

Summary Table

Addressing ModeOperand LocationExample
ImmediateIn the instructionMVI A, 30H
RegisterIn a registerMOV A, B
DirectMemory (address given)LDA 2050H
Register IndirectMemory (address in register pair)MOV A, M
Implicit/ImpliedFixed (accumulator)CMA

Note: The reference notes were not available for this topic. The above answer is based on standard 8085 microprocessor curriculum as taught in BSc CSIT, consistent with Tribhuvan University syllabus.

Open this answer on its own page →

Arithmetic instructions with examples

2082 · 5 marks

Write an assembly language program to multiply 08H and 09H, store the product in memory location 8050H and carry in 8051H using 8085 microprocessor instructions. [5]

Show solved answer

Assembly Language Program: Multiply 08H × 09H (8085 Microprocessor)

Given

  • Multiplicand = 08H
  • Multiplier = 09H
  • Product storage address = 8050H
  • Carry (higher byte) storage address = 8051H

Solution

Concept

The 8085 has no hardware multiply instruction, so multiplication is done by repeated addition: add the multiplicand (08H) to itself the number of times given by the multiplier (09H). Any carry beyond 8 bits is counted in a separate register.

Program

        LXI  H, 8050H   ; HL points to product location 8050H
        MVI  B, 08H     ; B = multiplicand (08H)
        MVI  C, 09H     ; C = multiplier / counter (09H)
        MVI  A, 00H     ; A = 00H (accumulate product low byte)
        MVI  D, 00H     ; D = 00H (accumulate carry / high byte)

LOOP:   ADD  B          ; A = A + B
        JNC  SKIP       ; if no carry, skip
        INR  D          ; else increment high byte
SKIP:   DCR  C          ; decrement counter
        JNZ  LOOP       ; repeat until C = 0

        MOV  M, A       ; store product low byte at 8050H
        INX  H          ; HL points to 8051H
        MOV  M, D       ; store carry / high byte at 8051H

        HLT             ; halt

Execution Trace

IterationA beforeADD B (08H)CarryD
100H08H000H
208H10H000H
310H18H000H
418H20H000H
520H28H000H
628H30H000H
730H38H000H
838H40H000H
940H48H000H

Verification

$$08H \times 09H = 8 \times 9 = 72_{10} = 48H$$

Since the result 72 fits in one byte (< 256), no carry is generated, so D = 00H.

Result in Memory

AddressContentMeaning
8050H48HProduct (low byte)
8051H00HCarry (high byte)

The final product is 48H with carry 00H.

Open this answer on its own page →

2080 · 5 marks

Write 8085 assembly language to add two numbers located at 2030H and 2040H. Store the sum in the address 2050H. [5]

  • First number is stored at memory address 2030H - Second number is stored at memory address 2040H - Store the result (sum) at memory address 2050H --- --- Step Instruction Operation ------------------------------ 1 LXI H, 2030H HL register pair points to address 2030H 2 MOV A, M Accumulator A = ...
Open this answer on its own page →

2079 · 5 marks

Write a 8085 assembly langauge for division of two 8-bit numbers by repeated subtraction method. [5]

Division by repeated subtraction works by repeatedly subtracting the divisor from the dividend until the result becomes zero or less than the divisor. The number of times subtraction is performed gives the quotient, and the remaining value is the remainder. --- Register Purpose ------------------...

Open this answer on its own page →

Instruction types and classification

2081 · 5 marks

Write an assembly language program to swap the content of memory location 8000H and 9000H using 8085 microprocessor instructions. [5]

To swap the contents of two memory locations, we need a temporary register to hold one value while we move the other. Steps: 1. Load the content of memory location 8000H into register A 2. Move it to register B (temporary storage) 3. Load the content of memory location 9000H into register A 4. St...

Open this answer on its own page →

2078 · 10 marks

What are different types of instructions available in 8085 microprocessor? Write a program to find smallest element of an array: (Assume all the necessary data and memory location).[10]

This is a conceptual + programming question. No numeric matrices given. Assumptions to be made by student: - Array base address, count location, result location, and sample data are all "assume as necessary." Chosen assumptions (standard): - Count of elements at 2050H = 05H - Array elements at 20...

Open this answer on its own page →

Instruction cycle and execution time

2079 · 5 marks

What is instruction cycle? If the clock frequency is 5 MHz, how much time is required to execute an instruction MVI A, 08H? [3+2]

  • Clock frequency: $f = 5 \text{ MHz} = 5 \times 10^6 \text{ Hz}$ - Instruction: MVI A, 08H (8085 microprocessor) --- An instruction cycle is the total time taken by a microprocessor to fetch, decode, and execute a single instruction. It represents one complete round of processing an instruction ...
Open this answer on its own page →