answersLogoWhite

0


Best Answer

This is my program, and it works with all no.s except multiples of 2.

org 100h

MOV CX,0000H

MOV DS,CX

MOV SS,CX

MOV SI,5000H

MOV DI,5002H

MOV [ DS:SI ],10H

MOV [ DS:DI ],20H

MOV SP,600FH

MOV BX,[ DS:SI ]

CMP BX,[ DS:DI ]

JZ E1

JC SMALL

THIK: MOV BX,0001H

OK: MOV AX,[ DS:SI ]

MOV DX,0000H

DIV BX

CMP DX,0000H

JZ L1

L2: INC BX

CMP [ DS:DI ],BX

JC HCF

JMP OK

SMALL: MOV AX,[ DS:DI ]

MOV [ DS:DI ],BX

MOV [ DS:SI ],AX

JMP THIK

L1: MOV AX,[ DS:DI ]

DIV BX

CMP DX,0000H

JNZ L2

PUSH BX

INC CX

JMP L2

HCF: MOV AX,0001H

AGAIN: POP BX

MUL BX

DEC CX

JNZ AGAIN

LCM: MOV BX,AX

MOV AX,[ DS:SI ]

MUL [ DS:DI ]

DIV BX

E1 : INC DI

INC DI

MOV [ DS:DI ],AX

ret

User Avatar

Wiki User

6y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Program to find GCF and LCM of 2 numbers in 8086?
Write your answer...
Submit
Still have questions?
magnify glass
imp