Question

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 short code segment that performs a mode change by modifying the contents of the CPSR from the supervisory mode to user mode.

Homework Answers

Answer #1

IV.Given t,x,y,z are stored in registera r0,r1,r2,r3

MOV r0,r1,r2,r3;

loop ADD r1,r1,#1;

ADD r3,r0,r3;

SUB r2,r2,r1;

halt SUBS r7,r2,#r1;

V.First i want to explain about the instructions like

RSB=reverse subtract of two 32-bit values

LSL=logical shift left of 32-bit values

in the first instruction i.e,

RSB r2,r3,r3,LSL #4

By the above instruction we can say that RSB r2,r3,r3 as r2=r3-r3 and LSL #4 as after logical shift left we have to assign the value as 4.

In the second instruction i.e,

RSB r2,r2,r2,LSL #3

here also we are having the same instructions but the registers are changed so in RSB r2,r2,r2 as r2=r2-r2 and LSL #3 as after the logical shift left we have to assign the value as 3

  

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
III. After execution of the following instructions what value will be in register r0? LDR                ...
III. After execution of the following instructions what value will be in register r0? LDR                 r12, =0xA4000000 LDR                 r0, =0x75 LDR                 r1, =0xD2 LDR                 r2, =0x9C LDR                 r5, =0xC STMDB           r12!, {r0-r2, r5} LDR                 r0, [r12, #8] SUB                 r0, #0x77 IV. Assume that the variables f, g, h, i, and j are assigned to registers r0, r1, r2, r3, and r4, respectively. Assume that the base address of the arrays A and...
(MIPS Assembly Language): Write the following sequence of code using *native* MIPS instructions: x = x...
(MIPS Assembly Language): Write the following sequence of code using *native* MIPS instructions: x = x - y[0] + y[1]; In memory x, y are stored beginning at 0x010000cc. Use registers $s1 for x,  and $s2 for the base address of y. Make sure your code includes all necessary declarations such that it could run in SPIM.
QUESTION 1 Convert the following code fragment to assembly code fragment, using instructions discussed in class....
QUESTION 1 Convert the following code fragment to assembly code fragment, using instructions discussed in class. if X > Y then Y=X else X=Y 2 QUESTION Suppose a user wants to do a system call. Assume that the service routine of this system call is at physical address 500. Suppose the user knows this address of the service routine. So instead of executing a system call, the user simply jumps to this location 500 (by executing “JMP 500”). Assume that...
Write the following code segment in MARIE's assembly language: if x <= y then Y =...
Write the following code segment in MARIE's assembly language: if x <= y then Y = Y+1; else if x! =x then Y= Y -1; else z=z+1
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT