perm filename CALL[IMS,AIL]1 blob sn#032337 filedate 1973-04-01 generic text, type T, neo UTF8
DSCR
	TENEX VERSION OF THE DEC CALL FUNCTION
⊗

HERE(CALL)
	
	DEFINE CALARG <-5(P)>		;WHERE THE ARGUMENT IS AT

	BEGIN CALL
	PUSH	P,2			;SAVE THESE ACS
	PUSH	P,3
	PUSH	P,4
	PUSH	P,5

	PUSH	SP,-1(SP)
	PUSH	SP,-1(SP)
	PUSHJ	P,CVSIX			;GET SIXBIT (BUT LEAVE STRING ON STACK)
	MOVSI	2,-CALTSZ
CALLUP:	CAMN	1,CAL6TB(2)
	  JRST	CALDTB(2)		;FOUND THE ROUTINE
	AOBJN	2,CALLUP
;CANNOT FIND THE CALL IN THE TABLE
	PUSH	SP,-1(SP)		;PRINT OUT THE OFFENDING NAME
	PUSH	SP,-1(SP)
	PUSHJ	P,OUTSTR
	ERR <CALL:  ABOVE CALL NOT EMULATED BY SAIL>,1
	SETZ	1,
	JRST	CALRET			;RETURN IF USER INSISTS

CALRES:	SETOM	.SKIP.			;HERE TO SKIP RETURN
	SKIPA
CALRET:	SETZM	.SKIP.
	POP	P,5
	POP	P,4
	POP	P,3
	POP	P,2
	SUB	SP,X22
	SUB	P,X22
	JRST	@2(P)

;ACTUAL EMULATING CODE LIVES HERE

.#EXIT:	HALTF
	JRST	CALRET

.#DATE:	SETO	2,			;CURRENT TIME AND DATE
	SETZ	4,			;GET YEAR, MONTH, DAY
	ODCNV
	HLRZ	1,2			;YEAR
	SUBI	1,=1964
	IMULI	1,=31			;(YEAR-1964)*12
	HLRZ	3,3
	ADDI	1,(3)			;(YEAR-1964)+(MONTH-1)*31
	IMULI	1,=31
	HLRZ	3,3
	ADDI	1,(3)			;+ (DAY-1)
	ANDI	1,7777			;12 BITS ONLY
	JRST	CALRET			;AND RETURN	

.#TIMER: SKIPA 5,[=60]
.#MSTIME: MOVEI 5,=1000
	SETO	2,
	SETZ	4,
	ODCNV
	MOVEI	1,(4)			;SECONDS SINCE MIDNIGHT
	IMUL	1,5
	JRST	CALRET			;NOW RETURN

.#RUNTIM:
	MOVE	1,[-5]			;ALL FORKS OF THE JOB
	RUNTM
	JRST	CALRET

.#PJOB:	GJINF
	MOVE	1,3			;JOB NUMBER
	JRST	CALRET

.#LOGOUT:	
	SETO	1,
	LGOUT
	JRST	CALRET

.#GETPPN:
	MOVE	1,P
	ADD	1,[XWD 5,5]
	SKIPL	1
	   ERR <CALL:  CANNOT DO GETPPN>
	GJINF
	SETZM	1(P)
	SETZM	2(P)
	HRROI	1,1(P)
	DIRST				;DIRECTORY NUMBER IN 2
	MOVEI	2,6			;ONLY LOOK AT 6 CHARS
	SETZ	1,	
	MOVE	3,[POINT 7,1(P)]
	MOVE	4,[POINT 6,1]
GETPP1:	ILDB	5,3
	JUMPE	5,GETPP2	
	SUBI	5,40			;CONVERT TO SIXBIT
	ANDI	5,77
	IDPB	5,4			;AND DEPOSIT INTO AC 1
GETPP2:	SOJG	2,GETPP1
	JRST	CALRET

IFN IMSSS,<

.#DATSAV:
	MOVE	1,CALARG
	DATSV
	   JRST	CALRET
	JRST	CALRES

.#PUTINF:
	SETO	1,
	MOVE	2,CALARG
	PTINF
	   ERR <CALL:  PUTINF HAS FAILED>,1
	JRST	CALRET

.#GETINF:
	SETO	1,
	MOVE	2,CALARG
	GTINF
	   ERR <CALL:  GETINF HAS FAILED>,1
	JRST	CALRET

>;IFN IMSSS

DEFINE CALTBL <

CZ EXIT
CZ DATE
CZ LOGOUT
CZ TIMER
CZ MSTIME
CZ GETPPN
CZ RUNTIM
CZ PJOB
IFN IMSSS,<
CZ DATSAV
CZ PUTINF
CZ GETINF
>
>

DEFINE CZ $ (X) <SIXBIT/$X$/>


CAL6TB:	CALTBL

CALTSZ←←.-CAL6TB+1
	
DEFINE CZ $ (X) <.#$X>
CALDTB:	CALTBL
	BEND CALL

;END OF TENEX CODE FOR THE CALL FUNCTION