aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile2
-rw-r--r--kernel/main.dats36
-rw-r--r--main_dats.c5
4 files changed, 33 insertions, 12 deletions
diff --git a/.gitignore b/.gitignore
index 641d5ba..a48f955 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@ build/
.ccls-cache/
.envrc
.direnv
+.out
+_dats.c
diff --git a/Makefile b/Makefile
index 4ee4e14..ef3446b 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@ CLFAGS_ATS :=
CFLAGS_ATS += -D_ATS_CCOMP_RUNTIME_NONE_
CFLAGS_ATS += -D_ATS_CCOMP_EXCEPTION_NONE_
-CFLAGS=-ffreestanding -mcmodel=large -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -m64
+CFLAGS=-ffreestanding -mcmodel=large -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -m64
.PHONY: all clean run iso
diff --git a/kernel/main.dats b/kernel/main.dats
index 1eb7813..e7a68f5 100644
--- a/kernel/main.dats
+++ b/kernel/main.dats
@@ -1,13 +1,37 @@
#include "share/atspre_staload.hats"
-typedef test = @{test2 = uint8}
+%{^
+ #define get_vram(_) ((void *) 0xB8000 + 1988)
+%}
+
+typedef cell = @{ ch = char, attrib = uint8 }
+
+extern fun get_vram {n: nat} (n : size_t n):<> [l: agz] (@[cell][n] @ l | ptr l) = "mac#"
+
+extern prfun eat_vram {l: agz} {n: int} (pf: @[cell][n] @ l): void
extern castfn uint8_of {n: nat} (i: int n): uint8 n
-implement main0 () =
-let
- val t = @{test2 = uint8_of(4)} : test
-in
- main0 ()
+fn string_length {n:nat} (str: string (n)) : size_t (n) = let
+ fun loop {i:nat | i <= n} .<n-i>. (str: string n, i: size_t i): size_t (n) =
+ if string_isnot_atend (str, i) then loop (str, succ(i)) else i
+in
+ loop (str, i2sz(0))
+end
+
+implement main0 () = let
+ val hello = "Hello world!"
+ val length = string_length hello
+ val color_byte = 0x1f
+ val (pf_vram | vram) = get_vram(length)
+ fun loop {l : agz} {n,i: nat | i <= n} .<n-i>. (pf: !(@[cell][n] @ l) | n : size_t n, i : int i, p : ptr l, str: string (n)) : void =
+ if n > i then (
+ p->[i] := @{ ch = str[i], attrib = uint8_of color_byte };
+ loop(pf | n,i+1,p,str))
+ else ()
+
+in
+ loop(pf_vram | length, 0, vram, hello);
+ let prval () = eat_vram pf_vram in () end
end
diff --git a/main_dats.c b/main_dats.c
deleted file mode 100644
index c334a63..0000000
--- a/main_dats.c
+++ /dev/null
@@ -1,5 +0,0 @@
-/* ****** ****** */
-//
-#error(PATSOPT_ERROR_(patsopt(kernel/main.dats): trans3-errors))
-//
-/* ****** ****** */