我这里有一个程序,它创建一个由 10 个整数组成的数组,并要求用户为正在评估的数字创建限制。例如,输入 7 将评估数组中的数字 1-7。由于我的索引方法,我从 1 开始,而不是 0。在选择的数字中,最大的数字将被存储并打印在输出中。一切正常;但是,我无法多次运行该程序。我必须每次手动重置模拟器以获得准确的结果,因为添加命令时只有 AC 会清除。我想知道是否有任何命令可以完全擦除寄存器而不使用 MARIE jar 中的下拉菜单?这是我的代码:
/Begin at line 100.
org 0100
/clear AC of previous runs.
clear
/user input.
input
/Subtract 1 due to indexing method.
subt one
/add location of first
/value to input ro find limit.
add ctr
/store into limit variable n.
store n
/load first value @ location ctr.
loadi ctr
/first value becomes largest for now.
store large
/subtract ctr to begin loop @ beginning of index
load ctr
subt one
store ctr
/loop while ctr < n
/Increment ctr.
loop, load ctr
add one
store ctr
/compare value @ ctr
/to current largest value.
loadi ctr
subt large
/stores value @ ctr
/if greater than large.
skipcond 800
skipcond 000
jump store
/Post test
/When ctr reaches n,
/loop breaks to Stop.
test, load n
subt ctr
skipcond 400
jump loop
jump Stop
/stores variable @ address ctr
/Reached if variable > large.
store, loadi ctr
store large
jump test
/Reached when ctr == n.
/Outputs large and halts.
Stop, load large
output
halt
/Variables.
/ctr begins @ location of
/first variable in array.
ctr, hex 122
one, hex 1
n, hex 0
next, hex 0
large, hex 0
/Array.
hex 1
hex 3
hex 2
hex 5
hex 6
hex 4
hex 8
hex 0
hex 9
hex 8
谢谢!