Register | Login
Forum Index > Source Help > detecting '\'
Author Message
Pages: 1 2 3 4 5
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1164] - posted: 2012-05-18 23:37:38

good, by the way i was tring this but it always crash.
Code:
for(ecx = 0 to 1)
{
  ebx=@myArr;
  mov eax,[ebx+ecx*4]
  print(eax:string , '\r\n');
}


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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1165] - posted: 2012-05-19 00:14:21
eax can not be passed as a string to print, i have added a error for this in next release, you can use edx or other registers:

Code:
char* myArr[2];
myArr[0] = 'Test 1';
myArr[1] = 'Test 2';

for(ecx = 0 to 1) {
  ebx = @myArr;
  edx = [ebx+ecx*4];
  print(edx:string, '\r\n');
}


but easiest and best way:

Code:
program WIN32CUI 'test';

#include 'ch.zir';

char* myArr[2];
myArr[0] = 'Test 1';
myArr[1] = 'Test 2';

ebx = @myArr;
for(ecx = 0 to 1) {
  print([ebx+ecx*4], '\r\n');
}


wait_key();
ExitProcess(0);


Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1168] - posted: 2012-05-19 19:07:27

ok , i was playing with printf function from msvcrt.dll and used it instead of print but it
crashed , i think it is a problem with cdecl.

Code:
program WIN32CUI 'test';

#include 'ch.zir';

imports('msvcrt.dll') 
{
  function printf(char* format[]): Int32; cdecl;
}


char* myArr[2];

//constant mem
myArr[0] = 'String 1';
myArr[1] = 'String 2';

edi=@myArr;
for(ecx = 0 to 1)
{
  printf('%s  ',[edi+ecx*4]);
}

delete myArr[0];
delete myArr[1];

wait_key();
ExitProcess(0);


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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1169] - posted: 2012-05-20 13:59:25
hi emil, there is no problem with cdecl, i see your mistake:

all windows functions do not preserve ecx and edx, infact it is normal for all functions to trash eax-edx, so you have 2 options:

Code:
edi=@myArr;
for(ecx = 0 to 1)
{
  push ecx
  printf('%s  ',[edi+ecx*4]);
  pop ecx
}


or better:

Code:
ebx=@myArr;
for(edi = 0 to 1)
{
  printf('%s  ',[ebx+edi*4]);
}


Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1170] - posted: 2012-05-20 15:53:54

oh , i see now.

but what exactly is the free register that can be used and what that used by windows function.

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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1171] - posted: 2012-05-20 16:23:56
well the registers are:

Code:
eax, ecx, edx, ebx, esp, ebp, esi, edi


eax-edx are usually trashed in external function calls (internal depends if the function has been written to protect the register.

ebp is used for stack frame in functions, esp is the stack pointer, else ebx, esi and edi are good to go in most cases, of course ecx and edx are still usable in alot of cases, you just need to check if the external functions will trash the register or not.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1172] - posted: 2012-05-20 18:54:56

ok , thanks for your help.

I am stuck here , i was implement strArr like this

Code:
  

   char strArr[10240]; storage for hold all string array each one is 128 byte len
   dword cnt;
   dword disp;
   ..........
   .........
   //later
    eax = Ziron_GetNextToken();
    ebx = 0; 
    cnt = 0;
    edi = @strArr;
    while( eax != zirParenClose)
     {
        H_strcpy( [edi+ebx],Ziron_GetStringValue());
        ebx += 128;
        cnt++;
        eax = Ziron_GetNextToken(); 
     }


but it crashed.

so i think Ziron_GetStringValue() may change edi or ebx?

then i tried this
Code:
   
   dword disp = 0;
   while( eax != zirParenClose)
    {
        eax=Ziron_GetStringValue();
        push eax
        edi = @parArr;  
        edi += disp; 
        push  edi
        call  H_strcpy             
        add   disp,128
        cnt++;
        eax = Ziron_GetNextToken();          
    }


it did not crashed , do you have any suggestion or another approach?

thanks.


http://www.freewebs.com/ogremagic/index.htm
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1173] - posted: 2012-05-20 19:29:33

ok i found the error , here is the new code
Code:
          eax = Ziron_GetNextToken();
          esi = 0; 
          cnt = 0;
          while( eax != zirParenClose)
           {
              edi = @parArr;
              edi += esi;
              H_strcpy( edi,Ziron_GetStringValue());
              esi += 128; 
              cnt++;
              eax = Ziron_GetNextToken();          
           }


there is another thing

when using this , it crashed
Code:
 
 for(edi = 0 to cnt)
  {

  }


and when using this , it's okay
Code:
  
  edi = cnt;
  while(edi>0)
   {

     edi--;
   }



http://www.freewebs.com/ogremagic/index.htm
Pages: 1 2 3 4 5
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 9 user(s) online. 0 member(s) and 9 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd