📚 Assembly Language Multiplication

Interactive Guide to Binary Multiplication Programming

📖 Overview
🔄 Flowchart
💾 Program Code
🧮 Example

🎯 Objective

Understand the step-by-step process of multiplying two positive binary numbers using an assembly-level algorithm.

⚡ Key Concepts

🎯 X - Multiplicand

The number to be multiplied. This value remains relatively stable during the process but gets shifted left as we progress through each bit.

🔢 Y - Multiplier

The number by which we multiply. Its bits are examined one by one to determine whether to add the multiplicand to the partial product.

✨ P - Product

The result formed during the multiplication process. Starts at zero and accumulates the final result through repeated additions.

🧠 Core Principle

This program performs multiplication using bit manipulation and repeated addition, simulating manual binary multiplication efficiently for early computers without hardware multiplication units.

🔄 Flowchart

Multiplication

🧠 Analysis

1 Initialize Variables:
• Set counter CTR ← 8 (handling 8 bits)
• Initialize P ← 0 (Product starts at zero)
• Initialize E ← 0 (Extra bit)
2 Load Multiplier:
• AC ← Y (Load multiplier into accumulator)
3 Circular Shift Right:
• Perform cir EAC (Shift E with AC right as a group, so least significant bit of AC is move to E)
4 Transfer Bit:
• Y ← AC (Bit shifted out of Y is stored in E)
5 Conditional Addition:
• If E == 1: Add X (Multiplicand) to P (Product)
• Else: Skip addition step
6 Clear E Bit:
• Reset E ← 0
7 Shift Multiplicand Left:
• AC ← X, then perform cil EAC
• X ← AC (Update shifted multiplicand)
8 Decrement Counter:
• CTR ← CTR - 1
9 Loop Check:
• If CTR ≠ 0: Repeat from step 2
• Else: Halt program (multiplication complete)

💾 Assembly Program Code

Complete assembly listing with detailed comments:

     ORG 100 ; Start program at address 100

LOP, CLE ; Clear E (Extra bit register)
     LDA Y ; Load multiplier into AC
     CIR ; Circular shift right
     STA Y ; Store shifted multiplier
     SZE ; Check if E == 0
     BUN ONE ; Branch to ONE if E == 1
     BUN ZRO ; Branch to ZRO if E == 0

ONE, LDA X ; Load multiplicand into AC
     ADD P ; Add partial product to AC
     STA P ; Store result back into P
     CLE ; Clear E register again

ZRO, LDA X ; Load multiplicand
     CIL ; Circular shift left
     STA X ; Store shifted multiplicand
     ISZ CTR ; Increment counter
     BUN LOP ; Repeat loop if counter ≠ 0
     HLT ; Halt program when done

CTR, DEC -8 ; Initialize counter with -8
  X, HEX 000F ; Multiplicand storage
  Y, HEX 000B ; Multiplier storage
  P, HEX 0 ; Product storage
     END ; End of program

🔧 Instruction Breakdown

CLE - Clear E

Clears the extra bit register E to 0, preparing for the next operation.

CIR/CIL - Circular Shifts

CIR shifts right, CIL shifts left. These preserve bits by moving them in a circular fashion.

SZE - Skip if Zero

Tests if the E register is zero and skips the next instruction if true.

ISZ - Increment and Skip

Increments the counter and skips the next instruction if the result is zero.

🧮 Binary Multiplication Example

Let's trace through multiplying 15 (1111₂) by 11 (1011₂):

Initial Values:

X (Multiplicand): 0000 1111
Y (Multiplier): 0000 1011
P (Product): 0000 0000
Step X (Multiplicand) Y (Multiplier) P (Product) E Bit Action
Initial 0000 1111 0000 1011 0000 0000 0 Setup
1 0001 1110 0000 0101 0000 1111 1 Add X to P
2 0011 1100 0000 0010 0010 1001 1 Add X to P
3 0111 1000 0000 0001 0010 1001 0 Skip addition
4 1111 0000 0000 0000 1010 0101 1 Add X to P

✅ Final Result

15 × 11 = 165

Binary: 1010 0101₂ = 165₁₀