; TITLE "SAGO1 - Syslib 4.0" NAME ('AGOTO1') ;================================================================= ; The Libraries, Version 4, (C) 1989 by Alpha Systems Corp. ;----------------------------------------------------------------- ; Author : Richard Conn ; Date : ; Version : 1.1 ; Module : SAGO1 ; Abstract: This module contains the routine AGOTO1 which is a ; computed GOTO based on an 8-bit value passed to it. No ; range checking is done, and no default exists if bounds ; are exceeded. It is implemented as: ; ; LD A,INDEX ; zero-relative ; CALL AGOTO1 ; DEFW ADDR0 ; IF A=0 ; DEFW ADDR1 ; IF A=1 ; DEFW ADDR2 ; IF A=2 ; ... ; ADDR0: ; COME HERE IF A=0 ; ... ; ADDR1: ; COME HERE IF A=1 ; ... ; ADDR2: ; COME HERE IF A=2 ; ... ; Revision: ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC AGOTO1 .Z80 CSEG ;=============================================================== ; NAME - AGOTO1 ; Entry: (Stack) - Contains table start address ; A - Contains relative address in the table to go to ; Exit : - N/A ; Uses : - None (Saved for destination routine) ; Special Requirements: The user is responsible for insuring ; the validity of the entry parameter ;=============================================================== AGOTO1: EX (SP),HL ; get address of routines, save HL PUSH DE ; save regs PUSH AF LD D,0 LD E,A ; index in DE EX DE,HL ; index in HL, return address in DE ADD HL,HL ; double index to compute offset ADD HL,DE ; point to jump in HL LD A,(HL) ; get low INC HL LD H,(HL) ; get high LD L,A ; HL = address to return to POP AF ; get regs POP DE EX (SP),HL ; restore HL, set address of routine RET END