Without using the mul instruction give the instructions to m

Without using the mul 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. (a) 10 (b) 100 (c) 575 (d) 123

Solution

a.

add r1,r1,r3,LSL #3 ;8*r3

add r0,r1,r1,LSL #1 ;8*r3 + 2*r3= 10*r3

b.

add r1,r1,r3,LSL #6 ;64*r3

add r0,r1,r1,LSL #5 ;64*r3 + 32*r3= 86*r3

add r0,r0,r0,LSL #3 ;86*r3 + 8*r3 = 94*r3

add r0,r0,r0,LSL #2 ;98*r3

add r0,r0,r0,LSL #1 ;100*r3

c.

add r1,r1,r3,LSL #9 ;512*r3

add r0,r1,r1,LSL #6 ;512*r3 + 64*r3= 576*r3

sub r0,r0,r3 ;576*r3 - r3=575*r3

d.

add r1,r1,r3,LSL #7 ;128*r3

sub r0,r1,r1,LSL #2 ;128*r3 - 4*r3= 124*r3

sub r0,r0,r3 ;124*r3 - r3=123*r3

 Without using the mul instruction, give the instructions to multiply r3 by the following constants, leaving the result in r0. You may also use r1 and r2 to hol

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site