【发布时间】:2010-10-25 00:58:22
【问题描述】:
我正在使用 MARIE 程序学习汇编,但我无法从书中找出做这个问题的热门:
将一个数除以另一个数并将商和余数存储在两个不同的内存位置。
这是我到目前为止所拥有的,我做错了什么?仅供参考,程序中没有内置除法或乘法,所以我必须使用循环来完成,但我想我错过了一些东西。
程序可以在这里http://computerscience.jbpub.com/ecoa/2e/downloads/MarieSim-v1.3.01.zip
ORG 100
Input / Enter a number
Store X / Saves the number
Input / Enter a number
Store Y / Saves the number
Load Zero / Move 0 into AC
Store Z / Set Z to 0
If, Load Z / Load Z
Skipcond 400 / If AC=0 (Z=0), skip the next instruction
Jump Endif / Jump to Endif if X is not greater than 1
Then, Load X
Subt Y / X - Y
Store X / X = X - Y
Endif, Load Z / Load Z into AC
Add One / Add 1 to Z
Store Z / Z = Z + 1
Output / Print to screen
Halt / Terminate program
X, Dec 0 / X has starting value
Y, Dec 0 / Y has starting value
Z, Dec 0
One, Dec 1 / Use as a constant
Zero, Dec 0 / Use as a constant
END
【问题讨论】:
-
你还是点击了“添加评论”? :)