Documentation of kernel API

This commit is contained in:
Kyle J Cardoza 2024-07-08 17:14:01 -04:00
parent 7eb76db305
commit 69cda888f5
1 changed files with 58 additions and 58 deletions

View File

@ -1,21 +1,21 @@
# System Calls # System Calls
The system API is exposed to user code using the COP interrupt. The system API is exposed to user code using the COP interrupt.
The B accumulator is loaded with a function number; The B accumulator is loaded with a function number;
the other registers are loaded with call-specific data (or nothing), the other registers are loaded with call-specific data (or nothing),
and any return values are placed in the same registers. and any return values are placed in the same registers.
What follows is a list of the system calls, their numbers, and What follows is a list of the system calls, their numbers, and
register arguments they take, and what if any values they return. register arguments they take, and what if any values they return.
The system API is based loosely on, but not compatible with, that of The system API is based loosely on, but not compatible with, that of
CP/M-3 and MSX-DOS 2. CP/M-3 and MSX-DOS 2.
## 0x00: Terminate with Error Code ## 0x00: Terminate with Error Code
Arguments: Arguments:
C: 0x00 C: 0x00
X: Error code X: Error code
Return Values: Return Values:
This call does not return. This call does not return.
@ -24,13 +24,13 @@ This call exits the calling program, setting the exit status code
for the system on its way out. Program control will be returned to for the system on its way out. Program control will be returned to
the command shell. the command shell.
## 0x01: Console Input ## 0x01: Console Input
Arguments: Arguments:
C: 0x01 C: 0x01
Return Values: Return Values:
C: Character read from stdin C: Character read from stdin
This call reads one character from standard input. If there is no character This call reads one character from standard input. If there is no character
ready, this call waits until there is one. The read character will also be ready, this call waits until there is one. The read character will also be
@ -41,11 +41,11 @@ This call traps certain sequences of characters for "terminal control"
purposes. When this call traps such a character, it outputs nothing an purposes. When this call traps such a character, it outputs nothing an
continues waiting for another character to be ready. continues waiting for another character to be ready.
## 0x02: Console Output ## 0x02: Console Output
Arguments: Arguments:
C: 0x02 C: 0x02
X: Character to output X: Character to output
Return Values: Return Values:
None None
@ -54,36 +54,36 @@ This call sends a single chracter to the standard output, which is usually
the terminal emulator. The character will be parsed by the terminal emulator the terminal emulator. The character will be parsed by the terminal emulator
to handle control characters and escape sequences. to handle control characters and escape sequences.
## 0x03: Direct Console Input ## 0x03: Direct Console Input
Arguments: Arguments:
C: 0x03 C: 0x03
Return Values: Return Values:
C: Character value C: Character value
This call does direct (raw) console input; if there is a character ready, it This call does direct (raw) console input; if there is a character ready, it
will be read, and if not, NULL will be returned. will be read, and if not, NULL will be returned.
## 0x04: Direct Console Output ## 0x04: Direct Console Output
Arguments: Arguments:
C: 0x04 C: 0x04
X: Character value X: Character value
Return Values: Return Values:
C: Character value C: Character value
This call does direct (raw) console output; the value supplied will be treated This call does direct (raw) console output; the value supplied will be treated
as the value to write to screen memory, and will not be interpreted for terminal as the value to write to screen memory, and will not be interpreted for terminal
control. control.
## 0x05: String Output ## 0x05: String Output
Arguments: Arguments:
C: 0x05 C: 0x05
X: Address of string (15:0) X: Address of string (15:0)
Y: Address of string (23:16) Y: Address of string (23:16)
Return Values: Return Values:
None None
@ -91,53 +91,53 @@ Return Values:
This call uses the 0x02 call "Console Output" above to send a NULL-terminated This call uses the 0x02 call "Console Output" above to send a NULL-terminated
string to stdout. string to stdout.
## 0x06: Buffered Line Input ## 0x06: Buffered Line Input
Arguments: Arguments:
C: 0x06 C: 0x06
X: Address of buffer (15:0) X: Address of buffer (15:0)
Y: Address of buffer (23:16) Y: Address of buffer (23:16)
Return values: Return values:
C: Error code C: Error code
This call will read up to 255 characters from stdin, or up to the first newline, This call will read up to 255 characters from stdin, or up to the first newline,
whichever comes first. While taking input, a simple line editor is presented to whichever comes first. While taking input, a simple line editor is presented to
the user. When the 255th character has been entered into the buffer, any further the user. When the 255th character has been entered into the buffer, any further
input will be ignored until a newline is entered. input will be ignored until a newline is entered.
The newline in the resulting buffer will be replaced with a NULL to terminate the The newline in the resulting buffer will be replaced with a NULL to terminate the
string. string.
## 0x07: Console Status ## 0x07: Console Status
Arguments: Arguments:
C: 0x07 C: 0x07
Return Values: Return Values:
C: Status Code C: Status Code
This call checks stdin for a character to read. If there is none, this call will return This call checks stdin for a character to read. If there is none, this call will return
zero in A; if there is a character ready, it will return nonzero in A. zero in A; if there is a character ready, it will return nonzero in A.
## 0x08: Return Version Number ## 0x08: Return Version Number
Arguments: Arguments:
C: 0x08 C: 0x08
Return Values: Return Values:
C: Major version C: Major version
X: Minor version X: Minor version
Y: Micro version Y: Micro version
This call returns the version number of the kernel. This call returns the version number of the kernel.
## 0x09: Get Date ## 0x09: Get Date
Arguments: Arguments:
C: 0x09 C: 0x09
X: Bank of buffer X: Bank of buffer
Y: Address of buffer Y: Address of buffer
Return Values: Return Values:
None None
@ -152,12 +152,12 @@ in the following format:
uint8_t weekday; // 0 = Sunday..6=Saturday uint8_t weekday; // 0 = Sunday..6=Saturday
} }
## 0x0A: Set Date ## 0x0A: Set Date
Arguments: Arguments:
C: 0x0A C: 0x0A
X: Bank of buffer X: Bank of buffer
Y: Address of buffer Y: Address of buffer
Return Values: Return Values:
None None
@ -172,12 +172,12 @@ which must be in the following format:
uint8_t weekday; // 0 = Sunday..6=Saturday uint8_t weekday; // 0 = Sunday..6=Saturday
}; };
## 0x0B: Get Time ## 0x0B: Get Time
Arguments: Arguments:
C: 0x0B C: 0x0B
X: Bank of buffer X: Bank of buffer
Y: Address of buffer Y: Address of buffer
Return Values: Return Values:
None None
@ -191,12 +191,12 @@ in the following format:
uint8_t second; // 0..59 uint8_t second; // 0..59
}; };
## 0x0C: Set Time ## 0x0C: Set Time
Arguments: Arguments:
C: 0x0C C: 0x0C
X: Bank of buffer X: Bank of buffer
Y: Address of buffer Y: Address of buffer
Return Values: Return Values:
None None
@ -210,15 +210,15 @@ be in the following format:
uint8_t second; // 0..59 uint8_t second; // 0..59
}; };
## 0x0D: Open File ## 0x0D: Open File
Arguments: Arguments:
C: 0x0D C: 0x0D
X: Bank of pathname string X: Bank of pathname string
Y: Address of pathname string Y: Address of pathname string
Return Values: Return Values:
C: File handle or error code C: File handle or error code
This call attempts to open the file referred to by the provided NULL-terminated This call attempts to open the file referred to by the provided NULL-terminated
string, which must contain a fully-qualified pathname -- something of the form string, which must contain a fully-qualified pathname -- something of the form