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...
Consider a program having following sequence of instructions, where the syntax consists of an opcode followed...
Consider a program having following sequence of instructions, where the syntax consists of an opcode followed by the destination register followed by one or two source registers: Instruction no Instructions 1 ADD R3, R1, R2 2 LOAD R6, [R3] 3 AND R7, R5, 3 4 ADD R1, R6, R0 5 SUB R2, R1, R6 6 AND R3, R7, 15 7 SUB R5, R3, R4 8 ADD R0, R1, R10 9 LOAD R6, [R5] 10 SRL R7, R0, 8 Assume the...
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...
For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables...
For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables f, g, h, and I are assigned to registers $s0 - $s3, respectively. Assume that the base address of arrays X, Y, and Z are in registers $s4 - $s6, respectively. Be conservative and use a single temp register as possible. It is a C arithmetic command with two source operands and a destination. Each part is 3 points. Add $t0, $s0, $s1 addi...
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,...
Given the following sequential list of VEX operations: A. add $r3 = $r1, $r2 B. sub...
Given the following sequential list of VEX operations: A. add $r3 = $r1, $r2 B. sub $r8 = $r1, $r3 C. sub $r7 = $r1, 2 D. add $r1 = $r1, 1 E. mpy $r6 = $r3, $r2 Which VEX operations can be scheduled simultaneously to make up the second VLIW instruction? The constructed schedule should satisfy the following conditions: Assume infinite resources and no limit to the number of operations scheduled to a single instruction. Operations that are scheduled...
Find the contents of register WREG after each of the following instructions: a. MOVLW 0x65 XORLW...
Find the contents of register WREG after each of the following instructions: a. MOVLW 0x65 XORLW 0xAB b. MOVLW 0x2E ANDLW 0x56 Assume that MYREG = 27H.Indicate the value in MYREG after the execution of the sequence of instructions in each of the following cases: a. MOVLW 0x5E CPFSLT MYREG INCF MYREG, F ADDLW 0x5 b. MOVLW 0x84 CPFSGT MYREG INCF MYREG, F ADDLW 0x5
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT