You are asked to add a multiply instruction to LC3 making us
Solution
first_num .fill #5
sec_num .fill #4
;R1 is our sum
AND R1, R1, #0 ;// set R1 to zero
LD R2, first_num; //load data in R2 from register first_num
LD R3, sec_num; //load data in R3 from register sec_num
enter loop
MULTIPLY ADD R1, R1, R2 ; //add to sum i.e. R1<-R1+R2
ADD R3, R3, #-1 ; //decrement our counter i.e.R3
BRp MULTIPLY ; //continue until the 2nd num is 0 i.e.R3
in this program AND and ADD can use immediate mode.
sourece and destination operands are registers.
R2 and R3 are the source operands and the result also storing in R3 register.
the above program works like.R1 is initially 0.
in the loop we are adding R1 and R2 to R1.and we took R3 as counter.
first interation R1=0+5(R1=R1+R2)
decrementing R3=3
R1=5+5(R1+R2) and R3=2
R1=10+5(R1+R2) and R3=1
R1=15+5(R1+R2) and R3=0
R1=20 and R3=-1
Ex: 5*4
5+5+5+5=20.adding 5 for 4 times this is multiplicaion rule.
hope u understand this..
