Added cstrings
This commit is contained in:
@@ -16,3 +16,9 @@ const FS_O_PATH 2097152 end // open descriptor for obtaining permissions and sta
|
||||
const FS_O_SYNC 1052672 end // wait for IO to complete before returning
|
||||
const FS_O_TMPFILE 4259840 end // create an unnamed, unreachable (via any other open call) temporary file
|
||||
const FS_O_TRUNC 512 end // if file exists, ovewrite it (careful!)
|
||||
|
||||
|
||||
fn fs_read_to_string with int ptr returns int ptr then
|
||||
|
||||
|
||||
done
|
||||
@@ -5,7 +5,7 @@
|
||||
// @arg buff_ptr: Ptr - pointer to the buffer to write
|
||||
// @arg fd: Int - file descriptor
|
||||
// @ret Int
|
||||
inline fn write with int ptr int returns int then
|
||||
inline fn fwrite with int ptr int returns int then
|
||||
SYS_write syscall3
|
||||
done
|
||||
|
||||
@@ -15,18 +15,29 @@ done
|
||||
// @arg buff_ptr: Ptr - pointer to the buffer to write
|
||||
// @arg fd: Int - file descriptor
|
||||
// @ret Int
|
||||
inline fn read with int ptr int returns int then
|
||||
inline fn fread with int ptr int returns int then
|
||||
SYS_read syscall3
|
||||
done
|
||||
|
||||
|
||||
// Write to a file descriptor using the SYS_write syscall
|
||||
// args: [buff_ptr, flags, mode]
|
||||
// @arg buff_ptr: Ptr - File to open
|
||||
// @arg flags: Int - Flags
|
||||
// @arg mode: Int - Mode
|
||||
// @ret Int - Fd
|
||||
inline fn fopen with int ptr int returns int then
|
||||
SYS_open 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
|
||||
inline fn puts with int ptr returns void then
|
||||
STDOUT write drop
|
||||
STDOUT fwrite drop
|
||||
done
|
||||
|
||||
// Print a string to STDERR
|
||||
@@ -35,7 +46,7 @@ done
|
||||
// @arg buff_ptr: Ptr - pointer to the buffer to write
|
||||
// @ret NULL
|
||||
inline fn eputs with int ptr returns void then
|
||||
STDOUT write drop
|
||||
STDOUT fwrite drop
|
||||
done
|
||||
|
||||
// TODO: make putc and eputc after we make local mem
|
||||
|
||||
Reference in New Issue
Block a user