9. Operating System Routines

OSFIND Entry address &FFCE, vector address &21C

This is a dummy routine provided for compatibility with BBC BASIC. Its normal function is to open a file for reading and writing, but since this is not required by the ATOM COS and only one file (channel number 13) can be open at any time, the routine will not be used by the user.

OSGBPB Not implemented
OSBPUT Entry address &FFD4, vector address &218

This routine puts a byte in A to the tape. On entry Y contains the channel number (13). On exit A, X and Y are preserved, N, V and Z are undefined and D=0.

OSBGET Entry address &FFD7, vector address &216

This routine gets a byte from tape and returns it in A. On entry Y contains the channel number (13).
On exit X and Y are preserved, N, V, and Z are undefined and D=0.

OSARGS Not implemented
OSWRCH Entry address &FFEE, vector address &20E

This routine writes the character in A to the screen. On exit A, X and Y are preserved, C,N,V and Z are undefined and D=0. The interrupt state is preserved but interrupts may be enabled during the operation. All lower case letters are converted to upper case. The following control codes (in hex) are provided:

0 Does nothing
7 Bleep
8,9,A,B Cursor movements
C Clear screen
D Carriage return
E,F Page mode on/off
16 Select screen mode
19 PLOT M,X,Y
1E Home cursor
OSBYTE Entry address &FFF4, vector address &20A

The multi-purpose OS routine. The call number is passed in A and the X and Y registers are used to pass other values. Values are returned in X and/or Y. The calls and their functions are as follows:

Call
(Hex)
Function
7E Acknowledge escape condition.
81 Read key within time limit. The call waits for the specified time or until a key is pressed.
The delay in centiseconds is passed in Y (ms byte) and X (ls byte), maximum value &7FFF.
On exit Y contains either &1B if ESC was pressed, &FF if time-out occurred, or 0 with X containing the character detected. In the event of ESC being pressed, OSBYTE &7E must be used to acknowledge it. OSBYTE &81 with negative values in A is not implemented.
83 Read top of OS RAM address. This call returns the address of the first free location in memory above that required by the operating system in Y (ms byte) and X (ls byte).
84 Read bottom of display RAM address. This call returns the lowest memory address used by the screen in Y (ms byte) and X (ls byte).
OSWORD Entry address &FFF1, vector address &20C

This routine invokes a number of miscellaneous OS operations that require more data or return more values than can be handled by OSBYTE. It is entered with the call number in A, and Y (m.s. byte) and X (l.s. byte) pointing to a parameter block. The calls and their functions are as follows:

Call
(Hex)
Function
0 Read an input line.
On entry the parameter block should contain, starting at byte 0, the address of the buffer for the line (2 bytes), the maximum length of line, the minimum acceptable ASCII code, and the maximum acceptable ASCII code.
On exit C=1 indicates that the line was terminated by ESC rather than CR, and Y contains the length of the line, including the CR if C=0.
1 Read 5-byte system time.
This call reads the elapsed-time clock into the five bytes pointed to by X and Y.
The clock is incremented by one every 10 ms.
2 Write 5-byte system time.
This call writes the value at the five bytes pointed to by X and Y into the elapsed-time clock.
7 Generate a sound.
This call generates a sound defined by the four 2-byte values pointed to by X and Y.
Refer to the keyword
SOUND for details.
OSCLI Entry address &FFF7, vector address &208

This routine sends a command line to the interpreter.
On entry X (l. s. byte) and Y (m. s. byte) point to the command line, terminated by &D. Leading spaces and asterisks are removed.

Next Chapter