Question

In: Computer Science

Write the following code in ARM assembly code g=12, h=8, i=2, j=5; f = (g +...

Write the following code in ARM assembly code

g=12, h=8, i=2, j=5;

f = (g + h) - (i + j);

Your program displays the message:

f = (g + h) – (i + j) = 13

Note that 13 should be calculated, not hardcoded

Solutions

Expert Solution

An ARM assembly code is an assembly language where in it understands the machine languages.

Moreover the assembly code ARM is also said to be the hexadecimal number pattern because it does follows the hexadecimal format,

So given value g=12, h=8, i=2 and j=5

These are the given values and we have to load the the details into the register using LDR

Instruction Mneomic Register/Memory Allocation Hexadecimal Equivalent

LDR R1, 12 C

LDR R2, 8   8

LDR R3 , 2 2

LDR R4 , 5 5

ADD R5, R1 ,R2 14

ADD R6 , R3 , R4   7

SUB R7 , R5 , R6 D

Summary:

In the above program we have loaded the value into the register and writing it down the HEX value and in ARM it is very important to write the HEX value because it works in that similar way.

With the help of hex value it becomes more simpler for the machine to compute the mathematical functions through out the program.

So in ADD R5, R1, R2 here we are taking the R1 value and R2 value and storing the value in R5 so that we can use it later. similary for another Add and the SUB functions.

This will help the program to run ARM assembly code.


Related Solutions

Write a complete ARM asembly program for following code: g=12, h=8, i=2, j=5; f = (g...
Write a complete ARM asembly program for following code: g=12, h=8, i=2, j=5; f = (g + h) - (i + j); Your program displays the message: f = (g + h) – (i + j) = 13 Note that 13 should be calculated, not hardcoded Below is my current code: .global _start _start: mov R0,#12 mov R1,#8 mov R2,#2 mov R3,#5 add R4,R0,R1 add R5,R2,R3 sub R6,R4,R5 How should I display the message: "f = (g + h) –...
I have this MIPS code and I need to find: add f,g,h add f,f,i sub f,f,j...
I have this MIPS code and I need to find: add f,g,h add f,f,i sub f,f,j a. How many bits does it take to encode ? b. How many bits needed in register file to store the data?
Consider the following bivariate data. Point A B C D E F G H I J...
Consider the following bivariate data. Point A B C D E F G H I J x 0 1 1 2 3 4 5 6 6 7 y 5 5 6 5 4 3 2 0 1 1 (a) Construct a scatter diagram of the given bivariate data. (Do this on paper. Your instructor may ask you to turn in this work.) (b) Calculate the covariance. (Give your answer correct to two decimal places.) (c) Calculate sx and sy. (Give...
Consider the following demand curve: A B C D E F G H I J P...
Consider the following demand curve: A B C D E F G H I J P $0.50 $0.45 $0.40 $0.35 $0.30 $0.25 $0.20 $0.15 $0.10 $0.05 QD 1 2 4 6 9 12 16 20 25 30 Calculate elasticities for pairs of points to check statements that were made during class and in the text. When making the calculations, use average price and average quantity for the two points. The formula for this should be in your notes. It is...
**Add comments to existing ARM code to explain steps** Write an ARM assembly program to convert...
**Add comments to existing ARM code to explain steps** Write an ARM assembly program to convert temperatures from Celsius to Fahrenheit or from Fahrenheit to Celsius. Here are the two formulas for your reference. Use variable to read and store values. C= 5* (F - 32) / 9 F = (9 * C / 5 ) + 32 My code below: TempConvert.s LDR R8,=temperature LDR R1,[R8] LDR R8,=unit LDRB R2,[R8] LDR R8,=celsius LDRB R3,[R8] LDR R8,=fahrenheit LDRB R4,[R8] MOV R6,#9...
If f and g are both differentiable functions. If h = f g, then h'(2) is: ___________________
  If f and g are both differentiable functions. If h = f g, then h'(2) is: ___________________ Given the function: y=sin(4x)+e^-3x and dx/dt = 3 when x=0. Then dy/dt = ________________ when x=0. Let f(x) = ln (√x). The value of c in the interval (1,e) for which f(x) satisfies the Mean Value Theorem (i.e f'(c)= f(e)-f(1) / e-1 ) is: _________________________ Suppose f(x) is a piecewise function: f(x) = 3x^2 -11x-4, if x ≤ 4 and f(x) =...
Compile the following C code to MIPS assembly. a. Assume that i and j are stored...
Compile the following C code to MIPS assembly. a. Assume that i and j are stored in register $s1 and $s2, respectively. i = i – 2 + j; b. Assume base address of Array B and the variable i are stored in registers $s3 and $s1, respectively. B[1] = (B[0] x 4) - I; Explain each step in detail! my professor has the following answer: 1) addi $t0, $s1, -2 add $s1, $$t0, $s2 2) lw $t0, 0 ($s3)...
Write MIPS assembly code for the following C code. for (i = 10; i < 30;...
Write MIPS assembly code for the following C code. for (i = 10; i < 30; i ++) { if ((ar[i] > b) || (ar[i] <= c)) ar[i] = 0; else ar[i] = a; }
1.) Translate the following C code to MIPS assembly code. Assume that the variables f, g,...
1.) Translate the following C code to MIPS assembly code. Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively   B[8] = A[i-j]; 2.Translate the following C code to MIPS assembly code. Assume that the values of v in $a0, k in $a1, temp in $t0.    // leaf procedure that...
1. ¬B∨(G↔J), H→(B&C) ∴(H&J)→G 2. A∨B, C↔¬(B∨D) ∴C→A 3. (A&B) ↔ (F→G), (A&F) & B∴(G→R)→R 4....
1. ¬B∨(G↔J), H→(B&C) ∴(H&J)→G 2. A∨B, C↔¬(B∨D) ∴C→A 3. (A&B) ↔ (F→G), (A&F) & B∴(G→R)→R 4. T→¬B, T→¬D ∴ T→¬(B∨D) 5. ¬(M∨¬S), S→(R→M) ∴A → (¬R∨T) 6. (F&G) → I, (I∨J) → K ∴F→(G→K) 7. ¬U, O→G, ¬(O∨G) →U ∴G Prove that the arguments are valid by constructing a dedication using the rules MP, MT, DN, Conj, Simp, CS, Disj, DS, DM, CP, HS, BE, and DL. Use CP if needed.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT