1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-29 06:37:41 +00:00

More work on x64 backend.

This commit is contained in:
Calvin Rose
2024-06-14 16:57:32 -05:00
parent 232a8faa35
commit 314e684097
4 changed files with 77 additions and 34 deletions

View File

@@ -2,4 +2,4 @@
build/janet examples/sysir/samples.janet > temp.nasm
nasm -felf64 temp.nasm -l temp.lst -o temp.o
ld -o temp.bin -dynamic-linker /lib64/ld-linux-x86-64.so.2 -lc temp.o
./temp.bin
valgrind ./temp.bin

View File

@@ -1,9 +1,13 @@
(use ./frontend)
(def square
'(defn square:int [num:int]
(return (* num num))))
(def simple
'(defn simple [x:int]
'(defn simple:int [x:int]
(def xyz:int (+ 1 2 3))
(return (* x 2 x))))
(return (the int (* x 2 x)))))
(def myprog
'(defn myprog:int []
@@ -16,6 +20,7 @@
(printf "i = %d\n" i))
(printf "hello, world!\n%d\n" (the int (if x abc xyz)))
(return (* abc xyz))))
#(return (the int (simple (* abc xyz))))))
(def doloop
'(defn doloop [x:int y:int]
@@ -35,6 +40,8 @@
####
#(compile1 square)
(compile1 simple)
(compile1 myprog)
(compile1 doloop)
(compile1 main-fn)