2082 4

BIT151 · 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.

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]

Microprocessor and Computer ArchitectureChapter 2: Instruction Set and Addressing ModesArithmetic instructions with examplesNumerical: 8085 assembly multiplication program

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.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.