; VARDEF.Z80 ; ; Module of Z3VARS library to search for a given variable definition. ; ; Author: Dreas Nielsen ; Revision history: ; Date Comments ; ------ ---------- ; 1/15/87 Created ; 7/27/89 Shortened code -- Howard Goldstein ; ; EOF EQU 'Z'-'@' ; EXT Z3VARS PUBLIC VARDEF ; ;================ ; ;---- VARDEF ; Resolve Named Variable Reference ; ; Enter with: ; HL = addr of variable name, in 8-character buffer filled out ; with spaces ; Return with: ; If found, HL = addr of variable definition and Z. ; If not found or vars not loaded, return NZ. ; VARDEF: LD A,(Z3VARS+1) ;use high byte of addres for loaded flag OR A JR NZ,VARDEF0 DEC A RET ; VARDEF0: PUSH BC PUSH DE EX DE,HL ;addr of name to de LD HL,(Z3VARS) ;pt to variable list VARDEF1: LD A,(HL) ;get char CP EOF ;end of list? JR Z,BADEXIT PUSH DE ;save addr of name LD B,8 ;8 chars VARDEF2: LD A,(DE) ;get name CP (HL) ;match? JR NZ,NOMATCH INC HL ;pt to next INC DE DJNZ VARDEF2 POP DE ;clean up stack POP DE POP BC XOR A RET ;found! NOMATCH: XOR A ;flush to end of string LD BC,1000H CPIR POP DE ;restore pointer to name JR NZ,BADEXIT ;structure error -- exit JR VARDEF1 ;resume search ; ; Search Failed ; BADEXIT: POP DE POP BC XOR A DEC A RET ; END ; ; End of VARDEF.Z80