Re: A83: getString routine


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

Re: A83: getString routine




>From: "ti-83" <ti-83@libertysurf.fr>
>To: "Assembly-83" <assembly-83@lists.ticalc.org>
>Subject: A83: getString routine
>
>Does someone can explain me these routine, particulary text wich are in 
>bold ? I found it in Periodic Table 2.0 of Ahmed El-Helw. There is a list 
>of elements. How does the program do to put the good string in hl.

ld hl,Elements
ld a,[number of the element : 1=Hydrogen, 2=Helium]
call getString

;---------= Point hl to string a =---------
; by: Joe Wingerbermuhle
; Thanks, this is a lot easier than my
; method of multiplying string # * 12
;
; Input: a=string number (0 to 255)
;  hl->string data
; Output: hl->string

getString:
          or a
;'or a' is the same as 'cp 0' but smaller and faster.
          ret z
          ld b,a
          xor a
getStringL1:
          push bc
          ld c,-1
;ld c,255
;That puts a big number into c so it can keep looking for 0's
;
          cpir
;cpir - compare increment repeat
;This just keeps searching for the next 0 (string terminator)
; (a=0 due to above xor a)
;each step, cpir does this:
;
;cp (hl)
;inc hl
;dec bc
;loop back unless a=(hl) or bc=0
;
          pop bc
          djnz getStringL1
          ret

Elements:
         .db "Hydrogen",0
         .db "Helium",0
         .db "Lithium",0
         .db "Beryllium",0
         .db "Boron",0
         .db "Carbon",0
         .db "Nitrogen",0
         .db "Oxygen",0
         ...

>Thanks

>Ti-83
>
>Le monde de la TI-83
>http://www.ti-83.fr.st
>ti-83@fr.st

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com