⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compiler.inc

📁 Turbo Pascal 6.0编译器源码
💻 INC
📖 第 1 页 / 共 2 页
字号:
Invoke  macro   Name
	global  Name:near
	call    Name
	endm

Chain   macro   Name
	global  Name:near
	jmp     Name
	endm

Argm    macro   Symbol,SType,Count
	local   Offset
	@AP = @AP + SType * Count
	Offset = @AP
Symbol  equ     (SType ptr [bp+@AF-Offset])
	endm

@AP = 0
@AF = 0

Loc     macro   Symbol,SType,Count
	local   Offset,S
	@LP = @LP + SType * Count
	Offset = @LP
Symbol  equ     (SType ptr [bp-Offset])
	endm

@LP = 0

Entry   macro   Dist
	@Dist = 0
	ifidni  <Dist>,<far>
		@Dist = 1
		push    bp
		mov     bp,sp
	elseif  @LP ne 0 or @AP ne 0
		ifndef  cmd
			inc bp
		endif
		push    bp
		mov     bp,sp
	endif
	@AF = @AP + 6
	if      @LP ne 0
		@LP = (@LP + 1) and 0fffeh
		sub     sp,@LP
	endif
	endm

Exit    macro
	if      @Dist eq 1
		if      @LP ne 0
			mov     sp,bp
		endif
		pop     bp
	elseif  @LP ne 0 or @AP ne 0
		if      @LP ne 0
			mov     sp,bp
		endif
		pop     bp
		ifndef  cmd
			dec     bp
		endif
	endif
	ret     @AP
	@AP = 0
	@LP = 0
	endm

dwc	macro a,b
	dw h&a&_&b
endm
zeroc	macro a,b
@h&a&_&b=0
endm
peekc	macro a,b,c
a=@h&b&_&c
endm
pokec	macro a,b,c
@h&a&_&b=c
endm
fixupc	macro a,b
h&a&_&b=@h&a&_&b
endm
@hn=0
hash	macro nbuck
local nb
@i=0
@hn=@hn+1
@nb=nbuck
nb=@nb
dw (nb-1) shl 1
rept @nb
	dwc %@hn,%@i
zeroc %@hn,%@i
@i=@i+2
endm
endm
hvalue	macro	nm,nb
local a,i
@i=0
@hs=0
irpc @c,<nm>
@i=@i+1
@hs=@hs+'&@c&'-1
endm
@hs=(@hs*2) and ((nb-1) shl 1)
endm
hent	macro nm,code
hvalue nm,%@nb
peekc a,%@hn,%@hs
pokec %@hn,%@hs,$
	dw a
i=@i
db code
db i,'&nm&'
endm
hend	macro
@i=0
rept @nb
fixupc %@hn,%@i
@i=@i+2
endm
endm

Offs    equ     (word ptr 0)
Segm    equ     (word ptr 2)
W0      equ     (word ptr 0)
W2      equ     (word ptr 2)
W4      equ     (word ptr 4)
W6      equ     (word ptr 6)
W8      equ     (word ptr 8)
B0      equ     (byte ptr 0)
B1      equ     (byte ptr 1)
B2      equ     (byte ptr 2)
B3      equ     (byte ptr 3)
B4      equ     (byte ptr 4)
B5      equ     (byte ptr 5)
B6      equ     (byte ptr 6)
B7      equ     (byte ptr 7)
B8      equ     (byte ptr 8)
B9      equ     (byte ptr 9)

Regs    struc
	rAX     dw      ?
	rBX     dw      ?
	rCX     dw      ?
	rDX     dw      ?
	rBP     dw      ?
	rSI     dw      ?
	rDI     dw      ?
	rDS     dw      ?
	rES     dw      ?
	rCSIP   label   dword
	rIP     dw      ?
	rCS     dw      ?
	rFL     dw      ?
	rSP     dw      ?
	rSS     dw      ?
	ends

rByte	equ	80h

TUnitHeader     struc
	uhSignature     db      'TPU9'
	uhNext          dw      ?
	uhLink		dw      ?
	uhName          dw      ?
	uhInterface     dw      ?
	uhProcMap       dw      ?
	uhCodeMap       dw      ?
	uhConstMap      dw      ?
	uhDataMap       dw      ?
	uhEndMaps	dw      ?
	uhUnits         dw      ?
	uhSources       dw      ?
	uhTrace         dw      ?
	uhEndTrace      dw      ?
	uhCodeSize      dw      ?
	uhConstSize     dw      ?
	uhCodeFixupSize dw      ?
	uhDataFixupSize dw      ?
	uhDataSize      dw      ?
	uhDebugHash     dw      ?
	uhFlags		dw      ?
	uhCodeStart     dw      ?
	uhCodeLength    dw      ?
	uhOverlayLength dw      ?
	uhTpuName	dw      ?
	uhCodeSeg	dw      ?
	uhConstSeg      dw      ?
	uhCodeFixupSeg	dw	?
	uhConstFixupSeg	dw	?
	uhReserved	dw	10 dup(?)
	ends

