On Friday, September 11, 2015 at 14:01, Paul Koning wrote: > It may be desirable to format or parse values differently for > different registers. As it stands, that's not possible because the > function can't tell which register it's formatting. [...] > > Ideally one of the argments, for the register case, should point to > the REG entry for the register in question.
I've run into this same problem with a new simulator I'm developing. I've solved it (unofficially) by passing a set of user-defined register flags in the upper 16 bits of the radix parameter, i.e.: - (fprint_sym (ofile, rdx, &val, NULL, sim_switches | SIM_SW_REG) > 0)) + (fprint_sym (ofile, (rptr->flags & REG_UFMASK) | rdx, &val, + NULL, sim_switches | SIM_SW_REG) > 0)) ...and the same for parse_sym. It also needs this in sim_defs.h: +#define REG_V_UF 16 /* device specific */ +#define REG_UFMASK (~((1u << REG_V_UF) - 1)) I considered passing a register pointer, but this method has two advantages: - it's backward compatible, so no changes to calls in existing simulators are needed - it allows groups of registers to be handled easily As an example, I have a "current instruction register" and a "next instruction register" that both need the same special treatment. I tag both register definitions with a used-defined REG_IR value, and then in fprint_sym I need only test for the one flag value rather than two separate register-pointer values. I was eventually going to get around to discussing this with Mark :-), but if you're running into the same problem, perhaps now is a good time. I'm also not wedded to this approach if there's a cleaner option. -- Dave _______________________________________________ Simh mailing list Simh@trailing-edge.com http://mailman.trailing-edge.com/mailman/listinfo/simh