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

fastcall question

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

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

fastcall question

when ues fastcall do i have to move first param into Eax , and second param into Edx and so on or it automatically done by Ziorn

for example i am implement a simple strcpy function like this

function fastcall strcpy(Dword src,dst)
{ 
  Eax = src; 
  Edx = dst; 
  push Edx;
  BL = BYTE [Eax]; 
  while ( BL != 0)  
   { 
      BYTE [Edx] = BL; 
      Eax++; Edx++; 
      BL =  BYTE [Eax]; 
   }  
  [Edx] = 0;
  pop Eax;
} 

or like this

function fastcall strcpy(Dword src,dst)
{ 
// eax already holds src and edx holds dst
  push Edx;
  BL = BYTE [Eax]; 
  while ( BL != 0)  
   { 
      BYTE [Edx] = BL; 
      Eax++; Edx++; 
      BL =  BYTE [Eax]; 
   }  
  [Edx] = 0;
  pop Eax;
} 

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

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

it is done automatically, so the first 3 variables are just register references, in your case

src = eax

dst = edx

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok ,

when calling my function like this i got error

invalid operand "mov eax, 5000"

    char  buf[5000];
    DWord Len;
    strcpy(@buf,'mov eax, 5000');

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

yes, i've just been playing around with this, and it seems i have left out some support for a few different types of operands related to fastcall and zircall - i'm going to look into this now, and hopefully have a fix updated later.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok

i was plaing with plugin system , got this red error when test a program that uses the plugin.

Access violation at address 00405786 in module 'Ziron.exe'. read of address ffffec74

function event_Test() {
    uses edi;
    char  buf[5000];
    DWord Len;
    strcpy(@buf,'\'mov eax, 5000\'');
    Len = strlen(@buf);
    Ziron_ShowMessage(@buf);
    eax = Ziron_Execute(@buf,Len);
    if (eax == false) {
        Ziron_FatalError('myCMD plugin is not compatible with this version of Ziron');
     }  
    
    eax = true;
}

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

i will look into the access violation but

    strcpy(@buf,'\'mov eax, 5000\'');

this line is putting

"'mov eax, 5000'" into the buffer and executing it, you can not execute a string value.

you need to remove the \'

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

remove \ done.

still have the error.

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

looking into this now, will let you know asap.