1 ;[]-----------------------------------------------------------------[]
\r
2 ;| RULES.ASI -- Rules & Structures for assembler |
\r
4 ;| Turbo C++ Run Time Library |
\r
6 ;| Copyright (c) 1987, 1991 by Borland International Inc. |
\r
7 ;| All Rights Reserved. |
\r
8 ;[]-----------------------------------------------------------------[]
\r
10 ;*** First we begin with a few of the major constants of C.
\r
12 false equ 0 ; Beware ! For incoming parameters, non-false = true.
\r
13 true equ 1 ; For results, we generate the proper numbers.
\r
15 lesser equ -1 ; Incoming, lesser < 0
\r
17 greater equ 1 ; Incoming, greater > 0
\r
20 ;[]------------------------------------------------------------[]
\r
22 ;| Conditional Assembly Directives |
\r
24 ;[]------------------------------------------------------------[]
\r
26 ;memory model aliases, for the convenience of building the library
\r
54 %OUT You must supply a model symbol.
\r
63 ;bit masks to extract default pointer types from MMODEL (at run-time)
\r
67 IFDEF __TINY__ ; Small Code - Small Data
\r
74 IFDEF __SMALL__ ; Small Code - Small Data
\r
81 IFDEF __MEDIUM__ ; Large Code - Small Data
\r
88 IFDEF __COMPACT__ ; Small Code - Large Data
\r
94 IFDEF __LARGE__ ; Large Code - Large Data
\r
97 MMODEL equ FCODE+FDATA+4
\r
100 IFDEF __HUGE__ ; Large Code - Large Data
\r
103 MMODEL equ FCODE+FDATA+5
\r
113 ;[]------------------------------------------------------------[]
\r
115 ;| Segment Declarations Macros |
\r
117 ;[]------------------------------------------------------------[]
\r
119 Code_Seg@ MACRO ;; Open a Code Segment
\r
121 _TEXT SEGMENT WORD PUBLIC 'CODE'
\r
123 _TEXT SEGMENT BYTE PUBLIC 'CODE'
\r
128 Code_EndS@ MACRO ;; Close a Code Segment
\r
132 Data_Seg@ MACRO ;; Open a Data Segment (initialized)
\r
133 _DATA SEGMENT WORD PUBLIC 'DATA'
\r
136 Data_EndS@ MACRO ;; Close a Data Segment (initialized)
\r
141 BSS_Seg@ MACRO ;; Open a Data Segment (un-initialized)
\r
142 _BSS SEGMENT WORD PUBLIC 'BSS'
\r
145 BSS_EndS@ MACRO ;; Close a Data Segment (un-initialized)
\r
150 FarData_Seg@ MACRO ;; Open a FAR Data Segment
\r
151 _FARDATA SEGMENT PARA PUBLIC 'FAR_DATA'
\r
154 FarData_EndS@ MACRO ;; Close a FAR Data Segment
\r
158 FarBSS_Seg@ MACRO ;; Open a FAR BSS Segment
\r
159 _FARBSS SEGMENT PARA PUBLIC 'FAR_BSS'
\r
162 FarBSS_EndS@ MACRO ;; Close a FAR BSS Segment
\r
166 Const_Seg@ MACRO ;; Open a CONST Segment
\r
167 _CONST SEGMENT WORD PUBLIC 'CONST'
\r
170 Const_EndS@ MACRO ;; Close a CONST Segment
\r
174 Init_Seg@ MACRO ;; Open a INIT Segment
\r
175 _INIT_ SEGMENT WORD PUBLIC 'INITDATA'
\r
178 Init_EndS@ MACRO ;; Close a INIT Segment
\r
182 Exit_Seg@ MACRO ;; Open a EXIT Segment
\r
183 _EXIT_ SEGMENT WORD PUBLIC 'EXITDATA'
\r
186 Exit_EndS@ MACRO ;; Close a EXIT Segment
\r
191 _CVTSEG SEGMENT WORD PUBLIC 'DATA'
\r
199 _SCNSEG SEGMENT WORD PUBLIC 'DATA'
\r
213 ASSUME CS:_TEXT, DS:DGROUP
\r
216 ;[]------------------------------------------------------------[]
\r
218 ;| Segment Definitions |
\r
220 ;[]------------------------------------------------------------[]
\r
225 _TEXT SEGMENT WORD PUBLIC 'CODE'
\r
228 _TEXT SEGMENT BYTE PUBLIC 'CODE'
\r
232 _FARDATA SEGMENT PARA PUBLIC 'FAR_DATA'
\r
235 _FARBSS SEGMENT PARA PUBLIC 'FAR_BSS'
\r
240 _OVERLAY_ SEGMENT PARA PUBLIC 'OVRINFO'
\r
242 _1STUB_ SEGMENT PARA PUBLIC 'STUBSEG'
\r
248 NULL SEGMENT PARA PUBLIC 'BEGDATA'
\r
252 _DATA SEGMENT PARA PUBLIC 'DATA'
\r
256 _CONST SEGMENT WORD PUBLIC 'CONST'
\r
260 _FPSEG SEGMENT WORD PUBLIC 'DATA'
\r
264 _CVTSEG SEGMENT WORD PUBLIC 'DATA'
\r
267 _SCNSEG SEGMENT WORD PUBLIC 'DATA'
\r
270 _INIT_ SEGMENT WORD PUBLIC 'INITDATA'
\r
271 InitStart label byte
\r
273 _INITEND_ SEGMENT BYTE PUBLIC 'INITDATA'
\r
277 _EXIT_ SEGMENT WORD PUBLIC 'EXITDATA'
\r
278 ExitStart label byte
\r
280 _EXITEND_ SEGMENT BYTE PUBLIC 'EXITDATA'
\r
285 _BSS SEGMENT WORD PUBLIC 'BSS'
\r
286 BeginBSS label byte
\r
288 _BSSEND SEGMENT BYTE PUBLIC 'BSSEND'
\r
297 DGROUP GROUP NULL,_DATA,_CONST,_FPSEG,_CVTSEG,_SCNSEG,_INIT_,_INITEND_,_EXIT_,_EXITEND_
\r
299 DGROUP GROUP NULL,_DATA,_CONST,_FPSEG,_CVTSEG,_SCNSEG,_INIT_,_INITEND_,_EXIT_,_EXITEND_,_BSS,_BSSEND
\r
307 DGROUP GROUP _DATA,_CONST,_CVTSEG,_SCNSEG,_INIT_,_INITEND_,_EXIT_,_EXITEND_
\r
309 DGROUP GROUP _DATA,_CONST,_CVTSEG,_SCNSEG,_INIT_,_INITEND_,_EXIT_,_EXITEND_,_BSS,_BSSEND
\r
313 DGROUP GROUP _TEXT,_DATA,_CONST,_CVTSEG,_SCNSEG,_INIT_,_INITEND_,_EXIT_,_EXITEND_,_BSS,_BSSEND
\r
315 DGROUP GROUP _DATA,_CONST,_CVTSEG,_SCNSEG,_INIT_,_INITEND_,_EXIT_,_EXITEND_,_BSS,_BSSEND
\r
321 DGROUP GROUP _DATA,_CONST,_CVTSEG,_SCNSEG,_INIT_,_INITEND_,_EXIT_,_EXITEND_
\r
323 DGROUP GROUP _DATA,_CONST,_CVTSEG,_SCNSEG,_BSS,_BSSEND
\r
327 DGROUP GROUP _TEXT,_DATA,_CONST,_CVTSEG,_SCNSEG,_INIT_,_INITEND_,_EXIT_,_EXITEND_,_BSS,_BSSEND
\r
329 DGROUP GROUP _DATA,_CONST,_CVTSEG,_SCNSEG,_INIT_,_INITEND_,_EXIT_,_EXITEND_,_BSS,_BSSEND
\r
332 ENDIF ; __NOFLOAT__
\r
334 ENDIF ; __WINDOWS__
\r
347 ;[]------------------------------------------------------------[]
\r
349 ;| Old Segment Declarations Macros |
\r
351 ;[]------------------------------------------------------------[]
\r
354 CSeg@ MACRO ;; Open a Code Segment
\r
356 _TEXT SEGMENT WORD PUBLIC 'CODE'
\r
358 _TEXT SEGMENT BYTE PUBLIC 'CODE'
\r
363 CSegEnd@ MACRO ;; Close a Code Segment
\r
367 DSeg@ MACRO ;; Open a Data Segment (initialized)
\r
368 _DATA SEGMENT WORD PUBLIC 'DATA'
\r
371 DSegEnd@ MACRO ;; Close a Data Segment (initialized)
\r
377 BSeg@ MACRO ;; Open a Data Segment (un-initialized)
\r
378 _BSS SEGMENT WORD PUBLIC 'BSS'
\r
381 BSegEnd@ MACRO ;; Close a Data Segment (un-initialized)
\r
389 _TEXT SEGMENT WORD PUBLIC 'CODE'
\r
391 _TEXT SEGMENT BYTE PUBLIC 'CODE'
\r
394 _DATA SEGMENT WORD PUBLIC 'DATA'
\r
398 _BSS SEGMENT WORD PUBLIC 'BSS'
\r
403 ASSUME CS:_TEXT, DS:DGROUP
\r
407 ;[]------------------------------------------------------------[]
\r
409 ;| C Naming Convention Macros |
\r
411 ;[]------------------------------------------------------------[]
\r
415 ExtSym@ MACRO Sym, sType, sName
\r
417 IFIDN <sName>, <__PASCAL__>
\r
420 NAMING = UNDERSCORE
\r
424 EXTRN _&Sym : sType
\r
432 PubSym@ MACRO Sym, Definition, sName
\r
434 IFIDN <sName>, <__PASCAL__>
\r
437 NAMING = UNDERSCORE
\r
451 Static@ MACRO Sym, Definition, sName
\r
453 IFIDN <sName>, <__PASCAL__>
\r
456 NAMING = UNDERSCORE
\r
469 ;[]------------------------------------------------------------[]
\r
471 ;| Macros which are Data Size Dependent |
\r
473 ;[]------------------------------------------------------------[]
\r
476 DPTR_ equ DWORD PTR
\r
491 PushPtr MACRO dPtrOff, dPtrSeg
\r
497 dPtr@ MACRO Sym, VALUE, sName ;; Static Data pointer
\r
498 Static@ Sym, <DD VALUE>, sName
\r
501 dPtrPub@ MACRO Sym, VALUE, sName ;; Global Data Pointer
\r
502 PubSym@ Sym, <DD VALUE>, sName
\r
505 dPtrExt@ MACRO Sym, sName ;; External Data Pointer
\r
506 ExtSym@ Sym, DWORD, sName
\r
522 PushPtr MACRO dPtrOff, dPtrSeg
\r
526 dPtr@ MACRO Sym, VALUE, sName ;; Static Data pointer
\r
527 Static@ Sym, <DW VALUE>, sName
\r
530 dPtrPub@ MACRO Sym, VALUE, sName ;; Global Data Pointer
\r
531 PubSym@ Sym, <DW VALUE>, sName
\r
534 dPtrExt@ MACRO Sym, sName ;; External Data Pointer
\r
535 ExtSym@ Sym, WORD, sName
\r
539 ;[]------------------------------------------------------------[]
\r
541 ;| Macros which are Code Size Dependent |
\r
543 ;[]------------------------------------------------------------[]
\r
546 CPTR_ equ DWORD PTR
\r
549 Proc@ MACRO Sym, sName ;; Open a Static function
\r
550 Static@ Sym, <PROC FAR>, sName
\r
553 PubProc@ MACRO Sym, sName ;; Open a Public function
\r
554 PubSym@ Sym, <PROC FAR>, sName
\r
557 ExtProc@ MACRO Sym, sName ;; External Function
\r
558 ExtSym@ Sym, FAR, sName
\r
561 cPtr@ MACRO Sym, VALUE, sName ;; Static Function pointer
\r
562 Static@ Sym, <DD VALUE>, sName
\r
565 cPtrPub@ MACRO Sym, VALUE, sName;; Global Function Pointer
\r
566 PubSym@ Sym, <DD VALUE>, sName
\r
569 cPtrExt@ MACRO Sym, sName ;; External Function Pointer
\r
570 ExtSym@ Sym, DWORD, sName
\r
576 Proc@ MACRO Sym, sName ;; Open a Static function
\r
577 Static@ Sym, <PROC NEAR>, sName
\r
580 PubProc@ MACRO Sym, sName ;; Open a Public function
\r
581 PubSym@ Sym, <PROC NEAR>, sName
\r
584 ExtProc@ MACRO Sym, sName ;; External Function
\r
585 ExtSym@ Sym, NEAR, sName
\r
588 cPtr@ MACRO Sym, VALUE, sName ;; Static Function pointer
\r
589 Static@ Sym, <DW VALUE>, sName
\r
592 cPtrPub@ MACRO Sym, VALUE, sName ;; Global Function Pointer
\r
593 PubSym@ Sym, <DW VALUE>, sName
\r
596 cPtrExt@ MACRO Sym, sName ;; External Function Pointer
\r
597 ExtSym@ Sym, WORD, sName
\r
601 EndProc@ MACRO Sym, sName ;; Close a function
\r
602 Static@ Sym, ENDP, sName
\r
606 ;[]------------------------------------------------------------[]
\r
608 ;| Miscellaneous Definitions |
\r
610 ;[]------------------------------------------------------------[]
\r
612 ;*** Set up some macros for procedure parameters and export/import
\r
626 ;*** Next, we define some convenient structures to access the parts
\r
627 ; of larger objects.
\r
650 ; How to invoke MSDOS.
\r
657 ; The next section concerns the use of registers. SI and DI are used
\r
658 ; for register variables, and must be conserved.
\r
660 ; Registers AX, BX, CX, DX will not be preserved across function calls.
\r
662 ; Firstly, the registers to be conserved through function calls, including
\r
663 ; the setup of local variables.
\r
665 link@ MACRO _si,_di,_ES,locals
\r
679 unLink@ MACRO _si,_di,_ES,locals
\r