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

x64 allow dynamically switching between windows and sysv target.

This commit is contained in:
Calvin Rose
2024-06-17 23:01:11 -05:00
parent e5765b26d4
commit b6fb7ae69c
8 changed files with 89 additions and 59 deletions

View File

@@ -1,4 +1,4 @@
janet.exe examples/sysir/samples.janet > temp.nasm
janet.exe examples/sysir/windows_samples.janet > temp.nasm
nasm -fwin64 temp.nasm -l temp.lst -o temp.o
link /entry:Start /subsystem:windows kernel32.lib user32.lib temp.o /out:temp.exe
temp.exe

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash
build/janet examples/sysir/samples.janet > temp.nasm
valgrind 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
valgrind ./temp.bin

View File

@@ -38,24 +38,13 @@
(exit (the int 0))
(return)))
(def winmain
'(defn Start:void []
(MessageBoxExA (the pointer 0) "Hello, world!" "Test" 0 (the s16 0))
(ExitProcess (the int 0))
(return)))
####
#(compile1 square)
#(compile1 simple)
#(compile1 myprog)
#(compile1 doloop)
#(compile1 main-fn)
(compile1 winmain)
(compile1 square)
(compile1 simple)
(compile1 myprog)
(compile1 doloop)
(compile1 main-fn)
#(dump)
#(dumpc)
(dumpx64)
# Run with
# janet examples/sysir/scratch.janet > temp.nasm && nasm -felf64 temp.nasm -l temp.lst && ld temp.o && ./a.out

View File

@@ -0,0 +1,14 @@
(use ./frontend)
(def winmain
'(defn Start:void []
(MessageBoxExA (the pointer 0) "Hello, world!" "Test" 0 (the s16 0))
(ExitProcess (the int 0))
(return)))
####
(compile1 winmain)
#(dump)
#(dumpc)
(dumpx64)