我目前正在研究 MARIE SIMULATOR,我正在尝试获取三个输入的小数,然后将它们全部相乘。
出于某种原因,我的代码不断吐出比预期大得多的答案。例如 2 x 2 x 2 给了我 18。我一步一步地运行它,似乎 Skipcond 为每个周期运行了额外的时间。我尝试通过将其增加到 Skipcond 001 并将输入值更改为 Hex 来调整它,因为我在我的书中看到了类似的内容,但问题仍然存在。有人有想法么?
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
Loop2, 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 Loop2 /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
编辑:: 使用旧版本的代码。通过将第二个“Loop”更改为“Loop2”更正了代码。
问题仍然存在,得到的乘法答案不正确。问题似乎与 Skipcond 000 有关,尽管我不确定它是什么