Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Plugins

Plugin: EMIT source

A community discussion post from the original code:zIRON forum.

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

fastcall uses in this order as borlands fastcall method: eax, edx, ecx and the registers are trashed.

however, zircall is my special development for ziron...

first it preserves ecx, edx, ebx, esi, edi

then uses the registers in this order for first 6 params: ebx, esi, edi, eax, ecx, edx

once returned, registers are restored, and as you see it works good, since it is faster than fastcall :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok this is good , but...

to make thing is more clear , we can use that directly in our code eg.

function blabla(ebx, esi, edi, eax, ecx, edx)
{
  now when i see this function i will know the first para is in Ebx and so on
  
}

so you have the two options , and the user will choose the best for him.

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

as i said other time i will probably add this, however it is more complex, i will get round to that on my list at some point.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

oh sorry , forgot that i have mentioned that early.

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

i've slightly changed the zircall method, it will now use in order, eax, ecx, edx, ebx, esi then edi for 6 params, it will auto preserve ecx-edi when used. so basically i've changed it to be more similar to fastcall, but using 6 registers and auto preservation for simplicity... a bit less to write when coding.

the main advantage is when there is 4 or more params and you are using all of the params inside a function, since fastcall will use the stack above 3 params, and zircall will use stack above 6.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

i think that , auto preserve of ecx-edi or preserve all registers then call a functions

then restore them ,behind the sense , is not good.

we can use 'uses' keyword before the function call to preserve the only registers those we need to keep it's value. now we know what is going on.

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

actually i think it is very useful - you cant use uses to protect registers that have been moved before the function is called... imagine you pass 6 parameters, all those 6 registers would be trashed before the function is called, so you would need to usually write

push ecx
push edx
myFastCallFunc(...,...,...);
pop edx
pop ecx

without the push then pop, the originals before the mov to pass to fastcall func would be trashed, now same with zircall, however zircall will automatically preserve them and restore them when the function returns, i have done some testing and the performance difference with fastcall and zircall is the same (ish) with 3 params, the assembler optimises the pushes ahead of the moves to prevent dependancies... but as you see when there is 4 or more params, zircall is far faster.... so not only does it have advantages, but it can also be faster and no need to write lots of push's