Question: endsInSeven Write an HLA Assembly language program that implements a function which correctly identifies if both values end in seven and return returns a boolean
endsInSeven
Write an HLA Assembly language program that implements a function which correctly identifies if both values end in seven and return returns a boolean value in AL when both end in seven; otherwiseHINT: You can perform this operation by repetitively subtracting ten from the value. If you wind up hitting seven before you hit zero, then the value originally ended in seven
This function should have the following signature:
procedure endsInSeven x: int; y: int; @nodisplay; @noframe;
In order to receive full credit, you must pass your parameters on the runtime stack and 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 AL which is being used to pass an answer back to the calling code.
Feed Me X:
Feed Me Y:
Not ending in seven. AL
Feed Me X:
Feed Me Y:
Both ending in seven. AL
Feed Me X:
Feed Me Y:
Not ending in seven. AL
I want it in HLA and be able to run it in HLAbat and I provide instructions and sample program:
program RecursiveThree;
#include "stdlib.hhf;
static
iDataValue : int :;
iDataValue : int :;
Function isDivideableByThreeRec
procedure isDivideableByThreeRec n : int; @nodisplay; @noframe;
static
returnAddress : dword;
temp: int;
begin isDivideableByThreeRec;
this procedure returns its answer in EAX, so we don't need to save that
register. No other register is used, so no other registers need to be saved
get params from stack
pop returnAddress ;
pop temp ; padding stack must be bit aligned
pop n ;
push returnAddress ;
cmp n; if n return true
je ReturnTrue;
cmp n; if n return false
jle ReturnFalse;
jmp Neither; else isDivideableByThreeRec n
ReturnTrue:
mov EAX ; return true
jmp ExitSequence;
ReturnFalse:
mov EAX ; return false
jmp ExitSequence;
Neither:
sub n ; n
calling isDivideableByThreeRec n;
push n ;
push temp ; padding
call isDivideableByThreeRec;
jmp ExitSequence;
ExitSequence:
ret;
end isDivideableByThreeRec;
main program
begin RecursiveThree;
stdout.put "Gimme an n: ;
stdin.get iDataValue;
push iDataValue;
push iDataValue; padding
call isDivideableByThreeRec;
this function leaves the answer in EAX
cmpEAX;
je ISDIVISIBLE;
jmp NOTDIVISIBLE;
ISDIVISIBLE:
stdout.puttruenl;
jmp EndProgram;
NOTDIVISIBLE:
stdout.putfalsenl;
jmp EndProgram;
stdout.newln;
EndProgram:
Assembly Language Instructions
Instruction Syntax Description MOV mov source, dest ; dest source; ADD add source, dest ; dest source; SUB sub source, dest ; dest source; SHL shl count, dest ; shuffles left a total of count bits in dest operand; sets carry when count SHR shr count, dest ; shuffles right a total of count bits in dest operand; sets carry when count SAR sar count, dest ; shuffles right a total of count bits in dest operand; sets carry when count; leaves HO bit unchanged ROL rol count, dest ; rotates left a total of count bits in dest operand; sets carry when count ROR ror count, dest ; rotates right a total of count bits in dest operand; sets carry when count NOT not dest ; inverts the bits of the dest operand AND and source, dest ; bitwise logical AND; result placed in dest operand OR or source, dest ; bitwise inclusive OR; result placed in dest operand XOR xor source, dest ; bitwise exclusive OR; result placed in dest operand LAHF lahf; pushes the lower bits of EFLAGS register into AH INC inc operand ; operand operand ; DEC dec operand ; operand operand ; CMP cmp lhs rhs ; sets EFLAGS as if lhsrhs was performed; does not change the value of either operand TEST test operand operand; sets EFLAGS as if AND operand operand was performed; does not change the value of either operand NEG neg dest ; JMP jmp label; jmpbitregister; jmp dword ; unconditional transfer of control. Note the inconsistent use of parentheses. SETcc setccbitoperand; reads an EFLAG bit into a byte operand. Mnemonics listed below.
Available Datatypes
int
int
int
uns
uns
uns
boolean
Available IO
Routines
stdout.put
stdout.puti
stdout.puti
stdout.puti
stdout.putb
stdout.putw
stdout.putd
stdout.putuns
stdout.putuns
stdout.putuns
stdout.newln
JMP
jmp label; jmp bitregister; jmp dword;
unconditional transfer of control. Note the inconsistent use of parentheses.
SETcC setccbitoperand;
reads an EFLAG bit into a byte operand. Mnemonics listed below.
JCc jcc label;
transfers control to label when condition is met. Mnemonics listed below.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
