Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Requests and Feedback

get entire line

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

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

not sure you maybe have missed something, what did you change?

also you may want to lowercase the line buffer

in strings.zir, procedure strLower change to a function and add at bottom

function strLower(char* str) {
	uses esi;
	esi = str;
	edx = esi;

	repeat {
		lodsb
		if (al == 0) {
			break;
		} elseif ((al => "A") and (al <= "Z")) {
			add al, 0x20
			[esi-1] = al;
		}
	};
	
	eax = str;
}

then you can do:

  eax = strIndexOf(strLower(@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(zirINTO);        // remove into 
      if (eax == zirUnexpected) {
          return false;                        // let Ziron handle the line 
       }

   ....
Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

i have changed nothing , only update the package.

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

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

with lowercas got that error

-------------------------------------------- PlugSys: Emit plugin has loaded! PlugSys: Mov plugin has loaded! -------------------------------------------- [6,8]: Expected register or segment or segment:offset or [expression] or variable or local variable or local parameter but found 10 in [testprg.zir] Code: mov 10 into eax

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

and you changed the strings lowercase function? you can also remove edx = esi

you added the eax = str at the bottom?

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

after changes as you suggested , the same error as post #[477]

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

lol my mistake, i didnt read the code properly, actually when i wrote into ax, this syntax is incorrect anyways because into does not take a parameter.... lol

mov 10 into eax; into eax = 5;

this is 3 different operations :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok ,works fine , here is the final 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(strLower(@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
@lop:
      buf=0;
      Ziron_GetNextToken();                    // so what is after 'mov'
      H_strcpy(@val,Ziron_GetStringValue());   // and save it in val  
                        
      eax = Ziron_ExpectNextToken(zirINTO);    // 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
            
      eax = Ziron_ExecuteF(@buf);
      if (eax == false) {
          Ziron_FatalError('Error plugin');
         return true;
       }
       
      eax = Ziron_PeekNextToken(); 
      if (eax == zirCOMMA) 
      {
         Ziron_GetNextToken();
         goto @lop;
      } 
       
      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;

test program

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');  
                   
mov 10 into eax, 20 into ebx, 30 into ecx 
         
print('eax = ', eax:int, '\r\n');
print('ebx = ', ebx:int, '\r\n');
print('ecx = ', ecx:int, '\r\n');

mov eax, 10; into eax = 5;                        

wait_key(nil);
ExitProcess(0);

any suggestion you want to add?

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

not for now :)