diff options
author | Xander <xander@biltopia.org> | 2023-07-14 17:16:54 +0200 |
---|---|---|
committer | Xander <xander@biltopia.org> | 2023-07-14 17:16:54 +0200 |
commit | 5ad68a0c087d21fa1d0f82bea1550169f1e4c1aa (patch) | |
tree | f9d68644254e60926e568071cfbd5fcd2dc1ad5b /kernel/prelude/DATS/print.dats | |
parent | 059b5ba286b3fef4d01c3ced9cd829ace5dd6340 (diff) | |
download | ats-os-5ad68a0c087d21fa1d0f82bea1550169f1e4c1aa.tar.xz ats-os-5ad68a0c087d21fa1d0f82bea1550169f1e4c1aa.zip |
Preparing for multiboot information
Diffstat (limited to 'kernel/prelude/DATS/print.dats')
-rw-r--r-- | kernel/prelude/DATS/print.dats | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/kernel/prelude/DATS/print.dats b/kernel/prelude/DATS/print.dats index 6d378fa..0b5c38a 100644 --- a/kernel/prelude/DATS/print.dats +++ b/kernel/prelude/DATS/print.dats @@ -5,16 +5,38 @@ staload "lib/SATS/writer.sats" staload "lib/DATS/itoa.dats" +staload UN = "prelude/SATS/unsafe.sats" + extern fun print_newline() : void implement print_newline() = put_string("\n") extern fun assert_errmsg(b: bool, msg: string) : void implement assert_errmsg(b,msg) = if (~b) then put_string(msg) -extern fun print_int (n : int) : void +extern fun print_int (n : int) : void implement print_int(n) = put_string(itoa(n,10)) - + +extern fun print_uint32 (n : uint32) : void +implement print_uint32 (n) = put_string(itoa($UN.cast{int}(n),10)) + +extern fun print_uint16 (n : uint16) : void +implement print_uint16 (n) = put_string(itoa($UN.cast{int}(n),10)) + +extern fun print_uint8 (n : uint8) : void +implement print_uint8 (n) = put_string(itoa($UN.cast{int}(n),10)) + +extern fun print_uint64 (n : uint64) : void +implement print_uint64 (n) = put_string(itoa($UN.cast{int}(n),10)) + overload print with put_string of 1 overload print with print_int of 1 +overload print with print_uint32 of 1 +overload print with print_uint64 of 1 +overload print with print_uint16 of 1 +overload print with print_uint8 of 1 + +extern fun {a : t@ype} println_base {n:nat | n > 1 && n < 33} (n :a, base : int n) : void +implement{a} println_base(n,base) = println!(itoa($UN.cast{int}(n), base)) +macdef println_hex(s) = (put_string "0x"; println_base(,(s), 16)) macdef assertloc(tf) = assert_errmsg (,(tf), $mylocation) |