MARIE and exponents
Im trying to write a program in MARIE assembly where you can put in any 2 numbers (X to the Y power) and it will find your answer. I am completely stuck and need some help. This is what I have so far:
Im trying to write a program in MARIE assembly where you can put in any 2 numbers (X to the Y power) and it will find your answer. I am completely stuck and need some help. This is what I have so far:
Rich (BB code):
Input
Store M
Input
Store N
Load M /load 1st value as counter
Store Ctr1 /Store the counter
Loop, Load Sum /Load sum
Add M /Add M to Sum
Store Sum /Store result in Sum
Load Ctr1 /initialize counter
Subt One /Decrement counter
Store Ctr1 /Store counter
SkipCond 400 /discontinue loop if Ctr1=0
Jump Loop /if AC not 0, continue loop
Endloop, Load N /loading to counter
Store Ctr2
Jump B /off to B
C, Load Sum
Output /Print product
Halt /Sum = MeN
B, Load Sum /
Store P /
Jump E /off to E
Loop1, Load P / load P
Add Sum /add sum
Store Sum / save sum
Load Ctr1 /load counter 1
Subt One /subtract 1 from counter
Store Ctr1 /store value of counter
SkipCond 400 /skip next line if current value of ctr1 = 0
Jump Loop1 /off to loop1
EndLoop1, Load Ctr2 /load counter2
Subt One /subtract 1
Store Ctr2 /store counter 2
Load M /load M to get ready to use it as the counter again
F, Store Ctr1 /saved value for counter 1
Load Ctr2 / load counter 2
SkipCond 400 /checking for valve 0
Jump Loop1 /if not 0 off to loop1
Jump C /now we are done
D, Load M
Subt One
Store Ctr1
Jump B
E, Load M /Starting new counters
Store Ctr2 /Counter 2
Load M /Loading M for counter 1
Subt One /I have the first value for P so counter is starting now
Jump F /off to F
Ctr1, Dec 0 /Used for first couter to find
Ctr2, Dec 0 /going to use the N input as counter 2
M, Dec 0 /initial value of M
P, Dec 0 /init value of P
Sum, Dec 0 /initial value of Sum
One, Dec 1 /constant value 1
Two, Dec 2 /constant Value 2
N, Dec 0 /Initial value of M
Last edited by a moderator: