From 17f77da27d807ca4489a92a23506c88fb60bd89e Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 10 Apr 2021 18:32:27 -0700 Subject: shell: fake screens I just realized Mu has a pretty big weakness: writes to null pointers don't error out. Perhaps writes to address 0 do, but address 1 and so on don't? I need a slightly more sophisticated page table. --- shell/cell.mu | 2 ++ shell/print.mu | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/shell/cell.mu b/shell/cell.mu index 11a16821..b2b302e6 100644 --- a/shell/cell.mu +++ b/shell/cell.mu @@ -121,6 +121,8 @@ fn allocate-screen _out: (addr handle cell) { var out/eax: (addr handle cell) <- copy _out allocate out var out-addr/eax: (addr cell) <- lookup *out + var dest-ah/ecx: (addr handle screen) <- get out-addr, screen-data + allocate dest-ah var type/ecx: (addr int) <- get out-addr, type copy-to *type, 5/screen } diff --git a/shell/print.mu b/shell/print.mu index 3dec6cff..307b9ffd 100644 --- a/shell/print.mu +++ b/shell/print.mu @@ -47,6 +47,18 @@ fn print-cell _in: (addr handle cell), out: (addr stream byte), trace: (addr tra trace-higher trace return } + compare *in-type, 5/primitive + { + break-if-!= + write out, "[screen " + var screen-ah/eax: (addr handle screen) <- get in-addr, screen-data + var screen/eax: (addr screen) <- lookup *screen-ah + var screen-addr/eax: int <- copy screen + write-int32-decimal out, screen-addr + write out, "]" + trace-higher trace + return + } } # debug helper -- cgit 1.4.1-2-gfad0