-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.

closed as too broad by Scant Roger, Ixrec, GlenH7 Nov 28 '15 at 16:54

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

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.