我如何在 MARIE 中提高数字 x 的 y 次方?

How do I raise a number x to the power y in MARIE?

我正在尝试创建一个 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
/ 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

这应该可以正常工作。如果您对此有任何问题,请告诉我。