MARIE中的重置命令?

时间:2016-04-06 16:15:46

标签: java assembly marie

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

谢谢!

1 个答案:

答案 0 :(得分:0)

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

Clear Store n Store next Store large

这应该为您的变量指定交流值0 对不起,如果这不是你的问题,但希望我能提供帮助