; TITLE "SAGO2 - Syslib 4.0" NAME ('AGOTO2') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Derived from SAGO2.Z80 Ver 1.1 by Richard Conn ; Date : 17 Sep 89 ; Version : 1.2 ; Module : SAGO2 ; Abstract: This module contains the routine AGOTO2 which is a ; computed GOTO. It uses a table of JP xx instructions as ; opposed to a table of DEFW xx used in AGOTO1. No range ; or error checking is performed in this routine. It is ; used as: ; ; LD A,INDEX ; zero-relative ; CALL AGOTO2 ; JP ADDR0 ; IF A=0 ; JP ADDR1 ; IF A=1 ; JP ADDR2 ; IF A=2 ; ; IF A=3 ; ... ; ADDR0: ; COME HERE IF A=0 ; ... ; ADDR1: ; COME HERE IF A=1 ; ... ; ADDR2: ; COME HERE IF A=2 ; ... ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC AGOTO2 .Z80 CSEG ;=============================================================== ; NAME - AGOTO2 ; Entry: (Stack) - Contains the table start address ; A - Contains the Zero-based index into the JP table ; Exit : - N/A ; Uses : - None (saved for destination routine) ; Special Requirements: User is responsible for range and error ; checking of input value. ;=============================================================== AGOTO2: EX (SP),HL ; get address of routines, save HL PUSH DE ; save regs PUSH AF PUSH HL ; save return address LD H,0 LD L,A LD E,L ; index in DE LD D,H ; HL = index ADD HL,HL ; HL = index * 2 ADD HL,DE ; HL = index * 3 POP DE ; get return address ADD HL,DE ; point to jump in HL POP AF ; get regs POP DE EX (SP),HL ; restore HL, set address of routine RET END