Question: Fill in the blanks as appropriate with a register ( e . g . x 0 or XO ) or a mnemonic ( e .

Fill in the blanks as appropriate with a register (e.g. x0 or XO) or a mnemonic (e.g. b) or a
number (e.g. #2)
long long int procedureA(long long int arg1, long long int arg2, long long int arg3)
{ long long int var1;
var1= procedureB(arg3);
var1= var1+arg1+\operatorname{arg}2+\operatorname{arg}3;
return var1;
}
We will convert this code to ARM. Assume var1 is in X9.
//first we will prepare a stack frame for procedureA before the call to procedureB
//place arg1, arg2, arg3, return address, frame pointer on stack
sub sp, sp,
//make room on the stack, how many bytes?
//first we will prepare a stack frame for procedureA before the call to procedureB
//place arg1, arg2, arg3, return address, frame pointer on stack
sub sp, sp,
//make room on the stack, how many bytes?
stur
,[ sp, #32]//place arg1 on the stack, what register?
stur
[ sp, #24]//place arg2 on the stack, what register?
stur
[ sp, #16]//place arg3 on the stack, what register?
stur
[ sp, #8]//place the return address on the stack, what register?
mov
,2//put arg3 in the appropriate register to be the argument for
procedureB
procedureB //call procedureB
procedureB //call procedureB
mov9,1?? load 9(var1) with the value returned by procedureB
[ sp, #32]//restore arg1 from stack
[ sp, #24]//restore arg2 from stack
Idur
sp,#16?? restore arg3 from stack
Idur
[[ sp, #8]//restore the return address from stack
Idur X29,[ sp, #0]//restore frame pointer from stack
addi sp,sp,
Imove stack pointer
add x9,x9,x0??var1=var1+arg1
add 9,9,1??var1=var1+arg2
add 9,9,2??var1=var1+arg3
mov
, x9//move var1 to the appropriate register with for return from
procedureA
br
Nreturn
Fill in the blanks as appropriate with a register

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!