home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TOOLS4.ZIP / MACROS.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-07-28  |  2.7 KB  |  125 lines

  1.        IFNDEF    PRESERVE_REG
  2. PRESERVE_REG     EQU 1
  3.        ENDIF
  4.  
  5. lo               EQU (WORD PTR 0)
  6. hi               EQU (WORD PTR 2)
  7.  
  8. DOS              EQU 021h
  9.  
  10. FORWARD          EQU 0
  11. BACKWARD         EQU 1
  12.  
  13. StringOps        MACRO SOURCEPTR,DESTPTR,DIRECTION
  14.        LDS       SI,SOURCEPTR
  15.        LES       DI,DESTPTR
  16.        IF        DIRECTION
  17.        STD
  18.        ELSE
  19.        CLD
  20.        ENDIF
  21.                  ENDM
  22.  
  23. ;
  24. ; Normalizes a pointer.  Pointer may not use AX,CX, or DX as
  25. ; either the segment or offset portions of the pointer.
  26. ; Preserves all registers (not the flags), unless either
  27. ; _SEGMENT_ or _OFFSET_ is a register, in which case the
  28. ; register specified is Normalized, as in
  29. ;   Normal    ES,DI
  30. ;
  31. ;
  32. _Normal_         MACRO _SEGMENT_,_OFFSET_
  33.  
  34.        IF        PRESERVE_REG
  35.        PUSH      AX
  36.        PUSH      CX
  37.        PUSH      DX
  38.        ENDIF
  39.  
  40.        MOV       DX,_OFFSET_
  41.        MOV       AX,DX
  42.        MOV       CL,4
  43.        SHR       DX,CL
  44.        MOV       CX,_SEGMENT_
  45.        ADD       CX,DX
  46.        MOV       _SEGMENT_,CX
  47.        AND       AX,0Fh
  48.        MOV       _OFFSET_,AX
  49.        IF        PRESERVE_REG
  50.        POP       DX
  51.        POP       CX
  52.        POP       AX
  53.        ENDIF
  54.                  ENDM
  55.  
  56. ;
  57. ; Normalizes a pointer in memory.  If PRESERVE_REG = 0
  58. ; then NormalVar uses ES,DI,SI,AX, and BX. Note that
  59. ; regardless of the value of PRESERVE_REG BX is never
  60. ; used by _Normal_, therefore, we use it freely in
  61. ; NormalVar.
  62. ;
  63.  
  64. NormalVar        MACRO _POINTER_
  65.        IF PRESERVE_REG
  66.        PUSH      AX
  67.        PUSH      DI
  68.        PUSH      SI
  69.        PUSH      DS
  70.        PUSH      ES
  71.  
  72.        ELSE
  73.        MOV       BX,DS
  74.        ENDIF
  75.  
  76.        LES       DI,_POINTER_
  77.        LES       DI,ES:[DI]
  78.  
  79.        _Normal_  ES,DI
  80.        LDS       SI,_POINTER_
  81.        MOV       [SI].lo,DI
  82.        MOV       AX,ES
  83.        MOV       [SI].hi,AX
  84.        IF PRESERVE_REG
  85.        POP       ES
  86.        POP       DS
  87.        POP       SI
  88.        POP       DI
  89.        POP       AX
  90.        ELSE
  91.        MOV       DS,BX
  92.        ENDIF
  93.                  ENDM
  94.  
  95. StandEntry       MACRO
  96.        PUSH      BP
  97.        MOV       BP,SP
  98.                  ENDM
  99.  
  100. StandExit        MACRO PARAMSIZE
  101.        POP       BP
  102.        RET       PARAMSIZE
  103.                  ENDM
  104.  
  105. LocalVar         MACRO _SIZE_
  106.        SUB       SP,_SIZE_
  107.                  ENDM
  108.  
  109. UnDoLocals       MACRO
  110.        MOV       SP,BP
  111.                  ENDM
  112.  
  113. PushPtr          MACRO _PTR_
  114.        LES       DI,_PTR_
  115.        PUSH      ES
  116.        PUSH      DI
  117.                  ENDM
  118.  
  119. PushSPtr         MACRO _SPTR_
  120.        LEA       DI,_SPTR_
  121.        PUSH      SS
  122.        PUSH      DI
  123.                  ENDM
  124.  
  125.