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

for with var parametr

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

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

for with var parametr

hi i want for allow this

   int32 i;
   for(i =0 to indx)
    {
       IntToStr(indx,@tmp);
       edx = @right; eax = i; imul  eax,255; add eax , Edx; 
       H_strjoin(@buf, 'byte ' , @var, '[' , @tmp ,']=' , eax , ';' );
       Ziron_ShowMessage(@buf);
    } 

BTW C++ allow this , declare variable inside 'for' block

 for(int i=0; i<100; i++)
  {
   } 

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

Replies

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

also i need ziron allows that

 add eax , @right; // @right is a pointer

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

i will add it, but i should note that a variable inside a for loop is extremely slow.

a better way would be to use registers as often as possible like so:

   push edi
   push esi
   esi = indx;
   for(edi = 0 to esi) { //cmp of registers is much faster
       IntToStr(esi,@tmp);
       edx = @right; eax = edi; imul eax,255; add eax, edx; 
       H_strjoin(@buf, 'byte ' , @var, '[' , @tmp ,']=' , eax , ';' );
       Ziron_ShowMessage(@buf);
   } 
   pop esi
   pop edi