In basic we can do this:
Repeat A<16
A-16->A
End
i need to make a 16bit hex value into a 5 digit number
it can be done, and in basic i have, but in assembly it gets all confusing
please help?
(after converting it, the 5 digits are supposed to be ascii values of largefont numbers, which should be stored in a 5 byte string somewhere, if it matters anything to the conversion.. (optimisations maybe))
[TI ASM] converting hex to number?
Moderator: MaxCoderz Staff
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
Maybe you can use bcall(_dispHL). You can also have a look at http://baze.au.com/misc/z80bits.html#5.1.
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
If you want to do it without a bcall, or if you need the actual text, you can use this:King Harold wrote:well i Could do that.....
but its worth messing around with the code for a month or more to come up with the asm alternative (a good method has allready been provided by chickendude)
Code: Select all
NToS: ld bc, -10000
call _getDigit
ld bc, -1000
call _getDigit
ld bc, -100
call _getDigit
ld bc, -10
call _getDigit
ld a, l
add a, 48
ld (de), a
inc de
xor a
ld (de), a
ret
_getDigit: ld a, 47
_getDigitLp:inc a
add hl, bc
jp c, _getDigitLp
sbc hl, bc
ld (de), a
inc de
ret