; TITLE "SAIF1 - Syslib 4.0" NAME ('AIF1') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from SAIF1.Z80 Ver 1.1 by Richard Conn ; Date : 17 Sep 89 ; Version : 1.2 ; Module : SAIF1 ; Abstract: This module contains the routine AIF1 which is an ; arithmetic IF facility. It accepts an 8-bit value against ; which to test another value passed to it. A three-way ; branch is then calculated depending on whether the test ; value is greater than, less than, or equal to the key ; value. This routine is used as: ; ; LD B,5 ; key value ; LD A,TEST ; test value ; CALL AIF1 ; DEFW ALTB ; go here if A < B ; DEFW AEQB ; go here if A = B ; DEFW AGTB ; go here if A > B ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC AIF1 .Z80 CSEG ;=============================================================== ; NAME - AIF1 ; Entry: A - Contains the value against which to test ; B - Key value (Base index for table) ; Exit : - N/A ; Uses : - None (saved for destination routine) ; Special Requirements: None ;=============================================================== AIF1: EX (SP),HL ; get return address PUSH AF ; save regs PUSH DE CP B ; compare JR C,LESS JR Z,EQUAL LD DE,4 ; A > B, so add 4 ADD HL,DE JR LESS EQUAL: LD DE,2 ; A = B, so add 2 ADD HL,DE ; A < B, so HL contains the address pointer (no change) LESS: LD A,(HL) ; get low INC HL LD H,(HL) ; get high LD L,A ; HL = address to return to POP DE ; restore regs POP AF EX (SP),HL RET END