https://github.com/akkartik/mu/blob/main/shell/main.mu

     1 # Experimental Mu shell
     2 # A Lisp with indent-sensitivity and infix, no macros. Commas are ignored.
     3
     4 fn main {
     5   var sandbox-storage: sandbox
     6   var sandbox/esi: (addr sandbox) <- address sandbox-storage
     7   initialize-sandbox sandbox
     8   load-sandbox-from-secondary-disk sandbox
     9   var width/eax: int <- copy 0
    10   var height/ecx: int <- copy 0
    11   width, height <- screen-size 0/screen
    12   {
    13     render-sandbox 0/screen, sandbox, 2/x, 2/y, width, height
    14     {
    15       var key/eax: byte <- read-key 0/keyboard
    16       compare key, 0
    17       loop-if-=
    18       # no way to quit right now; just reboot
    19       edit-sandbox sandbox, key
    20     }
    21     loop
    22   }
    23 }
    24
    25 # Read a null-terminated sequence of keys from secondary disk and load them
    26 # into sandbox.
    27 fn load-sandbox-from-secondary-disk _self: (addr sandbox) {
    28   var self/esi: (addr sandbox) <- copy _self
    29   var s-storage: (stream byte 0x200)
    30   var s/ebx: (addr stream byte) <- address s-storage
    31   load-first-sector-from-primary-bus-secondary-drive s
    32   {
    33     var done?/eax: boolean <- stream-empty? s
    34     compare done?, 0/false
    35     break-if-!=
    36     var key/eax: byte <- read-byte s
    37     compare key, 0/null
    38     break-if-=
    39     edit-sandbox self, key
    40     loop
    41   }
    42 }