; TITLE "SAIF2 - Syslib 4.0" NAME ('AIF2') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from SAIF2.Z80 Ver 1.1 by Richard Conn ; Date : 17 Sep 89 ; Version : 1.2 ; Module : SAIF2 ; Abstract: This module contains the routine AIF2 which is an ; arithmetic IF facility that branches to one of three ; routines depending on whether an 8-bit value passed to ; the routine is greater than, less than, or equal to a ; key value. It differs from AIF1 in that the table is ; made up of JP xx instructions instead of DEFW xx addresses. ; It is used as: ; ; LD B,5 ; key value ; LD A,TEST ; test value ; CALL AIF2 ; JP ALTB ; go here if A < B ; JP AEQB ; go here if A = B ; JP AGTB ; go here if A > B ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC AIF2 .Z80 CSEG ;=============================================================== ; NAME - AIF2 ; Entry: A - Contains the value to test ; B - Contains the Key value (against which to test) ; Exit : - N/A ; Uses : - None (Preserved for destination routine) ; Special Requirements: None ;=============================================================== AIF2: EX (SP),HL ; get return address PUSH AF ; save regs PUSH DE CP B ; compare JR C,LESS JR Z,EQUAL LD DE,6 ; A > B, so add 6 ADD HL,DE JR LESS EQUAL: LD DE,3 ; A = B, so add 3 ADD HL,DE ; A < B, so HL contains the return address (no change) LESS: POP DE ; restore regs POP AF EX (SP),HL RET END