Write an ARM assembly function that takes an array of integers and returns the index of the first occurrence of the integer in the array if it exists or -1 if it does not. Remember the initial integer in the array is at index zero.
The C language program is:
#include
extern int intfind( int array[], int lookfor, int size ) ;
void main( int argc, char * argv[] )
{
int numarray[] = { 113, 114, 252, 280, 332 };
int lookfor = 252 ;
int size = sizeof(numarray)/sizeof(int) ;
int result ;
result = intfind( numarray, lookfor, size ) ;
printf( "Integer appears at %d\n", result ) ;
}
The input to the ARM assembly language function is a pointer to the first element of the array in register a1. The integer to look for is in a2 The size of the array is in a3and is the number of integers. Remember an integer is 4 bytes long.