Register | Login
Forum Index > Plugins > Basic PlugIn
Author Message
Pages: 1
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[361] Basic PlugIn - posted: 2011-11-05 17:06:36

Hi

here is what i have done tell now
Code:
//******************************************************//

//                                                      //
//******************************************************//

program WIN32DLL 'BASIC PLUGIN';

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


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

const strLoaded = 'Basic plugin has loaded!';



function H_strlen(char* str)
{
  Eax = nil;
  Ebx = str;
  while(char[Ebx] != 0)
   {
     Ebx++;
     Eax++;
   }
}

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;
} 

function H_GetTmpStr(DWord sizeInByte)
{
   uses Ebx Ecx;   
   global int32   StrCnt;
   global char*   StrFunc[2048];
   Eax = StrCnt;
   Eax++;
   and Eax,2047
   StrCnt = Eax;
   Ebx = @StrFunc;
   lea Ebx,[Ebx+Eax]
   Eax=DWord[Ebx];
   if( Eax> 0)
    {
       freemem( Eax);
    }
   [Ebx]= malloc(sizeInByte);
}



//
// event_Emit()
// return false to allow the assembler to process this keyword internally.
// return true to tell the assembler this keyword has been processed.
//

function event_Dim()
{
  uses edi;  
  Dword Len;
    char var[255];  
    char buf[1024]; 
    
repeat {    
    buf = 0; //make sure buf is initialized otherwise it may be filled with junk
      
    eax = Ziron_ExpectNextToken(zirIdent);
  if (eax == -1) {
    Ziron_FatalError('Expected Variable Name');
    return true;
  }
  H_strcpy(@var,Ziron_GetStringValue());   
//Ziron_ShowMessage(@var);
  
  eax = Ziron_GetNextToken(); 
  
  case (eax) 
   {
/*********   Dim Var as int32;    **************/         
     state zirAs:
        eax = Ziron_ExpectNextToken(zirDATA_TYPE);
        if (eax == -1) 
         {
           Ziron_FatalError('Expected data type');
           return true;
         }
        eax =  Ziron_GetStringValue();
          H_strcat(@buf,eax); 
          H_strcat(@buf,' ');  
          H_strcat(@buf,@var);
          H_strcat(@buf,';');  
          H_strcat(@buf,'\r\n'); 
//Ziron_ShowMessage(@buf);
          Len = H_strlen(@buf);          
        eax = Ziron_Execute(@buf,Len);
          if (eax == false)
           {
               Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
           }  
          break;
/*********   dim k%;    **************/        
       state zirModSym:
             H_strcat(@buf,'int32 '); 
             H_strcat(@buf,@var);
             H_strcat(@buf,';');  
             H_strcat(@buf,'\r\n'); 
//Ziron_ShowMessage(@buf);
             Len = H_strlen(@buf);          
           eax = Ziron_Execute(@buf,Len);
             if (eax == false)
              {
                 Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
              }  
          break;
        state zirDollarSym:
/*********   dim k$;    **************/          
             H_strcat(@buf,'char '); 
             H_strcat(@buf,@var);
             H_strcat(@buf,'[1024];');  
             H_strcat(@buf,'\r\n'); 
//Ziron_ShowMessage(@buf);
             Len = H_strlen(@buf);          
           eax = Ziron_Execute(@buf,Len);
             if (eax == false)
              {
                 Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
              }  
          break;
        state zirIdent:
              eax = Ziron_GetStringValue();  
              
              
              
          break;
     default:
        Ziron_FatalError('Expected as Keyword');
      return true;
   }

  eax = Ziron_IsNextLineBreak(); 
  if(eax)
   {
      break;      // check end of line so we end without semicolon
   } 

    eax = Ziron_GetNextToken();    
    if (eax == zirSEMI_COLON) 
     {
      break;
   } elseif (eax != zirCOMMA) {
      Ziron_FatalError('Unexpected token type');
          
   }  
};
  return true;
}



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

  //register our keyword
  Ziron_RegisterKeyword('Dim', @event_Dim);
  
  return strLoaded;
}

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

  return false;
}

exports InitPlugin;


here is a test program
Code:
program WIN32CUI 'Basic Syntax test';

#include 'console.zir';

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;
} 

eax = 1;
print('eax = ', eax:int, '\r\n');

Dim Var as int32  // not well , in basic there is no semicolon at end of file

DIM Name$;

DIM a AS int32, b AS Dword, c AS char;

dim k%;

Var = 1000;
a = -10;
b = 150;
c = ord('A');
k = -2000;

H_strcpy(@Name , 'Emil');

print('Var = ', Var, '\r\n');
print('a = ', a, '\r\n');
print('b = ', b, '\r\n');
print('c = ');
WriteLnEx(@c,1);
print('k = ', k, '\r\n');
WriteLnEx(@Name,4);

wait_key(nil);
ExitProcess(0);




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

avatar

(send private message)

Posts: 932
Topics: 54

Location:
OverHertz Studio
[362] - posted: 2011-11-05 17:09:57
looking good, what do you plan to add to the plugin next may i ask? smile

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
[363] - posted: 2011-11-05 17:13:59

actually i hope finishing Dim keyWord 100% as in basic syntax.

http://www.freewebs.com/ogremagic/index.htm
Pages: 1
create new reply


Quick reply:

Message:



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


Statistics:
Threads: 224 | Posts: 1847 | Members: 50 | Active Members: 50
Welcome to our newest member, NobodyAtWork
const Copyright = '2011-2022 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd