2

我这里有一个程序,它创建一个由 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  

谢谢!

4

1 回答 1

1

我没有完全阅读你的代码,但我遇到了类似的问题,这就是我找到你的帖子的方式。我刚刚弄清楚了如何清除寄存器一旦你清除了 AC,只需将清除的 AC 存储到变量中

Clear Store n Store next Store large

这应该将 0 的 ac 值分配给您的变量 抱歉,如果这不是您的问题,但希望我能提供帮助

于 2017-05-13T21:24:39.583 回答