The program below represents an answer to the following assignment: Write a Pep/
ID: 3831249 • Letter: T
Question
The program below represents an answer to the following assignment:
Write a Pep/9 program that reads integers until zero is entered then it outputs the sum of the
even numbers that were input.
For example if the input is 7 2 1 9 8 4 6 3 0 the output is 20.
Identify (a) the syntax errors that would be found by the assembler (5 points)
(b) logic errors that the assembler could not detect. (15 points)
deci N,d
breq endprog
top: ldwx N,d
asrx
brc top
adda total,d
stora total,d
br top
end: deci total
stop
total: .word 0
number:.block 2
.end
Explanation / Answer
zero: .word 0x0000
num .block 6 ; space for 3 ints
deci 0x0003,d ; get 1st number
back :lda 0x0003,d ; storing the 1st number in A
suba zero,d
bre last ; comparing if the entered nuber is zero or not
adda 0x0005,d ; adding the numbers
sta 0x0007,d ; storing the sum
br back
last : deco ox0007,d
STOP
.END
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.