! ! Undeclare 'ENQ' since it is already defined in MONSYM. ! UNDECLARE ENQ; ! ! INCLUDE FILES: ! REQUIRE 'BLI:MONSYM'; ! TOPS-20 symbols ! ! JSYS definitions ! LITERAL $BFADR = 0, ! TOPS-10 symbols for TOPS-10/TOPS-20 code $BFPTR = 1, $BFCTR = 2, t20$k_skip = 1, t20$k_non_skip = -1, X20$K_BUFFER_SZ = 128, X20$K_MAX_SPEC = 219, X20$K_CHAR_SIZE = %O'070000000000', X20$K_RIGHT_HLF = %O'000000777777', X20$K_LEFT_HLF = %O'777777000000', X20$K_WORD_SIZE = %O'440000000000'; ! ! TOPS-20 I/O Interface Macros ! MACRO $X20_ASCIZ( string_descr, work_space ) = ! Copy a string into a given area and make it ASCIZ. BEGIN IF ( .string_descr[STR$H_LENGTH] + 1 ) GTR ! If the string will not fit in the work area, (%ALLOCATION(work_space) * 5) ! THEN ! 0 ! return an error code to the caller. ELSE BEGIN CH$MOVE( .string_descr[STR$H_LENGTH], ! Copy the given string .string_descr[STR$A_POINTER], ! CH$PTR( work_space ) ); ! into the work area, ! CH$WCHAR( 0, CH$PLUS(CH$PTR(work_space), ! make it ASCIZ. .string_descr[STR$H_LENGTH]) ); 1 ! Return a successful completion code to the caller. END END %, $T20_CLOSF( flags_jfn, error_bits ) = ! Close the file(s). BEGIN REGISTER $t20$ac1 = 1; BUILTIN JSYS; LOCAL $t20$status; $t20$ac1 = flags_jfn; $t20$status = JSYS( t20$k_skip, CLOSF, $t20$ac1 ); %IF NOT %NULL( error_bits ) %THEN error_bits = .$t20$ac1; ! Return the error code. %FI .$t20$status END %, $T20_DELF( jfn, error_bits ) = ! Delete the file. BEGIN REGISTER $t20$ac1 = 1; BUILTIN JSYS; LOCAL $t20$status; $t20$ac1 = jfn; $t20$status = JSYS( t20$k_skip, DELF, $t20$ac1 ); %IF NOT %NULL( error_bits ) %THEN error_bits = .$t20$ac1; ! Return the error code. %FI .$t20$status END %, $T20_GETER( process_handle, error_bits ) = ! Get the most recent error. BEGIN REGISTER $t20$ac1 = 1, $t20$ac2 = 2; BUILTIN JSYS; $t20$ac1 = process_handle; JSYS( t20$k_non_skip, GETER, $t20$ac1, $t20$ac2 ); error_bits = .$t20$ac2 AND x20$k_right_hlf; ! Return the error code. END %, $T20_GTJFN( options, file_spec, jfn_error ) = ! Get JFN BEGIN REGISTER $t20$ac1 = 1, $t20$ac2 = 2; BUILTIN JSYS; LOCAL $t20$status; $t20$ac1 = options; $t20$ac2 = file_spec; $t20$status = JSYS( t20$k_skip, GTJFN, $t20$ac1, $t20$ac2 ); IF .$t20$status ! If the open was successful, THEN ! jfn_error = .$t20$ac1 AND x20$k_right_hlf ! just save the JFN, ELSE ! otherwise, jfn_error = .$t20$ac1; ! return the error code. .$t20$status END % , $T20_HALTF = ! Halt the process BEGIN BUILTIN JSYS; JSYS( 0, HALTF ); END % , $T20_OPENF( jfn, options, error_bits ) = ! Open the file. BEGIN REGISTER $t20$ac1 = 1, $t20$ac2 = 2; BUILTIN JSYS; LOCAL $t20$status; $t20$ac1 = jfn; $t20$ac2 = options; $t20$status = JSYS( t20$k_skip, OPENF, $t20$ac1, $t20$ac2 ); %IF NOT %NULL( error_bits ) %THEN error_bits = .$t20$ac1; ! Return the error code. %FI .$t20$status END % , $T20_PBIN( character ) = ! Input a byte from the primary input designator(TTY:). BEGIN REGISTER $t20$ac1 = 1; BUILTIN JSYS; LOCAL $t20$status; $t20$status = JSYS( t20$k_non_skip, PBIN, $t20$ac1 ); character = .$t20$ac1; ! Return the byte. .$t20$status END % , $T20_PSOUT( string_pointer ) = ! Output to primary output designator(TTY:). BEGIN REGISTER $t20$ac1 = 1; BUILTIN JSYS; $t20$ac1 = string_pointer; JSYS( t20$k_non_skip, PSOUT, $t20$ac1 ) END %, $T20_RDTTY( string_pointer, options, ! Input a string from the TTY:. prompt_pointer,updated_ptr,bits_count ) = BEGIN REGISTER $t20$ac1 = 1, $t20$ac2 = 2, $t20$ac3 = 3; BUILTIN JSYS; LOCAL $t20$status; $t20$ac1 = string_pointer; $t20$ac2 = options; $t20$ac3 = prompt_pointer; $t20$status = JSYS( t20$k_skip, RDTTY, $t20$ac1, $t20$ac2, $t20$ac3 ); updated_ptr = .$t20$ac1; ! Return the updated pointer. bits_count = .$t20$ac2; ! Return any error code and the count. .$t20$status END % , $T20_RESET = ! Reset and initialize the current process BEGIN BUILTIN JSYS; JSYS( 0, RESET ); END % , $T20_RLJFN( jfn ) = ! Release JFN(s). BEGIN REGISTER $t20$ac1 = 1; BUILTIN JSYS; $t20$ac1 = jfn; JSYS( t20$k_skip, RLJFN, $t20$ac1 ); END %, $T20_RMAP( process, page, access ) = ! Returns the accessibility of a page. BEGIN REGISTER $t20$ac1 = 1, $t20$ac2 = 2; BUILTIN JSYS; LOCAL $t20$status; $t20$ac1 = (process)^18 + (page); $t20$status = JSYS( t20$k_non_skip, RMAP, $t20$ac1, $t20$ac2 ); access = .$t20$ac2; .$t20$status END %, $T20_RNAMF( old_jfn, new_jfn, error_bits ) = ! Rename an existing file. BEGIN REGISTER $t20$ac1 = 1, $t20$ac2 = 2; BUILTIN JSYS; LOCAL $t20$status; $t20$ac1 = old_jfn; $t20$ac2 = new_jfn; $t20$status = JSYS( t20$k_skip, RNAMF, $t20$ac1, $t20$ac2 ); %IF NOT %NULL( error_bits ) %THEN error_bits = .$t20$ac1; ! Return the error code. %FI .$t20$status END % , $T20_SFPTR( jfn, pointer ) = ! Adjust the file pointer. BEGIN REGISTER $t20$ac1 = 1, $t20$ac2 = 2; BUILTIN JSYS; $t20$ac1 = jfn; $t20$ac2 = pointer; JSYS( t20$k_skip, SFPTR, $t20$ac1, $t20$ac2 ); END %, $T20_SIN( jfn, pointer, ! String input. number_of_bytes, terminator, counter ) = BEGIN REGISTER $t20$ac1 = 1, $t20$ac2 = 2, $t20$ac3 = 3, $t20$ac4 = 4; BUILTIN JSYS; LOCAL $t20$status; $t20$ac1 = jfn; $t20$ac2 = pointer; $t20$ac3 = number_of_bytes; $t20$ac4 = terminator; $t20$status = JSYS( t20$k_non_skip, SIN, $t20$ac1, $t20$ac2, $t20$ac3, $t20$ac4 ); counter = .$t20$ac3 + ABS(number_of_bytes); ! Return the number of bytes transferred. .$t20$status END % , $T20_SOUT( jfn, pointer, ! String output. number_of_bytes, terminator ) = BEGIN REGISTER $t20$ac1 = 1, $t20$ac2 = 2, $t20$ac3 = 3, $t20$ac4 = 4; BUILTIN JSYS; $t20$ac1 = jfn; $t20$ac2 = pointer; $t20$ac3 = number_of_bytes; $t20$ac4 = terminator; JSYS( t20$k_non_skip, SOUT, $t20$ac1, $t20$ac2, $t20$ac3, $t20$ac4 ) END %;