Thanks for all of the examples everyone! That helped a lot.
On 3 September 2014 12:41, Rich Alderson <RichA at livingcomputermuseum.org> wrote:
From: Kevin Keith
Sent: Tuesday, September 02, 2014 6:13 PM
Forgive my slowness, but I've having a hard
time seeing how this would
work. Could you point me to any examples?
A real life example, from the Tops-10 monitor (v7.04). In the page-fail
handler, we find the following code:
;HERE IF WE BELIEVE THAT THE ADDRESS IN THE PAGE FAIL WORD IS REALLY A
; VIRTUAL ADDRESS. MUST BE TRUE OR THE PARITY ERROR WAS SPURIOUS
PRTRP4: MOVE T4,[PXCT PX.MEM,[MAP P1,(P1)]] ;SET UP PXCT OF MAP INSTRUCTION
SKIPL .CPPFW## ;IS THIS A USER CONTEXT REFERENCE?
TLZ T4,(PX.MEM,) ;NO--THEN PXCT BECOMES REGULAR XCT
MOVE P1,.CPPFW## ;NOT PHYSICAL REFERENCE, GET VIRTUAL ADDRESS
XCT T4 ;DO A MAP TO TURN PF WORD INTO PHYS ADDR IN P1
A note on Macro-10 syntax: Literals are in square brackets [], and can be
nested. <symbolname>## indicates a global symbol.
PXCT is a privileged variant of the XCT instruction which is used in the
monitor (read "kernel") to perform instructions in the "previous
context"
(which is to say, the context in which a system call or other monitor event
occurred) to provide data to the monitor context which handles the event.
This particular piece of code sets up a MAP instruction, which will convert
a virtual address to a real physical address. It assumes that the page
fault took place in a user context (since if the system is running well
that's the usual state). If that is not the case, it zeroes the accumulator
field of the PXCT instruction in accumulator T4, making it an ordinary XCT.
It now moves the page-fail word into accumulator P1, for use by the MAP
instruction pointed to by the (P)XCT instruction in T4, and does an XCT of
the (P)XCT, which in turns executes the MAP instruction, which puts the
physical address of the word pointed to by the page-fail word into P1, for
the use of the monitor's page fault handler.
The XCT instruction, including its previous-context variant, allows all of
those variations on what we are looking for to be handled in 5 instructions,
instead of special case code to handle "is this in the monitor rather than
in user context?" Makes the code simpler to maintain, since we don't have
to make parallel changes in different routines.
Rich
Rich Alderson
Vintage Computing Sr. Systems Engineer
Living Computer Museum
2245 1st Avenue S
Seattle, WA 98134
mailto:RichA at
LivingComputerMuseum.org
http://www.LivingComputerMuseum.org/