EXPERIMENT NUMBER 10
EXPERIMENT NUMBER 10
TITLE :
Write an Assembly Language Program to find the GCD of two 16 bit unsigned
numbers
Example:
Algorithm;
Flowchart:
Start
Y
Is no 1= no 2 ?
N
Y
Is no 1 >no 2 ?
N
Interchange contents
DX = 0000H
Y
Is Rem = 0 ?
N
Move remainder into AX
Stop
Program:
.MODEL SMALL
.DATA
NO1 DW 0120
NO2 DW 0090
GCD DW 0H
.CODE
MOV AX,@DATA
MOV DS, AX
MOV AX,NO1
MOV BX,NO2
JE FINISH
JB EXCHG
DIV BX
CMP DX,0
JE FINISH
MOV AX,DX
JMP AGAIN
JMP UP
jbe L2
int 21h
jnz L1
mov ah,4ch
int 21h
END
CONCLUSION: Program executed to find GCD of the given numbers and output is verified.