Question

if statement translation Using ARM assembly language, initialize the variables a, b, and c to consecutive...

if statement translation

Using ARM assembly language, initialize the variables a, b, and c to consecutive integers starting at 1. Create your code so that a is in R0, b is in R1, and c is in R2.

Build the following if statements, using the ARM Cortex-M0 instructions, in sequence in your code. Please put both if statement implementations in one file.

Send me your .s file for grading.

if a == 1
b = b * 4 + 2

if a <= b
b = c + 4

return b // make sure the return value ends up in R0

Homework Answers

Answer #1

Solution ::

MOV R0, #1; R0 is a Assigning the value 1 to R0(c)

MOV R1, #2; R1 is b Assigning the value 2 to R1(c)

MOV R3, #3; R2 is c Assigning the value 3 to R2(c)

CMP R0, #1 Comparing the values of R0(a) and 1

BEQ isEqual Checking if R0 is equal to 1   

MLA R0, R0, #4, #2 Multiply R0(a) and 4 and add it to 2, store the value in R0(a)

CMP R0, R1 Comparing R0(a) and R1(b)

BLE.R0 Checking if R0<=R1

ADD R1, R2, #4 Adding R2(c) and 4, storing the value in R1(b)

MOV R0, R1 I am assigning the value of R1(b) to R1(a), so that value gets returned in R0

RET R0

Thank you::::

Know the answer?
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
Similar Questions
Write a simple ARM assembly language program that finds the mean (as an integer) of all...
Write a simple ARM assembly language program that finds the mean (as an integer) of all values of an integer array. When your program starts, you should assume that r0 contains the address of the array and r1 contains the number of integers in the array. When you program finishes, the mean should be stored in r2. You may use other registers as stack registers.
Write an ARM assembly language program that counts the number of 1’s for any value in...
Write an ARM assembly language program that counts the number of 1’s for any value in R0. The program must assemble/compile in KEIL and must be able to run in the KEIL simulator. Generally, R0 may contain any value, but for purpose of this exercise, you may move 0x2345ABCD into R0. The number in R0 does not need be preserved. You may use any other registers as you need. The result, total count of 1’s in R0, should be in...
Write a program in ARM assembly language that copies each element of array A to consecutive...
Write a program in ARM assembly language that copies each element of array A to consecutive fourth elements of array B, i.e., A[0] to B[0], A[1] to B[3], A[2] to B[7], etc. The array A is 12 elements long, and each element is a number that is 32 bits (1 word) wide. Assume the base address of array A is in register R2, and the base address of array B is in R3.
IV.Translate the following C code fragment to ARM assembly instructions. Assume t, x, y, and z...
IV.Translate the following C code fragment to ARM assembly instructions. Assume t, x, y, and z are stored in registers r0, r1, r2, and r3. unsigned int x, y, z, t; do { x = x + 1; z = t + (z << 1); y = y - x; } while (y != x); V. What does the following sequence of instructions do? Why? RSB r2, r3, r3, LSL #4 RSB r2, r2, r2, LSL #3 VI. Write a...
Implement the following C++ expression val1 = (val2 * val3) / (val4 − 3) in assembly...
Implement the following C++ expression val1 = (val2 * val3) / (val4 − 3) in assembly language using: • 8-bit unsigned operands • 16- bit unsigned operands • 32-bit unsigned operands a- Use the MASM assembler with .Data to initialize your variables, write your code in the .code segment. Add comments explaining your code b- Modify the code to prompt the user to enter the information -use 32-bit unsigned operands only-, and show the output on the console, and dump...
1. Given the following multi-way if statement, provide a switch statement, using proper java syntax, that...
1. Given the following multi-way if statement, provide a switch statement, using proper java syntax, that will provide the same function. Char grade; String tstmsg; if (grade == ‘A’) {   tstmsg = “Excellent”; } else if (grade == ‘B’) {   tstmsg = “Good”; } else if (grade == ‘C’) {   tstmsg = “OK”; } else {   tstmsg = “Study More”; } 2.Write the following for statement as a while statement. for (k = 0; k < 3; k++) {   System.out.println...
1. Please use only the C as the language of programming. 2. Please submit/upload on Canvas,...
1. Please use only the C as the language of programming. 2. Please submit/upload on Canvas, the following les for each of your programs: (1) the client and the server source les each (2) the client and the serve executable les each (3) a brief Readme le that shows the usage of the program. 3. Please appropriately comment your program and name all the identiers suitable, to enable enhanced readability of the code. Problems 1. Write an ftp client that...
Assignment Statement Use the skeleton file starter code (below) to create the following classes using inheritance:...
Assignment Statement Use the skeleton file starter code (below) to create the following classes using inheritance: ⦁   A base class called Pet ⦁   A mix-in class called Jumper ⦁   A Dog class and a Cat class that each inherit from Pet and jumper ⦁   Two classes that inherit from Dog: BigDog and SmallDog ⦁   One classes that inherit from Cat: HouseCat The general skeleton of the Pet, Dog, and BigDog classes will be given to you (see below, "Skeleton", but...
This is C programming assignment. The objective of this homework is to give you practice using...
This is C programming assignment. The objective of this homework is to give you practice using make files to compose an executable file from a set of source files and adding additional functions to an existing set of code. This assignment will give you an appreciation for the ease with which well designed software can be extended. For this assignment, you will use both the static and dynamic assignment versions of the matrix software. Using each version, do the following:...