Flash for Linux

來源:互聯網
上載者:User

http://f4l.sourceforge.net/

順便COPY段代碼先扔這裡:

--- d:\vsprojects\vcpros\consolepros\vckbase1\first.cpp  -------------------
1:    #include <stdio.h>
2:
3:    int main(int argc, char** argv, char** envp)
4:    {
00401010   push        ebp  ;save ebp(cpu->記憶體)
00401011   mov         ebp,esp  ;set stack frame pointer
00401013   sub         esp,40h  ;allocate space for locals
00401016   push        ebx  ;save registers-------下面內容均如此
00401017   push        esi
00401018   push        edi
00401019   lea         edi,[ebp-40h]
0040101C   mov         ecx,10h
00401021   mov         eax,0CCCCCCCCh
00401026   rep stos    dword ptr [edi]
5:        return 0;
00401028   xor         eax,eax
6:    }
0040102A   pop         edi
0040102B   pop         esi
0040102C   pop         ebx  ;restore registers
0040102D   mov         esp,ebp  ;restore stack pointer
0040102F   pop         ebp  ;restore ebp
00401030   ret    ;return from function
--- No source file  --------------------------------------------------------

argc = 1 ;因為在VC中要讀取你的*argv指向的應用程式名稱字(*.exe)
* argv = D:\VSPROJECTS\VCPROS\CONSOLEPROS\vckbase1\Debug\vckbase1.exe
* envp = ALLUSERSPROFILE=C:\Documents and Settings\All Users

 =============================================================

Considerations when Writing Prolog/Epilog Code

Microsoft Specific —>

Before writing your own prolog and epilog code sequences, it is important to understand how the stack frame is laid out. It is also useful to know how to use the __LOCAL_SIZE predefined constant.

C Stack Frame Layout

This example shows the standard prolog code that might appear in a 32-bit function:

push     ebp                 ; Save ebpmov      ebp, esp            ; Set stack frame pointersub      esp, localbytes     ; Allocate space for localspush     <registers>         ; Save registers

The localbytes variable represents the number of bytes needed on the stack for local variables, and the registers variable is a placeholder that represents the list of registers to be saved on the stack. After pushing the registers, you can place any other appropriate data on the stack. The following is the corresponding epilog code:

pop      <registers>         ; Restore registersmov      esp, ebp            ; Restore stack pointerpop      ebp                 ; Restore ebpret                          ; Return from function

The stack always grows down (from high to low memory addresses). The base pointer (ebp) points to the pushed value of ebp. The local variables area begins at ebp-2. To access local variables, calculate an offset from ebp by subtracting the appropriate value from ebp.

The __LOCAL_SIZE Constant

The compiler provides a constant, __LOCAL_SIZE, for use in the inline assembler block of function prolog code. This constant is used to allocate space for local variables on the stack frame in custom prolog code.

The compiler determines the value of __LOCAL_SIZE. The value is the total number of bytes of all user-defined local variables and compiler-generated temporary variables. __LOCAL_SIZE can be used only as an immediate operand; it cannot be used in an expression. You must not change or redefine the value of this constant. For example:

mov      eax, __LOCAL_SIZE           ;Immediate operand--Okaymov      eax, [ebp - __LOCAL_SIZE]   ;Error

The following example of a naked function containing custom prolog and epilog sequences uses __LOCAL_SIZE in the prolog sequence:

__declspec ( naked ) func(){int i;int j;__asm      /* prolog */{push   ebpmov      ebp, espsub      esp, __LOCAL_SIZE}/* Function body */__asm      /* epilog */{mov      esp, ebppop      ebpret}}  

END Microsoft Specific


 

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.