;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Potency routine ($02-$03 will hand the result)
;$00 must be the Base and $01 the Exponent
;Note: the result it's a 16 bits value.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Potency:
DEC $01 ;\Fix the
DEC $01 ;/Exponent
LDA $00 ;\$02 will be
STA $02 ;/the "second" base
LDX $01 ;Set up Loop
.LoopForIToExponentDo
LDA $00 ;\The "real" base
STA $4202 ;/Set at the multiply register A
LDA $02 ;\The "second" base
STA $4203 ;/Set at the multiply register B
NOP #8 ;Waste cycles. We need time to the multiplication works
LDA $4216 ;\Hand the result
STA $02 ;/Store first digit
LDA $4217 ;\Hand the result
STA $03 ;/Store second digit
DEX ;Decremet exponent/Loop
BPL .LoopForIToExponentDo ;If the loop doesn't end, return
RTS ;Finally, end...
LDA #$Base
STA $00
LDA #$Exponent
STA $01
JSR Potency
REP #$30
LDA $02
*Random Code*
SEP #$30
LDA #$Base
STA $00
LDA #$Exponent
STA $01
JSR Potency
LDA $02
*Random Code*
LDA $03
*Another Random Code*
I don't know why you should use this, but well... Do whatever you want, but just keep in mind that this routine doesn't work correctly with the Hex2Dec one, cause it has only 3 digits, and can't be higher than 255, and since my routine gives a 16 bits result, you would need to edit somethings in the Hex2Dec routine to works correctly.
No comments:
Post a Comment