Register | Login
Forum Index > Plugins > PlugIn Example in C
Author Message
Pages: 1 2 3 4 5 6 7 8 9 10 11
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[936] - posted: 2011-12-01 20:45:59
seems there is some other problem also, i will see if i can find why is there access violation before i upload, will let you know shortly.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[937] - posted: 2011-12-01 22:23:07
OK, this should be all corrected now, the new MOV handler had a few small issues.

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
[939] - posted: 2011-12-02 16:58:48

ok, i am trying to change this code
Code:
edx=10;
.WHILE( edx > 5)
{ 
  edx--;
}
print('edx = ', Edx); 


to this , so that ziron will understand it
Code:
@__While__1:
if( edx > 5)  {
 edx--;
 goto @__While__1; 
}


but got that error

[1,21]: Unexpected character "}". in [plugin buffer]
Code:
goto @__While__1; }


and here is the while event function ,part of masm plugin
Code:
function event_While() {
  uses edi esi ecx ebx;
  boolean Flg = true;  
  char condBuf[1024];
  char label[1024];
  char tmp[1024];
  global Dword incr; 
    
  if(Flg) {    
        //get the condition from while
        condBuf=0;
        eax = Ziron_GetNextToken();
        if (eax == zirParenOpen)
         {
            eax = Ziron_GetNextToken();
            while( eax != zirParenClose)
             {
               H_strjoin(@condBuf , ' ' ,Ziron_GetStrValue());
               eax = Ziron_GetNextToken(); 
             }      
         } 
        else
         {
             eax = Ziron_IsNextLineBreak();
             while(!eax)
              {
                H_strjoin(@condBuf , ' ' ,Ziron_GetStrValue());
                Ziron_GetNextToken(); 
                eax = Ziron_IsNextLineBreak();
              }
             H_strjoin(@condBuf , ' ' ,Ziron_GetStrValue()); 
         }             
       incr++; 
       // always start with  '{' 
       eax = Ziron_ExpectNextToken(zirBraceOpen);    
       if (eax == -1) {
            Ziron_FatalError('Expected { symbol');
            return true;
        }
       // put the label here
       label=0;
       IntToStr(incr, @tmp);
       H_strjoin(@label , '@__While__' , @tmp, ':'); 
       Ziron_Exec(@label);  
       Ziron_ShowMessage(@label);
       // local lable without ':' at the end
       label=0;
       H_strjoin(@label , '@__While__' , @tmp);        
       tmp=0;
       H_strjoin(@tmp , 'if(' , @condBuf , ')  {');
       Ziron_Exec(@tmp); 
       Ziron_ShowMessage(@tmp); 
             
       repeat {
          // found '}' so let's finished
          eax = Ziron_PeekNextToken(); 
          if (eax == zirBraceClose) {
              tmp=0;
              H_strjoin(@tmp , ' goto ' , @label, '; }');
              Ziron_ShowMessage(@tmp); 
              Ziron_Exec(@tmp); 
              Ziron_GetNextToken();
              break;
           } 
          // update to next line
          // get the entire line and execute it  
          Ziron_GetNextToken();    
          Ziron_ExtractLine(@tmp, 2048);  
          GotoLineEnd();
          Ziron_ShowMessage(@tmp); 
          Ziron_Exec(@tmp);  
       };        
        return true;   // let Ziron handle the next line   
  } else {     
        return false;  // let Ziron handle the line  
  }  
}



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

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[940] - posted: 2011-12-02 17:02:26

also when remove '}' from this line
Code:
H_strjoin(@tmp , ' goto ' , @label, '; }');


so that it is look like that
Code:
H_strjoin(@tmp , ' goto ' , @label, ';');

it compiles ok but did not work correctly e.g it does not print edx = 5

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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[941] - posted: 2011-12-02 17:05:41
this is because ziron is an assembler not a compiler, you can not pass fragmented code to be assembled, if you need to do this you would need to use raw assembly code...

instead of if you will need to write an if processor...

e.g.

Code:
if (eax == 1) {


to

Code:
cmp eax, 1
jne @myendif;


the options are if you are writing a masm compiler plugin then you would need to build a full buffer and then execute it... you could copy the whole contents of the if statement and execute it inside the buffer..

executing:
Code:
if (....) {
  //rest of buffer that was inside the while
}


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
[942] - posted: 2011-12-02 17:11:58
you would need to build a full buffer and then execute it... you could copy the whole contents of the if statement and execute it inside the buffer


i think that it is good solution , but what is the recommended buffer size that will hold the
entire while body?

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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[943] - posted: 2011-12-02 17:21:23
you would need to calculate this in real time and create a dynamic buffer...

so you would keep track of your pointer offset... then use another or variable to find the offset of the matching } and then create your buffer to match the size of

size=offset2-offset1

then do a strCopy from offset 1 to size

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
[944] - posted: 2011-12-02 17:21:49

or the better thing is using growable buffer , and i think the best implementation is using
a class , so what do you think.

http://www.freewebs.com/ogremagic/index.htm
Pages: 1 2 3 4 5 6 7 8 9 10 11
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 5 user(s) online. 0 member(s) and 5 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