// SUM the 10 numbers starting with a number read in // start, input / read star
ID: 3553304 • Letter: #
Question
// SUM the 10 numbers starting with a number read in
//
start, input / read starting value
store NextNum
load ten / initialize counter
store count
loop, load count
subt one
store count
skipcond 400 / skip next stmt if acc 0
jump addit
jump finish
addit, load NextNum
store workingon
add one
store NextNum
load runningsum
add workingon
store runningsum
jump loop
finish, load runningsum
output
halt
NextNum, dec 0
workingon, dec 0
one, dec 1
ten, dec 10
runningsum, dec 0
count, dec
what it does, how it does. and what should put next to (count dec. " ? ")
Explanation / Answer
// SUM the 10 numbers starting with a number read in
//
start, input / read starting value ***It takes input
store NextNum and stores it in variable NextNum
load ten / initialize counter This is Counter to Count 10 numbers
store count count variable stores the current counting status
loop, load count ***this loop starts loading count which is taken 10
subt one we subtract 1
store count and store count again
skipcond 400 / skip next stmt if acc 0 if the number loaded is 0 skip it
jump addit jumps to function addit
jump finish jumps to finish
addit, load NextNum *** this function adds numbers, loads 1st num
store workingon temporary variable workingon to store current loaded number
add one this adds one and determine next number i.e 2nd num
store NextNum stores the 2nd num
load runningsum runningsum initialised 0, loaded
add workingon 1st num added
store runningsum temporary sum stored
jump loop jumped to loop for counting
finish, load runningsum finish function displays output i.e runningsum
output
halt ** this exits the code
NextNum, dec 0 *** these are the variables initialised to their values
workingon, dec 0
one, dec 1
ten, dec 10
runningsum, dec 0
count, dec this count should be 10
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.