asmTron/tronScript/powCompiled.tron

34 lines
454 B
Plaintext
Raw Normal View History

2020-05-29 00:41:13 +02:00
#inputs
read BASE
read EXPONENT
setVar ONE 1
setVar ZERO 0
#newVar mulCOUNTER
#newVar mulOUT
copyVar BASE powOUT
jumpMark powLoop
copyVar powOUT IN_A
copyVar BASE IN_B
copyVar ZERO mulOUT
copyVar ZERO mulCOUNTER
jump mulLoop
jumpMark next
add powCOUNTER ONE powCOUNTER
if powCOUNTER != EXPONENT jump powLoop
write mulOUT
halt
jumpMark mulLoop
add mulOUT IN_A mulOUT
add mulCOUNTER ONE mulCOUNTER
if IN_B != mulCOUNTER jump mulLoop
jump next
halt