Re: A86: string decimal -- HL
[Prev][Next][Index][Thread]
Re: A86: string decimal -- HL
>Try this (not tested, obviously!):
>
>Str_to_hl:
> ld hl,0 ; clear out hl
> ld b,0 ; clear high byte
>loop:
> call Read_byte ; get the next byte
> sub 48 ; calc num value of the char ('0' = 48)
> cp 10 ; is it greater than 9?
> ret nc ; if so, then we're done
> ld c,a ; save value
> sla l ; hl * 2
> rl h ; ...
> ld de,hl ; save hl * 2
had to change this... can't do LD DE,HL
> sla l ; hl * 4
> rl h ; ...
> sla l ; hl * 8
> rl h ; ...
> add hl,de ; (hl * 8) + (hl * 2) = hl * 10
> add hl,bc ; add value
> jr Str_to_hl ; loop through the entire string
oh, and I had to change that jump to Jr loop
>I hope this helps!
This works great! Now I just have to fix the routine that calls it...
If anyone cares to do the hex equivelent for me... :) My routine for it
is just sooo ugly! hehe
--awwaiid
Retupmoc7@hotmail.com
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
Follow-Ups: