Flash for Linux

Source: Internet
Author: User

Http://f4l.sourceforge.net/

By the way, copyCodeHere:

--- 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-> memory)
00401011 mov EBP, esp; Set stack frame pointer
00401013 sub ESP, 40 h; Allocate space for locals
00401016 push EBX; save registers ------- the following content is as follows:
00401017 push ESI
00401018 push EDI
00401019 Lea EDI, [ebp-40h]
0040101c mov ECx, 10 h
00401021 mov eax, 0 cccccccch
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; because in VC, you need to read the application pointed to by * argv.ProgramName (*. EXE)
* Argv = D: \ vsprojects \ vcpros \ consolepros \ vckbase1 \ debug \ vckbase1.exe
* Envp = allusersprofile = c: \ Documents ents 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_ Local_sizePredefined 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

TheLocalbytesVariable represents the number of bytes needed on the stack for local variables, andRegistersVariable 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 valueEBP. The local variables area beginsEbp-2. To access local variables, calculate an offset fromEBPBy subtracting the appropriate value fromEBP.

The _ local_size constant

The compiler provides a constant,_ Local_size, For use in the inline into ER 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_ Local_size. The value is the total number of bytes of all user-defined local variables and compiler-generated temporary variables._ Local_sizeCan 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_sizeIn 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


 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.