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

1.What is the value of r0 after the code below executes? do: add r0, 12 bx lr ma

ID: 3810200 • Letter: 1

Question

1.What is the value of r0 after the code below executes?

do:
add r0, 12
bx lr
main:
mov r0, 10
bl do
add r0, 5


   5
   12
   22
   10
   27
   17


2.What is the value of r0 after the code below executes?

date: .int 1000, .int 100
do:
ldr r0, =date
ldr r0, [r0, 4]
add r0, r0, 10
bx lr
main:
bl do


   110
   1000
   100
   1010


3.What is the value of r0 after the code below executes?

do1:
add r0, 5
bx lr
do2:
sub r0, 5
bx lr
main:
mov r0, 10
cmp r0, 5
ite gt
blgt do1
blle do2


   5
   15
   0
   10


4.What is the value of r0 after the code below executes?

some: .int 5
main:
ldr r0, =some
ldr r0, [r0]
1:
subs r0, 1
it eq
beq 1f
b 1b
1:


   0
   1
   5
   -1


5.What is the value of r0 after the code below executes?

val: .int 100
do:
push {r3, lr}
ldr r3, =val
ldr r3, [r3]
cmp r3, 100
it lt
addlt r3, 10
it gt
addgt r3, 5
mov r0, r3
pop {r3, pc}
main:
ldr r0, =val
ldr r1, [r0]
add r1, r1, 11
str r1, [r0]
bl do


   111
   116
   11
   100
   5
   10

Explanation / Answer

1.27

Explanation:

do:
add r0, 12 (add 12 with contents of r0 and store it in r0 so r0 becomes 12)
bx lr
main:
mov r0, 10 (copy contents of 10 to register r0)
bl do (branch to the label)
add r0, 5 (22+5=27)

3.15

do1:
add r0, 5
bx lr
do2:
sub r0, 5
bx lr
main:
mov r0, 10 ( Copy contents of 10 to r0)
cmp r0, 5 (compare r0 with 5 )
ite gt (if then else statement if r0>5 execute do1 else do2)
blgt do1 (branch to do1 and perform add 5 to r0 so r0=10+5=15)
blle do2