Register | Login
Forum Index > Requests and Feedback > get entire line
Author Message
Pages: 1 2 3 4 5 6 7 8
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[462] - posted: 2011-11-08 12:46:51
at the bottom of strings.zir replace function with

Code:
function strIndexOf(char* buf; char* find) {
  eax = strOffset(buf, find);
  if (char[eax] == 0) {
    eax = -1;
  } else {
    sub eax, buf
  }
}


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
[463] - posted: 2011-11-08 14:38:21

oh , thank you.

so here is what i made till now

mov pluhin code
Code:
//******************************************************//
//                                                      //
//                 Mov Plugin                           //
//                                                      //
//               By Emil Halim                          //
//               7 / 11 / 2011                          //
//                                                      //
//******************************************************//

program WIN32DLL 'Mov PLUGIN';

#include 'zirplug/framework.zir';
#include 'strings.zir';

//////////////////////////////

const strLoaded = 'Mov plugin has loaded!';

//////////////////////////////
function H_strlen(char* str) {
  Eax = str;
  while(char[eax] != 0) {
    Eax++;
  }
  sub eax, str
}

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

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

inline procedure  H_strjoin(;)
{
  $temp = 1;
  $to = $argc - 1;  
  $repeat $to:  
     H_strcat($arg[0],$arg[$temp]);  
  $temp++;
  $end
}

inline procedure Ziron_ExecuteF(m_st)
{
   Ziron_Execute($m_st,H_strlen($m_st));
}

inline procedure Ziron_GotoNextLine()
{
  eax = Ziron_IsNextLineBreak();
  while(!eax)
   {
      ecx = Ziron_GetNextToken();
      eax = Ziron_IsNextLineBreak();
   }
}

//
// event_mov()
// return false to allow the assembler to process this keyword internally.
// return true to tell the assembler this keyword has been processed.
//
function event_mov()
{
  uses edi;
  char buf[2048];
  char line[2048];
  char val[255];
  Dword Len;
         
  len = Ziron_ExtractLine(@line, 2048);  
  eax = strIndexOf(@line, 'into');            // see if the line have to pares with the plugin
  if(eax != -1)
   { 
      Ziron_ShowMessage(@line);                // show our entire line for debug purpose
      buf=0;
      Ziron_GetNextToken();                    // so what is after 'mov'
      H_strcpy(@val,Ziron_GetStringValue());   // and save it in val  
      Ziron_GetNextToken();                    // remove into 
      Ziron_GetNextToken();                    // get the registere 
      eax =  Ziron_GetStringValue();
      H_strjoin(@buf, eax, ' = ', @val, ';');
      Ziron_ShowMessage(@buf);                 // show our new line that Ziron will understand it for debug purpose
      
      eax = Ziron_ExecuteF(@buf);
      if (eax == false) {
          Ziron_FatalError('Error plugin');
         return true;
       }
       
     // Ziron_GotoNextLine();
      return true;
   }
  else
   {
      return false;                           // let Ziron handle the line  
   }   
}


function InitPlugin(pointer pGetF) {
  Ziron_LoadAll(pGetF); //use framework utility function to load all

  //register our keyword
  Ziron_RegisterKeyword('mov', @event_mov);
  
  return strLoaded;
}

entry function DLLMain(DWord iDLL; DWord iReason; Pointer iResult) {
  if (iReason == DLL_PROCESS_ATTACH) {
    return true;
  }

  return false;
}

exports InitPlugin;


and here is the test program
Code:
program WIN32CUI 'mov plugin test';

#include 'console.zir';

// this will pares with mov plugin
mov 10 into eax
 
// this will pares by Ziron 
mov ebx, 30
 
print('eax = ', eax:int, '\r\n');

wait_key(nil);
ExitProcess(0);


i will post any progress.

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

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[464] - posted: 2011-11-08 14:44:48

this works fine also
Code:
[program WIN32CUI 'mov plugin test';

#include 'console.zir';

// this will pares with mov plugin
mov 10 into eax
 
// this will pares by Ziron 
mov ebx, 30
 
print('eax = ', eax:int, '\r\n');


mov 100 into edx; print('edx = ', 
                   edx:int, '\r\n');
                   
mov 300 into esi  print('esi = ', 
                   esi:int, '\r\n');                   

wait_key(nil);
ExitProcess(0);



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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[465] - posted: 2011-11-08 14:53:08
looking good, from what i can see of the code, it should work for variables too

Code:
int32 i;
mov 10 into i
mov 10 into eax
mov eax into i


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
[466] - posted: 2011-11-08 15:00:45
1 thing - a potential problem being:

Code:
Ziron_GetNextToken();                    // remove into 


if this is not actually the into keyword, e.g.

Code:
mov eax, 10; into ax;


so i'd advise doing an expect token, i will begin completing the zirToken enum now, and have it done shortly, will let you know.

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
[467] - posted: 2011-11-08 15:03:26

very good

i want to pares this too
Code:
mov 10 into eax 20 into ebx 30 into ecx


so i need a function like Ziron_ExtractLine to get the rest of line or a strRemove that will
remove the getting token from the original line.

what do you think?



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

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[468] - posted: 2011-11-08 15:36:03

ok here is it as you suggested
Code:
function event_mov()
{
  uses edi;
  char buf[2048];
  char line[2048];
  char val[255];
  Dword Len;
         
  len = Ziron_ExtractLine(@line, 2048);  
  eax = strIndexOf(@line, 'into');            // see if the line have to pares with the plugin
  if(eax != -1)
   { 
      Ziron_ShowMessage(@line);                // show our entire line for debug purpose
      buf=0;
      Ziron_GetNextToken();                    // so what is after 'mov'
      H_strcpy(@val,Ziron_GetStringValue());   // and save it in val  
                        
      eax = Ziron_ExpectNextToken(448);        // remove into 
      if (eax == -1) {
          return false;                        // let Ziron handle the line 
       }
       
      Ziron_GetNextToken();                    // get the register 
      eax =  Ziron_GetStringValue();
      H_strjoin(@buf, eax, ' = ', @val, ';');
      Ziron_ShowMessage(@buf);                 // show our new line that Ziron will understand it for debug purpose
      
      
  //    len = Ziron_ExtractLine(@line, 2048);  
  //    Ziron_ShowMessage(@line); 
      
      eax = Ziron_ExecuteF(@buf);
      if (eax == false) {
          Ziron_FatalError('Error plugin');
         return true;
       }
       
      return true;
   }
  else
   {
      return false;                           // let Ziron handle the line  
   }   
}


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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[469] - posted: 2011-11-08 15:41:10
I've re-updated the latest alpha package with the new framework file with all of the other reserved keywords.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Pages: 1 2 3 4 5 6 7 8
create new reply


Quick reply:

Message:



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