https://github.com/akkartik/mu/blob/main/baremetal/ex3.mu
 1 # Draw pixels in response to keyboard events, starting from the top-left
 2 # and in raster order.
 3 #
 4 # To build a disk image:
 5 #   ./translate_mu_baremetal baremetal/ex3.mu     # emits disk.img
 6 # To run:
 7 #   qemu-system-i386 disk.img
 8 # Or:
 9 #   bochs -f baremetal/boot.bochsrc               # boot.bochsrc loads disk.img
10 #
11 # Expected output: a new green pixel starting from the top left corner of the
12 # screen every time you press a key (letter or digit)
13 
14 fn main {
15   var x/ecx: int <- copy 0
16   var y/edx: int <- copy 0
17   {
18     var key/eax: byte <- read-key 0  # real keyboard
19     compare key, 0
20     loop-if-=  # busy wait
21     pixel-on-real-screen x, y, 0x31  # green
22     x <- increment
23     compare x, 0x400  # screen-width
24     {
25       break-if-<
26       y <- increment
27       x <- copy 0
28     }
29     loop
30   }
31 }