[A83] Re: Hex to decimal
[Prev][Next][Index][Thread]
[A83] Re: Hex to decimal
Not to sound stupid, but what exactly do rlc, adc, and daa do? I also assume
the @ sign is a different format than ZiLOG (I label using colon's). My code
seems to work...I just need it for values <19d, but I'd like to understand this
code. Thanks a lot for your help and suggestions.
-Tom
Kirk Meyer wrote:
> If you actually want to transfer it to a floating point (i.e., OP1), then
> use SetXXOP1. Um, the code you gave doesn't even get to the second half of
> it. To convert into just a register (hex number has to be in the range 0 to
> 99), the following should work:
>
> ;Input: C = hex
> ;Output: A = decimal (0-99)
> ld b,8
> xor a
> @loop rlc c
> adc a,a
> daa
> djnz @loop
> ret
>
> This is if you wanted to convert a strictly hex number to decimal (i.e. $1F
> to $31). You need a different routine to convert $14 to 14.
>
> -----Original Message-----
> From: assembly-83-bounce@lists.ticalc.org
> [mailto:assembly-83-bounce@lists.ticalc.org]On Behalf Of Thomas Lutz
> Sent: Monday, July 09, 2001 8:53 PM
> To: assembly-83@lists.ticalc.org
> Subject: [A83] Re: Hex to decimal
>
> Nevermind I figured it out...if anyone has any optimization suggestions
> feel free...
> Thanks..
> -Tom
>
> ;******************************
> ; Hex to decimal routine
> ;Inputs: A=1 less than number in hex
> ;C=number in decimal floating points format
> ;******************************
> HexToDecimal:
> ld b,9
> HexLoop:
> inc c
> dec a
> cp 0
> ret z ;Return if a=0
> djnz HexLoop
> ;c=9 now...increase first four bits, reset last four
> push af
> ld a,c
> and 11110000b
> add a,10h
> ld c,a
> ld b,9
> pop af
> jr HexLoop
>
> Thomas Lutz wrote:
>
> > What kind of code could I use for taking a hex value in the accumulator
> > and transfering it to a real variable in floating point format? Thanks.
> > -Tom
Follow-Ups:
References: