27 lines
581 B
Text
27 lines
581 B
Text
ExponentUnsigned:
|
|
;input: D0.W = BASE
|
|
; D1.W = EXPONENT
|
|
; OUTPUTS TO D0
|
|
; NO OVERFLOW PROTECTION - USE AT YOUR OWN RISK!
|
|
;HIGH WORDS OF D0 AND D1 ARE CLEARED.
|
|
;clobbers D1
|
|
|
|
MOVE.L D2,-(SP)
|
|
|
|
;using DBRAs lets us simultaneously subtract and compare
|
|
DBRA D1,.test_if_one
|
|
MOVEQ.L #1,D0 ;executes only if D1 was 0 to start with
|
|
.test_if_one:
|
|
DBRA D1,.go
|
|
bra .done ;executes only if D1 was 1 to start with
|
|
.go:
|
|
;else, multiply D0 by its ORIGINAL self repeatedly.
|
|
MOVE.L D0,D2
|
|
.loop:
|
|
MULU D0,D2
|
|
DBRA D1,.loop
|
|
|
|
MOVE.L D2,D0
|
|
.done:
|
|
MOVE.L (SP)+,D2
|
|
RTS
|