Question

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 constant 23. The quotient should be stored in r1 and the remainder should be stored in r2. Note that this is an integer division.

Homework Answers

Answer #1

Answer :- The code has been commeted with register values-

LDR r12, =0xA4000000 ;r12 = 0xA4000000

LDR r0, =0x2D ;r0 = 0x2D

STR r0, [r12, #-4]! ;r12 = 0xAFFFFFFC, and value at address 0xAFFFFFFC = 0x2D

LDR r0, =0x5E ;r0 = 0x5E

STR r0, [r12, #-4]! ;r12 = 0xAFFFFFF8, and value at address 0xAFFFFFF8 = 0x5E

LDR r0, =0xD5 ;r0 = 0xD5

STR r0, [r12, #-4]! ;r12 = 0xAFFFFFF4, and value at address 0xAFFFFFF4 = 0xD5

LDMIA r12!, {r0-r2} ;r0 = 0xD5, r1 = 0x5E, r2 = 0x2D and r12 = 0xA4000000

SUB r2, #0x68 ;r2 = 0x2D - 0x68 = 0xFFFFFFC5

Answer :- The assembly code is witten below-

LDR r3, =0x17 ;r3 = 23

UDIV r1, r0, r3 ;r1 = (r0 / r3)

MLS r2, r1, r3, r0 ;r2 = r0 - (r1 x r3)

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...
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...
Write a Hack Assembly Language program to calculate the quotient from a division operation. The values...
Write a Hack Assembly Language program to calculate the quotient from a division operation. The values of dividend a and divisor b are stored in RAM[0] (R0) and RAM[1] (R1), respectively. The dividend a is a non-negative integer, and the divisor b is a positive integer. Store the quotient in RAM[2] (R2). Ignore the remainder. Example: if you are given two numbers 15 and 4 as dividend a (R0) and divisor b (R1), respectively, the answer will be 3 stored...
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...
Write a simple ARM assembly language program that finds the mean (as an integer) of all...
Write a simple ARM assembly language program that finds the mean (as an integer) of all values of an integer array. When your program starts, you should assume that r0 contains the address of the array and r1 contains the number of integers in the array. When you program finishes, the mean should be stored in r2. You may use other registers as stack registers.
Write an ARM assembly language program that counts the number of 1’s for any value in...
Write an ARM assembly language program that counts the number of 1’s for any value in R0. The program must assemble/compile in KEIL and must be able to run in the KEIL simulator. Generally, R0 may contain any value, but for purpose of this exercise, you may move 0x2345ABCD into R0. The number in R0 does not need be preserved. You may use any other registers as you need. The result, total count of 1’s in R0, should be in...
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...