TITLE "Z3SNDR - Z3lib 4.0" NAME ('SUBNDR') ;================================================================ ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;---------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from Z3SNDR.Z80 Ver 1.1 by Richard Conn ; Date : 23 Jun 91 ; Version : 1.3 ; Module : Z3SNDR ; Abstract: This module contains the routine SUBNDR which tries ; to remove a specified Name from the Named Directory ; Buffer ; Revision: ; 1.2 - 29 Mar 89 - shortened code. HFB ; 1.3 - 23 Jun 91 - fixed error in Exit, shortened code. HFB ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC SUBNDR ; External References EXT ENVPTR, GETND0, CAPS .Z80 CSEG ;=============================================================== ; NAME - SUBNDR ; Entry: HL - Points to 8-char name to delete from NDR ; Exit : A <> 0, Zero Flag Reset (NZ) if Ok ; A = 0, Zero Flag Set (Z) if No NDR/Not found ; Uses : AF ; Special Requirements: None ;=============================================================== SUBNDR: PUSH HL PUSH DE PUSH BC LD (DNAME),HL ; Save ptr to DIR name CALL GETND0 ; Get ptr to Named Directory Buffer JR Z,SUBERR LD B,A ; Save number of Entries in counter ; Look for entry (every 18 bytes) LD DE,18 ; Size of each entry SUBN2: LD A,(HL) ; Get 1st char of name OR A ; Is it the end? JR Z,SUBERR ; ..exit if so (Error) CALL COMPNAM ; Compare names JR Z,FOUND ADD HL,DE ; Pt to next name DJNZ SUBN2 ; ..loop til found or out of entries SUBERR: XOR A ; Error status, Set Z Flag JR COMPEX ; ..restore regs and exit elsewhere ; Compare name whose entry is pted to by HL against that pted to by DNAME ; Return with Zero Set if match COMPNAM: PUSH HL PUSH DE PUSH BC INC HL ; Pt HL to name itself INC HL LD DE,(DNAME) ; DE pts to DNAME LD B,8 ; Compare 8 bytes in name COMP1: LD A,(DE) ; Get DNAME CALL CAPS ; .capitalize CP (HL) ; Do they match? JR NZ,COMPEX ; ..exit if not INC HL ; Else pt to next INC DE DJNZ COMP1 ; ..looping til finished COMPEX: POP BC POP DE POP HL RET ; Name found: HL = address of match ; DE = 18 (size of entry) FOUND: EX DE,HL ADD HL,DE ; HL pts to next entry, DE pts to entry to del ; Check for completion FOUND1: LD B,18 ; Copy/fill 18-byte entry LD A,(HL) ; End of dir? OR A JR Z,FOUND3 ; ..exit if so ; Move entry up FOUND2: LD A,(HL) ; Copy this byte LD (DE),A ; .here INC HL ; ..advancing to next INC DE DJNZ FOUND2 ; Loop til finished JR FOUND1 ; Check next ; Zero-Fill deleted last entry FOUND3: LD (DE),A ; Zero-fill entry to delete INC DE DJNZ FOUND3 ; ..looping til done ; OK exit OR 0FFH ; Set NZ for good return JR COMPEX ; ..restore regs and finish elsewhere ; Data Storage/Buffers DSEG ; Put in Data Segment DNAME: DEFS 2 ; Ptr to name to delete END