Question: Create an HLA function that forces a value into a passed parameters under certain circumstances. The parameters are being passed by - reference and are
Create an HLA function that forces a value into a passed parameters under certain circumstances. The parameters are being passed byreference and are intended to change the value of callers variables.
This function should have the following signature:
procedure makeOddByAddingOne var i : int;@nodisplay; @noframe;
After calling this function, the value of the drivers variables should be set to an odd value equal to one more that it started with if it was originally an even value. Your function should replicate the following C code:
void makeOddByCreate an HLA function that forces a value into a passed parameters under certain circumstances. The parameters are being passed byreference and are intended to change the value of callers variables.
This function should have the following signature:
procedure makeOddByAddingOne var i : int;@nodisplay; @noframe;
After calling this function, the value of the drivers variables should be set to an odd value equal to one more that it started with if it was originally an even value. Your function should replicate the following C code:
void makeOddByAddingOne int i
int value i;
after enough subtractions, value will be either or
while value
value value ;
now value is either or
was i originally even?? if so then add one
if value
value i;
value value ;
i value;
YOU MUST USE THE TEMPLATE SOLUTION SUPPLIED BELOWOf course, you will need to add code to the function to implement the desired algorithm explained above. In addition, you will need to prepare and push the parameters to the function.
I hope it will help simplify your development task.
Please look at the two TODO: notes below
programReferenceProgram;
#include "stdlib.hhf;
static
iValue : int :;
TODO: Add code below to implement this function
Several hints are supplied
procedure makeOddByAddingOne var i : int;@nodisplay; @noframe;
static
dReturnAddress : dword;
begin makeOddByAddingOne;
entry sequence
preserve registers used
pop dReturnAddress ; this is the return address
process the passed reference parameters
push back the return address
push dReturnAddress ;
preserve registers
begin subtask
restore the registers used
ret;
end makeOddByAddingOne;
beginReferenceProgram;
stdout.put "gimme a value: ;
stdin.get iValue;
TODO: push parameters to the function.
Please remember that these parameters must be passed byreference.
call makeOddByAddingOne;
stdout.put "after makeOddByAddingOne!" ;
stdout.newln;
stdout.put "iValue;
stdout.put iValue;
stdout.newln;
endReferenceProgram;
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
