Write an HLA Assembly language program that prompts for two integers from the user. Create and call a function that accepts these two values and then determines if these values both have the same ending digit. Sets DX to one if the values both have the same ending digit; otherwise, set DX to zero. In order to receive full credit, after returning back to the caller, your function should not change the value of any register other than DX. Implement the function whose signature is: procedure sameEndingDigit( value1 : int8; value2 : int8 ); @nodisplay; @noframe;
Here are some example program dialogues s:
Provide a value: 333
Provide a value: 18
sameEndingDigit returned false!
Provide a value: 88
Provide a value: 338
sameEndingDigit returned true!
\This is What I tried:
program Same;
#include( "stdlib.hhf" )
procedure SameEndingDigit( value1 : int8; value2 : int8 ); @nodisplay; @noframe;
begin SameEndingDigit;
mov( value1, AL );
mov( value2, BL );
cmp( AL, BL );
je sameEnding;
mov( 0, DX );
ret();
sameEnding:
mov( 1, DX );
ret();
NotsameEnding:
mov( 0, DX );
ret();
end SameEndingDigit;
begin Same;
stdout.put( "Provide a value: " );
stdin.get( EAX );
stdout.put( "Provide a value: " );
stdin.get( EAX );
SameEndingDigit( AL, BL );
je notSame;
stdout.put( "sameEndingDigit returned true!", nl );
jmp endProgram;
notSame:
stdout.put( "sameEndingDigit returned false!", nl );
jmp endProgram;
endProgram:
end Same;
This is What I am keep getting for my output:
Provide a value: 333
Provide a value: 18
sameEndingDigit returned true!
Provide a value: 88
Provide a value: 338
sameEndingDigit returned true!
whether I give values (1, DX) for the function same and (0, DX) as for the function not same , It is both giving me same result as shown above. I am having difficulty to understand where the code is wrong.
Amrat Bibi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.