calling-convention

CLR/Fastcall: How are large value types passed internally to called functions?

心不动则不痛 提交于 2019-12-01 09:19:43
Just out of curiosity: value types are generally copied, and the JIT compiler seems to use Microsoft's Fastcall calling convention when calling a method. This puts the first few arguments in registers, for fast access. But how are large value types (i.e. bigger than the size of a register or the width of the stack) passed to the called function? This book excerpt states that: The CLR's jitted code uses the fastcall Windows calling convention. This permits the caller to supply the first two arguments (including this in the case of instance methods) in the machine's ECX and EDX registers. It is

How to invoke a javascript function (generated from typescript) trapped within “System.register()” module while using Google protobuf?

心不动则不痛 提交于 2019-12-01 09:09:46
Update : It seems that, the problem is coming due to protobuf. I am fine with other solution as well, which help me to fix the Google protobuf issues. This problem boils down to: How to integrate Google protobuf with Typescript/Javascript for the browser? I am retaining below question for the future purpose. We have moved our application from Javascript to Typescript for obvious advantages of OOP etc.. Earlier invoking a direct javascript function from Html was as straight forward as: <script>window.MyFunction()</script> Now with Typescript, all the files are combined into a single

Behaviour of ebp and esp in stacks using function with parameter

半腔热情 提交于 2019-12-01 08:28:12
问题 i want to learn more about stack. Especially, what happens when a function with parameter are called. For this, i write the following code: #include <stdio.h> int sum(int d, int e, int f){ int result = d + e + f; return result; } int main(void){ int a = 5; int b = 4; int c = 2; int erg = sum(a,b,c); printf("Result is: %d", erg); } and I get the following Assembly-Code(I will only add the part of the main function, because first I want to understand this section): push ebp, mov ebp, esp and

CLR/Fastcall: How are large value types passed internally to called functions?

久未见 提交于 2019-12-01 06:01:20
问题 Just out of curiosity: value types are generally copied, and the JIT compiler seems to use Microsoft's Fastcall calling convention when calling a method. This puts the first few arguments in registers, for fast access. But how are large value types (i.e. bigger than the size of a register or the width of the stack) passed to the called function? This book excerpt states that: The CLR's jitted code uses the fastcall Windows calling convention. This permits the caller to supply the first two

What registers must be preserved by an x86 function?

一世执手 提交于 2019-12-01 03:08:20
I'm writing a function in x86 assembly that should be callable from c code, and I'm wondering which registers i have to restore before i return to the caller. Currently I'm only restoring esp and ebp , while the return value is in eax . Are there any other registers I should be concerned about, or could I leave whatever pleases me in them? Necrolis Using Microsoft's 32 bit ABI ( cdecl or stdcall or other calling conventions), EAX , EDX and ECX are scratch registers (call clobbered). The other general-purpose integer registers are call-preserved. The condition codes in EFLAGS are call-clobbered

C calling conventions and passed arguments

谁说胖子不能爱 提交于 2019-11-30 23:05:50
When making a function call in Linux (or OS X for that matter), can the callee modify the values of the arguments on the stack? I was under the assumption that since the caller is the one that cleans them up, that they should contain the same values after the function call. However I found that GCC with -O2 was modifying parameters that were passed to it on the stack. I have also looked for documentation including the System V i386 calling conventions, but was unable to find a definitive answer to this. Here is some sample code I was debugging. pushl %eax # %eax = 0x28 call _print_any popl

What's safecall?

筅森魡賤 提交于 2019-11-30 07:25:03
问题 I'm working on the creation of an ActiveX EXE using VB6, and the only example I got is all written in Delphi. Reading the example code, I noticed there are some functions whose signatures are followed by the safecall keyword. Here's an example: function AddSymbol(ASymbol: OleVariant): WordBool; safecall; What is the purpose of this keyword? 回答1: Safecall passes parameters from right to left, instead of the pascal or register (default) from left to right With safecall, the procedure or

What are callee and caller saved registers?

柔情痞子 提交于 2019-11-29 20:20:50
I'm having some trouble understanding the difference between caller and callee saved registers and when to use what. I am using the MSP430 : procedure: mov.w #0,R7 mov.w #0,R6 add.w R6,R7 inc.w R6 cmp.w R12,R6 jl l$loop mov.w R7,R12 ret the above code is a callee and was used in a textbook example so it follows the convention. R6 and R7 are callee saved and R12 is caller saved. My understanding is that the callee saved regs aren't "global" in the sense that changing its value in a procedure will not affect it's value outside the procedure. This is why you have to save a new value into the

Write a Fizz program in assembly / Using C library

不打扰是莪最后的温柔 提交于 2019-11-29 16:40:56
Could someone help me with this assembly program: First print out numbers 1 to 100. Then follow the rules for the children's counting game Fizz: whenever the number is evenly divisible by 5, or contains the digit 5, replace the number by the word “Fizz”. This is my program so far: extern printf section .data msg db "Hello, world!",0xa len equ $ - msg fmt: db "a=%d, eax=%d", 10, 0 ; The printf format, "\n",'0' section .text global main main: L1: mov eax,1 push eax call printf cmp eax,100 jae end inc eax end: I'm not going to give you a complete answer since this appears to be homework. I'll

How to pass a pointer to a member function to a C function? [duplicate]

。_饼干妹妹 提交于 2019-11-29 15:15:11
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: Using a C++ class member function as a C callback function I'm writing an object-oriented library using a C library (winpcap). I need to pass the callback function that is called when a network packet arrives as a function pointer. I would like to pass a member function pointer to winpcap, to keep my design object oriented and to allow for different objects to receive different packets. However member functions