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. 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
This is what I tried
program multiplesOfAnother;
#include("stdlib.hhf");
procedure themultiplesOfAnother( i : int32; j : int32);
@nodisplay;@noframe;
begin themultiplesOfAnother;
POP(EDX);
PUSH(EDX);
mov(i, EAX);
cmp(j, EAX);
jne ReturnZero;
mov(0, EAX);
jmp ExitSequence;
ReturnZero:
mov(1, EAX);
ExitSequence:
ret();
end themultiplesOfAnother;
begin multiplesOfAnother;
stdout.put("Feed me i: ");
stdin.geti32();
push(eax);
stdout.put("Feed me j: ");
stdin.geti32();
push(eax);
call themultiplesOfAnother;
cmp(EAX, 1);
jne NumbersAreDifferent;
stdout.put("EAX = 1");
jmp EndProgram;
NumbersAreDifferent:
stdout.put("EAX = 0");
EndProgram:
end multiplesOfAnother;
The output I am keep getting is:
Feed me i: 10
Feed me j: 20
EAX = 0
This is What I am expecting:
Feed Me i: 10
Feed Me j: 20
EAX = 1
Feed Me i: 7
Feed Me j: 30
EAX = 0