Question: how can I fix my code to detect if it has no multiple for example: Feed Me i: 7 Feed Me j: 3 0 EAX

how can I fix my code to detect if it has no multiple for example:
Feed Me i: 7
Feed Me j: 30
EAX =0
Feed Me i: 30
Feed Me j: 7
EAX =0
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); // EBX will hold the value of i
mov(j, ECX); // ECX will hold the value of j
// 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); // Swap so that ECX is always the larger
mov(EBX, EDX); // Start with the smaller value in EDX
START_ADDING:
// Loop to add the smaller number to itself and compare
add(EDX, EDX); // Double the smaller number
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!