Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How can I fix my code? program multiples; #include ( stdlib . hhf ) ; static Value 1 : int 3 2 :

How can I fix my code?
program multiples;
#include("stdlib.hhf");
static
Value1 : int32 :=0;
Value2 : int32 :=0;
procedure multiplesOfAnother(i: int32; j: int32); @nodisplay; @noframe;
static
returnAddress : dword;
temp: int32;
begin multiplesOfAnother;
pop( returnAddress );
pop( j );
pop( i );
push( returnAddress );
//initial check if the values are zero or negative
cmp( j,1);
jl NotMultiple;
cmp( i,1);
jl NotMultiple;
mov( i, ebx );
mov( j, ecx );
//determine which i and j is bigger
cmp( ebx, ecx );
jg Smalleri; //if i is greater than j jump to samlleri loop
jl Smallerj; //if i is smaller than j jump to smallerj loop
je YesMultiples; //if i is equal to j jump to equal loop
Smalleri:
mov( ebx, edx ); //set i to the edx register
add( ebx, edx ); //add i
cmp( ecx, edx ); //compare with j
jg NotMultiples; //if j is greater than multiples of i, exit with EDX=0
je YesMultiples; //if j is equal to multiples of i, exit with EDX=1
jmp Smalleri; //otherwise, keep adding
Smallerj:
mov( ecx, edx ); //set j to the edx register
add( ecx, edx ); //add j
cmp( ebx, edx ); //compare with i
jg NotMultiples;
je YesMultiples;
jmp Smallerj;
YesMultiples:
mov(1, eax );
jmp EndProcedure;
NotMultiples:
mov(0, eax );
jmp EndProcedure;
EndProcedure:
ret();
end multiplesOfAnother;
begin multiples;
stdout.put( "Feed me i : ");
stdin.get( Value1);
stdout.put( "Feed me j : ");
stdin.get( Value2);
push( Value1);
push( Value2);
call multiplesOfAnother;
//Check the result
cmp( eax, 1);
je Yes;
jmp No;
Yes:
stdout.put("EAX =", eax, nl);
jmp EndProgram;
No:
stdout.put("EAX =", eax, nl);
jmp EndProgram;
EndProgram:
stdout.newln();
end multiples;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions