pep9
pep9
编写一个伪代码算法,读入三个值,输出它们的和。
我使用了循环语句
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
用pep/9机器指令实现上述算法
12 00 0B 00 00 00 00 00 00 00 00 31 00 09 31 00
07 C1 00 03 61 00 07 E1 00 03 C1 00 05 60 00 01
E1 00 05 A1 00 09 18 00 2C 12 00 0E 39 00 03 00
zz
用pep/9汇编语言实现上述算法
BR main
sum: .WORD 0x0000
counter: .WORD 0x0000
num: .BLOCK 2
limit: .BLOCK 2
main: DECI limit,d
loop: DECI num,d
LDWA sum,d
ADDA num,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