Google
 

Trailing-Edge - PDP-10 Archives - mit_emacs_170_teco_1220 - info/sail.jsys
There are no other files named sail.jsys in the archive.

		     Calling JSYSes In SAIL

			  May 22, 1975
			
		            R. Smith


	The most common way that JSYSes are called in TENEX SAIL
is by using the runtime routines.  Most of the system
calls that users have wanted to make in the past two years
at IMSSS have been added as runtime routines.  However, the
need still exists to call other JSYSes, and new ones may be 
added in the future by BBN and individual sites.

	The SAIL START!CODE facility is the most used way
of calling JSYSes, particularly for those familiar with
machine language.  The START!CODE assembler is evoked
inline by the SAIL statement:

	START!CODE
	   machine instructions ending with semicolons

	END

which itself is a block or compound statement in the
language (i.e., declarations can occur after the word
START!CODE in the way that declarations can occur after
BEGIN.  Note that labels inside the block must be declared.)

	In the START!CODE assembler (which is more fully
described in the Van Lehn SAIL manual) valid PDP10 instructions
are accepted in the form

	OPCODE  AC, location ;

where OPCODE is a PDP10 opcode, AC an AC number, and LOCATION
is a label or a literal.  LOCATION may contain the indirect
(@) sign, and may be indexed.  Literals are one location only
and contain SAIL arithmetic expressions.

	For example, the following does a HALTF

	START!CODE
		HALTF;
	END;

and the following would do the NOUT jsys to the terminal,
printing out the number 15 in decimal notation.  Note that
numbers inside START!CODE are decimal.

	START!CODE
		MOVEI	1,'101; COMMENT primary output;
		MOVEI	2,15;   COMMENT number 15 to print;
		MOVEI	3,10;	COMMENT radix to print it in;
		NOUT;		COMMENT print it;
		JFCL;		COMMENT error return;
	END;
If the number that one wanted to print were in INTEGER I, the
following would be correct:

	START!CODE
		MOVEI	1,'101;
		MOVE	3,I;   COMMENT assembler uses 
				address of I here;
		MOVEI	3,10;
		NOUT;
		  JFCL;
	END;

(Note:  this is not how one would print out a number in SAIL,
generally one would OUTSTR(CVS(I)) for example.  It is more
efficient since it does not evoke the monitor NOUT code.)

	As mentioned, many SAIL users have used START!CODE
for these purposes.  There is also a function JSYS that
is available on-line at IMSSS and SUMEX by inserting

REQUIRE "<SAIL>JSYS" SOURCE!FILE;

at declaration level.  This includes a routine JSYS that does
the following:

	(1)  JSYS accepts two arguments.  The first argument
is a string naming a JSYS.  The second is a five-element
array.  The elements of the array are for the accumulators
into and out of the JSYS call.  Thus, one puts arguments
for the accumulators into the array, and values returned
by the JSYS will be returned in the array.
	(2)  JSYS returns, as the value of the call,
where the return from the JSYS was.  If the JSYS function returns 1,
then the return from the JSYS itself was +1, etc.
	(3)  JSYS is quite inefficient compared to START!CODE.
However, it may be implemented as a part of the compiler in which
case it would be quite efficient.

	For example, the following scenarios correspond to the
above:

INTEGER ARRAY ACS[1:5];



JSYS("HALTF",ACS);      COMMENT DO A HALTF;


ACS[1]_'101;  ACS[2]_15; ACS[3]_10;
JSYS("NOUT",ACS);

ACS[1]_'101; ACS[2]_I;  COMMENT I declared integer; ACS[3]_10;
JSYS("NOUT",ACS);

	If we wanted to check that the NOUT jsys executed
without error, the last line could be replaced by the following:


IF JSYS("NOUT",ACS) NEQ 2 THEN  ...error code...;

i.e., we would check that the return was "+2" in the sense of
the JSYS manual.