Search for question
Question

CPSC 3300-Assembly Language Homework 4 (55 points) 1. Write an assembly program that calculates y. Assume register RO holds integer x and register R1 saves the result. (5 pt) -1 ifx<0 y 0 if x=0 1 if x > 0 2. Write an assembly program that calculates the following. Assume the integer input x is stored in register RO and the result is saved in register R1. (10 pt) 9x if x <= 10 y 8x if x 10 and x <= 100 7x if x 100 and x <= 1000 6x if x 1000 3. Write a code which adds all even numbers from 0 to 1000 and stores the sum in the memory location of 0x10002010. Take a screenshot of the content in memory location 0x10002010. (10 pt) 4. Write a code which calculates the factorial of a number 11 (or 11!) and stores in the memory location of 0x10002020. Take a screenshot of the content in memory location 0x10002020. (10 pt) 5. Write ARM code to implement the following C++/JAVA operation. (10 pt) int s = 0; for (int i = 0; i < 10; i++) s = s + i * i; Store the result (value of s) in memory location 0x10002030. Take a screenshot of the content in memory location 0x10002030. 6. Translate the following C++/Java code to ARM assembly code. Store the result (value of s) in memory location 0x10002040. Take a screenshot of the content in memory location 0x10002040. (10 pt) int s = = 0; for (int i = 0; i < 5; i++) for (int j = 0; j < 5; j++) s = s + i *j;