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

data section.

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

Replies

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok , i want to know your opinion in this

to allow plugin now when a block of data is befin and when it finished , i think the following syntax is good

program WIN32CUI 'Basic Syntax test';

#include 'console.zir';

.DATA {
var      DB 64     ; Declare a byte, referred to as location var, containing the value 64.
var2     DB ?      ; Declare an uninitialized byte, referred to as location var2.
         DB 10     ; Declare a byte with no label, containing the value 10. Its location is var2 + 1.
X        DW ?      ; Declare a 2-byte uninitialized value, referred to as location X.
Y        DD 30000  ; Declare a 4-byte value, referred to as location Y, initialized to 30000.

Z        DD 1, 2, 3     ; Declare three 4-byte values, initialized to 1, 2, and 3. The value of location Z + 8 will be 3.
bytes    DB 10 DUP(?)   ; Declare 10 uninitialized bytes starting at location bytes.
arr      DD 100 DUP(0)  ; Declare 100 4-byte words starting at location arr, all initialized to 0
str1     DB 'hello',0   ; Declare 6 bytes starting at the address str, initialized to the ASCII character values for hello and the null (0) byte.
}


.CODE {
PUBLIC _myFunc
_myFunc PROC
  ; Subroutine Prologue
  
  mov eax,5
  ret
_myFunc ENDP
}

wait_key(nil);
ExitProcess(0);

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

It looks fine, but if you are going to change the syntax of masm, then what would be the point to changing syntax of ziron at all?

Unless it is intended to just make it easier and faster to convert masm projects to Ziron, then i think that will be a good option since it is a very little change to make :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

i used the '{}' just to know the start of data and the end , without that it's hard to know

which line will belong to masm and which not.

the main reason of masm is that , if i found some masm snippet is wanted then insert it directly in Ziron code without the need of converting.

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

ok then it's a good idea :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok , this is what i have done till now , only understand DB

function event_Data() {
  uses edi;
  char buf[2048];
  char val[255];
  char var[255];
  boolean Flg = true;  
  
  if(Flg)
   {
      eax = Ziron_ExpectNextToken(zirBraceOpen);    
      if (eax == -1) {
          Ziron_FatalError('Expected { symbol');
          return true;
       }
       Ziron_ShowMessage(Ziron_GetStringValue());
       
       repeat { 
              // found '}' so let's finished
             eax = Ziron_PeekNextToken(); 
             if (eax == zirBraceClose)
              {
                 Ziron_GetNextToken(); 
                 Ziron_ShowMessage(Ziron_GetStringValue());
                 break;
              } 
              
              // get the variable name and hold it in Var 
              eax = Ziron_ExpectNextToken(zirIdent);
              if (eax == -1) {
                  Ziron_FatalError('Expected Variable Name');
                  return true;
               }
              H_strcpy(@var,Ziron_GetStringValue());     
              Ziron_ShowMessage(@var);
              
              // get DB or DW or DD or DQ
              eax = Ziron_ExpectNextToken(zirIdent);
              if (eax == -1) {
                  Ziron_FatalError('Expected Variable Name');
                  return true;
               }
              boolean TypeFlg;
              TypeFlg = strCmp('DB',Ziron_GetStringValue()); 
              if(TypeFlg)
               { 
                   eax = Ziron_GetNextToken();  
                   case (eax) {
                          state zirHEXADECIMAL:
			              state zirNUMBER:
			                  H_strcpy(@val,Ziron_GetStringValue()); 
			                  Ziron_ShowMessage(@val);  
			                  buf=0;
                              H_strjoin(@buf, 'byte ' , @var, ' = ' , @val, ';' );
                              Ziron_ShowMessage(@buf);
                              Ziron_Exec(@buf);
                              break;       
                          default:
                              Ziron_FatalError('Expected number');
                              return true;
                    }      
               }
       };            
      return true;
   }
  else
   {   
      return false;                           // let Ziron handle the line  
   }  
}

test program

program WIN32CUI 'Basic Syntax test';

#include 'console.zir';


.DATA 
{

var      DB 64     

}

eax = 0;
al = var;
print('var = ', Eax); 

wait_key(nil);
ExitProcess(0);

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

why not include the masm compat file then you wont need to check for text DB DW, DD, DQ etc, you could just add them as data types.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

did you mean , ziron will convert 'DB' to byte before plugin will process that

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

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

can you please add '?' to ZirToken or if you tell me that how to detect '?' in our code?

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