Re: Writing a disassembler ?

"So and so" <>
Thu, 16 Oct 2008 04:15:25 +0200

          From comp.compilers

Related articles
Writing a disassembler ? (So and so) (2008-10-10)
Re: Writing a disassembler ? (Vimal) (2008-10-11)
Re: Writing a disassembler ? (Jeff Kenton) (2008-10-11)
Re: Writing a disassembler ? (Hans-Peter Diettrich) (2008-10-11)
Re: Writing a disassembler ? (Stephen Horne) (2008-10-11)
Re: Writing a disassembler ? (2008-10-11)
Re: Writing a disassembler ? (glen herrmannsfeldt) (2008-10-12)
Re: Writing a disassembler ? (So and so) (2008-10-16)
Re: Writing a disassembler ? (Bartc) (2008-10-16)
Re: Writing a disassembler ? (rlunger) (2008-10-18)
| List of all articles for this month |

From: "So and so" <>
Newsgroups: comp.compilers
Date: Thu, 16 Oct 2008 04:15:25 +0200
Organization: Compilers Central
References: 08-10-011 08-10-017 <>
Keywords: disassemble
Posted-Date: 16 Oct 2008 21:01:12 EDT

Hey all, thanks for all for your replies.
I will likely consider all of them once I'll get to those stages, as
for now - I'm working on the decoder itself, which seems to be the
earliest stage of the disassembler itself, and I'm having a bit

I've started building the structure of the decoder, starting from
reading raw opcodes stream(say, from the constructor
it has been yet decided)
I've created five classes, each for a specific "section" within an
instruction as follows:

1. A prefix class, with a byte prefix which identifies which prefix is
it (if at all)
2. An opcode class with byte[2] opcode, and boolean flags for
is_twobyte, is_modrm,has_disp,has_imm
3. A modrm class with a byte modrm and sib, along with boolean flags
for one, two, or four displacements
4. A displacement class with a byte displacement and boolean whether
it's two byte or four byte displacement (if all false it's obviously a
one byte)
5. An immediate class with the same variables as the previous one

and one class (instruction) which gathers them all together and
performs the checks with a result string and a long address
variable(for BB). I'm unsure whether where I should create the opcode
table (one byte opcodes for modrm/imm/disp fields, two byte etc ) and
how I'll represent it, either inside the opcode class or the
instruction. I got really lost in this side of the stream.
It seems that this is the main part of the decoder, afterwards the
representation (to the user screen) or something like it along with a
big while (1) loop goes into, if anyone could reference me or guide me
about this huge table I'd be fond

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.