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