我正在尝试创建一个MARIE程序,该程序会将数字(x)乘幂(y)并提供输出。我已经尝试过许多改变主意的想法,但是我仍然面临错误。下面的代码是我最接近解决这个问题的代码
INPUT
STORE X
STORE XNUM
INPUT
STORE Y
MULTIPLIERA,LOAD PROD
ADD X
STORE PROD
LOAD XNUM
SUBT ONE
STORE XNUM
SKIPCOND 400
JUMP MULTIPLIERA
JUMP NEWPRODUCT
NEWPRODUCT, LOAD X
STORE XNUM
LOAD PROD
STORE X
LOAD Y
SUBT ONE
STORE Y
SKIPCOND 400
JUMP MULTIPLIERA
LOAD PROD
OUTPUT
HALT
X, DEC 00
XNUM, DEC 00
Y, DEC 00
ONE, DEC 01
PROD, DEC 00
3^2 gives me a 36 and 1^3 gives me a 4
答案 0 :(得分:2)
/ Start of the main program
Input / Enter the exponent Store y
Subt One
Store Count
Input / Enter the Base
Store x
Store y
Jns Exp
/ Ending the main program
Load Ans
Output
End, Halt
Exp, Hex 0
Loop2, Load Count
Skipcond 800
JumpI Exp
JnS Multiplier
Load Ans
Store x
Load Count
Subt One
Store Counter
Jump Loop2
/ Start of the subroutine Multiplier
Multiplier, Hex 0
Load Zero
Store Ans
Loop, Load x
Skipcond 800
JumpI Multiplier
Load Ans
Add y
Store Ans
Load x
Subt One
Store x
Jump Loop
/ Declaration
x, Dec 2
y, Dec 3
Zero, Dec 0
One, Dec 1
Ans, Dec 0
Count, Dec 0
应该可以。让我知道您是否对此有任何疑问。