flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > pls, explain compiled code for IA32

Author
Thread Post new topic Reply to topic
qeos



Joined: 15 Jan 2008
Posts: 15
qeos
Situation such: there is an instruction
Code:
cmp byte [ebx+eax], 0    

it is compiled in following bytes
Code:
80 3C 03 00    

Under the documentation "IA32" it is a command
Quote:
80 /7 ib CMP r/m8, imm8

byte 3С it ModR/M ([--][--]), it indicate that is SIB byte follow, and SIB byte indicate by table 2-3:
[EAX] and r32 = EBX

It follows from this that the instruction should look so:
Code:
cmp [eax], EBX, 0
or
cmp [EAX] EBX, 0
or something else    

Can help to understand it?
Post 06 Jan 2011, 08:15
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
fasm syntax is made to be simple.

exit the strange adressing representations from early ages of computing science.

then:

cmp byte[eax+ebx],0

the result of the compilation is only fucntion of useN

if use16, then, will be prefixed for 32 bits interpretation under 16 bit mode
if use32, then, will be like you found, and if use64, then, will be about SIB.
Post 06 Jan 2011, 09:09
View user's profile Send private message Visit poster's website Reply with quote
qeos



Joined: 15 Jan 2008
Posts: 15
qeos
Yes, I should specify at once that at me use32

I not absolutely understand as to use it SIB in byte. For example if instead of 03 would be С6, this command would look so?

Code:
cmp [EAX*8 + ESI],0    


is this correct?
Post 06 Jan 2011, 10:48
View user's profile Send private message Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia
MazeGen
This is correct.

Download OllyDbg (www.ollydbg.de), load any EXE file into it and start playing with the opcodes: just press any key (while the code window has focus) and type DB 80, 3C, 0C6, 00. Press enter to disassemble it and see the result.
Post 06 Jan 2011, 11:48
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.