mclangc/include/io.mcl
MCorange 7e46c07cca Finalising functions
typechecking still buggy, but close enough cause i cant handle any more
typechecker dev

added:
 - Functions
 - Constants
 - Better file positions for error reporting
 - Better error reporting, with examples being drawn in term

-MC
2023-04-13 00:34:08 +03:00

51 lines
1.3 KiB
Plaintext

// Write to a file descriptor using the SYS_write syscall
// args: [buff_size, buff_ptr, fd]
// @arg buff_size: Int - number of bytes to write
// @arg buff_ptr: Ptr - pointer to the buffer to write
// @arg fd: Int - file descriptor
// @ret Int
fn write with int ptr int returns int then
SYS_write syscall3
done
// Write to a file descriptor using the SYS_write syscall
// args: [buff_size, buff_ptr, fd]
// @arg buff_size: Int - number of bytes to write
// @arg buff_ptr: Ptr - pointer to the buffer to write
// @arg fd: Int - file descriptor
// @ret Int
fn read with int ptr int returns int then
SYS_read syscall3
done
// Print a string to STDOUT
// args: [str_size, str_ptr]
// @arg buff_size: Int - number of bytes to write
// @arg buff_ptr: Ptr - pointer to the buffer to write
// @ret NULL
fn puts with int ptr returns void then
STDOUT write drop
done
// Print a string to STDERR
// args: [str_size, str_ptr]
// @arg buff_size: Int - number of bytes to write
// @arg buff_ptr: Ptr - pointer to the buffer to write
// @ret NULL
fn eputs with int ptr returns void then
STDOUT write drop
done
// TODO: make putc and eputc after we make local mem
// Exit the program with exit_code
// args: [exit_code]
// @arg exit_code: Int
// @ret NULL/NEVER
fn exit with int returns void then
SYS_exit syscall1 drop
done