startup.inc
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:6k
- .xlist
- ;
- ; Paradigm C++ common assembly language definitions/macros
- ; Copyright (C) 1996, 1999 Paradigm Systems. All rights reserved.
- ;
- ; $Revision: 16 $
- ; $NoKeywords: $
- ;
- ; *********************************************************************
- ; Permission to modify and distribute object files based on this
- ; source code is granted to licensed users of Paradigm C++.
- ;
- ; Under no circumstances is this source code to be re-distributed
- ; without the express permission of Paradigm Systems.
- ; *********************************************************************
- ;
- ; Many of the macros define C-style functions and data declarations
- ; by appending a leading underscore to public symbols. To fixup these
- ; symbols, a new symbol is defined which replaces all occurrences of
- ; the original. This permits the C declaration to be used except when
- ; a name clash occurs.
- ;
- ; Should a name clash occur, such as in exit() and _exit() (since _exit
- ; is the alias created for the symbol exit), the use of manual delcarations
- ; must be used.
- ;
- ;
- ; Pointer shorthand for assembly language
- ;
- bptr equ byte ptr ; Data references
- wptr equ word ptr
- dptr equ dword ptr
- qptr equ qword ptr
- nptr equ near ptr ; Function references
- fptr equ far ptr
- ;
- ; Define a macro for defining segments. The paramters in order are
- ; - Segment name
- ; - Alignment
- ; - Combine type
- ; - Class name
- ; - Group name
- ;
- ; All macro arguments are mandatory except for a group name.
- ;
- DefSeg macro sname, salign, scomb, sclass, sgroup
- .errb <sname>
- .errb <salign>
- .errb <scomb>
- .errb <sclass>
- sname segment salign scomb use16 '&sclass'
- sname ends
- ifnb <sgroup>
- sgroup group sname
- endif
- endm
- ;
- ; Some simple macros for defining global (public) data where
- ; B - byte W - word
- ; D - dword Q - qword
- ; and 'ginit' is an optional initializer.
- ;
- GlobalB macro gname, ginit
- .errb <gname>
- ifnb <ginit>
- _&gname db ginit
- else
- _&gname db ?
- endif
- public _&gname
- gname equ _&gname
- endm ; GlobalB
- GlobalW macro gname, ginit
- .errb <gname>
- ifnb <ginit>
- _&gname dw ginit
- else
- _&gname dw ?
- endif
- public _&gname
- gname equ _&gname
- endm ; GlobalW
- GlobalD macro gname, ginit
- .errb <gname>
- ifnb <ginit>
- _&gname dd ginit
- else
- _&gname dd ?
- endif
- public _&gname
- gname equ _&gname
- endm ; GlobalD
- GlobalQ macro gname, ginit
- .errb <gname>
- ifnb <ginit>
- _&gname dq ginit
- else
- _&gname dq ?
- endif
- public _&gname
- gname equ _&gname
- endm ; GlobalQ
- ;
- ; Some simple macros for defining local (non-public) data where
- ; B - byte W - word
- ; D - dword Q - qword
- ; and 'linit' is an optional initializer.
- ;
- LocalB macro lname, linit
- .errb <lname>
- ifnb <linit>
- lname db linit
- else
- lname db ?
- endif
- endm ; LocalB
- LocalW macro lname, linit
- .errb <lname>
- ifnb <linit>
- lname dw linit
- else
- lname dw ?
- endif
- endm ; LocalW
- LocalD macro lname, linit
- .errb <lname>
- ifnb <linit>
- lname dd linit
- else
- lname dd ?
- endif
- endm ; LocalD
- LocalQ macro lname, linit
- .errb <lname>
- ifnb <linit>
- lname dq linit
- else
- lname dq ?
- endif
- endm ; LocalQ
- ;
- ; A pair of macros for defining public functions and marking the end.
- ; use BegProc to define a function with an optional forced memory model
- ; or use the default current memory model. The macro EndProc is then
- ; used to close the function.
- ;
- BegProc macro pname, pmodel
- .errb <pname>
- ifb <pmodel>
- if @CodeSize EQ 0
- _&pname proc near
- else
- _&pname proc far
- endif
- else
- _&pname proc pmodel
- endif
- public _&pname
- pname equ _&pname
- endm ; BegProc
- EndProc macro pname
- .errb <pname>
- _&pname endp
- endm ; EndProc
- ;
- ; Some simple macros for defining labels where
- ; B - byte W - word
- ; D - dword Q - qword
- ; The optional parameter 'lpub' can be used to make the label public.
- ;
- LabelB macro lname, lpub
- .errb <lname>
- ifnb <lpub>
- public _&lname
- _&lname label byte
- lname equ _&lname
- else
- lname label byte
- endif
- endm ; LabelB
-
- LabelW macro lname, lpub
- .errb <lname>
- ifnb <lpub>
- _&lname label word
- public _&lname
- lname equ _&lname
- else
- lname label word
- endif
- endm ; LabelW
- LabelD macro lname, lpub
- .errb <lname>
- ifnb <lpub>
- public _&lname
- _&lname label dword
- lname equ _&lname
- else
- lname label dword
- endif ; ifnb
- endm ; LabelD
- LabelQ macro lname, lpub
- .errb <lname>
- ifnb <lpub>
- public _&lname
- _&lname label qword
- lname equ _&lname
- else
- lname label qword
- endif
- endm ; LabelQ
- ;
- ; A macro to determine the near/far-ness of an external function
- ; based on the defined memory model. Also a pair of macros for
- ; accessing external labels.
- ;
- ExtProc macro ename, emodel
- .errb <ename>
- ifb <emodel>
- if @CodeSize EQ 0
- extrn _&ename : near
- else
- extrn _&ename : far
- endif
- else
- extrn _&ename : emodel
- endif
- ename equ _&ename
- endm ; ExtProc
- ExtLbl macro ename, etype
- .errb <ename>
- ifb <etype>
- extrn &ename : byte
- else
- extrn &ename : etype
- endif
- endm ; ExtLbl
- ExtCLbl macro ename, etype
- .errb <ename>
- ifb <etype>
- extrn _&ename : byte
- else
- extrn _&ename : etype
- endif
- ename equ _&ename
- endm ; ExtCLbl
- ;
- ; Some useful constants for checking code/data memory models and
- ; the floating point options.
- ;
- MM_NEAR equ 0 ; Small code/data model definition
- MM_FAR equ 1 ; Large code/data model definition
- MM_HUGE equ 2 ; Huge code/data model definition
- ;
- ; Paradigm C++ initializer priorities
- ;
- PRI_FARDATA equ 0 ; FAR_DATA/FAR_BSS initialization
- PRI_DMM equ 1 ; Dynamic memory management initialization
- PRI_FPU equ 2 ; Floating point initialization
- PRI_STDIO equ 3 ; Stream I/O initialization
- ;
- ; Paradigm C++ - PDREMOTE/ROM exit codes
- ;
- PDE_ZERODIV equ 18 ; Zero divide exception
- PDE_ESCOP equ 128 ; Escape opcode exception
- PDE_IOTRAP equ 129 ; I/O trap exception
- PDE_ILLOP equ 130 ; Illegal opcode exception
- PDE_CHKIND equ 131 ; CHKIND exception
- PDE_INTO equ 132 ; INTO exception
- PDE_BADINT equ 133 ; Unexpected interrupt
- PDE_PUREERR equ 134 ; Pure virtual function error
- PDE_ABORT equ 135 ; abort() called
- PDE_EXIT equ 136 ; exit() called
- PDE_STKOVL equ 137 ; Stack overflow
- PDE_DOSEMU equ 141 ; Unsupported DOS call
- PDE_HEAPERR equ 142 ; Heap initialization error
- PDE_FPFMT equ 143 ; Floating point format error
- PDE_NULLPTR equ 144 ; Null pointer check failed
- .list