; ADDVAR.Z80 ; ; A module for the Z3VARS library to add a variable definition to the list ; in memory. This will make the list longer, and no bounds checking is done ; to ensure that the operating system is not written over. ; ; Author: Dreas Nielsen ; Revision history: ; Date Comments ; ------ ---------- ; 1/15/87 Created. ; ; EOF EQU 'Z'-'@' ; EXT Z3VARS,DELVAR PUBLIC ADDVAR ; ;================ ; ;---- ADDVAR ; ; Enter with: ; HL = addr of name of variable ; DE = addr of null-terminated string that is definition ; Return with: ; A = 0 and Z if OK ; A = FF and NZ if error (i.e., vars not loaded) ; ADDVAR: LD A,(Z3VARS+1) OR A JR NZ,ADD0 DEC A RET ; ADD0: PUSH BC PUSH DE PUSH HL CALL DELVAR LD HL,(Z3VARS) LD A,EOF LD BC,65535 CPIR DEC HL ;back up to write over ^Z EX DE,HL ;put destn in DE POP HL ;get addr of name PUSH HL ;save it again LD BC,8 LDIR POP BC ;move first arg out of way POP HL ;get addr of definition PUSH HL ;put top two args back PUSH BC ADD1: LD A,(HL) LD (DE),A INC HL INC DE OR A JR NZ,ADD1 LD A,EOF ;store ^Z at end again LD (DE),A ; POP HL ;restore registers POP DE POP BC XOR A ;signal success RET ; END ; ; End of ADDVAR.Z80