📄 cruntime.inc
字号:
CPTR equ <near ptr>
DDPTR equ <dd offset FLAT:>
DDPTR? equ <dd>
DPSIZE equ 4
CPWORD equ <dword> ; code pointers are dwords
DPWORD equ <dword> ; data pointers are dwords
APIDIST equ <near> ; all API calls are NEAR in the 32 bit model
; macro to declare API functions
EXTAPI macro apiname
extrn pascal apiname:near
endm
else ;--- 16-bit segment ---
; parameters and locals
IWORD equ <word>
LWORD equ <dword>
; static storage
DINT equ <dw>
DLONG equ <dd>
DSHORT equ <dw>
; sizes for fixing SP, stepping through tables, etc
ISIZE equ 2
LSIZE equ 4
SSIZE equ 2
NPSIZE equ 2
FPSIZE equ 4
; bit shift count to convert byte cnt/ptr to int/long cnt/ptr
ISHIFT equ 1 ; byte-to-int shift count
LSHIFT equ 2 ; byte-to-long shift count
; sizes dependent upon memory model
DNPTR equ <dw> ; near pointer
DFPTR equ <dd> ; far pointer
if sizeC
DCPTR equ <dd> ; 16 bit segment and 16 bit offset
DCPTR? equ <dd>
CPSIZE equ 4
CPDIST equ <far> ; code pointers are far
CPTR equ <far ptr>
CPWORD equ <dword> ; code pointers are dwords
else
DCPTR equ <dw> ; 16 bit offset only
DCPTR? equ <dw>
CPSIZE equ 2
CPDIST equ <near> ; code pointers are near
CPTR equ <near ptr>
CPWORD equ <word> ; code pointers are words
endif
if sizeD
DDPTR equ <dd>
DDPTR? equ <dd>
DPSIZE equ 4
DPWORD equ <dword> ; data pointers are dwords
else
DDPTR equ <dw>
DDPTR? equ <dw>
DPSIZE equ 2
DPWORD equ <word> ; data pointers are words
endif
APIDIST equ <far> ; API calls are FAR in 16 bit model
; macro to declare API functions
EXTAPI macro apiname
extrn pascal apiname:far
endm
endif ; --- 16/32 segment ---
; Float/double definitions
; (currently the same for 16- and 32-bit segments)
FLTSIZE equ 4 ; float
DBLSIZE equ 8 ; double
LDBLSIZE equ 10 ; long double
DFLOAT equ <dd>
DDOUBLE equ <dq>
DLDOUBLE equ <dt>
;
; savelist - Generate a list of regs to be saved by the proc 'uses' option.
;
; Input:
; reg1, reg2, reg3, reg4 = registers to be saved across function
; Output:
; reglist = text string of registers that can be passed to the 'uses'
; option on the 'proc' command.
;
savelist MACRO reg1, reg2, reg3, reg4
local ws, listsize
ws catstr < > ; whitespace char
IFNDEF I386
rbx equ <> ; 8086/286 don't save rbx
ENDIF
IFNB <reg4>
reglist catstr reg1, ws, reg2, ws, reg3, ws, reg4
ELSEIFNB <reg3>
reglist catstr reg1, ws, reg2, ws, reg3, ws
ELSEIFNB <reg2>
reglist catstr reg1, ws, reg2, ws, ws
ELSEIFNB <reg1>
reglist catstr reg1, ws, ws, ws
ELSE
reglist catstr <>
ENDIF
listsize sizestr reglist ; size of register list
IF listsize LE 3 ; if list is only the 3 ws chars...
reglist catstr <>
ENDIF
IFNDEF I386
rbx equ <bx> ; restore rbx
ENDIF
ENDM ; savelist
;
; codeseg - Define/declare the standard code segment. Maps to the proper
; form of the .code directive.
;
; Input:
;
; Output:
; .code _TEXT ; for large code models
; .code ; for small code models
; assume cs:FLAT ; for 386
; assume ds:FLAT ; for 386
; assume es:FLAT ; for 386
; assume ss:FLAT ; for 386
;
codeseg MACRO
if sizeC
.code _TEXT
else
.code
endif
ifdef I386
assume ds:FLAT
assume es:FLAT
assume ss:FLAT
endif
ENDM
;*========
;*
;* Debug lab macro
;*
;*========
lab macro name
ifdef DEBUG
public pascal name ;; define label public for Symdeb
endif
name:
endm
;*========
;*
;* Conditional jump short macros
;*
;*========
irp x,<Z,NZ,E,NE,S,NS,C,NC,P,NP,PE,PO,A,AE,B,BE,NB,G,GE,L,LE>
JS&x equ <j&x short>
endm
;*========
;*
;* Global data definition macros
;*
;* Usage:
;* globalI Name, InitialValue, Repeat
;*
;*========
MakeGlobal macro suffix, DataType ;; makes all of the global* macros
global&suffix macro name, data, rep
public name
ifb <rep>
_repeat = 1
else
_repeat = (rep)
endif
name &DataType _repeat dup( data )
endm
endm
MakeGlobal T, dt ; globalT
MakeGlobal Q, dq ; globalQ
MakeGlobal D, dd ; globalD
MakeGlobal W, dw ; globalW
MakeGlobal B, db ; globalB
% MakeGlobal I, <DINT> ; globalI
% MakeGlobal DP, <DDPTR> ; globalDP
% MakeGlobal CP, <DCPTR> ; globalCP
% MakeGlobal FP, <DFPTR> ; globalFP
% MakeGlobal NP, <DNPTR> ; globalNP
;*========
;*
;* Static data definition macros
;*
;* Usage:
;* staticI Name, InitialValue, Repeat
;*
;*========
MakeStatic macro suffix, DataType ;; makes all of the static* macros
static&suffix macro name, data, rep
ifdef DEBUG
public pascal name ;; make statics public if DEBUG
endif
ifb <rep>
_repeat = 1
else
_repeat = (rep)
endif
name &DataType _repeat dup( data )
endm
endm
MakeStatic T, dt ; staticT
MakeStatic Q, dq ; staticQ
MakeStatic D, dd ; staticD
MakeStatic W, dw ; staticW
MakeStatic B, db ; staticB
% MakeStatic I, <DINT> ; staticI
% MakeStatic DP, <DDPTR> ; staticDP
% MakeStatic CP, <DCPTR> ; staticCP
% MakeStatic FP, <DFPTR> ; staticFP
% MakeStatic NP, <DNPTR> ; staticNP
;*========
;*
;* Label definition macros
;*
;*========
;*
;* Label definition macros
;*
;* Usage:
;* labelI Name, {PUBLIC, PASCAL, C}
;*
;*========
__MakePublic macro name, option ;; decides if a label should be
ifidni <option>, <PUBLIC> ;; made public
public name
elseifidni <option>, <PASCAL>
public pascal name
elseifidni <option>, <C>
public C name
elseifb <option>
ifdef DEBUG
public pascal name ;; make public if DEBUG
endif
endif
endm
MakeLabel macro suffix, LabelType ;; makes all of the label* macros
%@CatStr(<label>,<suffix>) macro name, option
__MakePublic <name>,<option>
name label &LabelType
endm
endm
MakeLabel T, tbyte ; make labelT
MakeLabel Q, qword ; make labelQ
MakeLabel D, dword ; make labelD
MakeLabel W, word ; make labelW
MakeLabel B, byte ; make labelB
MakeLabel P, proc ; make labelP
MakeLabel FP, far ; make labelFP
MakeLabel NP, near ; make labelNP
% MakeLabel I, IWORD ; make labelI
labelDP macro name, option ;; labelDP
__MakePublic <name>,<option>
ifdef I386
if sizeD
name label fword
else
name label dword
endif
else ;not I386
if sizeD
name label dword
else
name label word
endif
endif ;not I386
endm
labelCP macro name, option ;; labelCP
__MakePublic <name>,<option>
ifdef I386
if sizeC
name label fword
else
name label dword
endif
else ;not I386
if sizeC
name label dword
else
name label word
endif
endif ;not I386
endm
;*
;* PUSH16 SegReg - pushes 16 bits in a use32 segment
;*
PUSH16 macro SegReg
ifdef I386
nop
db 66h ; operand size over-ride
endif ; I386
push SegReg
endm
;*
;* JMPFAR16 label - jmps far from a use32 to a use16 segment
;*
JMPFAR16 macro label
ifndef I386
error <JMPFAR16 can only be used in a use32 code segment>
endif ;I386
nop
db 66h ;; operand size over-ride
db 0eah ;; jmp far immediate op code
dw offset label
dw seg label
endm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -