Naked Assembly Routines
-
OK,...I'm a maniac, but I was thinking of writing some fairly simple assembly routines to use in a Managed C++ application. If you go over to the MSDN site, they tell you this: "For functions declared with the naked attribute, the compiler generates code without prolog and epilog code. You can use this feature to write your own prolog/epilog code sequences using inline assembler code." You can see the Microsoft specific implementation at this page: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/\_pluslang\_the\_naked\_attribute.asp\[^\] Anyway, another thing that the Microsoft specific people tell you is that: "The naked keyword is ignored when compiling with /clr." What I don't understand is what they refer to as the Prolog and Epilog code that the compiler automatically inserts. By the way, I got this maniacal concept while reading the book: "Assembly Language for Intel-Based Computers, Fourth Edition", by Kip Irvine, 2003. Anyone ever have any experience with this sort of thing? I'd appreciate ANY intel, no matter how obscure and trivial.
-
OK,...I'm a maniac, but I was thinking of writing some fairly simple assembly routines to use in a Managed C++ application. If you go over to the MSDN site, they tell you this: "For functions declared with the naked attribute, the compiler generates code without prolog and epilog code. You can use this feature to write your own prolog/epilog code sequences using inline assembler code." You can see the Microsoft specific implementation at this page: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/\_pluslang\_the\_naked\_attribute.asp\[^\] Anyway, another thing that the Microsoft specific people tell you is that: "The naked keyword is ignored when compiling with /clr." What I don't understand is what they refer to as the Prolog and Epilog code that the compiler automatically inserts. By the way, I got this maniacal concept while reading the book: "Assembly Language for Intel-Based Computers, Fourth Edition", by Kip Irvine, 2003. Anyone ever have any experience with this sort of thing? I'd appreciate ANY intel, no matter how obscure and trivial.
ursus zeta wrote: What I don't understand is what they refer to as the Prolog and Epilog code that the compiler automatically inserts. The compiler automatically inserts code to save the stack pointer (mov ebp, esp), test for stack overflow, and possibly push a couple registers, often ebp, edi and esi. The epilog pops those registers and restores esp. It saves esp because local variables are placed on the stack, and this is simple way of returning the stack pointer to the proper state before doing a return (which, BTW, should also pop off any parameters pushed onto the stack before the function was called, unless you're using PASCAL calling convention, which requires that the caller pops the parameters off). Marc MyXaml Advanced Unit Testing YAPO
-
ursus zeta wrote: What I don't understand is what they refer to as the Prolog and Epilog code that the compiler automatically inserts. The compiler automatically inserts code to save the stack pointer (mov ebp, esp), test for stack overflow, and possibly push a couple registers, often ebp, edi and esi. The epilog pops those registers and restores esp. It saves esp because local variables are placed on the stack, and this is simple way of returning the stack pointer to the proper state before doing a return (which, BTW, should also pop off any parameters pushed onto the stack before the function was called, unless you're using PASCAL calling convention, which requires that the caller pops the parameters off). Marc MyXaml Advanced Unit Testing YAPO
Marc, Thanks alot,...that is EXACTLY the information I was looking for. I appreciate it.