home *** CD-ROM | disk | FTP | other *** search
- IFNDEF PRESERVE_REG
- PRESERVE_REG EQU 1
- ENDIF
-
- lo EQU (WORD PTR 0)
- hi EQU (WORD PTR 2)
-
- DOS EQU 021h
-
- FORWARD EQU 0
- BACKWARD EQU 1
-
- StringOps MACRO SOURCEPTR,DESTPTR,DIRECTION
- LDS SI,SOURCEPTR
- LES DI,DESTPTR
- IF DIRECTION
- STD
- ELSE
- CLD
- ENDIF
- ENDM
-
- ;
- ; Normalizes a pointer. Pointer may not use AX,CX, or DX as
- ; either the segment or offset portions of the pointer.
- ; Preserves all registers (not the flags), unless either
- ; _SEGMENT_ or _OFFSET_ is a register, in which case the
- ; register specified is Normalized, as in
- ; Normal ES,DI
- ;
- ;
- _Normal_ MACRO _SEGMENT_,_OFFSET_
-
- IF PRESERVE_REG
- PUSH AX
- PUSH CX
- PUSH DX
- ENDIF
-
- MOV DX,_OFFSET_
- MOV AX,DX
- MOV CL,4
- SHR DX,CL
- MOV CX,_SEGMENT_
- ADD CX,DX
- MOV _SEGMENT_,CX
- AND AX,0Fh
- MOV _OFFSET_,AX
- IF PRESERVE_REG
- POP DX
- POP CX
- POP AX
- ENDIF
- ENDM
-
- ;
- ; Normalizes a pointer in memory. If PRESERVE_REG = 0
- ; then NormalVar uses ES,DI,SI,AX, and BX. Note that
- ; regardless of the value of PRESERVE_REG BX is never
- ; used by _Normal_, therefore, we use it freely in
- ; NormalVar.
- ;
-
- NormalVar MACRO _POINTER_
- IF PRESERVE_REG
- PUSH AX
- PUSH DI
- PUSH SI
- PUSH DS
- PUSH ES
-
- ELSE
- MOV BX,DS
- ENDIF
-
- LES DI,_POINTER_
- LES DI,ES:[DI]
-
- _Normal_ ES,DI
- LDS SI,_POINTER_
- MOV [SI].lo,DI
- MOV AX,ES
- MOV [SI].hi,AX
- IF PRESERVE_REG
- POP ES
- POP DS
- POP SI
- POP DI
- POP AX
- ELSE
- MOV DS,BX
- ENDIF
- ENDM
-
- StandEntry MACRO
- PUSH BP
- MOV BP,SP
- ENDM
-
- StandExit MACRO PARAMSIZE
- POP BP
- RET PARAMSIZE
- ENDM
-
- LocalVar MACRO _SIZE_
- SUB SP,_SIZE_
- ENDM
-
- UnDoLocals MACRO
- MOV SP,BP
- ENDM
-
- PushPtr MACRO _PTR_
- LES DI,_PTR_
- PUSH ES
- PUSH DI
- ENDM
-
- PushSPtr MACRO _SPTR_
- LEA DI,_SPTR_
- PUSH SS
- PUSH DI
- ENDM
-