Question: Write an ARM assembly language function that produces a pseudorandom number sequence using the middle squares method (described below). The C language program to test

Write an ARM assembly language function that produces a pseudorandom number sequence using the middle squares method (described below). The C language program to test the function is:

/* cdriver for prand function */

#include

#include

extern int prandom() ;

int main( int argc, char * argv[] )

{

int random ;

int i ;

for( i = 0 ; i < 10; i++ )

{

random = prandom() ;

printf( "%d ", random ) ;

}

}

The function does not require input and returns a pseudorandom number. The for loop prints the first ten values.

To obtain the pseudorandom value, square the previous value returned by the function, shift the resulting square 8 bits to the right. This is the current pseudorandom number and the seed for the next iteration.

The initial seed is 252252. Declare this as an .int that is outside the flow of control in the function: prand .int 252252. This memory location is replaced after every iteration with the pseudorandom number returned and become the seed. Use the 32 multiply instruction to square the number.

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!