|
Written by Ronald
|
;Summary: Convert hexadecimal digits to ASCII
;Compatibility: PowerPC platform
;Notes: Reads 3 parameters in R1-R3
; R1 = Number to convert to ASCII representation
; R2 = Number of LSD's of R1 to convert
; R3 = Address to store ASCII representation of number to
; R31 = Temp register that holds 4 bits
; Note that R1 is ruined during execution
.global TOHEX, TOHEX_LOOP, LT_TEN, STEP_OVER, TOHEX_EXIT
TOHEX:
cmpwi R2, 0
be TOHEX_EXIT
TOHEX_LOOP:
andi. R31, R1, 15
cmpwi R31, 10
blt LT_TEN
addi R31, R31, 'A'-10
b STEP_OVER
LT_TEN:
ori R31, R31, '0'
STEP_OVER:
srwi R1, R1, 4
subi R2, R2, 1
stbx R31, R2, R3
cmpwi R2, 0
bne TOHEX_LOOP
TOHEX_EXIT:
blr
|