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 / SAGO2.Z80 < prev    next >
Text File  |  2000-06-30  |  1KB  |  49 lines

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