; TITLE "SHIF2 - Syslib 4.0" NAME ('HIF2') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from SHIF2.Z80 Ver 1.1 by Richard Conn ; Date : 17 Sep 89 ; Version : 1.2 ; Module : SHIF2 ; Abstract: This module contains the single routine HIF2 which is ; an arithmetic IF facility. A key value is passed in the ; DE register pair and a test value is passed in the HL reg- ; ister pair. Execution is transferred to one of three Jump ; instructions which immediately follow the Call to HIF2 ; depending on whether the test value is Greater than, Less ; than, or equal to the key value. The routine is used as: ; ; LD DE,5 ; key value ; LD HL,TEST ; test value ; CALL HIF2 ; JMP HLTD ; go here if HL < DE ; JMP HEQD ; go here if HL = DE ; JMP HGTD ; go here if HL > DE ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points: PUBLIC HIF2 .Z80 CSEG ;========================================================================= ; NAME - HIF2 ; Entry: HL - A Test value to test ; DE - A Key value against which to evaluate the Test value ; Exit : - No parameters are returned, but execution is transferred ; Uses : - None. (all values preserved for destination routine) ; Special Requirements: None ;========================================================================= HIF2: EX (SP),HL ; get return address LD (RETURN),HL EX (SP),HL LD (HLSAVE),HL ; save HL PUSH DE ; save regs PUSH AF OR A ; Compare by subtraction SBC HL,DE LD DE,0 ; ..Set up for "less than" JR C,GOTO ; Jump if "less" LD DE,6 ; ..Set up for "greater than" JR NZ,GOTO ; Jump if "greater" LD DE,3 ; ..Else set for "equal" GOTO: LD HL,(RETURN) ; get return address ADD HL,DE ; add in offset POP AF ; restore regs POP DE EX (SP),HL ; set return address on stack LD HL,(HLSAVE) ; restore HL RET ; Save buffers DSEG ; Put in Data Segment HLSAVE: DEFS 2 ; original HL RETURN: DEFS 2 ; original return address END