📄 scitech.mac
字号:
push ds
%endif
%endmacro
%imacro unuse_ds 0
%ifndef flatmodel
pop ds
%endif
%endmacro
%imacro use_es 0
%ifndef flatmodel
push es
%endif
%endmacro
%imacro unuse_es 0
%ifndef flatmodel
pop es
%endif
%endmacro
; Macros for loading the address of a data pointer into a segment and
; index register pair. The %imacro explicitly loads DS or ES in the 16 bit
; memory model, or it simply loads the offset into the register in the flat
; memory model since DS and ES always point to all addressable memory. You
; must use the correct _REG (ie: _BX) %imacros for documentation purposes.
%imacro _lds 2
%ifdef flatmodel
mov %1,%2
%else
lds %1,%2
%endif
%endmacro
%imacro _les 2
%ifdef flatmodel
mov %1,%2
%else
les %1,%2
%endif
%endmacro
; Macros for adding and subtracting a value from registers. Two value are
; provided, one for 16 bit modes and another for 32 bit modes (the extended
; register is used in 32 bit modes).
%imacro _add 3
%ifdef flatmodel
add e%1, %3
%else
add %1, %2
%endif
%endmacro
%imacro _sub 3
%ifdef flatmodel
sub e%1, %3
%else
sub %1, %2
%endif
%endmacro
; Macro to clear the high order word for the 32 bit extended registers.
; This is used to convert an unsigned 16 bit value to an unsigned 32 bit
; value, and will evaluate to nothing in 16 bit modes.
%imacro clrhi 1
%ifdef flatmodel
movzx e%1,%1
%endif
%endmacro
%imacro sgnhi 1
%ifdef flatmodel
movsx e%1,%1
%endif
%endmacro
; Macro to load an extended register with an integer value in either mode
%imacro loadint 2
%ifdef flatmodel
mov e%1,%2
%else
xor e%1,e%1
mov %1,%2
%endif
%endmacro
; Macros to load and store integer values with string instructions
%imacro LODSINT 0
%ifdef flatmodel
lodsd
%else
lodsw
%endif
%endmacro
%imacro STOSINT 0
%ifdef flatmodel
stosd
%else
stosw
%endif
%endmacro
; Macros to provide resb, resw, resd compatibility with NASM
%imacro dclb 1
times %1 db 0
%endmacro
%imacro dclw 1
times %1 dw 0
%endmacro
%imacro dcld 1
times %1 dd 0
%endmacro
; Macro to get the addres of the GOT for Linux/FreeBSD shared
; libraries into the EBX register.
%imacro get_GOT 1
call %%getgot
%%getgot: pop %1
add %1,_GLOBAL_OFFSET_TABLE_+$$-%%getgot wrt ..gotpc
%endmacro
; Macro to get the address of a *local* variable that is global to
; a single module in a manner that will work correctly when compiled
; into a Linux shared library. Note that this will *not* work for
; variables that are defined as global to all modules. For that
; use the LEA_G macro
%macro LEA_L 2
%ifdef __PIC__
get_GOT %1
lea %1,[%1+%2 wrt ..gotoff]
%else
lea %1,[%2]
%endif
%endmacro
; Same macro as above but for global variables public to *all*
; modules.
%macro LEA_G 2
%ifdef __PIC__
get_GOT %1
mov %1,[%1+%2 wrt ..got]
%else
lea %1,[%2]
%endif
%endmacro
; macros to declare assembler function stubs for function structures
%imacro BEGIN_STUBS_DEF 2
begdataseg _STUBS
%ifdef __NOU_VAR__
extern %1
%define STUBS_START %1
%else
extern _%1
%define STUBS_START _%1
%endif
enddataseg _STUBS
begcodeseg _STUBS
%assign off %2
%endmacro
%imacro DECLARE_STUB 1
%ifdef __PIC__
global %1:function
%1:
get_GOT eax
mov eax,[eax+STUBS_START wrt ..got]
jmp [eax+off]
%else
%ifdef __NOU__
global %1
%1:
%else
global _%1
_%1:
%endif
jmp [DWORD STUBS_START+off]
%endif
%assign off off+4
%endmacro
%imacro SKIP_STUB 1
%assign off off+4
%endmacro
%imacro DECLARE_STDCALL 2
%ifdef STDCALL_MANGLE
global _%1@%2
_%1@%2:
%else
%ifdef STDCALL_USCORE
global _%1
_%1:
%else
global %1
%1:
%endif
%endif
jmp [DWORD STUBS_START+off]
%assign off off+4
%endmacro
%imacro END_STUBS_DEF 0
endcodeseg _STUBS
%endmacro
; macros to declare assembler import stubs for binary loadable drivers
%imacro BEGIN_IMPORTS_DEF 1
BEGIN_STUBS_DEF %1,4
%endmacro
%imacro DECLARE_IMP 2
DECLARE_STUB %1
%endmacro
%imacro SKIP_IMP 2
SKIP_STUB %1
%endmacro
%imacro SKIP_IMP2 1
DECLARE_STUB %1
%endmacro
%imacro SKIP_IMP3 1
SKIP_STUB %1
%endmacro
%imacro END_IMPORTS_DEF 0
END_STUBS_DEF
%endmacro
else ; __NASM_MAJOR__
;============================================================================
; Macro package when compiling with TASM.
;============================================================================
; Turn off underscores for globals if disabled for all externals
ifdef __NOU__
__NOU_VAR__ = 1
endif
; Define the __WINDOWS__ symbol if we are compiling for any Windows
; environment
ifdef __WINDOWS16__
__WINDOWS__ = 1
endif
ifdef __WINDOWS32__
__WINDOWS__ = 1
__WINDOWS32_386__ = 1
endif
ifdef __WIN386__
__WINDOWS__ = 1
__WINDOWS32_386__ = 1
endif
ifdef __VXD__
__WINDOWS__ = 1
__WINDOWS32_386__ = 1
MASM
.386
NO_SEGMENTS = 1
include vmm.inc ; IGNORE DEPEND
include vsegment.inc ; IGNORE DEPEND
IDEAL
endif
; Macros for accessing 'generic' registers
ifdef __FLAT__
_ax EQU eax ; EAX is used for accumulator
_bx EQU ebx ; EBX is used for accumulator
_cx EQU ecx ; ECX is used for looping
_dx EQU edx ; EDX is used for data register
_si EQU esi ; ESI is the source index register
_di EQU edi ; EDI is the destination index register
_bp EQU ebp ; EBP is used for base pointer register
_sp EQU esp ; ESP is used for stack pointer register
_es EQU ; ES and DS are the same in 32 bit PM
typedef UCHAR BYTE ; Size of a character
typedef USHORT WORD ; Size of a short
typedef UINT DWORD ; Size of an integer
typedef ULONG DWORD ; Size of a long
typedef BOOL DWORD ; Size of a boolean
typedef DPTR DWORD ; Size of a data pointer
typedef FDPTR FWORD ; Size of a far data pointer
typedef NDPTR DWORD ; Size of a near data pointer
typedef CPTR DWORD ; Size of a code pointer
typedef FCPTR FWORD ; Size of a far code pointer
typedef NCPTR DWORD ; Size of a near code pointer
typedef DUINT DWORD ; Declare a integer variable
FPTR EQU NEAR ; Distance for function pointers
intsize = 4 ; Size of an integer
flatmodel = 1 ; This is a flat memory model
P386 ; Turn on 386 code generation
MODEL FLAT ; Set up for 32 bit simplified FLAT model
else
_ax EQU ax ; AX is used for accumulator
_bx EQU bx ; BX is used for accumulator
_cx EQU cx ; CX is used for looping
_dx EQU dx ; DX is used for data register
_si EQU si ; SI is the source index register
_di EQU di ; DI is the destination index register
_bp EQU bp ; BP is used for base pointer register
_sp EQU sp ; SP is used for stack pointer register
_es EQU es: ; ES is used for segment override
typedef UCHAR BYTE ; Size of a character
typedef USHORT WORD ; Size of a short
typedef UINT WORD ; Size of an integer
typedef ULONG DWORD ; Size of a long
typedef BOOL WORD ; Size of a boolean
typedef DPTR DWORD ; Size of a data pointer
typedef FDPTR DWORD ; Size of a far data pointer
typedef NDPTR WORD ; Size of a near data pointer
typedef CPTR DWORD ; Size of a code pointer
typedef FCPTR DWORD ; Size of a far code pointer
typedef NCPTR WORD ; Size of a near code pointer
typedef DUINT WORD ; Declare a integer variable
FPTR EQU FAR ; Distance for function pointers
intsize = 2 ; Size of an integer
P386 ; Turn on 386 code generation
endif
invert EQU not
; Provide a typedef for real floating point numbers
ifdef DOUBLE
typedef REAL QWORD
typedef DREAL QWORD
else
typedef REAL DWORD
typedef DREAL DWORD
endif
; Macros to access the floating point stack registers to convert them
; from NASM style to TASM style
st0 EQU st(0)
st1 EQU st(1)
st2 EQU st(2)
st3 EQU st(3)
st4 EQU st(4)
st5 EQU st(5)
st6 EQU st(6)
st7 EQU st(7)
st8 EQU st(8)
; Boolean truth values (same as those in debug.h)
ifndef __VXD__
False = 0
True = 1
No = 0
Yes = 1
Yes = 1
endif
; Macros for the _DATA data segment. This segment contains initialised data.
MACRO begdataseg name
ifdef __VXD__
MASM
VXD_LOCKED_DATA_SEG
IDEAL
else
ifdef flatmodel
DATASEG
else
SEGMENT _DATA DWORD PUBLIC USE16 'DATA'
endif
endif
ENDM
MACRO enddataseg name
ifdef __VXD__
MASM
VXD_LOCKED_DATA_ENDS
IDEAL
else
ifndef flatmodel
ENDS _DATA
endif
endif
ENDM
; Macro for the main code segment.
MACRO begcodeseg name
ifdef __VXD__
MASM
VXD_LOCKED_CODE_SEG
IDEAL
else
ifdef flatmodel
CODESEG
ASSUME CS:FLAT,DS:FLAT,SS:FLAT
else
SEGMENT &name&_TEXT PARA PUBLIC USE16 'CODE'
ASSUME CS:&name&_TEXT,DS:_DATA
endif
endif
ENDM
; Macro for a near code segment
MACRO begcodeseg_near
ifdef flatmodel
CODESEG
ASSUME CS:FLAT,DS:FLAT,SS:FLAT
else
SEGMENT _TEXT PARA PUBLIC USE16 'CODE'
ASSUME CS:_TEXT,DS:_DATA
endif
ENDM
MACRO endcodeseg name
ifdef __VXD__
MASM
VXD_LOCKED_CODE_ENDS
IDEAL
else
ifndef flatmodel
ENDS &name&_TEXT
endif
endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -