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

📄 scitech.mac

📁 uboot在arm处理器s3c2410的移植代码
💻 MAC
📖 第 1 页 / 共 2 页
字号:
; macros to declare assembler import stubs for binary loadable drivers%imacro BEGIN_IMPORTS_DEF   1BEGIN_STUBS_DEF %1,4%endmacro%imacro   DECLARE_IMP   2DECLARE_STUB    %1%endmacro%imacro   SKIP_IMP   2SKIP_STUB    %1%endmacro%imacro   SKIP_IMP2   1DECLARE_STUB    %1%endmacro%imacro   SKIP_IMP3   1SKIP_STUB    %1%endmacro%imacro   END_IMPORTS_DEF 0END_STUBS_DEF%endmacroelse    ; __NASM_MAJOR__;============================================================================; Macro package when compiling with TASM.;============================================================================; Turn off underscores for globals if disabled for all externalsifdef   __NOU____NOU_VAR__         = 1endif; Define the __WINDOWS__ symbol if we are compiling for any Windows; environmentifdef   __WINDOWS16____WINDOWS__         = 1endififdef   __WINDOWS32____WINDOWS__         = 1__WINDOWS32_386__   = 1endififdef   __WIN386____WINDOWS__         = 1__WINDOWS32_386__   = 1endififdef   __VXD____WINDOWS__         = 1__WINDOWS32_386__   = 1        MASM        .386        NO_SEGMENTS = 1        include vmm.inc         ; IGNORE DEPEND        include vsegment.inc    ; IGNORE DEPEND        IDEALendif; Macros for accessing 'generic' registersifdef   __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 modelelse        _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 generationendif        invert      EQU not; Provide a typedef for real floating point numbersifdef   DOUBLEtypedef REAL    QWORDtypedef DREAL   QWORDelsetypedef REAL    DWORDtypedef DREAL   DWORDendif; Macros to access the floating point stack registers to convert them; from NASM style to TASM stylest0         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       =       0True        =       1No          =       0Yes         =       1Yes         =       1endif; Macros for the _DATA data segment. This segment contains initialised data.MACRO   begdataseg nameifdef   __VXD__        MASMVXD_LOCKED_DATA_SEG        IDEALelseifdef   flatmodel        DATASEGelseSEGMENT _DATA DWORD PUBLIC USE16 'DATA'endifendifENDMMACRO   enddataseg nameifdef   __VXD__        MASMVXD_LOCKED_DATA_ENDS        IDEALelseifndef  flatmodelENDS    _DATAendifendifENDM; Macro for the main code segment.MACRO   begcodeseg nameifdef   __VXD__        MASMVXD_LOCKED_CODE_SEG        IDEALelseifdef   flatmodel        CODESEG        ASSUME  CS:FLAT,DS:FLAT,SS:FLATelseSEGMENT &name&_TEXT PARA PUBLIC USE16 'CODE'        ASSUME CS:&name&_TEXT,DS:_DATAendifendifENDM; Macro for a near code segmentMACRO   begcodeseg_nearifdef   flatmodel        CODESEG        ASSUME  CS:FLAT,DS:FLAT,SS:FLATelseSEGMENT _TEXT PARA PUBLIC USE16 'CODE'        ASSUME CS:_TEXT,DS:_DATAendifENDMMACRO   endcodeseg nameifdef   __VXD__        MASMVXD_LOCKED_CODE_ENDS        IDEALelseifndef  flatmodelENDS    &name&_TEXTendifendifENDMMACRO   endcodeseg_nearifndef  flatmodelENDS    _TEXTendifENDM; Macro to be invoked at the start of all modules to set up segments for; later use.MACRO   header namebegdataseg nameenddataseg nameENDM; Macro for an extern C symbol. If the C compiler requires leading; underscores, then the underscores are added to the symbol names, otherwise; they are left off. The symbol name is referenced in the assembler code; using the non-underscored symbol name.MACRO   cextern name,sizeifdef   __NOU_VAR__        EXTRN   name:sizeelse        EXTRN   _&name&:sizename    EQU     _&name&endifENDMMACRO   cexternfunc name,sizeifdef   __NOU__        EXTRN   name:sizeelse        EXTRN   _&name&:sizename    EQU     _&name&endifENDMMACRO   stdexternfunc   name,num_args,sizeifdef   STDCALL_MANGLE        EXTRN   _&name&@&num_args&:sizename    EQU     _&name&@&num_argselse        EXTRN   name:sizeendifENDM; Macro for a public C symbol. If the C compiler requires leading; underscores, then the underscores are added to the symbol names, otherwise; they are left off. The symbol name is referenced in the assembler code; using the non-underscored symbol name.MACRO   cpublic nameifdef   __NOU_VAR__name:        PUBLIC  nameelse_&name&:        PUBLIC  _&name&name    EQU     _&name&endifENDM; Macro for an global C symbol. If the C compiler requires leading; underscores, then the underscores are added to the symbol names, otherwise; they are left off. The symbol name is referenced in the assembler code; using the non-underscored symbol name.MACRO   cglobal nameifdef   __NOU_VAR__        PUBLIC  nameelse        PUBLIC  _&name&name    EQU     _&name&endifENDM; Macro for an global C function symbol. If the C compiler requires leading; underscores, then the underscores are added to the symbol names, otherwise; they are left off. The symbol name is referenced in the assembler code; using the non-underscored symbol name.MACRO   cglobalfunc nameifdef   __NOU__        PUBLIC  nameelse        PUBLIC  _&name&name    EQU     _&name&endifENDM; Macro to start a C callable function. This will be a far function for; 16-bit code, and a near function for 32-bit code.MACRO   cprocstatic name        ; Set up model independant private procifdef flatmodelPROC    name NEARelsePROC    name FARendifLocalSize   = 0ENDMMACRO   cprocstart name         ; Set up model independant procifdef flatmodelifdef   __NOU__PROC    name NEARelsePROC    _&name& NEARendifelseifdef   __NOU__PROC    name FARelsePROC    _&name& FARendifendifLocalSize   = 0        cglobalfunc nameENDMMACRO   cprocnear name          ; Set up near procifdef   __NOU__PROC    name NEARelsePROC    _&name& NEARendifLocalSize   = 0        cglobalfunc nameENDMMACRO   cprocfar name           ; Set up far procifdef   __NOU__PROC    name FARelsePROC    _&name& FARendifLocalSize   = 0        cglobalfunc nameENDMMACRO   cprocend               ; End procedure macroENDPENDM; This macro sets up a procedure to be exported from a 16 bit DLL. Since the; calling conventions are always _far _pascal for 16 bit DLL's, we actually; rename this routine with an extra underscore with 'C' calling conventions; and a small DLL stub will be provided by the high level code to call the; assembler routine.MACRO   cprocstartdll16 nameifdef   __WINDOWS16__cprocstart  _&name&elsecprocstart  nameendifENDM; Macros for entering and exiting C callable functions. Note that we must; always save and restore the SI and DI registers for C functions, and for; 32 bit C functions we also need to save and restore EBX and clear the; direction flag.MACRO   save_c_regsifdef   flatmodel        push    ebxendif        push    _si        push    _diENDMMACRO   enter_c        push    _bp        mov     _bp,_sp    IFDIFI  <LocalSize>,<0>        sub     _sp,LocalSize    ENDIF        save_c_regsENDMMACRO   restore_c_regs        pop     _di        pop     _siifdef   flatmodel        pop     ebxendifENDMMACRO   leave_c        restore_c_regs        cld    IFDIFI  <LocalSize>,<0>        mov     _sp,_bp    ENDIF        pop     _bpENDMMACRO   use_ebxifdef flatmodel        push    ebxendifENDMMACRO   unuse_ebxifdef flatmodel        pop     ebxendifENDM; Macros for saving and restoring the value of DS,ES,FS,GS when it is to; be used in assembly routines. This evaluates to nothing in the flat memory; model, but is saves and restores DS in the large memory model.MACRO   use_dsifndef flatmodel        push    dsendifENDMMACRO   unuse_dsifndef flatmodel        pop     dsendifENDMMACRO   use_esifndef flatmodel        push    esendifENDMMACRO   unuse_esifndef flatmodel        pop     esendifENDM; Macros for loading the address of a data pointer into a segment and; index register pair. The macro 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) macros for documentation purposes.MACRO   _lds    reg, addrifdef flatmodel        mov     reg,addrelse        lds     reg,addrendifENDMMACRO   _les    reg, addrifdef flatmodel        mov     reg,addrelse        les     reg,addrendifENDM; 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).MACRO   _add    reg, val16, val32ifdef flatmodel        add     e&reg&, val32else        add     reg, val16endifENDMMACRO   _sub    reg, val16, val32ifdef flatmodel        sub     e&reg&, val32else        sub     reg, val16endifENDM; 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.MACRO   clrhi   regifdef   flatmodel        movzx   e&reg&,regendifENDMMACRO   sgnhi   regifdef   flatmodel        movsx   e&reg&,regendifENDM; Macro to load an extended register with an integer value in either modeMACRO   loadint reg,valifdef flatmodel        mov     e&reg&,valelse        xor     e&reg&,e&reg&        mov     reg,valendifENDM; Macros to load and store integer values with string instructionsMACRO   LODSINTifdef flatmodel        lodsdelse        lodswendifENDMMACRO   STOSINTifdef flatmodel        stosdelse        stoswendifENDM; Macros to provide resb, resw, resd compatibility with NASMMACRO   dclb    countdb  count dup (0)ENDMMACRO   dclw    countdw  count dup (0)ENDMMACRO   dcld    countdd  count dup (0)ENDM; Macros to provide resb, resw, resd compatibility with NASMMACRO   resb    countdb  count dup (?)ENDMMACRO   resw    countdw  count dup (?)ENDMMACRO   resd    countdd  count dup (?)ENDM; Macros to declare assembler stubs for function structuresMACRO   BEGIN_STUBS_DEF name, firstOffsetbegdataseg  _STUBSifdef   __NOU_VAR__        EXTRN   name:DWORDSTUBS_START =   nameelse        EXTRN   _&name&:DWORDname    EQU     _&name&STUBS_START =   _&nameendifenddataseg  _STUBSbegcodeseg  _STUBSoff = firstOffsetENDMMACRO   DECLARE_STUB    nameifdef   __NOU__name:        PUBLIC  nameelse_&name:        PUBLIC  _&nameendif        jmp     [DWORD STUBS_START+off]off = off + 4ENDMMACRO   SKIP_STUB    nameoff = off + 4ENDMMACRO   DECLARE_STDCALL name,num_argsifdef   STDCALL_MANGLE_&name&@&num_args&:        PUBLIC  _&name&@&num_args&elsename:        PUBLIC  nameendif        jmp     [DWORD STUBS_START+off]off = off + 4ENDMMACRO   END_STUBS_DEFendcodeseg  _STUBSENDMMACRO   BEGIN_IMPORTS_DEF   nameBEGIN_STUBS_DEF name,4ENDMifndef LOCAL_DECLARE_IMPMACRO   DECLARE_IMP name, numArgsDECLARE_STUB    nameENDMMACRO   SKIP_IMP nameSKIP_STUB       nameENDMMACRO   SKIP_IMP2 name, numArgsDECLARE_STUB    nameENDMMACRO   SKIP_IMP3 nameSKIP_STUB       nameENDMendifMACRO   END_IMPORTS_DEFEND_STUBS_DEFENDMMACRO   LEA_L    reg,name        lea     reg,[name]ENDMMACRO   LEA_G    reg,name        lea     reg,[name]ENDMendif

⌨️ 快捷键说明

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