-1

I am writing a simple x86 disassembler in c++ and I would like to hear an input on class which will handle disassembly. I thought to make a class which would receive a pointer to the table which will contain instruction description. In that way I would have logic implemented in a class which could disassemble code for any platform by just receiving different input table. Do you think that's a good way to solve a problem, or should I put the table definition inside a class and then have special classes for x86 disassembler, arm disassembler and so on. I'm a student and I didn't worry before about code elegance but I'm trying to write more elegant code now so any advice about design is welcomed.

1 Answer 1

1

If you are planning to write a Recursive Descent Parser (Wikipedia) then a general-purpose description of the machine code to be disassembled might be feasible, but even that is debatable, and you are certainly going to be getting into some very deep waters by just trying that.

If you are not going to be writing a recursive descent parser, then there is probably no point at all in trying to make it so general-purpose.

I would recommend that you first get your disassembler to work in a hard-coded way for a single CPU, and afterwards worry about making it general-purpose. Try to be focused to a single, simple goal, or else you will never get anything done.

Most chances are, YAGNI. (Ya Ain't Gonna Need It.)

Not the answer you're looking for? Browse other questions tagged or ask your own question.