Question: how can I fix my code to detect if it has no multiple for example ( cant use division or multiplication operator ) : Feed

how can I fix my code to detect if it has no multiple for example(cant use division or multiplication operator):
Feed Me i: 7
Feed Me j: 30
EAX =0
Feed Me i: 30
Feed Me j: 7
EAX =0
the output i get is
Input a number: 30
Input a number: 7
EAX =1
how can i fix it?
program multiples;
#include("stdlib.hhf");
static
iDataValue1 : int32 :=0;
iDataValue2 : int32 :=0;
procedure multiplesOfAnother( i: int32; j: int32); @nodisplay; @noframe;
begin multiplesOfAnother;
// Preserving registers
push(EBX);
push(ECX);
push(EDX);
// Initialize EAX to 0(default return value)
mov(0, EAX);
// Assign parameters to registers for manipulation
mov(i, EBX);
mov(j, ECX);
// Determine the smaller and larger values
cmp(EBX, ECX);
jg LARGER_IS_EBX; // Jump if EBX > ECX
// If we reach here, ECX is larger or they are equal
mov(EBX, EDX); // Start with the smaller value in EDX
jmp START_ADDING;
LARGER_IS_EBX:
xchg(EBX, ECX);
mov(EBX, EDX);
START_ADDING:
add(EDX, EDX);
cmp(EDX, ECX);
je ARE_MULTIPLES; // If they are equal, they are multiples
jl START_ADDING; // If EDX is still less, keep adding
ARE_MULTIPLES:
mov(1, EAX); // Set EAX to 1 to indicate they are multiples
end multiplesOfAnother;
begin multiples;
stdout.put( "Input a number: ");
stdin.get( iDataValue1);
push( iDataValue1);
push( iDataValue2);
call multiplesOfAnother;
// this function leaves the answer in EAX
cmp(EAX,1);
je Multiple;
jmp NotMultiple;
Multiple:
stdout.put("EAX =1");
jmp EndProgram;
NotMultiple:
stdout.put("EAX =0",nl);
jmp EndProgram;
stdout.newln();
EndProgram:
end multiples;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!