home *** CD-ROM | disk | FTP | other *** search
- ; ECLMACRO.INC Macro definition file for Essential Communications Library
- ;
- ; ============================
- ; MICROSOFT C COMPILER VERSION
- ; ============================
- ;
- ; MASM <file>,,/DSMALL; ** or **
- ; MASM <file>,,/DMEDIUM; ** or **
- ; MASM <file>,,/DCOMPACT; ** or **
- ; MASM <file>,,/DLARGE; ** or **
- ; MASM <file>,,/DHUGE;
- ;
- ; These macros are not dependent on the compiler or its memory model:
- ;
- ; getvec Return the vector 32-bit address
- ; setvec Set the vector with a new handler
- ; swapvec Swap the vector's contents
- ;
- ; THESE ARE DEPENDENT ON THE C COMPILER AND ITS MEMORY MODEL:
- ;
- ; modstart Start the module (setup compiler's segments)
- ; modend End the module
- ; entry Start a procedure (function)
- ; endit Conclude a procedure (function)
- ; pushreg Save registers, establish entry stack frame
- ; popreg Restore registers prior to function exit
- ; loadint1 Load first stack argument (type integer)
- ; loadint2 Load second stack argument (type integer)
- ; loadint3 Load third stack argument (type integer)
- ; loadptr2 Load second stack argument (type pointer)
- ;
- ; (C) Copyright 1986, 1987, 1988 Essential Software Incorporate
- ; (C) Copyright 1986, 1987, 1988 Advanced Firmware Engineering
- ; All Rights Reserved
- ;
-
- ; Define constants for communication board types
- AST EQU 2
- DIGI8 EQU 4
- STAR8 EQU 6
- PS2 EQU 8
- DIGIMC EQU 10
- DIGIPC16 EQU 12
- ASTCMP EQU 14
- ;
- ; ===============================================================
- ; getvec Return the vector contents *** MACRO ***
- ; ===============================================================
- ;
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; AL Vector number
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; BX Offset of the returned vector
- ; DX Segment of the returned vector
- ;
- ; Registers used Description
- ; -------------- ---------------------------
- ; AX Vector number and scratch
- ; BX Offset of the returned vector
- ; DX Segment of the returned vector
- ; ===============================================================
- ;
-
- getvec MACRO
- PUSH ES
- MOV AH, 35h
- INT 21h
- MOV DX, ES
- POP ES
- ENDM
-
-
- ;
- ; ===============================================================
- ; setvec Set the vector contents *** MACRO ***
- ; ===============================================================
- ;
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; AL Vector number
- ; BX Offset of the new vector
- ; DX Segment of the new vector
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; Not applicable
- ;
- ; Registers used Description
- ; -------------- ---------------------------
- ; AX Vector number and scratch
- ; BX Offset of the returned vector
- ; DX Segment of the returned vector
- ; ===============================================================
- ;
-
- setvec MACRO
- PUSH DS
- MOV DS, DX
- MOV DX, BX
- MOV AH, 25h
- INT 21h
- POP DS
- ENDM
-
- ;
- ; ===============================================================
- ; swapvec Exchange the vector contents *** MACRO ***
- ; ===============================================================
- ;
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; AL Vector number
- ; BX Offset of the new vector
- ; DX Segment of the new vector
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; BX Offset of the returned vector
- ; DX Segment of the returned vector
- ;
- ; Registers used Description
- ; -------------- ---------------------------
- ; AX Vector number and scratch
- ; BX Offset of the returned vector
- ; DX Segment of the returned vector
- ; ===============================================================
- ;
-
- swapvec MACRO
- PUSH BP
- MOV BP, SP
- PUSH BX
- PUSH DX
- PUSH AX
- CLI
- getvec
- POP AX
- XCHG BX, [BP-2]
- XCHG DX, [BP-4]
- setvec
- STI
- POP DX
- POP BX
- POP BP
- ENDM
-
-
- ;
- ; ===============================================================
- ; modstart Start the module segment *** MACRO ***
- ; ===============================================================
- ;
- ; ldata lprog model
- ; ----- ----- -----
- ; ndef ndef SMALL
- ; ndef 1 MEDIUM
- ; 1 ndef COMPACT
- ; 1 1 LARGE
- ; 1 1 HUGE
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; /Dmodel Make sure that when assembled, model symbol is defined
- ; ldata Data space (=0 within one segment)
- ; lprog Large program space (=0 within one segment)
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; <module>_code Symbolic replacement string with code segment name
- ;
- ; ===============================================================
- ;
-
- modstart MACRO module
-
- ifdef LARGE
- ;
- ; standard large model segmenting
- ;
-
- module&_code segment byte public 'CODE'
- assume cs:module&_code
- ldata = 1
- lprog = 1
- cdseg equ module&_code
- IFDEF BUNDLD
- ASSUME DS:module&_code
- ENDIF
- endif
-
-
- ifdef HUGE
- ;
- ; standard large model segmenting
- ;
-
- module&_code segment byte public 'CODE'
- assume cs:module&_code
- ldata = 1
- lprog = 1
- cdseg equ module&_code
- IFDEF BUNDLD
- ASSUME DS:module&_code
- ENDIF
- endif
-
-
- ifdef SMALL
- ;
- ; standard small segmenting
- ;
- _text segment byte public 'CODE'
- assume cs:_text
- cdseg = _text
- IFDEF BUNDLD
- ASSUME DS:_text
- ENDIF
- endif
-
- ifdef MEDIUM
- ;
- ; standard medium model segmenting
- ;
-
- module&_code segment byte public 'CODE'
- assume cs:module&_code
- lprog = 1
- cdseg equ module&_code
- IFDEF BUNDLD
- ASSUME DS:module&_code
- ENDIF
- endif
-
- ifdef COMPACT
- ;
- ; standard compact segmenting
- ;
- _text segment byte public 'CODE'
- assume cs:_text
- ldata = 1
- cdseg = _text
- IFDEF BUNDLD
- ASSUME DS:_text
- ENDIF
- endif
- ENDM
-
- ;
- ; ===============================================================
- ; modend End the module segment *** MACRO ***
- ; ===============================================================
- ;
- ; Using the table below, close the segmentation
- ;
- ; ldata lprog model
- ; ----- ----- -----
- ; 0 0 SMALL
- ; 0 1 MEDIUM
- ; 1 0 COMPACT
- ; 1 1 LARGE
- ; 1 1 HUGE
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; <module>_code Symbolic replacement string with code segment name
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; Not applicable
- ; ===============================================================
- ;
-
- modend MACRO module ; MODule END
-
- ifdef LARGE
- ;
-
- module&_code ends
- endif
-
- ifdef HUGE
- ;
-
- module&_code ends
- endif
-
-
-
- ifdef SMALL
- ;
- ; standard small segmenting
- ;
- _text ends
- endif
-
- ifdef COMPACT
- ;
- ; standard small segmenting
- ;
- _text ends
- endif
-
-
-
- ifdef MEDIUM
- ;
- ; standard medium model segmenting
- ;
-
- module&_code ends
- endif
- ENDM
-
-
-
- ;
- ; ===============================================================
- ; entry Establish the procedure entry *** MACRO ***
- ; endit Establish the procedure exit *** MACRO ***
- ; ===============================================================
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; Not applicable
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; Not applicable
- ; ===============================================================
- ;
-
- entry MACRO NAME
- PUBLIC _&NAME
- IFDEF LPROG
- _&NAME PROC FAR
- ELSE
- _&NAME PROC NEAR
- ENDIF
- ENDM
-
-
- endit MACRO NAME
- _&NAME ENDP
- ENDM
-
-
- ;
- ; ===============================================================
- ; pushreg Establish the stack frame *** MACRO ***
- ; ===============================================================
- ;
- ; |----------|
- ; | ret ip | [BP+2]
- ; |----------|
- ; BP =>| old bp | [BP+0]
- ; |----------|
- ;
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; Not applicable
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; BP pointer to stack frame
- ; BP saved on the stack
- ; ===============================================================
- ;
- pushreg MACRO
- PUSH BP
- MOV BP, SP
- ENDM
-
- ;
- ; ===============================================================
- ; popreg Restore the stack frame *** MACRO ***
- ; ===============================================================
- ;
- ;
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; BP preset by pushreg macro
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; BP Restored from the stack
- ; ===============================================================
- ;
- popreg MACRO
- POP BP
- ENDM
-
- ;
- ; ===============================================================
- ; loadint1 Load in reg first integer argument *** MACRO ***
- ; ===============================================================
- ;
- ;
- ; lprog def (large code space) other (code space is small)
- ; [ldata definition has no bearing]
- ;
- ; |----------|
- ;======>| int arg | [BP+6]
- ; |----------| |----------|
- ; | caller cs| [BP+4] ======>| int arg | [BP+4]
- ; |----------| |----------|
- ; | caller ip| [BP+2] | caller ip| [BP+2]
- ; |----------| |----------|
- ; | old bp | [BP] | old bp | [BP]
- ; |----------| |----------|
- ;
- ; MEDIUM SMALL
- ; LARGE COMPACT
- ; HUGE
- ;
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; BP preset by pushreg macro
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; AX Loaded with first parameter from stack frame
- ; ===============================================================
- ;
-
- loadint1 MACRO reg ; load in first integer argument
- IFDEF LPROG
- MOV reg, [BP+6]
- ELSE
- MOV reg, [BP+4]
- ENDIF
- ENDM
-
- loadint2 MACRO reg ; load in second integer argument
- IFDEF LPROG
- MOV reg, [BP+8]
- ELSE
- MOV reg, [BP+6]
- ENDIF
- ENDM
-
- loadint3 MACRO reg ; load in third integer argument
- IFDEF LPROG
- MOV reg, [BP+10]
- ELSE
- MOV reg, [BP+8]
- ENDIF
- ENDM
-
- ;
- ; ===============================================================
- ; loadptr1 Load in DX:BX second pointer argument *** MACRO ***
- ; ===============================================================
- ;
- ;
- ; lprog def (large code space) lprog ndef (small code space)
- ; ldata ndef (small data space) ldata ndef (small data space)
- ;
- ; |----------|
- ;======>| pointer | [BP+8]
- ; |----------| |----------|
- ; | int arg | [BP+6] ======>| pointer | [BP+6]
- ; |----------| |----------|
- ; | caller cs| [BP+4] | int arg | [BP+4]
- ; |----------| |----------|
- ; | caller ip| [BP+2] | caller ip| [BP+2]
- ; |----------| |----------|
- ; | old bp | [BP] | old bp | [BP]
- ; |----------| |----------|
- ;
- ; MEDIUM SMALL
- ;
- ; lprog def (large code space) lprog ndef (small code space)
- ; ldata def (small data space) ldata def (small data space)
- ;
- ; |----------|
- ; | | [BP+10]
- ;======>|-- --| |----------|
- ; | pointer | [BP+8] | | [BP+8]
- ; |----------| ======>|-- --|
- ; | int arg | [BP+6] | pointer | [BP+6]
- ; |----------| |----------|
- ; | caller cs| [BP+4] | int arg | [BP+4]
- ; |----------| |----------|
- ; | caller ip| [BP+2] | caller ip| [BP+2]
- ; |----------| |----------|
- ; | old bp | [BP] | old bp | [BP]
- ; |----------| |----------|
- ;
- ; LARGE COMPACT
- ; HUGE
- ;
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; BP preset by pushreg macro
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; DX:BX Segment and offset of pointer value from stack frame
- ; ===============================================================
- ;
-
-
- loadptr2 MACRO
- IFDEF SMALL
- MOV BX, [BP+6]
- MOV DX, DS
- ENDIF
-
- IFDEF MEDIUM
- MOV BX, [BP+8]
- MOV DX, DS
- ENDIF
-
- IFDEF COMPACT
- MOV BX, [BP+6]
- MOV DX, [BP+8]
- ENDIF
-
- IFDEF LARGE
- MOV BX, [BP+8]
- MOV DX, [BP+10]
- ENDIF
-
- IFDEF HUGE
- MOV BX, [BP+8]
- MOV DX, [BP+10]
- ENDIF
-
- ENDM
-
-