0% found this document useful (0 votes)
13 views6 pages

Name of Program:-: ALP To Perform Multiplication Two 16 Bit Numbers

The document outlines an assembly language program designed to multiply two 16-bit numbers, storing the result in DX:AX. It includes an algorithm detailing the steps for initialization, looping through the multiplication process, and saving the result. Additionally, it provides a flowchart and memory table showing the machine code and data before and after execution.

Uploaded by

atharvanichat420
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views6 pages

Name of Program:-: ALP To Perform Multiplication Two 16 Bit Numbers

The document outlines an assembly language program designed to multiply two 16-bit numbers, storing the result in DX:AX. It includes an algorithm detailing the steps for initialization, looping through the multiplication process, and saving the result. Additionally, it provides a flowchart and memory table showing the machine code and data before and after execution.

Uploaded by

atharvanichat420
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Name of Program :-

ALP to perform Multiplication two 16 bit numbers

Algorithm:-
Input:
• Two 16-bit numbers (e.g., stored in registers or memory)
Output:

• Product in DX:AX
• Steps:
START

1. Initialize:
BL ← 0
AX ← 0000
SI ← 1300
DI ← 1302
Carry ← 0

2. Move multiplier into CL:


CL ← [1300] ; Load multiplier from memory address 1300
SI ← SI + 1 ; Point to next location (multiplicand)

3. LOOP:
AL ← AL + [SI] + Carry ; Add multiplicand and carry to AL
CL ← CL - 1 ; Decrement multiplier

4. Check if multiplier is zero:


IF CL ≠ 0 THEN
GOTO LOOP

5. IF Carry = 1 THEN
BL ← BL + 1 ; Increment Carry register
6. SAVE:
[DI] ← AL ; Store result low byte at memory pointed by DI
DI ← DI + 1 ; Increment destination pointer
[DI] ← BL ; Store carry (high byte) at next memory location

STOP

Flowchart :-
Program :-
.MODEL SMALL
.STACK 100H

.DATA
MULTIPLIER DW 3 ; First number (e.g., 3)
MULTIPLICAND DW 5 ; Second number (e.g., 5)

RESULT_LOW DW 0 ; Lower 16 bits of the result


RESULT_HIGH DW 0 ; Higher 16 bits (carry/overflow)

.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX ; Initialize data segment

MOV BX, MULTIPLIER ; BX = Multiplier (loop counter)


MOV CX, MULTIPLICAND ; CX = Multiplicand

XOR AX, AX ; AX will store result (low word)


XOR DX, DX ; DX will store high word (carry)

LOOP_START:
CMP BX, 0
JE END_LOOP ; If BX == 0, multiplication is done

ADD AX, CX ; Add multiplicand to result


JNC SKIP_CARRY ; If no carry, skip
INC DX ; Else, increment high word

SKIP_CARRY:
DEC BX ; Decrement loop counter
JMP LOOP_START

END_LOOP:
MOV RESULT_LOW, AX ; Store result low word
MOV RESULT_HIGH, DX ; Store result high word

MOV AH, 4CH ; Exit program


INT 21H
MAIN ENDP
END MAIN
OUTPUT:
Memory Table
Memory
Machine
Address Label Instruction Comment
Code
(CS:IP)
Load address of
2000 B8 00 13 MOV AX, @DATA
data segment
2003 8E D8 MOV DS, AX Move to DS
8B 1E 00 MOV BX,
2005 Load multiplier
13 MULTIPLIER
8B 0E 02 MOV CX,
2009 Load multiplicand
13 MULTIPLICAND
Clear AX (result
200D 31 C0 XOR AX, AX
low)
Clear DX (result
200F 31 D2 XOR DX, DX
high)
2011 LOOP_START: Start of loop
Check if multiplier
2011 83 FB 00 CMP BX, 00
is 0
2014 74 0A JE END_LOOP If yes, jump to end
Add multiplicand
2016 03 C1 ADD AX, CX
to result
2018 73 02 JNC SKIP_CARRY Jump if no carry
Increment DX
201A 42 INC DX
(carry)
Label for skipping
201B SKIP_CARRY:
carry
Decrement
201B 4B DEC BX
multiplier
201C EB F3 JMP LOOP_START Loop back
201E END_LOOP: End label
MOV
201E A3 04 13 Store low part
RESULT_LOW, AX
89 16 06 MOV
2021 Store high part
13 RESULT_HIGH, DX
2025 B4 4C MOV AH, 4CH Exit program
2027 CD 21 INT 21H DOS interrupt
Data Before Execution

Value
Variable Address Description
(Hex)
MULTIPLIER 1300H 0003 The number of times to add
MULTIPLICAND 1302H 0005 The number to be added
RESULT_LOW 1304H 0000 Lower 16-bit result (initially 0)
Higher 16-bit result (carry,
RESULT_HIGH 1306H 0000
initially 0)

Data After Execution

Variable Value (Decimal) Value (Hex)


MULTIPLIER 3 0003h
MULTIPLICAND 5 0005h
RESULT_LOW 15 000Fh
RESULT_HIGH 0 0000h

You might also like