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

arithmetic expression

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

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

arithmetic expression

hi i need to calculate index of array like this

pointer addr; 
addr = @right + indx * 255;

but Ziron did not yet understand it so i start to make it like this

eax = indx
eax *= 255
eax +=  @right

or that

eax = indx
imul eax,255
eax +=  @right

but still ziron can not understand that , any help please?

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

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria
DWord myarr[512];

ecx = myarr;

//set item 100
DWord[ecx*4+100] = 1111;

//get item 100
eax = [ecx*4+100];

not sure if the scalar will work in current beta version, i'm almost finished with the new MOV handler which will be able to handle this.

The reason i did not add *= as i stated in changelog is because alot of the int math opcodes are incomplete, once i finish the new mov and lea handler, i will work on updating add, sub, mul etc etc

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok , but how to calculate my state.

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

how do you mean state? :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

i meant , my first post example

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

from the code you posted, i do not understand what it is you are trying to do.

if you require maths functions, for now you could use the fpu maths opcodes.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok , here is the code example

char right[5000];
dword indx;

indx = 5;

pointer addr = @right + indx * 255 // how to calculate this line
 

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

well you could using fpu do something like.... hmm well:

DWord myArr[512];
dword addr;

finit;

//5 = index
eax = @myArr;
push eax
fild [esp]
pop eax
fpush 5
fpush sizeof DWord
fmulp;
faddp;
fistp addr;

//addr now holds the offset address