Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following ARM assembly language code segment. A breakpoint is set a

ID: 3667289 • Letter: C

Question

Consider the following ARM assembly language code segment. A breakpoint is set at the branch instruction. Determine the value of the condition codes when the breakpoint is encountered. Will the branch be taken when the program continues execution? Assume initial values of Qx0000007E and 0x0000001C in rO and r2 respectively. MOV r3, rO, LSL r2 CMP r3, #4 BCC process Write a short assembly language program which implements a loop to calculate the product of two unsigned numbers stored in r4 and r5, storing the product in rO. You may assume the product will not overflow a 32-bit register.

Explanation / Answer

r2 has value 0x1c. left shift by2 it will become 0x70 .

value in r0 is 7e.

r3 will have 7e value after the mov instruction is executed.

Now cmp r3,4 will basically subtract 7e from value 4 which will return 7A.

It won't set any one of the flags ZNCV as nothing is done.

Assembly code will be:

mov r0,0 //initiliazation of r0 for result.

loop:

add r0,r0,r5 // we are adding the value of r5 by r5 in each loop.

sub r4,r4,1 //we are subtracting value of r4 by 1. basically using repetitive addition to get multiplication.

cmp r4,0 // comparing r4 with 0. if equal then exit out of loop else continue.

bne loop

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote