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 / SLIB2.LBR / SHIF2.Z80 < prev    next >
Text File  |  2000-06-30  |  1KB  |  57 lines

  1. ;
  2. ; SYSLIB Module Name: HIF2
  3. ; Author: Richard Conn
  4. ; SYSLIB Version Number: 3.6
  5. ; Module Version Number: 1.1
  6.  
  7.     public    hif2
  8.  
  9. ;
  10. ; HIF2 is an arithmetic IF facility.  A key value is passed in the DE register
  11. ; pair and a test value is passed in the HL register pair:
  12. ;
  13. ;    LXI    D,5    ; key value
  14. ;    LXI    H,TEST    ; test value
  15. ;    CALL    HIF2
  16. ;    JMP    HLTD    ; go here if HL < DE
  17. ;    JMP    HEQD    ; go here if HL = DE
  18. ;    JMP    HGTD    ; go here if HL > DE
  19. ;
  20. hif2:
  21.     ex    (sp),hl        ; get return address
  22.     ld    (return),hl
  23.     ex    (sp),hl
  24.     ld    (hlsave),hl    ; save HL
  25.     push    de        ; save regs
  26.     push    af
  27.     ld    a,h        ; compare highs
  28.     cp    d
  29.     jp    c,less
  30.     jp    nz,greater
  31.     ld    a,l        ; highs are equal, compare lows
  32.     cp    e
  33.     jp    c,less
  34.     jp    nz,greater
  35.     ld    de,3        ; HL = DE, so offset is 3 bytes
  36.     jp    goto
  37. greater:
  38.     ld    de,6        ; HL > DE, so offset is 6 bytes
  39.     jp    goto
  40. less:
  41.     ld    de,0        ; HL < DE, so offset is 0 bytes
  42. goto:
  43.     ld    hl,(return)    ; get return address
  44.     add    hl,de        ; add in offset
  45.     pop    af        ; restore regs
  46.     pop    de
  47.     ex    (sp),hl        ; set return address on stack
  48.     ld    hl,(hlsave)    ; restore HL
  49.     ret
  50. ;
  51. ; Save buffers
  52. ;
  53. hlsave:    ds    2    ; original HL
  54. return:    ds    2    ; original return address
  55.  
  56.     end
  57.