TITLE "Z3INDR - Z3lib 4.0" NAME ('IDXNDR') ;================================================================ ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;---------------------------------------------------------------- ; Author : Harold F. Bower ; Date : 22 Jun 91 ; Version : 1.0 ; Module : Z3INDR ; Abstract: This module contains the routine IDXNDR which returns ; a pointer to the Named Directory Entry specified by a ; relative index [0..n], or an Error flag if No NDR or the ; index is out-of-range. ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC IDXNDR ; External References EXT GETND0 .Z80 CSEG ;=============================================================== ; NAME - IDXNDR ; Entry: A = relative index [0..n] of desired NDR entry ; Exit : HL - Pointer to requested entry if found, 0 if Error ; A <> 0, Zero Flag Reset (NZ) if Record exists ; A = 0, Zero Flag Set (Z) if No NDR/Record doesn't exist ; Uses : AF,HL ; Special Requirements: None ;=============================================================== IDXNDR: LD (IDX),A ; Save requested index CALL GETND0 ; Get ptr to NDR and # of recs RET Z ; ..quit w/Error if No ENV or NDR PUSH DE ; Else prepare for range check LD E,A ; Store number of Entries ; Check requested record index against possible entries LD A,(IDX) ; Get requested entry index CP E ; Is it within range? JR NC,EREXIT ; ..Exit Error if not ; Step into the NDR by 18-byte steps until index achieved LD DE,18 ; Set length of each record INC A ; Preindex incase 0th record desired IDX0: INC (HL) ; Test for any entry in case buffer empty DEC (HL) ; Zero? JR Z,EREXIT ; ..Hit the end of entries, so exit w/Error DEC A ; Have we arrived? JR Z,OKEXIT ; ..Exit Ok if so ADD HL,DE ; Else advance to next entry JR IDX0 ; ..and loop OKEXIT: DEFB 0F6H ; Ok set with "OR 0AFH" w/next instruction EREXIT: XOR A ; Error set if entered here POP DE ; Restore regs RET ; ..and quit ; Data Storage/Buffers DSEG ; Put in Data Segment IDX: DEFS 1 ; Entry index for desired record END