Mike_W_Ryan@cup.portal.com (04/21/88)
Does anyone know of how to utilize control Y traps in PASCAL3000? Althogh various run time traps are mentioned, it seems that control Y is not mentioned in the manual, hence apparently not supported. I was thinking of putting a SPL subroutine in a RL and trying calling that from PASCAL. I suspect the catch is that you have to assemble the SXIT instruction yourself when using control Y in SPL programs and that PASCAL hs no way to do this. While I am at it.. does anyone know if PASCAL on the SPECTRUM systems (commercial) will support control Y traps?
dennett@kodak.UUCP (Charlie Dennett) (04/23/88)
In article <4654@cup.portal.com> Mike_W_Ryan@cup.portal.com writes: >Does anyone know of how to utilize control Y traps in PASCAL3000? I happen to have a copy of the MPE V Intrinsics manual in front of me. It contains a few intrinsics dealing with traps. I think it has the one you need. XCONTRAP enables or disables the CONTROL-Y trap. It describes the parameters needed to call the intrinsic and also refers the reader to Section 5 of the Intrinsics Manual. All traps are discussed in pages 5-37 through 5-49 with control-Y traps discussed on page 5-46. There is also a small sample SPL program using the Control-Y trap. Be aware - I have never used what I described above. This might be way out in left field. If you get it to work, I'd be curious to hear about it. -- Charlie Dennett | UUCP: ...!rutgers!rochester!kodak!dennett Eastman Kodak Company | Voice: 716-726-4480 901 Elmgrove Road | Company Mail: Dept 420 Tech. Support B-2/F-1 Rochester, NY 14650 | Company DECnet: VXMM07::DENNETT
shankar@hpclscu.HP.COM (Shankar Unni) (04/26/88)
> / hpclscu:comp.sys.hp / Mike_W_Ryan@cup.portal.com / 5:11 pm Apr 20, 1988 / > Does anyone know of how to utilize control Y traps in PASCAL3000? Althogh Control-Y traps on the classic 3000's are a *little* tricky, unless you want to exit immediately on receipt of the Control-Y. This is because control-Y's on the classic 3000's push a variable number of items on the stack before calling the user's trap handler. The technique that we use goes as follows: we write a little onion-skin routine in SPL, whose PLabel is passed to XContrap for calling on receipt of the signal. The onionskin then calls the regular Pascal routine for doing the real thing on receipt of the control-Y. Specifically: SPL Onionskin: PROCEDURE AltCntlY; BEGIN PROCEDURE RealCntlY; OPTION EXTERNAL; INTRINSIC ResetControl; RealCntlY; << Call the real handler >> ResetControl; << Re-arm the control-y trap >> ASSEMBLE (ADDM *+2; XEQ 0); << This is why the onionskin is needed >> END; Pascal routine: PROCEDURE RealCntlY; (* the real thing *) BEGIN (* whatever you want to do on receipt of a control-Y *) END; Arming the trap (I assume you want to do it from the Pascal Outer Block): PROGRAM Whatever; ... VAR OldPLabel : -32768..32767; PROCEDURE XCONTRAP; INTRINSIC; PROCEDURE AltCntlY; EXTERNAL SPL; ... BEGIN (* outer block *) ... XConTrap (WAddress (AltCntlY), OldPLabel); (* arms the trap handler *) ... END. (* outer block *) If you just want to, say, print a message and exit on receipt of a Control-Y, then you can bypass the SPL onionskin, and pass the WAddress of the Pascal Handler directly to XContrap. > > While I am at it.. does anyone know if PASCAL on the SPECTRUM systems > (commercial) will support control Y traps? Absolutely. And here, fortunately, the Onionskin in SPL is not necessary. The calling convention is absolutely straightforward: Pascal trap handler: PROCEDURE RealCntlY; (* declarations *) PROCEDURE ResetControl; INTRINSIC; BEGIN (* RealCntlY *) (* whatever you do on receipt of a cntl-y *) ResetControl; (* re-arm the trap *) END; (* RealCntlY *) Outer block: PROGRAM Whatever; VAR OldPLabel : Integer; (* <<<< NOTE: 32-bit integer required!! *) ... PROCEDURE XContrap; INTRINSIC; PROCEDURE RealCntlY; EXTERNAL; (* or forward, or whatever ... *) ... BEGIN (* outer block *) ... XContrap (WAddress (RealCntlY), OldPLabel); (* arm the trap *) ... END. (* outer block *) > ---------- Shankar
spuhler@hpisoa2.HP.COM (Tom Spuhler) (04/26/88)
It's been a couple of years, but I was able to create a control Y trap without having to resort to SPL or such geegaws. I used the general scheme described in my (old) copy of the Pascal/3000 manual (p10-19) and it worked fine. The slightly tricky bit in Pascal is that you can't go branching off to anywhere, you have to either exit the program or set a flag which is checked edxternally (good programming practice anyway). but that's the language. I suppose it might actually be possible to got -Tom Spuhler
shankar@hpclscu.HP.COM (Shankar Unni) (04/28/88)
> ................................................. I used the general > scheme described in my (old) copy of the Pascal/3000 manual (p10-19) and it > worked fine. The slightly tricky bit in Pascal is that you can't go > branching off to anywhere, you have to either exit the program or set a > flag which is checked edxternally (good programming practice anyway). > but that's the language. You also won't be able to "return normally" with absolute certainty. Apparently, when you hit a Control-Y, a variable number of words is pushed onto (or left on) the stack. The stack layout looks vaguely like this (pp 4-38..4-42 of the MPE Intrinsics Manual (30000-90010)): | | | User prog stack | |-----------------------| | | | User stack marker | <--- Q-2 = relative P | | | | |-----------------------| <--- Q | | n | <--- Q+1 (n = number of words) |-----------------------| | | | | |-----------------------| <--- S | | | ControlY proc data | | | The value of "n" will be > 0 if the Cntl-Y interrupted a system intrinsic, and it is then the user program's responsibility to peel back the stack (the control-Y will *not* return to the intrinsic (I don't think so)). There is no way of doing this reliably in Pascal, and if the "n" words are not popped, then the stack will sooner or later be trashed. The above mentioned reference (the Intrinsics manual) has an interesting description of the exact workings of the Control-Y trap (morbidly fascinating, if you enjoy this kind of stuff). Enjoy, --Shankar Unni