.title setcc Trap Control/C (RSTS/E RT11 mode only) .ident /000004/ ; ;+ ; ; Index Trap Control/C (RSTS/E RT11 mode only) ; ; Usage ; ; setcc(function); ; extern int function(); ; ; Description ; ; The function is defined as a CTRL/C trap routine. Executing ; setcc(0) disables CTRL/C trapping. ; ; Note: If the routine is reentered (because CTRL/C was ; typed during the execution of function()), the program aborts. ; ; Bugs ; ; Runs on RSTS/E RT11 mode only. ; ;- ; Edit history ; 000001 19-Feb-80 MM Original ; 000002 25-Jun-80 MM Added to the library ; 000003 02-Jul-80 MM Cleared r5 before calling function ; 000004 19-Jan-87 JMC Change .psect for I/D space. .iif ndf rsx rsx = 1 .if ne rsx .psect c$code setcc:: CRASH .iff .MCALL .rctrlo,.exit .GLOBL error .psect c$code setcc:: mov 2(sp),r0 ; Get routine name beq 10$ ; isn't any, disable trapping mov r0,subnam ; save routine name mov #20$,r0 ; go here on ctrl/c clr ccseen ; clear looping flag 10$: emt 362 ; enable trapping rts pc ; that's all for now ; ; Here on ctrl/c ; 20$: .rctrlo ; reset ctrl/o from ctrl/c tst ccseen ; been here before? bne twocc ; oops inc ccseen ; no, up the flag mov r0,-(sp) mov r1,-(sp) mov r2,-(sp) mov r3,-(sp) mov r4,-(sp) mov r5,-(sp) mov sp,savesp ; save the stack, too mov #20$,r0 ; reenable ctrl/c trapping emt 362 ; to grab looping clr r5 ; dump C environment pointer ;03 jsr pc,@subnam ; recall the user ; ; Return from the user ; mov savesp,sp ; grab the stack mov (sp)+,r5 ; and mov (sp)+,r4 ; restore mov (sp)+,r3 ; all mov (sp)+,r2 ; working mov (sp)+,r1 ; registers mov (sp)+,r0 clr ccseen ; no more ctrl/c rti ; back to rt11 ; ; Here if two ctrl/c's typed ; twocc: mov #ccmsg,-(sp) call error .exit ; ; Data areas ; .psect c$data,d ;04 savesp: .word 0 ; save stack from caller subnam: .word 1 ; user ctrl/c handler ccseen: .word 0 ; Reentry flag ccmsg: .asciz "?IO-F-Second ctrl/c typed" .endc .end