I don’t understand why my code outputs The values don’t increase even though I input increasing values for example
Enter a value: 2
Enter a value: 4
Enter a value: 10
The values don’t increase
I also don’t understand what this means
“after returning back to the caller, your function should not change the value of any register other than DX”.
program IncreasingCheck;
#include( "stdlib.hhf" );
static
value1: int8;
value2: int8;
value3: int8;
procedure increasing( valuel : int8; value2 : int8; value3 : int8 ); @nodisplay; @noframe;
begin increasing;
// Checking if value2 is greater than value1
mov( valuel, AL );
mov( value2, BL );
mov( value3, CL );
cmp( AL, BL );
jge NotIncreasing;
// Checking if value3 is greater than value2
cmp( BL, CL );
jge NotIncreasing;
// If both conditions are true, it's increasing
mov( 1, DX );
jmp Done;
NotIncreasing:
mov( 0, DX );
Done:
ret();
end increasing;
begin IncreasingCheck;
stdout.put( "Enter a value: " );
stdin.get( value1 );
stdout.put( "Enter a value: " );
stdin.get( value2 );
stdout.put( "Enter a value: " );
stdin.get( value3 );
// Call the increasing procedure
call increasing;
// Output result
cmp(DX, 1);
je Increase;
jmp NoInc;
Increase:
stdout.put( "The values increase!" );
jmp EndProgram;
NoInc:
stdout.put( "The values don't increase" );
EndProgram:
end IncreasingCheck;
New contributor
Hooray is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.