uf8087		equ	1
ufOverlay	equ	2

TTypeDescriptor struc
	tdType          db      ?
	tdModifier      db      ?
	tdSizeOf        dw      ?
	tdNext          dw      ?
	ends

ttVoid          equ     0
ttArray         equ     1
ttRecord        equ     2
ttObject        equ     3
ttFile          equ     4
ttText          equ     5
ttProc          equ     6
ttSet           equ     7
ttPointer       equ     8
ttString        equ     9
tt8087          equ     10
ttReal          equ     11
ttInteger       equ     12
ttBoolean       equ     13
ttChar          equ     14
ttEnum          equ     15

tmVoid		equ	1 shl ttVoid
tmArray		equ	1 shl ttArray
tmRecord	equ	1 shl ttRecord
tmObject	equ	1 shl ttObject
tmFile		equ	1 shl ttFile
tmText		equ	1 shl ttText
tmProc		equ	1 shl ttProc
tmSet		equ	1 shl ttSet
tmPointer	equ	1 shl ttPointer
tmString	equ	1 shl ttString
tm8087		equ	1 shl tt8087
tmReal		equ	1 shl ttReal
tmInteger	equ	1 shl ttInteger
tmBoolean	equ	1 shl ttBoolean
tmChar		equ	1 shl ttChar
tmEnum		equ	1 shl ttEnum

TArrayType      struc
			TTypeDescriptor <>
	atBase          dd      ?
	atBounds        dd      ?
	ends

TRecordType     struc
			TTypeDescriptor <>
	rtHash          dw      ?
	rtFirst         dw      ?
	ends

TObjectType     struc
			TRecordType	<>
	otParent        dd      ?
	otVMTSize       dw      ?
	otVMTAddr       dw      ?
	otVMTOffset     dw      ?
	otName		dw      ?
	otReserved	dw      ?
	otReserved2	dw      ?
	otReserved3	dd      ?
	ends

TFileType	struc
			TTypeDescriptor <>
	ftBase          dd      ?
	ends

TSetType	struc
			TTypeDescriptor <>
	stBase          dd      ?
	ends

TPointerType	struc
			TTypeDescriptor <>
	ptBase          dd      ?
	ends

TProcParam      struc
	ppType          dd      ?
	ppFlags         db      ?
	ends

TProcType       struc
			TTypeDescriptor <>
	ptResult        dd      ?
	ptParamCount    dw      ?
	ptParams	label	TProcParam
	ends

TOrdinalType    struc
			TTypeDescriptor <>
	itLowerBound    dd      ?
	itUpperBound    dd      ?
	itBase          dd      ?
	ends

TEnumType       struc
			TOrdinalType    <>
	etSet		TSetType	<>
	etReserved	dw              ?
	ends

TSymbol struc
	sePrev          dw      ?
	seType          db      ?
	seName          db      ?
	ends

TLabelStub	struc
	lsLink		dw	?
	ends

TConstStub      struc
	csType          dd      ?
	csValue		equ	$
	ends

TTypeStub	struc
	tsType	dd	?
	ends

TVarStub        struc
	vsFlags         db      ?
	vsAddress       label   dword
	vsLink          label   dword
	vsOffset        dw      ?
	vsScope         label   word
	vsMap           label   word
	vsNext          dw      ?
	vsType          dd      ?
	ends

vfVar           equ     0
vfConst         equ     1
vfLocal         equ     2
vfAbsolute      equ     3
vfType		equ	3
vfAddress       equ     4
vfField         equ     8
vfAlias         equ     10h
vfParam         equ     20h

TProcStub       struc
	psFlags		db      ?
			db      ?
	psInlineLen	label	word
	psProcMap	dw      ?
	psScope		dw      ?
	psHash		dw      ?
	psOwner		dw      ?
	psType		label	TProcType
	ends

pfFar           equ     1
pfInline        equ     2
pfInterrupt     equ     4
pfExternal      equ     8
pfMethod        equ     10h
pfConstructor   equ     20h
pfDestructor    equ     40h
pfAssembler     equ     80h

