>paramucho wrote:
>On Sun, 15 Jan 2012 09:37:21 -0500, "Jerome H. Fine" wrote:
I have an interesting hardware question.

I have been looking at the results for the program RESORC.SAV in RT-11
with respect the MFPT instruction.  When the J11 chip is used, the value
is 5 and the Maintenance Register at 177750 seems to determine what the
rest of the actual hardware supports.

I thought it would also be helpful for the user to know if an emulator 
is being
used, either software or hardware, or if perhaps some other 3rd party 
hardware
CPU.  I would probably target the various 3rd party boards as far as 
hardware
is concerned (such as QED and Mentec).  For software emulators, I would
suggest that only the high end PDP-11 processors be supported (the DEC
CPUs which support the MFPT instruction) in order to keep things simple,
at least initially.
    
<snip>

Modifying the MFPT instruction is not the right way to go. CPU
software detection is a delicate business and that process should not
be interfered with directly.
  
As I already answered with Johnny, I have my own
doubts for using MFPT.  I do like his suggestion of a
currently illegal instruction code (a new hardware
instruction) which an actual DEC  J11 chip would
need to trap.
In any case, an emulator is not equivalent to a processor type since
SimH and E11 support a range of PDP-11 CPUs.
  
And having a new instruction would be very easy
Ersatz-11.  I suspect that SIMH would also be
very easy.  What about RUST?
Some CPU software detection is handled by examining CPU behavior. The
same process can be used to detect an emulator and to determine which
emulator is being used.
  
It would even be possible to tell the user details of
the emulator environment.  There would need to be
some sort of standard.  Any suggestions?
I currently use some of the behavior of the MMU SR0 and SR1 to detect
emulators in RUST. Clearly, these tests only work when E11 and SIMH
are emulating a machine with MMU, but that's their default state and
there's not much point running RUST in other configurations. Here's
some of the code:

bt$emu:	call	tr$cat			; capture traps

	...				; skip V11 checks	
				
	mov	#m$msr0,r0		; emulator check
	mov	#m$msr1,r1		;
	tst	(r1)			; got MMU with SR1 etc?
	bcs	40$			; nope
	clr	(r0)+			; clear SR0 with increment
	bis	#160000,-(r0)		; overwrite and freeze

	cmpb	(r1),#27		; SIMH magic number
	bne	10$			; not SIMH
	btwar$	<Emulator detected: SIMH>;
	br	20$			;
					;
10$:	mov	#340,(r0)		; SR0 = 340
	cmpb	(r0),#140		; E11 magic number
	bne	30$			; not E11
	btwar$	<Emulator detected: E11>; (misses some read-only bits)
					;
20$:	inc	b$temu			; is emulator
					;
30$:	clr	(r0)			; make them all clean again
	clr	(r1)			;
40$:	call	tr$res			; restore traps
	return 

There is more code which checks for my V11 emulator. That check is
done with a hacked IOT instruction. 

The reason I need detection is because emulators lack standard
terminal output behavior which I use during startup to detect the
clock rate of a PDP-11 (I count the number of null characters output
to the console terminal per clock tick and use a table to determine
both the clock rate and the terminal rate). The test doesn't work on
E11, SIMH or V11.

In fact, the V11 emulator has a little API which is used to pass
information between the emulator and the system. It's used to
relinquish control so that the emulator doesn't hog all the CPU time
and for various other functions. It would be great if there was a
common API for PDP-11 emulators for this kind of thing, but I'm not
sure the motivation is there for the effort involved.
I don't think that the about properties (or at least how
the PDP-11 instructions react to the above code) has
been documented under Ersatz-11.  I would imagine
that the source code could be used under SIMH to
figure out why the above code is needed.

I am VERY curious!!!!!!!!!  How did you figure out the
code for Ersatz-11?  Did John Wilson help?  Does the
above code still work with V6.0 of E11?

Jerome Fine