我在这里有一个程序,它创建一个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 谢谢!
发布于 2017-05-14 05:24:40
我没有完全阅读你的代码,但我遇到了类似的问题,这就是我如何找到你的帖子的。我刚刚了解了如何在清除AC后清除寄存器,只需将清除的AC存储到变量中
Clear Store n Store next Store large
这应该将ac值0赋给您的变量对不起,如果这不是您的问题,但希望我能提供帮助
https://stackoverflow.com/questions/36456704
复制相似问题