Question: 1. Assembly Programming a) Write an assembly fragment which reads numbers from an input array, multiplies them by 4, and stores the result into another

 1. Assembly Programming a) Write an assembly fragment which reads numbers

1. Assembly Programming a) Write an assembly fragment which reads numbers from an input array, multiplies them by 4, and stores the result into another array. Assume that each entry of the array is a 32-bit number. RO contains the address of the first element of the input array, R1 contains the address of the first element of the output array, and R2 is the number of elements in the array (it may be equal to zero!). Try to use as few instructions in your loop as possible, and do not use the MUL instruction. b) What is the size of your code in bytes? You can find the binary encoding for each instruction that you used on the ARMv7-M Reference Manual (posted on Blackboard). c) Now write the same code fragment as a function following ARM's calling convention. The function takes three arguments: the address of the first element of the input array, the address of the first element of the output array, and the number of elements in the array. The following shows the function prototype. void multby4 (int inarray[], int outarray[], int n); d) Many instructions have restrictions on what registers can be used as inputs and outputs. Even though SP, LR, and PC can also be referred to as R13, R14, and R15, respectively, these registers cannot always be used in an instruction. Using the ARMv7-M Reference Manual (posted on Blackboard), determine whether "AND RO, PC, #Ox0F" is a legal instruction. If it is, explain what the instruction will do. If it isn't, explain how you know it's not allowed. Note: You will need to look at the pseudocode in the encoding section of the instruction description to properly answer this. When pseudocode says "UNPREDICTABLE", it means operation isn't allowed. 1. Assembly Programming a) Write an assembly fragment which reads numbers from an input array, multiplies them by 4, and stores the result into another array. Assume that each entry of the array is a 32-bit number. RO contains the address of the first element of the input array, R1 contains the address of the first element of the output array, and R2 is the number of elements in the array (it may be equal to zero!). Try to use as few instructions in your loop as possible, and do not use the MUL instruction. b) What is the size of your code in bytes? You can find the binary encoding for each instruction that you used on the ARMv7-M Reference Manual (posted on Blackboard). c) Now write the same code fragment as a function following ARM's calling convention. The function takes three arguments: the address of the first element of the input array, the address of the first element of the output array, and the number of elements in the array. The following shows the function prototype. void multby4 (int inarray[], int outarray[], int n); d) Many instructions have restrictions on what registers can be used as inputs and outputs. Even though SP, LR, and PC can also be referred to as R13, R14, and R15, respectively, these registers cannot always be used in an instruction. Using the ARMv7-M Reference Manual (posted on Blackboard), determine whether "AND RO, PC, #Ox0F" is a legal instruction. If it is, explain what the instruction will do. If it isn't, explain how you know it's not allowed. Note: You will need to look at the pseudocode in the encoding section of the instruction description to properly answer this. When pseudocode says "UNPREDICTABLE", it means operation isn't allowed

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 Databases Questions!