我目前正在研究MARIE SIMULATOR,我试图得到三个输入的小数,并将它们全部加在一起。我将我的代码保存为.mas并尝试组装它。它说我有1个错误,但汇编列表完全是空的!我发现当我从中移除Jump OP时,代码会组装并运行,但是,我需要Jump来获得正确的答案。无论我到哪里,我都会看到跳跃,因为我已经写好了,所以我不知道自己是不是错了,如果我的模拟人员被错误或是什么。
ORG 100 /Starting point // Gustavo Brandao. No Partners
Input /Request user input for first number
Store NumA /Store the number
Output /Display number to screen
Input /Request user for a second number
Store NumB /Store number
Output /Display number
Input /Request user for third number
Store NumC /Show number
Output /Display number
Loop, Load NumA /Load the first number, will also loop from here
Add Sum /Add with zero and location which will save the sum
Store Sum /Store the sum
Load NumB /Load the second number for the skip condition control
Subt One /decrement the number
Store NumB /Store the number. when 0, code will skip the jump
Skipcond 000 /Skip when the second number reaches zero
Jump Loop /Used to repeat addition until second number reaches zero
Load Sum
Store NumA /Storing sum in NumA slot to make code easier to read
Loop, Load NumA /Loading the previous sum
Add FSum /Adding previous sum to zero and final sum location
Store FSum /Storing final sum
Load NumC /Second skip condition control
Subt One /decrememting number
Store NumC /Storing skip condition
Skipcond 000 /When the third inputed number is zero, loop will end
Jump Loop /Loops back to second part of code
Load FSum /load the final sum for output
Output /Display final sum
HALT
NumA, Dec 0 /First number; Will be overwritten with input
NumB, Dec 0 /Second number
NumC, Dec 0 /Third number
Sum, Dec 0 /Stores the sum for the first multiplication process
FSum, Dec 0 /Stores sum for the second multiplication process
One, Dec 1 /Used to decrement values
答案 0 :(得分:0)
所以我意识到我不能在程序中有两个“循环”,因为它不会识别要跳转到哪个。我将第二个命名为Loop2并且它有效。我得到了错误的答案,但没有任何一点调整不会解决