Question: Create an ( HLA languge) function that checks whether a desired value is not a factor of another number. For example, the factors of the

Create an (HLA languge) function that checks whether a desired value is not a factor of another number. For example, the factors of the number 12 happen to be 1, 12, 3, 4, 2 and 6 because 1 * 12 = 12, 3 * 4 = 12 and 2 * 6 = 12 but 7 and 8 are not.

This function should have the following signature: procedure isNotFactor( value : int16; notAFactor : int16 );@nodisplay; @noframe; This function should return a boolean value of true if the notAFactor parameter is a not factor of the value parameter. Your function should replicate the following C code: bool isNotFactor( int value, int notAFactor ) {

bool result = true;

if (notAFactor > 0) { while (value > 0) {

value = value - notAFactor; // eventually we will hit 0 or a negative number... }

// if we hit zero, then the notAFactor really was a factor of value!

if (value == 0) result = false;

}

return( result );

}

IN ORDER TO RECEIVE FULL CREDIT, YOU CANNOT USE MULTIPLY OR DIVIDE INSTRUCTIONS. Instead, please loop as shown above.

IN ORDER TO RECEIVE FULL CREDIT, YOU MUST USE THE TEMPLATE SOLUTION SHOWN BELOW. 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.

// isNotFactor 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 isNotFactorProgram; #include( "stdlib.hhf" ); static

iValue: int16 := 0; iFactor: int16 := 0; iAnswer : int32 := 0;

// TODO: CS 17 Students add code below to implement this function // Several hints are supplied procedure isNotFactor( value : int16; desiredFactor : int16 );@nodisplay; @noframe;

static dReturnAddress : dword;

begin isFactor;

// 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

// leave the answer in EAX

ret();

end isNotFactor;

begin isNotFactorProgram;

mov( 16, iValue); mov( 7, iFactor ); // TODO: push parameters to the function.

call isNotFactor;

mov( EAX, iAnswer );

stdout.put( iAnswer ); stdout.newln();

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!