2023-03-20 14:13:34 +00:00
|
|
|
|
|
|
|
// Write to a file descriptor using the SYS_write syscall
|
2023-03-22 12:58:11 +00:00
|
|
|
// 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
|
2023-03-20 14:13:34 +00:00
|
|
|
// @ret Int
|
2023-04-12 21:34:08 +00:00
|
|
|
fn write with int ptr int returns int then
|
2023-03-20 14:13:34 +00:00
|
|
|
SYS_write syscall3
|
2023-04-12 21:34:08 +00:00
|
|
|
done
|
2023-03-20 14:13:34 +00:00
|
|
|
|
2023-03-22 12:58:11 +00:00
|
|
|
// 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
|
2023-04-12 21:34:08 +00:00
|
|
|
fn read with int ptr int returns int then
|
2023-03-22 12:58:11 +00:00
|
|
|
SYS_read syscall3
|
2023-04-12 21:34:08 +00:00
|
|
|
done
|
2023-03-22 12:58:11 +00:00
|
|
|
|
2023-03-20 14:13:34 +00:00
|
|
|
|
|
|
|
// Print a string to STDOUT
|
|
|
|
// args: [str_size, str_ptr]
|
2023-03-22 12:58:11 +00:00
|
|
|
// @arg buff_size: Int - number of bytes to write
|
|
|
|
// @arg buff_ptr: Ptr - pointer to the buffer to write
|
2023-03-20 14:13:34 +00:00
|
|
|
// @ret NULL
|
2023-04-12 21:34:08 +00:00
|
|
|
fn puts with int ptr returns void then
|
2023-03-20 14:13:34 +00:00
|
|
|
STDOUT write drop
|
2023-04-12 21:34:08 +00:00
|
|
|
done
|
2023-03-20 14:13:34 +00:00
|
|
|
|
|
|
|
// Print a string to STDERR
|
|
|
|
// args: [str_size, str_ptr]
|
2023-03-22 12:58:11 +00:00
|
|
|
// @arg buff_size: Int - number of bytes to write
|
|
|
|
// @arg buff_ptr: Ptr - pointer to the buffer to write
|
2023-03-20 14:13:34 +00:00
|
|
|
// @ret NULL
|
2023-04-12 21:34:08 +00:00
|
|
|
fn eputs with int ptr returns void then
|
2023-03-20 14:13:34 +00:00
|
|
|
STDOUT write drop
|
2023-04-12 21:34:08 +00:00
|
|
|
done
|
2023-03-20 14:13:34 +00:00
|
|
|
|
|
|
|
// 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
|
2023-04-12 21:34:08 +00:00
|
|
|
fn exit with int returns void then
|
2023-03-20 14:13:34 +00:00
|
|
|
SYS_exit syscall1 drop
|
2023-04-12 21:34:08 +00:00
|
|
|
done
|
2023-03-20 14:13:34 +00:00
|
|
|
|