fa/examples/repeat.fa
Ari Archer c30a3de674
Deprecate mutability contexts
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
2022-07-27 13:41:50 +03:00

24 lines
549 B
Text

include 'std/std.fa'
include 'std/mem/gmem.fa'
macro SIZE 2 128 mul end
fun main [ str str int ] eo
%SIZE #malloc -- Allocate SIZE ammount of bytes
as string -- Store buffer as a pointer
"What do I repeat? " %STDOUT %fputs
%SIZE @string deref %STDIN
%SYS_read sys 4 -- read(STDIN, *string, SIZE) => <bytes_read>
1 swap sub @string deref
%puts -- puts(string) => null
%SIZE @string deref #mfree
pop -- free(string) => null
0 %exit
end
#main