RE: A83: getString routine


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

RE: A83: getString routine



See comments in the code...
-----Oorspronkelijk bericht-----
Van: ti-83 [mailto:ti-83@libertysurf.fr]
Verzonden: dinsdag 20 juni 2000 18:23
Aan: Assembly-83
Onderwerp: 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 ; same as 'cp 0' but faster and smaller
         ret z
         ld b,a
         xor a
getStringL1:
         push bc
         ld c,-1 ; c= -1 or c=254
         cpir ; cp (hl); inc hl; dec bc; continue while  a<>(hl) and while 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