Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create an HLA function t hat often forces a value into both passed parameters. T

ID: 3668137 • Letter: C

Question

Create an HLA function that often forces a value into both passed parameters. This function should have the following signature:

procedure makeThirtyIfMoreTwelve( var i : int16; var j : int16 );@nodisplay; @noframe;

After calling this function, the value of both the driver’s variables should be changed to the value 30, if the values passed add up to more than 12. Your function should replicate the following C code:

void makeThirtyIfMoreTwelve( int * i, int * j ) {

if ( (*i) + (*j) > 12 )

*i = 30;
*j = 30;

}

}

To assist you with this task, I am offering you the following program template to use to create your solution. Of 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.

// Reference Parameter Template Solution For CS 17 Final
// CS 17 Students must use this template as the basis for
// their solution. I hope it will help simplify your
// development task.
// Please look at the two TODO: notes below

program ReferenceProgram;
#include( "stdlib.hhf" );
static iValue1 : int16 := 0;
iValue2 : int16 := 0;
// TODO: CS 17 Students add code below to implement this function
// Several hints are supplied
procedure makeThirtyIfMoreTwelve( var i : int16; var j : int16 );@nodisplay; @noframe;
static
dReturnAddress : dword;
begin makeThirtyIfMoreTwelve;

// entry sequence

// preserve registers used

pop( dReturnAddress );   // this is the return address

// push back the return address
push( dReturnAddress );

// preserve registers

// begin sub-task

// restore the registers used

ret();

end makeThirtyIfMoreTwelve;

begin ReferenceProgram;

mov( 11, iValue1 );
mov( 12, iValue2 );

// TODO: push parameters to the function.
// Please remember that these parameters must be passed by-reference.
call makeThirtyIfMoreTwelve;


stdout.put( "the first parameter = " );
stdout.put( iValue1 );
stdout.put( " the second parameter = " );
stdout.put( iValue2 );
stdout.newln();

end ReferenceProgram;

Explanation / Answer

program ReferenceProgram;
#include( "stdlib.hhf" );
static iValue1 : int16 := 0;
iValue2 : int16 := 0;
// TODO: CS 17 Students add code below to implement this function
dReturnAddress : dword;
push( dReturnAddress );
makeThirtyIfMoreTwelve(13,14)
// Several hints are supplied
procedure makeThirtyIfMoreTwelve( var i : int16; var j : int16 );@nodisplay; @noframe;
static
dReturnAddress : dword;
begin makeThirtyIfMoreTwelve;
// entry sequence
// preserve registers used
pop( dReturnAddress ); // this is the return address
// push back the return address
push( dReturnAddress );
// preserve registers


// begin sub-task
// restore the registers used
ret();


end makeThirtyIfMoreTwelve;
begin ReferenceProgram;
mov( 11, iValue1 );
mov( 12, iValue2 );

// TODO: push parameters to the function.
makeThirtyIfMoreTwelve(19,21)
// Please remember that these parameters must be passed by-reference.
call makeThirtyIfMoreTwelve;

stdout.put( "the first parameter = " );
stdout.put( iValue1 );
stdout.put( " the second parameter = " );
stdout.put( iValue2 );
stdout.newln();


end ReferenceProgram;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote