%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This is an ecstract of a library of monitor-calls for Nord-Pascal. % % The routines are well tested, but should any errors surface, % % please report them to H}vard Eidnes/Erlend Dahl c/o Studio 54 % % % % Assembeled at Nord-10.54 "computing centre" 30.01.84 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Contributing programmers : % % Bernt Marius Johnsen - bmj % % Frode Hernes - fh % % Bjarte Holmedal - bjh % % H}vard Eidnes - he % % Anders Herbj|rnsen - ah % % + many more for the original library.. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %%%%% % bmj FUNCTION PM1 (DEV: INTEGER): CHAR; EXTERN; % INBT ^x,Inbt; % % Function to input one byte from a device. % The routine removes parity % ^cc, )9BEG )9LIB PM1 INBT )9ENT PM1 INBT INBT=* PM1, COPY SA DX % pointer to parameter-list LDT ,X,B 7 % get device number MON 1 % INBT MON 65 % error return ( QERMS ) SAT 177 % mask to remove parity bit RAND ST DA % remove parity STA ,X,B 6 % store returned value from function EXIT )9END % ;^cp,6; %%%%% % bmj PROCEDURE PM2(DEV: INTEGER; CH: CHAR); EXTERN; % OUTBT ^x,Outbt; % % Procedure to output a byte to a device % ^cc, )9BEG )9LIB PM2 OUTBT )9ENT PM2 OUTBT OUTBT=* PM2, COPY SA DX % pointer to parameter list LDT ,X,B 6 % get device number LDA ,X,B 7 % get input character MON 2 % OUTBT MON 65 % error return ( QERMS ) EXIT % skip return : ok )9END % ;^cp,9; %%%%% % bmj PROCEDURE PM3(MODE: INTEGER); EXTERN; % ECHOM ^x,Echom; % % Procedure to set the echo mode as specified in % the Sintran manual. Be aware that this is not % the full monitor call. % Only for MODE < 3. % ^cc, )9BEG )9LIB PM3 ECHOM )9ENT PM3 ECHOM ECHOM=* PM3, COPY SA DX LDA ,X,B 6 % Get echo mode MON 3 % ECHOM EXIT )FILL )9END % ;^cp,10; %%%%% % bmj PROCEDURE PM4(MODE: INTEGER); EXTERN; % BRKM ^x,Brkm; % NOT FOR MODE > 2 % % Procedure to set the break mode as specified in the % Sintran manual. The procedure XBRKM should be used % if the one wants to set break mode for an arbitrary % device. (Only possible for RT-programs) % ^cc, )9BEG )9LIB PM4 BRKM )9ENT PM4 BRKM BRKM=* PM4, COPY SA DX LDA ,X,B 6 % Get mode MON 4 % BRKM EXIT )9END % ;^cp,6; %%%%% % bmj PROCEDURE PM13(DEV: INTEGER); EXTERN; % CIBUF ^x,Cibuf; % % Procedure to clear the input buffer of a device % ^cc, )9BEG )9LIB PM13 CIBUF )9ENT PM13 CIBUF CIBUF=* PM13, COPY SA DX LDT ,X,B 6 % Get device number MON 13 % CIBUF MON 65 % Error return ( QERMS ) EXIT )FILL )9END % ;^cp,7; %%%%% % bmj FUNCTION PM66(DEV: INTEGER): INTEGER; EXTERN; % ISIZE ^x,Isize; % % Procedure to get the size of the input buffer of % a device given the device number. % ^cc, )9BEG )9LIB PM66 ISIZE )9ENT PM66 ISIZE ISIZE=* PM66, COPY SA DX LDT ,X,B 7 % Get device number MON 66 % Isize MON 65 % Error return STA ,X,B 6 % Store size EXIT )9END % ;^cp,7; %%%%% % bmj PROCEDURE PM71(DEV: INTEGER); Extern; % DESCF ^x,Descf; % % Procedure to disable escape. % ^cc, )9BEG )9LIB PM71 DESCF )9ENT PM71 DESCF DESCF=* PM71, COPY SA DX LDT ,X,B 6 MON 71 EXIT )9END % ;^cp,6; %%%%% % bmj PROCEDURE PM72(DEV: INTEGER); Extern; % EESCF ^x,Eescf; % % Procedure to enable escape % ^cc, )9BEG )9LIB PM72 EESCF )9ENT PM72 EESCF EESCF=* PM72, COPY SA DX LDT ,X,B 6 MON 72 EXIT )9END % ;^cp,7; %%%%% % bmj FUNCTION ADDR(VAR X: ANYTYPE): INTEGER; EXTERN; % ^x,Addr; % % Procedure to get the address of any type except, of % course, a file. The "var" is essential !!!! % ^cc, )9BEG )9LIB ADDR )9ENT ADDR ADDR, COPY SA DX LDA ,X,B 7 % The address lies on the stack STA ,X,B 6 % Store address as function out value EXIT )9END % ;^cp,16; %%%%% % bmj PROCEDURE PM143(VAR RUNMOD,IDEV,ODEV,USNO : INTEGER); EXTERN; % RSIO ^x,Rsio; % % Procedure to get execution mode of calling background % program, user, input and output file numbers. % USNO contains main directory index (most significant byte) % and user number (least significant byte) of the user under % which the program is running. % ^cc, )9BEG )9LIB PM143 RSIO )9ENT PM143 RSIO PAROF=6 BSAV=PAROF+4 RSIO=* PM143, SWAP SA DB % Exchange A-reg and B-reg RADD SA DB % Get stack pointer STA ,B BSAV % In order to generate reentrant code. MON 143 % RSIO % JMP *+1 % This one seems to be superfluous. STA I ,B PAROF % Store mode STT I ,B PAROF+1 % Store input device number COPY SD DA % Get output device number STA I ,B PAROF+2 % Store output device number STX I ,B PAROF+3 % Store user number LDA ,B BSAV % Restore B-reg COPY SA DB EXIT )9END % ;^cp,10; %%%%% % he PROCEDURE SETBT(FILENUMBER:INTEGER; % BTPTR:LONGINT);EXTERN; % PM74 ^x,Setbt; % Procedure to set the byte pointer on an open file % The byte pointer must be a double integer. % ^cc, )9BEG )9LIB SETBT PM74 )9ENT SETBT PM74 QERMS=65 SETBT=* PM74, RADD DA SB % get pointer to parameter list COPY DX SA LDT ,X 6 % filenumber LDD ,X 7 % get byte pointer (double word) MON 74 % SETBT MON QERMS % error ? EXIT )9END % ;^cp,8; %%%%% % he PROCEDURE REABT(FILNUMBER:INTEGER; % VAR BTPTR:LONGINT);EXTERN; % PM75 ^x,Reabt; % % Procedure to read the byte pointer of an open file. % The byte pointer must be a double word. % ^cc, )9BEG )9LIB REABT PM75 )9ENT REABT PM75 QERMS=65 REABT=* PM75, COPY SB DX % save B-reg RADD DB SA % get pointer to parameters LDT ,B 6 % first parameter - file number MON 75 % REABT MON QERMS % error ? STD I,B 7 % store indirect COPY SX DB % restore B-reg EXIT )9END % ;^cp,9; %%%%% % he FUNCTION XOPEN(VAR FILENAME:CHARARR; VAR FILETYPE:FTTYPE; % ACCESS:INTEGER; % VAR STATUS:INTEGER):INTEGER;EXTERN; % ^x,XOpen; % % Function to open a file and return status. Otherwise, this % routine is identical with OPEN. % ^cc, )9BEG )9LIB XOPEN )9ENT XOPEN SAVB=13 XOPEN, RADD DA SB % get base of parameters SWAP SA DB STA ,B SAVB % save B register LDX ,B 7 % first parameter (address of filename string) LDA ,B 10 % second parameter (address of filetype string) LDT ,B 11 % access code MON 50 % open JMP ERROR % comment? STA ,B 6 % ok, store file number as function return value SAA 0 % zero error-code ERROR, STA I,B 12 % error-code in sintranIII LDA ,B 6 % function value in A-reg also LDT ,B SAVB SWAP ST DB % restore B EXIT )FILL )9END % ;^cp,6; %%%%% % ah PROCEDURE PM12(VAR S: CHARARR); EXTERN; % SETCM ^x,Setcm; % % Procedure to transfer a string to the % command input buffer. % The string must be terminated by a CR. % NB : The "var" is essential !!!! % ^cc, )9BEG )9LIB PM12 SETCM )9ENT PM12 SETCM SETCM=* PM12, COPY SA DX LDA ,X,B 6 % Get address of string MON 12 % SETCM EXIT )FILL )9END % ;^cp,14; %%%%%%% % he PROCEDURE T8INB ( Dev : integer; % PM310 VAR Data : AnyType; % VAR BreakRead : boolean; % VAR NByt : integer );extern; % ^x,T8inb; % Procedure to input 8 bytes from given logical device number. % Does appropriate break- and echo-checking. % Reads bytes up to and including break character. % % Stores all eight bytes from registers, so watch out if less % than 8 bytes has been transfered. % % NByt is returned as number of bytes actually read. % % Data should be a buffer to store bytes in, any type will % be acceptable as long it is transferable using VAR, and % sufficient space is available (ie. 8 bytes). % % The routine is reentrant - uses B+A+ 12,13 & 14 for temporary storage. % ^cc, )9BEG )9ENT T8INB PM310 )9LIB T8INB PM310 SAVL= 12 SAVB= 13 XBYTS=14 PM310=* T8INB, SWAP SA DB % In order to save B-register. RADD DB SA % Get pointer to parameter-list. STA ,B SAVB % save B-register on top of stack. COPY SL DA % save L-register also STA ,B SAVL % in SAVLink LDT ,B 6 % Set up device number MON 310 % and do the actual input - T8INB MON 65 % THIS ANIMAL HAS SKIP-RETURN - UNDOCUMENTED!!! STX ,B XBYTS % Save the bytes read into X-register in XBYTS SAX 0 % and use X-reg as offset in data-area. STD I,B,X 7 % Store first four bytes. SAX 2 % Adjust offset COPY SL DA % In order to store bytes read into L-register. STA I,B,X 7 % Store bytes - address in 4th byte relative B SAX 3 % and adjust offset once again. LDA ,B XBYTS % Get bytes read into X-reg STA I,B,X 7 % and store them also. SAA -1 % Make pattern 077777 SHA ZIN SHR 1 % in A-reg. RAND ST DA % Mask off upper bit STA I,B 10 % and store in NByt. SAA 1 % Make pattern 100000 SHA ROT 17 % in A-reg. RAND ST DA % Mask out upper bit SHA ZIN SHR 17 % and shift to lower position. STA I,B 11 % and store value in BreakRead. LDA ,B SAVL % Save return-address in A-register LDX ,B SAVB % Restore COPY SX DB % B-register COPY SA DP % .. return )9END % END of BRF-unit % ;^cp,19; %%%%%%% % he procedure m8out ( Dev : integer; VAR Buffer : AnyType ); extern; % PM22 ^x,M8out; % % Procedure to output 8 bytes to a device. Stops output when an % null is encountered. "Buffer" shold be a buffer containing % at least 8 bytes to be output (any type will work - % as long as the parameter is possible to transfer using VAR.) % ^cc, )9BEG )9ENT M8OUT PM22 )9LIB M8OUT PM22 SAVL=10 SAVB=11 PM22=* M8OUT, SWAP SA DB % In order to save B-register RADD SA DB % Get pointer to top of stack STA ,B SAVB % and save B-register in SAVB COPY SL DA % Save return-address also STA ,B SAVL % in SAVL LDD I,B 7 % Get first 4 bytes into A- and D-registers SAX 2 % Offset into Buffer LDT I,B,X 7 % Get next two bytes COPY ST DL % and copy to L-register SAX 3 % New offset LDX I,B,X 7 % Get last 2 bytes LDT ,B 6 % Fetch device-number MON 22 % MON M8OUT MON 64 % Error? LDX ,B SAVB % Get saved B-register LDT ,B SAVL % Get return-address into T-register COPY SX DB % Restore B-register COPY ST DP % and return )9END % ;^cp,8; %%%%%% % he Procedure xhold( unit,n : integer ); extern; % PM104 ^x,XHold; % % In order to be runnable on both 32- and 48-bits floating ND-machines, % the library routine Hold from pas-lib must be avoided (uses floating % point arithmetic). See SINTRAN REF. MAN. % ^cc, )9BEG )9LIB PM104 XHOLD )9ENT PM104 XHOLD SAVB= 10 % Save location relative stack top NADDR= 11 % Displacement to address-location UADDR= 12 % Displacement to address-location PM104=* XHOLD, RADD SB DA % Get pointer to top of stack in A-reg SWAP SA DB % and swap so that we can STA ,B SAVB % save B-reg as it was on entry. COPY SB DA % Get address to top of stack in A-reg AAA 6 % add 3 to get address of "unit" STA ,B UADDR % Store calculated address. AAA 1 % Increment to get address of "n" STA ,B NADDR % Store calculated address. AAA 2 % And now get address of address-list. MON 104 % HOLD LDA ,B SAVB % Get saved B-reg to A COPY SA DB % and restore. EXIT )9END % ;^cp,6; %%%%%% % he function xtusd:longint; extern; % (pm114) ^x,XTusd; % Possible to use both on 32- and 48-bits floating machines without % recompilation. (Routine in pas-lib involves FP-arithmetic.) % ^cc, )9BEG )9ENT PM114 XTUSD )9LIB PM114 XTUSD PM114=* XTUSD, MON 114 % Get time used in AD EXIT )9END % ;^cp,6; %%%%%% % he function xtime:longint; extern; ^x,XTime; % (pm11) % Possible to use on 32- and 48-bits floating machines without % recompilation. % ^cc, )9BEG )9ENT PM11 XTIME )9LIB PM11 XTIME PM11=* XTIME, MON 11 % Give current internal time in basic time-units. EXIT % (20 ms) )9END % ;^cp,6; %%%%% % PROCEDURE RMAX(filenumber:integer;VAR bytptr:longint; % VAR status : integer);extern; % fh/bjh/he PM62 ^x,Rmax; % Procedure returning max-byte-pointer of file. % Filenumber is open-file-number (logic device in S III) % ^cc, )9BEG )9ENT RMAX PM62 )9LIB RMAX PM62 PM62=* RMAX, COPY SB DX RADD SA DB % get pointer to parameter-list LDT ,B 6 % first parameter of procedure MON 62 % RMAX JMP ERROR % error-code in A-reg STD I ,B 7 % store resulting byte-pointer ( skip-return ) SAA 0 % set error code to 0 ERROR, STA I ,B 10 % store error code COPY SX DB EXIT )9END % ;^cp,11; %%%%% % bmj PROCEDURE PM43(NO: INTEGER); EXTERN; % CLOSE ^x,Close; % % Procedure to close a file from open file number % ^cc, )9BEG )9LIB PM43 CLOSE )9ENT PM43 CLOSE CLOSE=* PM43, COPY SA DX LDT ,X,B 6 % Get file number MON 43 % Close MON 65 % Error return EXIT )9END %%%%% % bjh FUNCTION IAND (I,J:INTEGER):INTEGER;EXTERN; % % Function returning the bitwise and of two integers. % % )9BEG )9ENT IAND )9LIB IAND IAND, COPY DX SA % saves stack-pointer LDA ,X,B 7 % loads in first integer LDT ,X,B 10 % loads in second integer RAND DA ST % takes bitwise and stores STA ,X,B 6 % return in first field EXIT )FILL )9END %%%%% % bjh FUNCTION IOR (I,J:INTEGER):INTEGER;EXTERN; % % Function returning the bitwise or of two integers. % )9BEG )9ENT IOR )9LIB IOR IOR, COPY DX SA % saves stack-pointer LDA ,X,B 7 % loads in first integer LDT ,X,B 10 % loads in second integer RORA DA ST % takes bitwise or and stores STA ,X,B 6 % return in first field EXIT )FILL )9END %%%%% % he FUNCTION CXOR(CH1,CH2:CHAR):CHAR;EXTERN; % % Function returning the logical 'xor' of two characters. % )9BEG )9ENT CXOR )9LIB CXOR CXOR, COPY DX SA LDA ,X,B 7 % first parameter LDT ,X,B 10 % secind parameter REXO DA ST % execute EXOR STA ,X,B 6 % store function value EXIT )FILL )9END )9EOF )LINE