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 / SAIF1.Z80 < prev    next >
Text File  |  2000-06-30  |  896b  |  47 lines

  1. ;
  2. ; SYSLIB Module Name: AIF1
  3. ; Author: Richard Conn
  4. ; SYSLIB Version Number: 3.6
  5. ; Module Version Number: 1.1
  6.  
  7.     public    aif1
  8.  
  9. ;
  10. ; AIF1 is an arithmetic IF facility.  A key value is passed in the B register
  11. ; and a test value is passed in the A register:
  12. ;
  13. ;    MVI    B,5    ; key value
  14. ;    MVI    A,TEST    ; test value
  15. ;    CALL    AIF1
  16. ;    DW    ALTB    ; go here if A < B
  17. ;    DW    AEQB    ; go here if A = B
  18. ;    DW    AGTB    ; go here if A > B
  19. ;
  20. aif1:
  21.     ex    (sp),hl    ; get return address
  22.     push    af    ; save regs
  23.     push    de
  24.     cp    b    ; compare
  25.     jp    c,less
  26.     jp    z,equal
  27.     ld    de,4    ; A > B, so add 4
  28.     add    hl,de
  29.     jp    less
  30. equal:
  31.     ld    de,2    ; A = B, so add 2
  32.     add    hl,de
  33. ;
  34. ;  A < B, so HL contains the address pointer (no change)
  35. ;
  36. less:
  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    de    ; restore regs
  42.     pop    af
  43.     ex    (sp),hl
  44.     ret
  45.  
  46.     end
  47.