summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-12-24 13:41:53 -0800
committerOri Bernstein <ori@eigenstate.org>2014-12-24 13:41:53 -0800
commit5e0ca55f184256a7a3868843bec2922b56a1126f (patch)
tree71cb9c5d577df29c4084e90835e826b35bba12f4
parent193c0a031b36a4d6d0ca90bb56d1427fd1b15bc0 (diff)
downloadmc-5e0ca55f184256a7a3868843bec2922b56a1126f.tar.gz
Get plan9 even closer to workingness.
A few more oddities.
-rw-r--r--6/genp9.c5
-rw-r--r--libstd/mkfile3
-rw-r--r--libstd/util+plan9-x64.s40
-rw-r--r--mkfile2
-rw-r--r--rt/_myrrt-plan9.s20
5 files changed, 41 insertions, 29 deletions
diff --git a/6/genp9.c b/6/genp9.c
index 8694234..af1b715 100644
--- a/6/genp9.c
+++ b/6/genp9.c
@@ -246,7 +246,7 @@ static size_t writebytes(FILE *fd, char *name, size_t off, char *p, size_t sz)
size_t i, len;
for (i = 0; i < sz; i++) {
- len = min(i, 8);
+ len = min(sz - i, 8);
if (i % 8 == 0)
fprintf(fd, "DATA %s+%zd(SB)/%zd,$\"", name, off + i, len);
if (p[i] == '"' || p[i] == '\\')
@@ -426,6 +426,7 @@ static void genstrings(FILE *fd, Htab *strtab)
k = htkeys(strtab, &nk);
for (i = 0; i < nk; i++) {
s = k[i];
+ fprintf(fd, "GLOBL %s+0(SB),$%lld\n", htget(strtab, k[i]), (vlong)s->len);
writebytes(fd, htget(strtab, k[i]), 0, s->buf, s->len);
}
}
@@ -436,7 +437,7 @@ static void writeasm(FILE *fd, Isel *s, Func *fn)
size_t i, j;
char *hidden;
- hidden = "<>";
+ hidden = "";
if (fn->isexport || streq(fn->name, Symprefix "main"))
hidden = "";
fprintf(fd, "TEXT %s%s+0(SB),$%zd\n", fn->name, hidden, fn->stksz);
diff --git a/libstd/mkfile b/libstd/mkfile
index 48dcfcd..bb80c59 100644
--- a/libstd/mkfile
+++ b/libstd/mkfile
@@ -92,10 +92,11 @@ lib$SYSLIB.a: $SYSSRC $SYSASMSRC
OBJ=${STDSRC:%.myr=%.o} ${SYSSRC:%.myr=%.o} ${STDASMSRC:%.s=%.o} ${SYSASMSRC:%.s=%.o}
USE=${STDSRC:%.myr=%.use} ${SYSSRC:%.myr=%.use} ${STDLIB}
+LIBS=lib$STDLIB.a lib$SYSLIB.a
.PHONY: clean
clean:V:
rm -f $OBJ
rm -f $USE
- rm -f lib${STDLIB}.a lib${SYSLIB}.a
+ rm -f $LIBS
nuke:V: clean
diff --git a/libstd/util+plan9-x64.s b/libstd/util+plan9-x64.s
index 7351118..17d5c21 100644
--- a/libstd/util+plan9-x64.s
+++ b/libstd/util+plan9-x64.s
@@ -10,12 +10,13 @@
*/
TEXT sys$cstring+0(SB),$0
/* save registers */
- PUSHQ BP
+ SUBQ $48,SP
+ MOVQ BP,40(SP)
MOVQ SP,BP
- PUSHQ R15
- PUSHQ SI
- PUSHQ DI
- PUSHQ CX
+ MOVQ R15,32(SP)
+ MOVQ SI,24(SP)
+ MOVQ DI,16(SP)
+ MOVQ CX,8(SP)
MOVQ 8(BP),R15 /* ret addr */
MOVQ 16(BP),SI /* src */
@@ -30,9 +31,9 @@ TEXT sys$cstring+0(SB),$0
CLD
REP; MOVSB
- MOVB $0,(DI) /* terminate */
+ MOVB $0,(DI) /* terminate */
- PUSHQ R15 /* ret addr */
+ MOVQ R15,0(SP) /* ret addr */
/* Restore registers */
MOVQ -32(BP),CX
@@ -44,26 +45,27 @@ TEXT sys$cstring+0(SB),$0
TEXT sys$alloca+0(SB),$0
/* save registers */
- PUSHQ BP
- MOVQ SP,BP
- PUSHQ R15
- PUSHQ BX
+ SUBQ $32,SP
+ MOVQ BP,24(SP)
+ MOVQ SP,BP
+ MOVQ R15,16(SP)
+ MOVQ BX,8(SP)
MOVQ 8(BP),R15 /* ret addr */
MOVQ 16(BP),BX /* len */
/* get stack space */
- SUBQ BX,SP /* get stack space */
- MOVQ SP,AX /* top of stack (return value) */
- SUBQ $16,SP /* "unpop" the args for return */
- ANDQ $(~15),SP /* align */
+ SUBQ BX,SP /* get stack space */
+ MOVQ SP,AX /* top of stack (return value) */
+ SUBQ $16,SP /* "unpop" the args for return */
+ ANDQ $(~15),SP /* align */
- PUSHQ R15 /* ret addr */
+ MOVQ R15,0(SP) /* ret addr */
/* restore registers */
- MOVQ -16(BP),BX
- MOVQ -8(BP),R15
- MOVQ (BP),BP
+ MOVQ -16(BP),BX
+ MOVQ -8(BP),R15
+ MOVQ (BP),BP
RET
TEXT sys$gettos+0(SB),$0
diff --git a/mkfile b/mkfile
index d94faec..dd1882e 100644
--- a/mkfile
+++ b/mkfile
@@ -44,6 +44,6 @@ config.h:
echo '#define Instroot "'/'"' > config.h
echo '#define Asmcmd {"6a", "-o", NULL}' >> config.h
echo '#define Linkcmd {"ar", "ru", NULL}' >> config.h
- echo '#define Symprefix "_"' >> config.h
+ echo '#define Symprefix ""' >> config.h
echo '#define Defaultasm Plan9' >> config.h
diff --git a/rt/_myrrt-plan9.s b/rt/_myrrt-plan9.s
index c9d5853..31e8011 100644
--- a/rt/_myrrt-plan9.s
+++ b/rt/_myrrt-plan9.s
@@ -9,11 +9,19 @@ TEXT _main(SB), 1, $(2*8+NPRIVATES*8)
LEAQ inargv+0(FP), AX
MOVQ AX, 8(SP)
CALL main(SB)
+exitloop:
+ MOVQ $0,estatus+0(FP)
+ MOVQ $8,RARG
+ SYSCALL
+ JMP exitloop
-loop:
- MOVQ $_exits<>(SB), RARG
- CALL exits(SB)
- JMP loop
+TEXT _rt$abort_oob(SB),1,$0
+broke:
+ XORQ AX,AX
+ MOVQ $1234,(AX)
+ JMP broke
-DATA _exits<>+0(SB)/4, $"main"
-GLOBL _exits<>+0(SB), $5
+GLOBL argv0(SB), $8
+GLOBL _tos(SB), $8
+GLOBL _privates(SB), $8
+GLOBL _nprivates(SB), $4