Write an ARM assembly function that takes an array of integers and insures that all entries are positive. Remember the initial integer in the array is at index zero. The C language program is: /*...

Write an ARM assembly function that takes an array of integers and insures that all entries are positive. Remember the initial integer in the array is at index zero. The C language program is: /* absdriver.c - driver for absarray function */ #include #include extern int absarray( int array[], int size ) ; int main( intargc, char * argv[] ) { int array[] = {1, 3, -5, -252, 280, -332 } ; int asize = sizeof(array) / sizeof(int) ; int result ; int i ; result = absarray( array, asize ) ; for( i = 0 ; i printf( " %d ", array[i] ) ; printf( "\n" ) ; exit( 0 ) ; } The input to the ARM assembly language function is a pointer to the first element of the array in register a1. The size of the array is in a2 and is the number of integers. Remember an integer is 4 bytes long. Recall that the ldr instruction does not affect the condition codes. Also consider the reverse subtract instruction, rsb. For ARM we have AREA Program,CODE,READONLY ENTRY Main EOR R3,R3,R3; Clear R3 ADD R3,R1,R3; load R3 with R1 ie address EOR R0,R0,R0; clear R0 ADD R0,R1,R0; load R0 with the size EOR R4,R4,R4; clear R4 Loop LDR R5,[R3] ; load R5 with the value at address ADD R4,R4,R5 ; add R4 with the value present at address,signed ADD R3,R3,#4; increment address pointer by 4 as int is 4 bytes SUB R0,R0,#1; decrease the count CMP R0,#0; compare the count with 0 to check for end of array BNE Loop ;loop back if count is not 0 MOV PC,R14 ; load Pc with the return address with the result stored in R4 END Is this correct? Can someone provide me with the output of this since I have not installed correct librarys for this.
Nov 24, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here