Question

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 B are in registers r6 and r7, respectively. Translate the following C code fragment to ARM assembly instructions.

f = –g + h + B[1];

f = A[B[g]+1];

Homework Answers

Answer #1

Answer iii) :- The register values after each instruction has been written below as comment-

LDR r12, =0xA4000000 ;r12 = 0xA4000000

LDR r0, =0x75 ;r0 = 0x75

LDR r1, =0xD2 ;r1 = 0xD2

LDR r2, =0x9C ;r2 = 0x9C

LDR r5, =0xC ;r5 = 0xC

STMDB r12!, {r0-r2, r5} ;at memory 0xA3FFFFC, 0x75 is stored
--------------------------------------- ;at memory 0xA3FFFF8, 0xD2 is stored
---------------------------------------;at memory 0xA3FFFF4, 0x9C is stored
--------------------------------------;at memory 0x3AFFFF0, 0xC is stored

LDR r0, [r12, #8] ;So from memory (0xA3FFFF0 + 0x8) i.e. 0xD2 is kept in r0

SUB r0, #0x77 ;r0 = (0xD2 - 0x77) = 0x5B

So final value in register r0 is 0x5B.

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
VII. After execution of the following instructions what value will be in register r2? Trace the...
VII. After execution of the following instructions what value will be in register r2? Trace the program and write the value of the registers at each line to receive full credit. LDR r12, =0xA4000000 LDR r0, =0x2D STR r0, [r12, #-4]! LDR r0, =0x5E STR r0, [r12, #-4]! LDR r0, =0xD5 STR r0, [r12, #-4]! LDMIA r12!, {r0-r2} SUB r2, #0x68 VIII. Write a simple ARM assembly program to divide a 32 bit positive number stored in r0 by a...
I. What value will be in register r2 after execution of the following instructions? Show your...
I. What value will be in register r2 after execution of the following instructions? Show your work with the register values after executing each instruction. MOV r2, #0x0 LDR r1, =0xCF MOVS r1, r1, LSR #1 ADC r2, r2, #0 MOVS r1, r1, LSR #1 ADC r2, r2, #0 II. Assume a 32 bit register holds a data of four bytes as B3B2B1B0. Write a sequence of ARM instruction that takes this data as input and swaps the bytes 0...
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...
Consider the following code segment, where the branch is taken 30% of the time and not-taken...
Consider the following code segment, where the branch is taken 30% of the time and not-taken 70% of the time. R1 = R2 + R3 R4 = R5 + R6 R7 = R8 + R9 if R10 = 0, branch to linex R11 = R12 + R13 R14 = R11 + R15 R16 = R14 + R17 ... linex: R18 = R19 + R20 R21 = R18 + R22 R23 = R18 + R21 ... Consider a 10-stage in-order processor,...