#
# canola - canon canola 1614p emulator
# Copyright (C) 2011 Peter Miller
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 3, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
#
; ---------- Card-Pocket-Begin -------------------------------------------
; Title: MS-7: a**n
; where n is an integer
; a => m14
; n => m13
; Color: green
; Style: blank
; ---------- Card-Pocket-End ---------------------------------------------
;
SFJ $207
1
SM12 ; answer in m12
RM14 ; a
MJ $214
CS
MJ $214
SM12 ; a==0
UJ $300 ; return m12 (i.e. 0)
FJ $214
RM13 ; n
MJ $301
CS
MJ $302
1 ; n==0
SM12
UJ $300 ; return m12 (i.e. 1)
FJ $301 ; n<0
1
/
RM14
+=
SM14 ; a = 1 / a
UJ $303
FJ $302
SM13 ; n = -|n|
FJ $303
RM12
*
RM14
+=
SM12 ; answer *= a
RM13
1
+=
SM13 ; ++n
MJ $303 ; until (n >= 0)
FJ $300
RM12 ; return answer in x-register
SRJ