[Simh] fprint_sym and parse_sym limitation

Paul Koning paulkoning at comcast.net
Fri Sep 11 15:32:01 EDT 2015


> On Sep 11, 2015, at 3:05 PM, J. David Bryan <jdbryan at acm.org> wrote:
> 
> 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

Not quite.  It would break existing simulators that use the addr field for register radix without masking it.  Those may not be common.  

If you want to disregard that case, would it not be just as simple, but more powerful, to pass the index into the registers array as "addr"?  Then all you need is to find the regs vector from the UNIT pointer, and index that with addr, and you have all the information you might want about that register -- its flags, name, or the register number if you want to use that.

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

True, but if you can see the register array entry, then you can test the flag from that entry, which is just as general.

	paul



More information about the Simh mailing list