Menu

[Solved]Function Adds Two Arguments Returns Result Remember Return Value Placed Ro Returning Param Q37055402

This function adds two arguments and returns the result. Remember that the return value is placed in rO before returning. @paThere are many ways to do this Chard) problem. If you want to try and use fewer instructions, look up ARMv7 addressing modesthis is run through gitbash

This function adds two arguments and returns the result. Remember that the return value is placed in rO before returning. @param r0: first arg, x param rl: second arg, y *@returns the sumof the two .global add type add, %function add TODO: finish this procedure here. */ /* return from this procedure (jump to 1r) */ bx 1r * This function returns the greater of two arguments. You will need to do a comparison for this. Remember that cmp sets all the CSPR registers (EQ, ZERO, etc) and the next *instruction can use them. (BEQ, BLE, etc). HINT: to copy the value of a register into another, use the “mov” *instruction: mov r0, rl ; copies value of rl into rO *param r0: first arg, x param rl: second arg, y *areturns the greater value of x or y .global greater type greater, %function greater: TODO: finish this procedure here* /* return from this procedure (jump to 1r) */ This function sums an array. *You’11 need a loop for this, and will probably want to *use a few registers as temporary storage. *Some hints: to multiply the value in a register by 2, shift it left one bit. This instruction shifts a r4’s value left one bit and stores the result in r3: 1s1 r3, r4 , #1 in ARM, things in [ ] are treated as a memory address. For example, the following instruction loads the value in memory at the address contained in r4 plus 2 (r3 Mem[r4+2]): ldr r3, [r4, #2] There are many ways to do this Chard) problem. If you want to try and use fewer instructions, look up ARMv7 addressing modes or ask your instructor for tips. @param r0: the base address of the array (pointer) *@param rl: the number of elements in the array * @returns the sum of the elements in the array global sumArray type sumArray, %function sumArray: TODO: finish this procedure here /* return from this procedure (jump to 1r) */ Show transcribed image text This function adds two arguments and returns the result. Remember that the return value is placed in rO before returning. @param r0: first arg, x param rl: second arg, y *@returns the sumof the two .global add type add, %function add TODO: finish this procedure here. */ /* return from this procedure (jump to 1r) */ bx 1r * This function returns the greater of two arguments. You will need to do a comparison for this. Remember that cmp sets all the CSPR registers (EQ, ZERO, etc) and the next *instruction can use them. (BEQ, BLE, etc). HINT: to copy the value of a register into another, use the “mov” *instruction: mov r0, rl ; copies value of rl into rO *param r0: first arg, x param rl: second arg, y *areturns the greater value of x or y .global greater type greater, %function greater: TODO: finish this procedure here* /* return from this procedure (jump to 1r) */ This function sums an array. *You’11 need a loop for this, and will probably want to *use a few registers as temporary storage. *Some hints: to multiply the value in a register by 2, shift it left one bit. This instruction shifts a r4’s value left one bit and stores the result in r3: 1s1 r3, r4 , #1 in ARM, things in [ ] are treated as a memory address. For example, the following instruction loads the value in memory at the address contained in r4 plus 2 (r3 Mem[r4+2]): ldr r3, [r4, #2]
There are many ways to do this Chard) problem. If you want to try and use fewer instructions, look up ARMv7 addressing modes or ask your instructor for tips. @param r0: the base address of the array (pointer) *@param rl: the number of elements in the array * @returns the sum of the elements in the array global sumArray type sumArray, %function sumArray: TODO: finish this procedure here /* return from this procedure (jump to 1r) */

Expert Answer


Answer to This function adds two arguments and returns the result. Remember that the return value is placed in rO before returning… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *