Question: Write a MARIE program using a loop that multiplies two positive numbers by using repeated addition. For example, to multiply 3x6, the program would add
Write a MARIE program using a loop that multiplies two positive numbers by using repeated addition. For example, to multiply 3x6, the program would add 3 six times, or 3+3+3+3+3+3.
Can someone tell me what's wrong with my code?
ORG 100
Load y
Store Count /Initialize a Counter to compare to y Loop,
Load y /Load y constant
Subt Count /compare y to Counter
SkipCond 000 /if y < Count
Jump EndLoop /if y !< counter then end the loop
Load x /Lode x
Add x /Add x to x
Store x /Store new value to x
Load Count /load counter
Add One /Add one to Count each loop
Store Count /Store new value of Count
Jump Loop /go back to loop
Endloop Halt /exit loop and terminate program
x, Dec 2
y, Dec 3
Count, Dec 0
One, Dec 1
END
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
