Step by Step would be extremely appreciated ARM processor ha

Step by Step would be extremely appreciated!

ARM processor has the SWP r1, [r2, offset] instruction that swaps the contents of register r1 and the contents of the memory location given by the address r2+offset atomically. For example, if r1 = -2, r2 = 500 offset = 0, and Memory [500] = 66 after the execution of SWP r1, [r2, offset], register r1 will have 66 and Memory [500] will have -2 and either the whole operation happens or nothing happens (that\'s what atomically means). Write a short MIPS assembly language program that accomplishes the same functionality as the ARM SWP instruction. Describe one advantage and one disadvantage of incorporating the SWP instruction to the MIPS instruction set to implement atomic operations.

Solution

a)

move        $r3, $r1                   # move content of register r1 to r3

lw             $r1, offset($r2)        #load word at RAM address ($r2+offset) into register $r1

sw             $r3, offset($r2)         #store word in register $r1 into RAM at address ($r2+offset)

b)

Advantages

Low power consumption, reduced code size and, increased speed.

Disadvantages

Does not support memory to memory data processing operations. Must move data values into registers before using them.If the address is not word aligned, things will go wrong (CPUs without an MMU will rotate right the value, and CPUs with an MMU will result in fault) and none of the registers specified in SWP can be R15.

Step by Step would be extremely appreciated! ARM processor has the SWP r1, [r2, offset] instruction that swaps the contents of register r1 and the contents of t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site