fa/std/mem/gmem.fa
Ari Archer 9bac4c1555
Add negative number support, argument support and get file contents example
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
2022-07-19 09:34:52 +03:00

42 lines
629 B
Text

include 'std/syscall.fa'
--<
Allocate memory
Takes:
INT: The buffer size
Returns:
INT: *buffer
>--
fun malloc [ int ] int eo
as __malloc_length -- Element from the stack
34 -- Flags
0 -- Offset
-1 -- Fd
3 -- Prot
@__malloc_length
deref -- Length
0 -- Addr
%SYS_mmap sys 7
unname __malloc_length
end
--<
Deallocate memory
Takes:
INT: The buffer size
INT: *buffer
Returns:
INT: ?error
>--
fun mfree [ int int ] int eo
%SYS_munmap sys 3
end