home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / H_PSBP.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-06-07  |  1.6 KB  |  60 lines

  1. ;[]-----------------------------------------------------------------[]
  2. ;|      H_PSBP.ASM -- long pointer routines                          |
  3. ;|                                                                   |
  4. ;|      Turbo-C Run Time Library        Version 3.0                  |
  5. ;|                                                                   |
  6. ;|      Copyright (c) 1987,1988,1990 by Borland International Inc.   |
  7. ;|      All Rights Reserved.                                         |
  8. ;[]-----------------------------------------------------------------[]
  9.  
  10.                 INCLUDE RULES.ASI
  11.  
  12. ; calls to these routines are generated by the compiler to perform
  13. ; arithmetic operations on long pointers.
  14.  
  15. _TEXT           SEGMENT BYTE PUBLIC 'CODE'
  16.                 ASSUME  CS:_TEXT
  17. ;
  18. ;    ax:dx    left hand pointer
  19. ;    bx:cx    right hand pointer
  20. ;
  21. ;        To subtract, first convert both pointers to longs.
  22. ;        then do a simple signed long subtraction.  Actually
  23. ;        we only store 24 bit ints until the subtraction is
  24. ;        done.
  25. ;
  26.                 public  PSBP@
  27.                 public  F_PSBP@
  28.                 public  N_PSBP@
  29.  
  30. N_PSBP@:
  31.                 pop     es              ;fix up far return
  32.                 push    cs
  33.                 push    es
  34. PSBP@:
  35. F_PSBP@:
  36.         push    di
  37.         mov    di,cx
  38.         mov    ch,dh
  39.         mov    cl,4
  40.         shl    dx,cl
  41.         shr    ch,cl        ; dx:ch has the left hand long
  42.         add    dx,ax
  43.         adc    ch,0
  44.         mov    ax,di
  45.         shl    di,cl
  46.         shr    ah,cl
  47.         add    bx,di
  48.         adc    ah,0        ; bx:ah has the right hand long
  49.         sub    dx,bx
  50.         sbb    ch,ah
  51.         mov    al,ch
  52.         cbw            ; sign extend the upper part
  53.         xchg    ax,dx
  54.         pop    di
  55.                 retf
  56.  
  57. _TEXT           ENDS
  58.                 END
  59.  
  60.