TITLE "Z3IF - Z3lib 4.0" ;================================================================ ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;---------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from Z3IF.Z80 Ver 1.1 by Richard Conn ; Date : 29 Mar 89 ; Version : 1.2 ; Module : Z3IF ; Abstract: This module contains the routines IFT and IFF which ; turn on the next level of IF testing and set the condi- ; tions to TRUE and FALSE respectively ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC IFT, IFF ; External References EXT GETMSG .Z80 CSEG ;=============================================================== ; NAME - IFT ; Entry: - None ; Exit : A <> 0, Zero Flag Reset (NZ) if OK ; A = 0, Zero Flag Set (Z) on IF level overflow ; Uses : AF ; Special Requirements: None ;=============================================================== IFT: PUSH BC ;save BC LD B,0FFH ;turn on CALL IFSET POP BC RET ;=============================================================== ; NAME - IFF ; Entry: - None ; Exit : A <> 0, Zero Flag Reset (NZ) if OK ; A = 0, Zero Flag Set (Z) on IF level overflow ; Uses : AF ; Special Requirements: None ;=============================================================== IFF: PUSH BC ;save BC LD B,0 ;turn off CALL IFSET POP BC RET ;..... ; Turn on next IF level ; B register is 0 if level is inactive, 0FFH is level is active ; Return with Z flag set if IF overflow IFSET: PUSH HL ;save regs PUSH DE PUSH BC CALL GETMSG ;pt to messages INC HL ;pt to IF byte LD A,(HL) ;get IF byte OR A ;if no IF at all, start 1st one JR Z,IFSET1 CP 80H ;check for overflow (8 IFs max) JR Z,IFERR INC HL ;pt to active IF AND (HL) ;check to see if current IF is TRUE JR NZ,IFSET0 ;continue if so LD B,A ;B=0 to set next IF to FALSE IFSET0: DEC HL ;pt to IF level LD A,(HL) ;get it RLCA ;advance to next level AND 0FEH ;only 1 bit on LD (HL),A ;set IF byte JR IFSET2 IFSET1: INC A ;A=1 LD (HL),A ;set 1st IF INC HL ;clear active IF byte LD (HL),0 DEC HL IFSET2: LD D,A ;get IF byte AND B ;set interested bit LD B,A INC HL ;pt to active flag LD A,D ;complement IF byte CPL LD D,A LD A,(HL) ; Get active byte AND D ; Mask in only uninterested bits OR B ; Mask in complement of interested bit LD (HL),A ; ..save result DEFB 0F6H ; Return with NZ ("OR 0AFH") IFERR: XOR A ; Set Error code of Z POP BC ; Restore regs POP DE POP HL RET END