Nios/arrayinsert

From ASMBits

Write a function that inserts a new element into an array of 32-bit integers. The elements after the insertion position should be moved by one position (expanding the array by one).

The first argument is a pointer to the start of the array. The second argument is the number of elements in the array. The third argument indicates where to insert the new element. The fourth argument is the number to insert.

There is no return value.

void array_insert (int *array, unsigned int length, unsigned int insert_at, int num);

insert_at is guaranteed to be no greater than length (No insertion past the end of the array)


Expected solution length: Around 15 lines.

Sample Input

[1 2 3 4], 2, 123 

Sample Output

[1 2 123 3 4]

Write your solution here

Upload a source file...