Program to find the GCF of two numbers


8.Program to find the GCF of two numbers :

mov dptr,#9000h ;Load 9000h into dptr register
movx a,@dptr ; move data from external memory location to a
mov b,a ; move data from a to b
inc dptr ;increment dptr
movx a,@dptr ; move data from external memory location to a
back:mov r1,b ;move data from b to r1
div ab ;divide a by b
mov a,b ;move data from b to a
jz mess ;if a=0, jump to label mess
mov a,r1 ;move data from r1 to a
jmp back ;jump to label back
mess:mov dptr,#9005h ;Load dptr with immediate data 9005h
mov a,r1 ;move data from r1 to a
movx @dptr,a ;move data from a to external memory location
here:sjmp here
end
Input: 05 02
Output:01


Web Statistics