; DELVAR.Z80 ; ; A module for the Z3VARS library to delete a shell variable from the list ; loaded into memory ; ; Author: Dreas Nielsen ; Revision history: ; Date Comments ; ------ ---------- ; 1/15/87 Created ; 7/27/89 Shortened code -- Howard Goldstein ; ; EOF EQU 'Z'-'@' ; EXT Z3VARS,VARDEF PUBLIC DELVAR ; ;================ ; ;---- DELVAR ; ; Enter with: ; HL = addr of 8-char buffer containing variable name, blank-padded. ; Return with: ; A = 0 and Z if var deleted or not in list. ; A = FF and NZ if some error. ; DELVAR: PUSH BC PUSH DE LD A,(Z3VARS+1) OR A JR NZ,DV0 JR Z,BADEXIT ;quick (but unstructured) exit. ; DV0: CALL VARDEF JR NZ,DV2 ;name not found, return with 'success' message ; DV1: LD DE,-8 ;does exist -- calc var address ADD HL,DE ;HL=start of var/definition construct PUSH HL ;save to use for ending addr of move XOR A ;find end of variable, marked by 0 LD BC,500 ;var can't be longer than this CPIR ;HL now points after variable JR NZ,BADEXIT0 ;...unless there's some problem PUSH HL ;save for starting address of move LD D,H ;move to DE to calc length of remainder of file LD E,L LD A,EOF LD BC,65535 CPIR OR A ;clear carry SBC HL,DE ;# of bytes to move LD B,H LD C,L POP HL ;get starting addr of move POP DE ;get ending addr LDIR DV2: POP DE POP BC XOR A RET ; BADEXIT0: POP DE BADEXIT: POP DE POP BC XOR A DEC A RET ; END ; ; End of DELVAR.Z80