ref: 6df84aac3adcbcc21c64312472347634d8237dc3
parent: e4bb030b6fd7e00652f7f58a815b149f7be85f7d
parent: d3862b5a63077cb3d8967f97eb487368cd431d23
author: Ori Bernstein <[email protected]>
date: Wed Aug 1 20:38:50 EDT 2012
Merge branch 'master' of git+ssh://mimir.eigenstate.org/git/ori/libmyr
--- a/bld.sh
+++ b/bld.sh
@@ -67,8 +67,3 @@
echo $COMP
$COMP
-build f.myr
-COMP="$CC -m32 -o f f.o -L. -lstd"
-echo $COMP
-$COMP
-
--- /dev/null
+++ b/fmt.myr
@@ -1,0 +1,34 @@
+use "die.use"
+use "sys.use"
+use "types.use"
+use "str.use"
+
+pkg std =
+ const bfmt : (buf : byte[,], fmt : byte[,], args:... -> size)
+ const fmt : (fmt : byte[,], args:... -> size)
+;;
+
+const fmt = {fmt, args
+ var c
+ var s
+ var n
+
+ n = 0
+ for (c, s) = striter(fmt); s.len; (c, s) = striter(s)
+ if c == '%'
+ (c, s) = striter(s)
+ match c
+ 's':
+ write(1, "str")
+ ;;
+ 'd':
+ write(1, "int")
+ ;;
+ 'p':
+ write(1, "ptr")
+ ;;
+ ;;
+ ;;
+ ;;
+ -> n
+}
--- /dev/null
+++ b/hello.myr
@@ -1,0 +1,19 @@
+use "sys.use"
+use "alloc.use"
+extern const printf : (str:byte*, ap:... -> void)
+const main = {
+ var x : byte*[1024]
+ var sz
+ var i
+
+ for sz = 1; sz < 65536; sz *= 2
+ for i = 0; i < 1024; i++
+ x[i] = std.bytealloc(sz)
+ ;;
+ for i = 0; i < 1024; i++
+ std.bytefree(x[i], sz)
+ ;;
+ ;;
+ std.write(1, "Hello world\n")
+ printf("some string %d %d \n" castto(byte*), 123, 456)
+}
--- a/syscall-linux.s
+++ b/syscall-linux.s
@@ -1,24 +1,22 @@
.globl std$syscall
std$syscall:
- pushl %ebp
+ pushq %rbp
/*
- hack: 6 args uses %ebp, so we index
- relative to %esp.
-
- hack: We load 6 args regardless of
- how many we actually have. This may
- load junk values, but if the syscall
- doesn't use them, it's going to be
- harmless.
+ hack: We load 6 args regardless of
+ how many we actually have. This may
+ load junk values, but if the syscall
+ doesn't use them, it's going to be
+ harmless.
*/
- movl 8(%esp),%eax
- movl 12(%esp),%ebx
- movl 16(%esp),%ecx
- movl 20(%esp),%edx
- movl 24(%esp),%esi
- movl 28(%esp),%edi
- movl 32(%esp),%ebp
+ movq 16(%rsp),%rax
+ movq 24(%rsp),%rdi
+ movq 32(%rsp),%rsi
+ movq 40(%rsp),%rdx
+ movq 48(%rsp),%r10
+ movq 56(%rsp),%r8
+ movq 64(%rsp),%r9
- int $0x80
- popl %ebp
+ sysenter
+
+ popq %rbp
ret