home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ZSYS / SIMTEL20 / SYSLIB / SLIB1.LBR / SAGO1.Z80 < prev    next >
Text File  |  2000-06-30  |  1KB  |  47 lines

  1. ;
  2. ; SYSLIB Module Name: AGOTO1
  3. ; Author: Richard Conn
  4. ; SYSLIB Version Number: 3.6
  5. ; Module Version Number: 1.1
  6.  
  7.     public    agoto1
  8.  
  9. ;
  10. ; AGOTO1 is a computed GOTO.  When called, register A = index of following
  11. ; address to branch to, as indicated:
  12. ;
  13. ;    MVI    A,INDEX    ; zero-relative
  14. ;    CALL    AGOTO1
  15. ;    DW    ADDR0    ; IF A=0
  16. ;    DW    ADDR1    ; IF A=1
  17. ;    DW    ADDR2    ; IF A=2
  18. ;    ...
  19. ; ADDR0:        ; COME HERE IF A=0
  20. ;    ...
  21. ; ADDR1:        ; COME HERE IF A=1
  22. ;    ...
  23. ; ADDR2:        ; COME HERE IF A=2
  24. ;    ...
  25. ;
  26. ; No error or range checking is done
  27. ;
  28. agoto1:
  29.     ex    (sp),hl        ; get address of routines, save HL
  30.     push    de    ; save regs
  31.     push    af
  32.     ld    d,0
  33.     ld    e,a    ; index in DE
  34.     ex    de,hl        ; index in HL, return address in DE
  35.     add    hl,hl    ; double index to compute offset
  36.     add    hl,de    ; point to jump in HL
  37.     ld    a,(hl)    ; get low
  38.     inc    hl
  39.     ld    h,(hl)    ; get high
  40.     ld    l,a    ; HL = address to return to
  41.     pop    af    ; get regs
  42.     pop    de
  43.     ex    (sp),hl        ; restore HL, set address of routine
  44.     ret
  45.  
  46.     end
  47.