Write an ARM function subroutine to count the number of odd

Write an ARM function (subroutine) to count the number of odd integers in an integer array. The function signature is:

int numodd( int array[], int size ) ;

where:

            int array[] is passed to the ARM function as a pointer to the first element of the integer array and,

            int size is passed by value and is the number of elements in the array.

The C language source code is:

#include

#include

extern int numodd( int array[], int size ) ;

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

{

            int numarray[] = { 2, 3, 1025, 3024, 4057, -3, -1025, -3578 } ;

            int size = sizeof(numarray) / sizeof( int ) ;

            int result ;

           

            result = numodd( numarray, size ) ;

            printf( \"Number of odd numbers: %d\ \", result ) ;

           

            exit( 0 ) ;

           

}

A number is odd if the LSB is set (value = 1) and even if the LSB is reset (value = 0) .

Example Format:

.global numodd
.text
numodd:
   stmfd sp!, {v1-v6,lr}
   ldmfd sp!, {v1-v6,pc}
   .end

Solution

#include

#include

extern int numodd( int array[], int size ) ;

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

{

            int numarray[] = { 2, 3, 1025, 3024, 4057, -3, -1025, -3578 } ;

            int size = sizeof(numarray) / sizeof( int ) ;

            int result ;

           

            result = numodd( numarray, size ) ;

            printf( \"Number of odd numbers: %d\ \", result ) ;

           

            exit( 0 ) ;

           

}

A number is odd if the LSB is set (value = 1) and even if the LSB is reset (value = 0) .

Example Format:

.global numodd
.text
numodd:
   stmfd sp!, {v1-v6,lr}
   ldmfd sp!, {v1-v6,pc}
   .end

Write an ARM function (subroutine) to count the number of odd integers in an integer array. The function signature is: int numodd( int array[], int size ) ; whe
Write an ARM function (subroutine) to count the number of odd integers in an integer array. The function signature is: int numodd( int array[], int size ) ; whe

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site