.begin
in counter
while: load counter
compare zero
jumpeq done
out counter
decrement counter
jump while
done: halt
counter: .data 0
zero: .data 0
.end
Modify the program so it checks to see that the input data is greater than zero before it starts the loop. If that's not the case, the program should halt without any output.
ANSWER:
I have provided the properly commented
and indented code so you can easily copy the code as well as check
for correct indentation.
Have a nice and healthy day!!
CODE
.begin
in counter
load counter --loading counter to Register R
compare zero --Comparing R to zero
jumpgt while --If Counter>0, jump to while
jump done --otherwise jump to done
while: load counter
compare zero
jumpeq done
out counter
decrement counter
jump while
done: halt
counter: .data 0
zero: .data 0
.end
Get Answers For Free
Most questions answered within 1 hours.