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...
Assembly Language Programming create an .asm [assembly language program file, using Microsoft Visual Studio or equivalent...
Assembly Language Programming create an .asm [assembly language program file, using Microsoft Visual Studio or equivalent Windows32 integrated development environment (IDE)] program into one that inputs two positive integers, and outputs their greatest common divisor, by implementing the following pseudo-code: input num1 and num2 (assume num1 > 0 and num2 > 0) gcd := num1 remainder := num2 repeat numerator := gcd gcd := remainder remainder := numerator % gcd until (remainder == 0) output gcd The following 3 windows...
ARM on a raspberry pi 1. Create a assembly program that branches based off the value...
ARM on a raspberry pi 1. Create a assembly program that branches based off the value of three different variables. ## Details Task 1: I highly suggest reading the book and doing the practice before doing this. Name your file cp5.s. You need to initally start with the three variables. * the variables should be called max, t1, t2. * Set the values to whatever you would like. * max tells us the cut off for a value * if...
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...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using the following guidelines - Write two primary helper functions - one iterative (IsArrayPrimeIter) and one recursive (IsArrayPrimeRecur) - each of which Take the array and its size as input params and return a bool. Print out a message "Entering <function_name>" as the first statement of each function. Perform the code to test whether every element of the array is a Prime number. Print out...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT