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

!!!Must use HLA please!!! Create an HLA function t hat often forces a value into

ID: 3668166 • Letter: #

Question

!!!Must use HLA please!!!

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;

Comment

Expert Answer

Was this answer helpful?

0

0

66 answers

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;

!!!Must use HLA please!!!

Explanation / Answer

   makeThirtyIfMoreTwelve(int *i,int *j)
   {
       if(((*i)+(*j))>12)
       {
           *i=30;
           *j=30;
           stdout.put("Changed to 30");
       }

   }
  
   This can be converted to Assembly Language Program like this:
   sum $r1, $r2, L1 # (0) put R[1] + R[2] in L1
jle L1,12       # go to L2 if greater than 12
L2: mov $r1, 30 # set R1 and R2 to 30
   mov $r2,30

Please see if this helps. Let me know if more details are required. :)