Re: A83: Opposite of _formreal


[Prev][Next][Index][Thread]

Re: A83: Opposite of _formreal




Woops I really need to test this stuff first :P

;de->start of string
 ld hl,0
AddLineNum:
 add hl,hl
 ld b,h
 ld c,l
 add hl,hl
 add hl,hl
 add hl,bc                  ;hl=hl*10
 ld b,0
 ld a,(de)
 sub '0'
 jr c,DoneAddLineNum
 ld c,a
 add hl,bc                  ;add new number
 inc de
 jr AddLineNum
DoneAddLineNum

In a message dated 2/23/00 2:37:45 PM Eastern Standard Time, 
ComAsYuAre@aol.com writes:

> Wouldn't be too hard to right one.  Just multiply a (or hl or whatever) by 
> 10 
>  and then add each digit until you reach the null terminator.
>  
>  ;de->start of string
>   ld hl,0
>   ld b,h
>  AddLineNum:
>   add hl,hl
>   ld b,h
>   ld c,l
>   add hl,hl
>   add hl,hl
>   add hl,bc                  ;hl=hl*10
>   ld a,(de)
>   sub '0'
>   jr c,DoneAddLineNum
>   ld c,a
>   add hl,bc                  ;add new number
>   inc de
>   jr AddLineNum
>  DoneAddLineNum:



----
Jonah Cohen
<ComAsYuAre@aol.com>
http://linux.hypnotic.org/~jonah/