pep9课下作业
(1)编写一个伪代码算法,读入三个值,输出它们的和。
Set sum to 0
Set counter to 0
Set limit to number of values to sum
WHILE(counter<limit)
Read num
Set sum to sum + num
Set counter to counter + 1
Write sum
(2)用PEP/9 机器指令实现(1)中的算法,提交测试结果截图。
(3)用PEP/9 汇编语言实现(1)中的算法,提交测试结果截图。
BR main
sum: .WORD 0x0000
num: .BLOCK 2
limit: .BLOCK 2
counter: .WORD 0x0000
main: DECI limit,d
loop: DECI num,d
LDWA num,d
ADDA sum,d
STWA sum,d
LDWA counter,d
ADDA 1,i
STWA counter.d
CPWA limit,d
BREQ finish
BR loop;
finish: DECO sum,d
STOP
.END