It is a difficult one to implement. I've only seen one example written in java and that one had a generated source (almost 4Mb of sheer uglyness). I am *trying* to do it with a more generic OO approach and less code, but man it's not an easy one. Since many instructions seem to have many different combinations in operands and addressing modes, I'm trying to do something with an Operand interface which I can use for the registers, the effective address, a pointer to memory etc. That way I hope to be able to create for example all ADD opcodes by creating the correct Operands in the constructor of the ADD class, so that the instruction can basically always do 'void add(Operand, Operand)' then. The Operands could be the EA, a register or anything else. Would that be a sensible approach? Any remarks here?
|