Assuming that a is stored in register r0 and b is stored in

Assuming that a is stored in register r_0 and b is stored in register r1, show the ARM assembly code that is equivalent to the following C code. if (a & 1) a = -a; else b = b + 7; Without using the mu l instruction, give the instructions to multiply r3 by the following constants, leaving the result in r0. You may also use r1 and r2 to hold temporary results, and you do not need to preserve the original contents of r3. 10 100 575 123

Solution

4.6 question

.LC0:
.ascii \"show a\\000\"
.LC1:
.ascii \"show b\\000\"
main:
stmfd sp!, {fp, lr}
add fp, sp, #4
sub sp, sp, #8
mov r3, #1
str r3, [fp, #-8]
mov r3, #2
str r3, [fp, #-12]
ldr r3, [fp, #-8]
and r3, r3, #1
cmp r3, #0
beq .L2
ldr r3, [fp, #-8]
rsb r3, r3, #0
str r3, [fp, #-8]
b .L3
.L2:
ldr r3, [fp, #-12]
add r3, r3, #7
str r3, [fp, #-12]
.L3:
ldr r0, .L5
bl printf
ldr r0, .L5+4
bl printf
mov r3, #0
mov r0, r3
sub sp, fp, #4
ldmfd sp!, {fp, lr}
bx lr
.L5:
.word .LC0
.word .LC1

 Assuming that a is stored in register r_0 and b is stored in register r1, show the ARM assembly code that is equivalent to the following C code. if (a & 1)

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site