diff options
| -rw-r--r-- | compiler/elymasGlobalSysAsm.ey | 13 | ||||
| -rw-r--r-- | compiler/standardClient.ey | 39 | ||||
| l--------- | examples/working-compiler/asm.test | 1 | ||||
| l--------- | examples/working-compiler/cat.test | 1 | ||||
| -rw-r--r-- | examples/working-compiler/io.test | 16 | ||||
| l--------- | examples/working-compiler/strcat.test | 1 | ||||
| l--------- | examples/working-compiler/testing.test | 1 | ||||
| -rw-r--r-- | examples/working/syscall.ey | 1 |
8 files changed, 72 insertions, 1 deletions
diff --git a/compiler/elymasGlobalSysAsm.ey b/compiler/elymasGlobalSysAsm.ey index 7bb79f6..c24ef5e 100644 --- a/compiler/elymasGlobalSysAsm.ey +++ b/compiler/elymasGlobalSysAsm.ey @@ -37,6 +37,19 @@ :retn ]] /eypoke defv + # call absolute address + # 0 -> address to call + [[ + /rbx :popqReg + + /rax :popqReg + 8 /rax /rax :movqMemDisp8Reg + /rax :callqReg + + /rbx :pushqReg + :retn + ]] /eyexecute defv + # conduct a syscall # 0 -> syscall number, rax before entry # 1 -> rdi before entry diff --git a/compiler/standardClient.ey b/compiler/standardClient.ey index c865a5e..a788d92 100644 --- a/compiler/standardClient.ey +++ b/compiler/standardClient.ey @@ -1,16 +1,26 @@ -< +< # sys extensions # TODO: handle EINTR correctly 0 _ ==RDONLY 1 _ ==WRONLY 2 _ ==RDWR bor bor ==RWMASK + + 1 ==PROTREAD + 2 ==PROTWRITE + 4 ==PROTEXEC + + 2 ==MAPPRIVATE + 32 ==MAPANONYMOUS 0 ==READ 1 ==WRITE 2 ==OPEN 3 ==CLOSE + 9 ==MMAP + 11 ==MUNMAP + { < ==mode ==flags ==fd < { flags RWMASK bnot band RDONLY bor =flags } /readonly deff { flags RWMASK bnot band WRONLY bor =flags } /writeonly deff @@ -53,6 +63,33 @@ 0 RDONLY 0 makefile /in sys .defv 1 WRONLY 0 makefile /out sys .defv 2 WRONLY 0 makefile /err sys .defv + + < # sys .asm extensions + { ==reqAddr ==reqSize + < + reqAddr + reqSize + PROTEXEC PROTREAD PROTWRITE bor bor + MAPPRIVATE MAPANONYMOUS bor + 1 neg + 0 + MMAP sys .asm .syscall -- _ + 0 lt { "mmap failed" die } rep + + ==base + reqSize ==size + + { + base size 0 0 0 0 MUNMAP sys .asm .syscall -- + 0 lt { "munmap failed" die } rep + } =*free + > + } /allocAt sys .asm .deff + + { + 0 sys .asm .allocAt + } /alloc sys .asm .deff + > -- > -- # vim: syn=elymas diff --git a/examples/working-compiler/asm.test b/examples/working-compiler/asm.test new file mode 120000 index 0000000..04060ba --- /dev/null +++ b/examples/working-compiler/asm.test @@ -0,0 +1 @@ +../working/asm.ey
\ No newline at end of file diff --git a/examples/working-compiler/cat.test b/examples/working-compiler/cat.test new file mode 120000 index 0000000..730f793 --- /dev/null +++ b/examples/working-compiler/cat.test @@ -0,0 +1 @@ +../working/cat.ey
\ No newline at end of file diff --git a/examples/working-compiler/io.test b/examples/working-compiler/io.test new file mode 100644 index 0000000..a835c28 --- /dev/null +++ b/examples/working-compiler/io.test @@ -0,0 +1,16 @@ +# ## variant 0 +# +# < sys .file with +# "io.ey" RO open +# 512 read +# close +# > - + +## variant 1 + +sys .file /f defv +"io.test" f .open +512 f .read +f .close + +sys .out .writeall diff --git a/examples/working-compiler/strcat.test b/examples/working-compiler/strcat.test new file mode 120000 index 0000000..d90f3e4 --- /dev/null +++ b/examples/working-compiler/strcat.test @@ -0,0 +1 @@ +../working/strcat.ey
\ No newline at end of file diff --git a/examples/working-compiler/testing.test b/examples/working-compiler/testing.test new file mode 120000 index 0000000..4eae848 --- /dev/null +++ b/examples/working-compiler/testing.test @@ -0,0 +1 @@ +../working/testing.ey
\ No newline at end of file diff --git a/examples/working/syscall.ey b/examples/working/syscall.ey new file mode 100644 index 0000000..4b17190 --- /dev/null +++ b/examples/working/syscall.ey @@ -0,0 +1 @@ +"not available in the interpreter" die |
