Question: help with the following program. Please look at the hints that are at the end of the program. I have completed this assigment but the

help with the following program. Please look at the "hints" that are at the end of the program. I have completed this assigment but the only issue is that I was not able to make it work with a procedure function, which is required for this assigment.
PROGRAM 8: multiplesOfAnother Function
Write an HLA Assembly language program that implements the following function:
procedure multiplesOfAnother( i: int32; j : int32); @nodisplay; @noframe;
This function should return into EAX the value 1 if the parameters are multiples of one another; otherwise, return into EAX the value 0. In order to receive full credit, you should be preventing register corruption by preserving and then restoring the value of any register your function touches. This rule applies to every register except for EAX which is being used to pass an answer back to the calling code.
Feed Me i: 10
Feed Me j: 20
EAX =1
Feed Me i: 7
Feed Me j: 30
EAX =0
Feed Me i: 20
Feed Me j: 10
EAX =1
Feed Me i: 30
Feed Me j: 7
EAX =0
Hint: Since we haven't learned how to do much math (coming soon...), I am assuming you will keep adding the smaller value to itself over and over again until you reach the bigger amount
Below is the code I have so far without the procedure function, which I need help implementing.
program MultiplesOfAnother;
#include( "stdlib.hhf")
static
i : int32;
j : int32;
temp : int32;
begin MultiplesOfAnother;
stdout.put("Feed Me i: ");
stdin.get(i);
stdout.put("Feed Me j: ");
stdin.get(j);
push(ebx);
push(ecx);
push(edx);
mov(i, ecx); // Move i to ECX
mov(j, ebx); // Move j to EBX
mov(0, eax); // Initialize EAX to 0(not multiple)
cmp(ecx, ebx);
jle checkMultiple;
checkMultiple:
mov(ecx, temp);
add(ecx, temp);
checkLoop:
cmp(ebx, temp);
je multipleFound;
add(ecx, temp);
cmp(ebx, temp);
jg checkLoop;
jmp done;
multipleFound:
mov(1, eax); // Set EAX to 1
done:
// Restore registers
pop(edx);
pop(ecx);
pop(ebx);
stdout.put("EAX =");
stdout.puti32(eax);
stdout.newln();
end MultiplesOfAnother;

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!