ffProc          equ     0
ffCode          equ     4000h
ffData          equ     8000h
ffConst         equ     0c000h
ffOffs          equ     1000h
ffSegm          equ     2000h
ffPtr           equ     ffOffs+ffSegm

TInlineRecord	struc
	irType		db	?
	irValue		dw	?
	irFixup		dd	?
	ends

itByte		equ	0
itWord		equ	1
itDataFixup	equ	2
itConstFixup	equ	3

TUnitStub	struc
	usAddress	dw	?
	usChecksum	dw	?
	usNext		dw	?
	usPrev		dw	?
	ends

TProcMap        struc
	pmStub		dw	?
	pmFlags		dw      ?
	pmCodeMap	dw      ?
	pmEntryPoint    dw      ?
	ends

TSegMap struc
	smAddr          dw      ?
	smLength        dw      ?
	smFixupLength   dw      ?
	smTrace		label	word
	smOwner		dw      ?
	ends

TUnitList	struc
	ulSegment	dw	?
	ulName		db	?
	ends

TSourceList     struc
	slFileType      db      ?
	slNumber        dw      ?
	slTimeStamp     dd      ?
	slName          db      ?
	ends

TTraceTable     struc
	trSymbol        dw      ?
	trSource        dw      ?
	trDataBytes     dw      ?
	trLineNumber    dw      ?
	trLineCount     dw      ?
	ends

TFixup		struc
	fiUnit		dw	?
	fiMap		dw	?
	fiTarget	dw	?
	fiOffset	dw	?
	ends

_InitTurbo      equ     4
_HaltError      equ     8
_HaltTurbo      equ     12
_BlockMove      equ     16
_LongMul        equ     20
_LongDiv        equ     24
_LongShr        equ     28
_LongShl        equ     32
_LongAbs        equ     36
_LongSqr        equ     40
_SLoad          equ     44
_SStore         equ     48
_SLength        equ     52
_SCopy          equ     56
_SConcat        equ     60
_SPos           equ     64
_SCompare       equ     68
_SChar          equ     72
_SPacked        equ     76
_SInsert        equ     80
_SDelete        equ     84
_ZLoad          equ     88
_ZStore         equ     92
_ZInTest        equ     96
_FTrunc         equ     100
_FRound         equ     104
_FInt           equ     108
_FSqrt          equ     112
_FSin           equ     116
_FCos           equ     120
_FArcTan        equ     124
_FLn            equ     128
_FExp           equ     132
_NewPtr         equ     136
_DisposePtr     equ     140
_MarkPtr        equ     144
_ReleasePtr     equ     148
_GetFreMem      equ     152
_GetFreMax      equ     156
_ZClear         equ     160
_ZAddComp       equ     164
_ZAddRange      equ     168
_ZUnion         equ     172
_ZDifference    equ     176
_ZIntersect     equ     180
_ZEqual         equ     184
_ZRelation      equ     188
_GetParCnt      equ     192
_GetIORes       equ     196
_InOutCheck     equ     200
_RangeCheck     equ     204
_StackCheck     equ     208
_WriteFloat     equ     212
_WriteStr       equ     216
_WriteInt       equ     220
_WriteBool      equ     224
_WriteChar      equ     228
_WriteLine      equ     232
_WriteEnd       equ     236
_WriteFile      equ     240
_ReadFloat      equ     244
_ReadStr        equ     248
_ReadInt        equ     252
_ReadChar       equ     256
_ReadLine       equ     260
_ReadEnd        equ     264
_ReadFile       equ     268
_InitRand       equ     272
_AssignText     equ     276
_ResetText      equ     280
_RewriteText    equ     284
_CloseText      equ     288
_AssignFile     equ     292
_ResetFile      equ     296
_RewriteFile    equ     300
_CloseFile      equ     304
_EraseFile      equ     308
_RenameFile     equ     312
_GetSEoln       equ     316
_GetSEof        equ     320
_GetTEoln       equ     324
_GetTEof        equ     328
_ReadBlock      equ     332
_WriteBlock     equ     336
_SeekFile       equ     340
_GetFPos        equ     344
_GetFSize       equ     348
_GetFEof        equ     352
_FFrac          equ     356
_UpperCase      equ     360
_TruncFile      equ     364
_FillMem        equ     368
_RandInt        equ     372
_RandFloat      equ     376
_GetParStr      equ     380
_MoveMem        equ     384
_StrInt         equ     388
_ValInt         equ     392
_StrFloat       equ     396
_ValFloat       equ     400
_DirGet         equ     404
_DirSet         equ     408
_DirCreate      equ     412
_DirRemove      equ     416
_AppendText     equ     420

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -