Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

code. This code is designed to be called from a C uestions about the 5. Conside

ID: 3348633 • Letter: C

Question

code. This code is designed to be called from a C uestions about the 5. Conside r the following program. Answer the following questions about comments uncommented. Sorry about that but then agan needs comments righta) myFunction PROO export myFunction push (r4-r5,1r) mov r4,#0 mov r3, #0 b check loop Idrb r5, [r0],#1 r4,r4,r5 r3, r3, #1 check cmp r3,r1 add add bcc loop mov ro, r4 pop (r4-r5,pc) ENDP END (a) What is the purpose of the push and pop instructions. Be VERY specific for each element that is being saved. (b) How many parameters are being passed to this routine and what is their purpose for the overall function? (c) There is no final branch instruction. How does the function return to the calling routine? d) Wirite the C function prototype for this function giving appropriate variable names

Explanation / Answer

Answer :- a) PUSH instruction keeps the values present in the register list to the stack memory. Similarly POP instruction is used to move the value from stack to the register list. This POP instruction ca be used to branch at any point if program counter(PC) is changed.

Answer :- b) Two parameters are being passed, r0 contains base address of the array and r3 contains length of the array. The overall purpose is to find the sum of the elements in the array. The sum is kept back in register r0.

Answer :- c)  The pop instruction is changing PC here by fetching value from the stack, this value is the link register value(LR) that was pushed initially.

Answer :- d) The C function prototype can be written as-

int ArraySum( int *arr, int length);

Here return type is int for sum value.
Parameters are array base address(r0) and the length of the array(r1).