We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
Migol 11/IO Functions
Jump to navigation
Jump to search
This is a list of all the currently available I/O functions in Migol 11.
I/O operations are initiated by writing pointers to data structures to the execution register, !. This page describes the format of each structure and the associated I/O operation.
I/O function list
| Immediate interrupt | |
|---|---|
| Position | Value |
| 0 | 5 |
| Adds the operation data structure to the interrupt queue immediately. Can be used for software interrupts. | |
| Read from I/O channel | |
|---|---|
| Position | Value |
| 0 | 10 |
| 1 | I/O handle |
| 2 | Read buffer address |
| 3 | Read buffer length |
| 4 | Error number |
| 5 | Number of bytes read (-1 if error) |
| Reads as many bytes as possible from the I/O channel to the buffer. | |
| Write to I/O channel | |
|---|---|
| Position | Value |
| 0 | 11 |
| 1 | I/O handle |
| 2 | Write buffer address |
| 3 | Write buffer length |
| 4 | Error number |
| 5 | Number of bytes written (-1 if error) |
| Writes as many bytes as possible from buffer to the I/O channel | |
| Close I/O channel | |
|---|---|
| Position | Value |
| 0 | 12 |
| 1 | I/O handle |
| 2 | Error number |
| Closes the I/O channel | |
| Open file channel | |
|---|---|
| Position | Value |
| 0 | 20 |
| 1 | File name address |
| 2 | File name length |
| 3 | File mode |
| 4 | Error number |
| 5 | New file channel handle (-1 if operation fails) |
| Opens a new file channel | |
| Get file channel position | |
|---|---|
| Position | Value |
| 0 | 24 |
| 1 | File channel handle |
| 2 | Error number |
| 3 | File channel position (-1 if the operation fails) |
| Obtains the current file position of the file channel | |
| Set file channel position | |
|---|---|
| Position | Value |
| 0 | 25 |
| 1 | File channel handle |
| 2 | New file channel position |
| 3 | Error number |
| Sets the file position of the file channel | |
| Get file size | |
|---|---|
| Position | Value |
| 0 | 26 |
| 1 | File channel handle |
| 2 | Error number |
| 3 | File size (-1 if the operation fails) |
| Obtains the file size of the file channel | |
| Open TCP socket | |
|---|---|
| Position | Value |
| 0 | 30 |
| 1 | IP address type |
| 2 | Pointer to IP address |
| 3 | Port number |
| 4 | Error number |
| 5 | Socket channel handle |
| Opens a connection to a TCP socket | |
| Open server socket | |
|---|---|
| Position | Value |
| 0 | 31 |
| 1 | Port number |
| 2 | Error number |
| 3 | New server socket channel handle |
| Opens a new server socket for listening to incoming TCP connections | |
| Listen to server socket | |
|---|---|
| Position | Value |
| 0 | 32 |
| 1 | Server socket handle |
| 2 | Error number |
| 3 | New socket channel handle |
| Listens to a incoming connection from a specific server socket and creates a new TCP connection. | |
| Resolve DNS Address to IP Address | |
|---|---|
| Position | Value |
| 0 | 34 |
| 1 | DNS name memory address |
| 2 | DNS name memory length |
| 3 | Address where the IP address is saved |
| 4 | Error number |
| 5 | IP address type |
| Resolves a DNS name to a IPv4 or IPv6 address | |
| Get current time in milliseconds | |
|---|---|
| Position | Value |
| 0 | 70 |
| 1 | The current time |
| Obtains the current system time, measured in milliseconds. | |
| Timed interrupt | |
|---|---|
| Position | Value |
| 0 | 71 |
| 1 | Delay until interrupt occurs |
| 2 | Time in milliseconds when the interrupt occured |
| Schedules an interrupt after a specific amount of milliseconds. This feature can be used to implement preemptive multitasking. | |
Various tables
Predefined I/O channels
| Number | Description |
|---|---|
| 1 | STDIN |
| 2 | STDOUT |
| 3 | STDERR |
IP address types
| Number | Description |
|---|---|
| 0 | IPv4, each byte is stored in a separate memory cell |
| 1 | IPv6, each byte is stored in a separate memory cell |
File opening mode
| Number | Description |
|---|---|
| 0 | Read-only |
| 1 | Read and write |
I/O error numbers
| Number | Description |
|---|---|
| 0 | No error |
| 1 | Unspecified I/O error |
| 2 | I/O channel does not exist |
| 3 | Illegal operation argument |
| 4 | Operation not supported for this channel |
| 5 | Operation refused by operating system/runtime |