Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Plugins

PlugIn Example in C

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

Replies

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

yes of course , it a Little lines that allows all ziron data type understood

here is a part that allow it

 // get DB or DW or DD or DQ or (data type)
      DWord dt = Ziron_GetNextToken(); 
      boolean  _db, _dw, _dd, _dq;        
      char* strTemp = strLower(Ziron_GetStringValue());
      _db = strCmp('db',strTemp);
      if (_db)
       {
            H_strcpy(@dtype,'byte ');     // found DB
       } 
      else
       {
           _dw = strCmp('dw',strTemp); //  
            if (_dw) 
             {
                  H_strcpy(@dtype,'word '); // found DW
             }
            else 
             {
                  _dd = strCmp('dd', strTemp);     
                  if (_dd) 
                   {
                        H_strcpy(@dtype,'DWord '); // found DD
                   } 
                  else 
                   {
                        _dq = strCmp('dq', strTemp);    
                        if (_dq) 
                         {
                              H_strcpy(@dtype,'qword '); // found DQ
                         }
                        else
                         {
                           if(dt == zirData_Type)  // found data type
                             {
                                H_strcpy(@dtype,Ziron_GetStringValue()); 
                                H_strcat(@dtype,' '); 
                             }
                            else
                             {          
                               // there is no DB or DW or DD or DQ or (data type) so fire error 
                               Ziron_FatalError('Expected DB or DW or DD or DQ symple');
                               return true;
                             }
                         }
                  }
            }
      }

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

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

this is not understood

svar  single  1.5

but this okay

svar  single  1

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

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

to make things going well i need ziron support that

single myVar = 1.5; 

this is already supported

byte b = 1;

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

1 is detected as zirNumber

but

1.5 is deteceted as zirFloat :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok , i have already add the needed code but it does not work because ziron do not understand that

single svar = 1.5;

here is the part that understand float

case (eax) {
        // var DB 0x0f 
        state zirHEXADECIMAL:
          edx = indx; imul edx, stp; eax = @right; edx += eax;
          H_strcpy(edx,'0x');            
          H_strcat(edx,Ziron_GetStringValue());
          break; 
        // var Db 1  
        state zirNUMBER:
          edx = indx; imul edx, stp; eax = @right; edx += eax;            
          H_strcpy(edx,Ziron_GetStringValue());                 
          break;   
        // str  DB 'hello',0  
        state zirConstString:
              char str1[2048];
              H_strcpy(@str1,Ziron_GetStringValue());
              ecx = H_strlen(@str1);
              while(ecx > 0)
               {      
                 esi = @str1;
                 edx = indx; bl = [esi+edx]; imul edx, stp; eax = @right; edx += eax; 
                 char[edx] = ord('"');
                 char[edx+1] = bl;
                 char[edx+2] = ord('"');
                 char[edx+3] = 0;
                 indx++;
                 ecx--; 
               } 
               indx--;  
          break;
          state zirFLOAT:
              edx = indx; imul edx, stp; eax = @right; edx += eax;            
              H_strcpy(edx,Ziron_GetStringValue());         
              //Ziron_ShowMessage(Ziron_GetStringValue());
          break;     
        default:
          Ziron_FatalError('Expected number');
          return true;
      }

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

you will need to do a mov var, 1.5

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

i think that is good for single var so you can use mov instruction , but if you have an array

of floating type how could you initializing them.

is it hard to allow that 'single svar =1.5' just like integer types , or what.

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

no, but as i've said in a previous post, i need to rewrite some of the float handlers, so it is not worth to spend time on them when i will rewrite them.