Question

Write a function (subroutine) that inputs a data value in register r0 and returns value in...

Write a function (subroutine) that inputs a data value in register r0 and returns value in r0. The function returns y 5 a 1 bx 1 cx2, where a, b, and c are parameters built into the function (i.e., they are not passed to it). The subroutine also performs clipping. If the output is greater than a value d, it is constrained to d (clipped). The input in r0 is a positive binary value in the range 0 to 0xFF. Apart from r0, no other registers may be modified by this subroutine.

Write ARM code to implement the following C operation.

Int s=0;

for ( i = 0; i < 10; i++) {

s        =        s        +        i*i;)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have also provided the code along with the code screenshot. Do comment, if you have any queries.

ARM code for expression a+bx+cx^2

   /*pseudo-code of the given problem
   int f(int x){
       return a + b*x +c*x*x;
   }
*/


   int f(int R0){
       int stack[2] = {R1,R2};
       R1 = R0;
       R1 = R1 * R1;
       R2 = C;
       R1 = R1 * C; /*R1 = cx^2*/
       R2 = B;
       R0 = R0 * R2; /* R0 = bx */
       R0 = R0 + R1; /*R0 = bx + cx^2*/
       R2 = C;
       R0 = R0 + R2; /*R0 = a+bx+cx^2 */
       R1 = stack[0];
       R2 = stack[1];
       return R0;
   }

   /*ARM code to implement the following C operation
   int s=0;
   for ( i = 0; i < 10; i++)
   { s = s + i*i;)
   */

           AREA SumSquares, code, readWrite
           ENTRY
           MOV r0, #0        ;loop counter i present at 0
           MOV r1, #0       ; s = 0
   Loop   MUL r2, r0, r0   ;calculate i*i
           ADD r1, r1, r2   ;s = s+ i*i
           ADDS r0, r0, #1   ; i = i+1
           CMP r0,#10       ; test for end
           BNE Loop        ; continue until all added
           END

PLEASE UPVOTE IF U UNDERSTOOD THE ANSWER..THANKS..

Add a comment
Know the answer?
Add Answer to:
Write a function (subroutine) that inputs a data value in register r0 and returns value in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write an ARM assembly language subroutine (named nfibo) to calculate and return the n-th Fibonacci number....

    Write an ARM assembly language subroutine (named nfibo) to calculate and return the n-th Fibonacci number. Fibonacci numbers (or a Fibonacci sequence) are a series of numbers with a property that the next number in the series is a sum of previous two numbers. Starting the series from 0, 1 as the first two numbers we have 0, 1, (0 + 1) = 1, (1 + 1) = 2, (1 + 2) = 3, (2 + 3) = 5, (3...

  • Problem 1 Write a find subroutine that can locate a specified 8-bit quantity in a null-terminated...

    Problem 1 Write a find subroutine that can locate a specified 8-bit quantity in a null-terminated string 8-bit quantities. (Remember that null terminated means "it ends with zero"). The subroutine is passed two parameters. The pointer to the array is passed in array X, the value to be found is passed in ACCA. The function should return the index of the first occurrence of the value in ACCB, or -1 (0xFF) if the value is not found. a) Write the...

  • 4. Write a function that returns a value to the main program illustrated below. In the...

    4. Write a function that returns a value to the main program illustrated below. In the function, the variable passed by the main program needs to be evaluated using a switch statement. The value returned is determined by the case that it matches. (10 points) If value is: return 10 return 20 3 return 30 Anything else, return 0 Main program: #include <iostream> using namespace std; int findValue (int); int main) { Int numb, retvalue cout << "In Enter a...

  • Write a javascript function that accepts 3 arrays and returns a string of the elements sorted...

    Write a javascript function that accepts 3 arrays and returns a string of the elements sorted in ascending value, with duplicates removed. Return all alphabetic characters in lowercase. E.G. function([ 1,2,3, d], [5, 3, 0, ‘a’], [‘a’,’d’,9]) returns “0,1,2,3,5,9,a,d” E.G. function(['w', 'i', 'H', 5], [8, 5, 9, 'c', 'Z'], [6, 4, 'a', 'b', 'y']) returns “4,5,6,8,9,a,b,c,h,i,w,y,z” we must not use ' sort, remove, split,join and any built-in fucntions

  • write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy....

    write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy. The function should be passed 2 parameters, as illustrated in the prototype below. int pow_xy(int *xptr, int y); Assuming that xptr contains the address of variable x, pow_xy should compute x to the y power, and store the result as the new value of x. The function should also return the result. Do not use the built-in C function pow. For the remaining problems,...

  • 2) Write a function stringManip that takes in a character string and returns a character string...

    2) Write a function stringManip that takes in a character string and returns a character string following these rules: a) any vowel (a, e, i, o, u) is replaced by the character '&' b) any numeric character has 1 added to it (if it was 9, it becomes O instead) (str2num() is useful here) c) all lowercase characters become uppercase d) replace the final character with '!' e) append the length of the string before this step to the end...

  • /*    Write a function that takes as an argument the value x,    and returns...

    /*    Write a function that takes as an argument the value x,    and returns the result of the expression: 20x^4 - 12x^3 - 3x^2 + 15x + 3    Note: No importing; use the power function given to you, and use it    as a reference for writing functions (note also that main itself        if a function!). */ public class Exercise9_1 { public static void main(String[] args) { int num = 5, pow = 2; System.out.println(num...

  • C ++Write a function, anyThree (int a[], int n), that returns true if the value 3...

    C ++Write a function, anyThree (int a[], int n), that returns true if the value 3 appears in the array exactly 3 times, and no 3's are next to each other. The parameter n will be greater than or equal to 0. Write a function, anyThree (int all, int n), that returns true if the value 3 appears in the array exactly 3 times, and no 3's are next to each other. The parameter n will be greater than or...

  • Python homework Write a function called insert_value(my_list, value, insert_position) that takes a list, a value and...

    Python homework Write a function called insert_value(my_list, value, insert_position) that takes a list, a value and an insert_position as parameters. The function returns a copy of the list with the value inserted into the list (my_list) at the index specified by insert_position. Check for the insert_position value exceeding the list (my_list) bounds. if the insert_position is greater than the length of the list, insert the value at the end of the list. if the insert_position is less than or equal...

  • 1.1. Write a function named "areFirstTwoTheSame AsLast TwoChars" that accepts a string. It returns true if...

    1.1. Write a function named "areFirstTwoTheSame AsLast TwoChars" that accepts a string. It returns true if the first two characters and the last two characters of the string are the same. It returns false otherwise. In addition, if the string is empty or has only one character, it also returns false. For example, these are the strings with their expected return values false falsc "AB" true "ABA" false "ABAB" trus "ABBA" false "ABCABC false "ABCCAB" true 1.2 Write a function...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT