flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > Cost of different custom calling convention

Author
Thread Post new topic Reply to topic
Summermute



Joined: 14 Nov 2009
Posts: 4
Location: Washington, DC
Summermute 14 Nov 2009, 18:17
C x86 Normal: arg1 | arg2 | rtn | ebp | -> locals

My Custom: rtn | ebp | arg1 | arg2 | -> locals

Skip register usage for now, and just imagine stack allocation. Obviously, I cannot use x86's CALL/RET, but have to use my own JMP and manipulation of the esp register.

My question is, given the design of modern x86 chips with their various caches, branch prediction and lord knows what else, what might be the actual, theoretical and or speculative cost of my calling convention that puts the rtn addr and ebp "above" the arguments for the callee and executes the needed JMP and esp manipulation directly.

Many, many thanks in advance. It's been darned hard to find any good information on the "costs" of alternative calling conventions.

_________________
- Scott

Building "bicycles for the mind...."
Post 14 Nov 2009, 18:17
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20357
Location: In your JS exploiting you and your system
revolution 14 Nov 2009, 23:51
Just program it up and run a test to see what effect it has on your programs.

Don't waste time trying to think it through, the CPUs are far too complex and seemingly unpredictable to get any good estimates purely by thought.
Post 14 Nov 2009, 23:51
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 15 Nov 2009, 01:08
Specially test the following with both methods and tells us what results you get:
Code:
mov ebx, LARGE_VALUE

.loop:
custom_call testCustom, [var1], [var2]
mov edx, eax

custom_call testCustom, [var3], [var4] ; Yes, it is important this second call although you may use the same arguments used in the previous call if you want
add eax, edx

dec ebx
jnz .loop    

Versus
Code:
mov ebx, LARGE_VALUE

.loop:
normal_call testNormal, [var1], [var2]
mov edx, eax

normal_call testNormal, [var3], [var4] ; Yes, it is important this second call although you may use the same arguments used in the previous call if you want
add eax, edx

dec ebx
jnz .loop    
Post 15 Nov 2009, 01:08
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.