8085 is a very basic microprocessor with the capability of limited arithmetic and logical operations. It has dedicated arithmetic instructions for addition, subtraction, increment and decrement. If we want to perform a multiplication operation then we need to write a program for it. Multiplication is nothing but repeated addition. This post presents assembly language program for the multiplication of two 8-bits numbers with the illustration of 3 different cases.

The maximum result from the multiplication of two 8-bit numbers can be up-to 16-bits.

FF_{H} x FF_{H} = FE01_{H}

The following three cases can arise for the multiplication of different 8-bit numbers:

(i) The generated result is a 8-bit number

eg: 02_{H} x 03_{H} = 06_{H}

(ii) The generated result is a 9-bit number with “1” at the ninth bit

eg: FF_{H} x 02_{H} = 1FE_{H}

(iii) The generated result is lager than 9-bit number

eg: A7_{H} x F2_{H} = 9DDE_{H}

You might find Different Coding Styles of Verilog Language interesting

Let’s start with the 1st case and move on to the 3rd case:

**The generated result is a 8-bit number:**

// Manually store the multiplicand and the multiplier in the memory locations 4200H & 4201H respectively // For this case let's say multiplicand = 03H and the multiplier = 04H // Store the result in the memory location 4202H and 4203H // For this Example result will be 03H x 04H = 0CH // 4202<-00H, 4203<-0CH #ORG 0000H #BEGIN 0000H LDA 4200H // Fetched the Multiplicand MOV B,A LDA 4201H // Fetched the Multiplier MOV D,A MVI A,00H // Cleared the Acuumulator for multiple addition of the Multiplicand L1: ADD B DCR D JNZ L1 // Repeated Addition for multiplication STA 4203 HLT #ORG 4200H #DB 03H, 04H

Now when you would run the program it would give you the memory locations with the following values

**Memory Location**

**Input**

4200 4201

03 04

**Output**

4202 4203

00 0C

In this case we get 00_{H} in 4202_{H} as there is no carry generated in this example. Let’s consider the 2^{nd} case example (FF_{H} x 02_{H} = 1FE_{H}) where a carry would be generated. The above program would generate the result as FE_{H} but the carry would be 00_{H}. Let’s modify the program to deal with this type of situation.

**The generated result is a 9-bit number with “1” at the ninth bit:**

// For this case let's say multiplicand = FFH and the multiplier = 02H // Result would be FFH x 02H = 1FEH // 4202<-01H, 4203<-FEH #ORG 0000H #BEGIN 0000H MVI C,00H // Preserves the Carry LDA 4200H // Fetched the Multiplicand MOV B,A LDA 4201H // Fetched the Multiplier MOV D,A MVI A,00H // Cleared the Acuumulator for multiple addition of the Multiplicand L1: ADD B DCR D JNZ L1 // Repeated addition for multiplication JNC L2 // Jump if no carry generated INR C L2: STA 4203 MOV A,C STA 4202 HLT #ORG 4200H #DB FFH, 02H

Now when you would run the program it would give you the memory locations with the following values

**Memory Location**

**Input**

4200 4201

FF 02

**Output**

4202 4203

01 FE

In this case we get 01_{H} in 4202_{H} as there is a single carry generated in this example. Let’s consider the 3^{rd} case example (A7_{H} x F2_{H} = 9DDE_{H}) where multiple carries would be generated during the repeated additions. The above program would generate the result as DE_{H} but the carry would be 01_{H}. Let’s modify the program to deal with this type of situation.

**The generated result is lager than 9-bit number:**

// For this case let's say multiplicand = A7H and the multiplier = F2H // Result would be A7H x F2H = 9DDEH // 4202<-9DH, 4203<-DEH #ORG 0000H #BEGIN 0000H MVI C,00H // Preserves the Carry LDA 4200H // Fetched the Multiplicand MOV B,A LDA 4201H // Fetched the Multiplier MOV D,A MVI A,00H // Cleared the Acuumulator for multiple addition of the Multiplicand L1: ADD B JC L2 // Jump if carry generated DCR D JNZ L1 // Repeated addition for multiplication JMP L3 // Jump after the repeated additions get completed L2: INR C DCR D JNZ L1 L3: STA 4203 MOV A,C STA 4202 HLT #ORG 4200H #DB A7H, F2H

**Memory Location**

**Input**

4200 4201

A7 F2

**Output**

4202 4203

9D DE

**Note:** The above Hex codes have been assembled and simulated on **Jubin’s 8085 Simulator**.

Hope the post would help you. If any doubt, please mention the same in the comment section, we would revert back to you.