- stktst.c: add (s,c,o) breakdown of sp address - dotst.s: skip -c and -s for negative counts
stktst: a program testing 2.11BSD stack extension logic
The stktst program exercises the 2.11BSD stack extension logic.
In a first step, the sp can be aligned to a click (64 byte) or a
segment (8129 byte) boundary.
An offset can also be applied after this alignment.
In a second step, a sequence of integer and floating point instructions with
a -(sp) destination is executed.
This allows to set up almost every possible stack extension situation.
Motivation for stktst were differences in the MMR1 register implementation
in different PDP-11 CPUs, and differences in the modeling of MMR1 in
different PDP-11 simulators.
That combined with the 2.11BSD stack extension handling prior to #473 can lead
to unexpected "Memory fault" aborts in 2.11BSD.
The results are collected in the data folder.
stktst has an assembler core dotst.s which is called from a
C main program stktst.c. It is called as
./stktst <cmd> <count> [-s ns] [-c nc] [-o no]
The options control the initial stack alignment:
-s ns: aligns to 8192 byte segment boundaries. ns=1 to the next one, nc=2 to the second next one, etc. Obviously,nsshould be smaller than 8. The option is ignored if ns<=0.-c nc: aligns to 64 byte click boundaries. nc=1 to the next one, nc=2 to the second next one, etc. The first alignment step will not change the stack if it was alreay on a click bounday, it will therefore add 0 to 64 bytes to the stack. The option is ignored if nc<=0. Click alignment is done after segment alignment.-o no: addsnotosp.nomust be even and can be positive or negative.
Notes:
- no range checks is done for
no. After a -s is is save to use small positivenovalues to positionspa bit before a segment boundary. After a -c is is better to use negativenovalues to positionspbefore the next click boundary. - the stack allocated below the argument and environment values.
The initial
spvalue will therefore decrease when the number of characters in the argument list increases because the stack base moves down. In some cases it is therefore prudent to specify the numbers as quoted strings with some leading blanks, likeThat allows to change the counts without changing the length of the argument list../stktst d ' 3' -c ' 2' -o ' 4'
The cmd argument selects the instruction that does the stack push and
count determines how often it is executed.
The available modes for cmd are
I: useclr -(sp)--> integer word pushi: usemovfi -(sp)afterseti--> word push from FPPl: usemovfi -(sp)aftersetl--> double word push from FPPf: usemovf -(sp)aftersetf--> double word push from FPPd: usemovf -(sp)aftersetd--> quad word push from FPP
For debug purposes three additional cmd modes are available:
r: usescountas an address and readsw: usescountas an address, reads and re-writesh: runs ahalt
stktst prints the sp after alignment and after the stack pushes like
stktst-I: before sp 177304 (0, 4,60); 177200 (0, 5,64);
stktst-I: after sp 177304 (0, 4,60); 177200 (0, 5,64); 167200 (0, 69,64);
and gives the sp value
- after
dotst.sis called - after alignments and offsets were applied
- after stack pushes were executed
and prints it in octal and broken down in segment, click and byte offset.
Because the stack is a downward growing segment, all offsets measure the
distance to the top of memory and increase when the sp decreases.
When a stack extension fails, the program will print the first line and abort.