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

  1. ;
  2. ; SYSLIB Module Name: AIF2
  3. ; Author: Richard Conn
  4. ; SYSLIB Version Number: 3.6
  5. ; Module Version Number: 1.1
  6.  
  7.     public    aif2
  8.  
  9. ;
  10. ; AIF2 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    AIF2
  16. ;    JMP    ALTB    ; go here if A < B
  17. ;    JMP    AEQB    ; go here if A = B
  18. ;    JMP    AGTB    ; go here if A > B
  19. ;
  20. aif2:
  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,6    ; A > B, so add 6
  28.     add    hl,de
  29.     jp    less
  30. equal:
  31.     ld    de,3    ; A = B, so add 3
  32.     add    hl,de
  33. ;
  34. ;  A < B, so HL contains the return address (no change)
  35. ;
  36. less:
  37.     pop    de    ; restore regs
  38.     pop    af
  39.     ex    (sp),hl
  40.     ret
  41.  
  42.     end
  43.