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.

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria
finit;

char right[5000];
dword indx;
dword addr;

indx = 5;

eax = @right;
push eax
fild [esp]
pop eax
fild indx
fpush 255
fmulp;
faddp;
fistp addr;
Colin admin
Posts
928
Threads
49
Location
Bulgaria

also i would suggest 5000 = 5100, 20x 255's

once i finish the mul opcodes and other int math opcodes, it will be better :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok , thank you for your suggestion

but i did not like using fpu in integer expression

the other solution is , you can tell me the machine code of imul eax,255 ,so that i can emit it inside my code.

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

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

this is what i get from sphinx C-- , so is it wright

6669C0FF000000           imul    eax,0FFh

if so how code i emit that , i mean the byte order ?

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

hmm that does not look correct

0x66 first byte would mean it is in 16bit... anyways here is what you need:

emit byte 0x6B,0xC0,0xFF;

i guess that should work, i will implement imul tomorrow hopefully :)

Colin admin
Posts
928
Threads
49
Location
Bulgaria

infact i've just implemented imul now.. for now only accepts reg, value.

imul eax, 32

//etc

i have updated the latest beta package :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

after updating , i got this error

                   edx = @right
                   eax = indx
                   imul  eax,255
                  // emit byte 0x6B,0xC0,0xff;              
                   IntToStr(indx,@tmp);
                   Ziron_ShowMessage(@tmp);
                   IntToStr(eax,@tmp);
                   Ziron_ShowMessage(@tmp);  
                   add eax , Edx             
                   H_strcpy(eax , @val );
[137,25]: Unknown Identifier "imul" in [masm.zir] Code: imul eax,255

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

my apologies, i added the code for it to work, but did not add the keyword, i have re-updated the beta pack. :)