[Simh] Custom PC formatting

Mark Pizzolato - Info Comm Mark at infocomm.com
Sun Oct 6 12:37:10 EDT 2013


On Sunday, October 06, 2013 at 9:19 AM, Peter Onion wrote:
> On Sun, 2013-10-06 at 08:46 -0700, Mark Pizzolato - Info Comm wrote:
> > On Sunday, October 06, 2013 at 7:54 AM, Peter Onion wrote:
> > > I'm just having a look at porting an existing emulation into the
> > > simh framework.
> > >
> > > My first problem is that there seems to be no way to provide a
> > > custom "print" routine for the value of the PC.
> > >
> > > Why do I need one ?
> > >
> > > Because the least significant bit of the Sequence Control Register
> > > in my machine has the value "half" as there are 2 instructions in each
> word.
> > >
> > > I'm sure I'll have lots more questions soon !
> >
> > Hi Peter,
> >
> > Actually there is a custom way to display the contents of any simh device
> register.
> >
> > This is available on the most recent simh codebase on github:
> > https://github.com/simh/simh
> >
> > In the latest code, registers can have an optional bit field description for
> the register.  The bitfields can be formatted in a variety of flexible ways.
> >
> > An example of a register which uses a custom formatting paradigm is
> > the PSL register definition in the VAX CPU module at
> > https://github.com/simh/simh/blob/master/VAX/vax_cpu.c
> >
> > FYI a zip of the current code base is available at:
> > https://github.com/simh/simh/archive/master.zip
> >
> > Please come back with more questions as you encounter them.
> >
> 
> I'll reply to the list this time !
> 
> Ok, so I guess this is done via HRDATADF and the psl_bits definition ?
> 
> HRDATADF is not mentioned in the docs and from that one example it is
> rather hard to see how to use it to do what I need.

I believe that these are mentioned in the doc files in the doc directory at github.com/simh/simh.

> I have a 14 bit SCR register and I want to print ((SCR >> 1) & 8191) and a
> decimal, and add a "+" on the end if ((SCR & 1) == 1).
> 
> I've tried to define my PC using HRDATADF, and it picks up the name string
> OK but it isn't doing anything with the bit/field definitions as far as I can tell,
> it's still just printing it out a decimal.

Please provide your code.

I'll take a shot, not knowing precisely what you really want to see:

It seems like this register has two fields.  Lets say it is a 16 bit register with the high 15 bits the PCValue and the Low Bit this extra flag bit you want to see as a "+" when it is set.  And you'd like to see the high 15 bits displayed in octal.

I'd define the low bit as a selector on two strings:

uint16 scr;

char *lowbit_values[] = {"", "+"};

BITFIELD SCR_bits {
    BITFNAM(LOW,1, lowbit_values),
    BITFFMT(PCV,15,"%o") ,
    ENDBITS
};

REG cpu_reg[] = {
   ....
    { HRDATADF(SCR,        scr, 16, "sequence control register", SCR_bits) },
   ....
   NULL
};


- Mark




More information about the Simh mailing list