about summary refs log tree commit diff stats
path: root/baremetal
diff options
context:
space:
mode:
Diffstat (limited to 'baremetal')
-rw-r--r--baremetal/403unicode.mu2
-rw-r--r--baremetal/500text-screen.mu10
-rw-r--r--baremetal/501draw-text.mu40
-rw-r--r--baremetal/502test.mu4
-rw-r--r--baremetal/504test-screen.mu94
-rw-r--r--baremetal/ex2.mu4
-rw-r--r--baremetal/ex3.mu6
-rw-r--r--baremetal/ex4.mu4
-rw-r--r--baremetal/ex5.mu4
-rw-r--r--baremetal/ex6.mu20
-rw-r--r--baremetal/ex7.mu30
-rw-r--r--baremetal/rpn.mu16
12 files changed, 117 insertions, 117 deletions
diff --git a/baremetal/403unicode.mu b/baremetal/403unicode.mu
index ea45f707..6ec30c3d 100644
--- a/baremetal/403unicode.mu
+++ b/baremetal/403unicode.mu
@@ -93,7 +93,7 @@ fn read-grapheme in: (addr stream byte) -> _/eax: grapheme {
   # if at eof, return EOF
   {
     var eof?/eax: boolean <- stream-empty? in
-    compare eof?, 0  # false
+    compare eof?, 0/false
     break-if-=
     return 0xffffffff
   }
diff --git a/baremetal/500text-screen.mu b/baremetal/500text-screen.mu
index f5cd4125..cd72209b 100644
--- a/baremetal/500text-screen.mu
+++ b/baremetal/500text-screen.mu
@@ -52,7 +52,7 @@ fn screen-size screen: (addr screen) -> _/eax: int, _/ecx: int {
   compare screen, 0
   {
     break-if-!=
-    return 0x80, 0x30  # 128x48
+    return 0x80/128, 0x30/48
   }
   # fake screen
   var screen-addr/esi: (addr screen) <- copy screen
@@ -194,7 +194,7 @@ fn clear-screen screen: (addr screen) {
     {
       compare x, *width
       break-if->
-      draw-grapheme screen, space, x, y, 0  # color=black
+      draw-grapheme screen, space, x, y, 0/fg=black
       x <- increment
       loop
     }
@@ -209,13 +209,13 @@ fn clear-screen screen: (addr screen) {
 fn clear-real-screen {
   var y/eax: int <- copy 0
   {
-    compare y, 0x300  # screen-height = 768
+    compare y, 0x300/screen-height=768
     break-if->=
     var x/edx: int <- copy 0
     {
-      compare x, 0x400  # screen-width = 1024
+      compare x, 0x400/screen-width=1024
       break-if->=
-      pixel-on-real-screen x, y, 0  # black
+      pixel-on-real-screen x, y, 0/color=black
       x <- increment
       loop
     }
diff --git a/baremetal/501draw-text.mu b/baremetal/501draw-text.mu
index 0bb95dee..fc69c604 100644
--- a/baremetal/501draw-text.mu
+++ b/baremetal/501draw-text.mu
@@ -80,7 +80,7 @@ fn draw-text-rightward screen: (addr screen), text: (addr array byte), x: int, x
     compare xcurr, xmax
     break-if->
     var g/eax: grapheme <- read-grapheme stream
-    compare g, 0xffffffff  # end-of-file
+    compare g, 0xffffffff/end-of-file
     break-if-=
     xcurr <- increment
     loop
@@ -95,7 +95,7 @@ fn draw-text-rightward screen: (addr screen), text: (addr array byte), x: int, x
   xcurr <- copy x
   {
     var g/eax: grapheme <- read-grapheme stream
-    compare g, 0xffffffff  # end-of-file
+    compare g, 0xffffffff/end-of-file
     break-if-=
     draw-grapheme screen, g, xcurr, y, color
     xcurr <- increment
@@ -128,7 +128,7 @@ fn draw-text-wrapping-right-then-down screen: (addr screen), text: (addr array b
     compare ycurr, ymax
     break-if->=
     var g/eax: grapheme <- read-grapheme stream
-    compare g, 0xffffffff  # end-of-file
+    compare g, 0xffffffff/end-of-file
     break-if-=
     xcurr <- increment
     compare xcurr, xmax
@@ -150,7 +150,7 @@ fn draw-text-wrapping-right-then-down screen: (addr screen), text: (addr array b
   ycurr <- copy y
   {
     var g/eax: grapheme <- read-grapheme stream
-    compare g, 0xffffffff  # end-of-file
+    compare g, 0xffffffff/end-of-file
     break-if-=
     draw-grapheme screen, g, xcurr, ycurr, color
     xcurr <- increment
@@ -184,7 +184,7 @@ fn draw-text-wrapping-right-then-down-over-full-screen screen: (addr screen), te
   var x2/eax: int <- copy 0
   var y2/ecx: int <- copy 0
   x2, y2 <- screen-size screen  # width, height
-  x2, y2 <- draw-text-wrapping-right-then-down screen, text, 0, 0, x2, y2, x, y, color
+  x2, y2 <- draw-text-wrapping-right-then-down screen, text, 0/xmin, 0/ymin, x2, y2, x, y, color
   return x2, y2  # cursor-x, cursor-y
 }
 
@@ -207,7 +207,7 @@ fn draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen: (addr
   var width/eax: int <- copy 0
   var height/ecx: int <- copy 0
   width, height <- screen-size screen
-  draw-text-wrapping-right-then-down-from-cursor screen, text, 0, 0, width, height, color
+  draw-text-wrapping-right-then-down-from-cursor screen, text, 0/xmin, 0/ymin, width, height, color
 }
 
 fn draw-int32-hex-wrapping-right-then-down screen: (addr screen), n: int, xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int -> _/eax: int, _/ecx: int {
@@ -221,7 +221,7 @@ fn draw-int32-hex-wrapping-right-then-down screen: (addr screen), n: int, xmin:
     compare ycurr, ymax
     break-if->=
     var g/eax: grapheme <- read-grapheme stream
-    compare g, 0xffffffff  # end-of-file
+    compare g, 0xffffffff/end-of-file
     break-if-=
     xcurr <- increment
     compare xcurr, xmax
@@ -243,7 +243,7 @@ fn draw-int32-hex-wrapping-right-then-down screen: (addr screen), n: int, xmin:
   ycurr <- copy y
   {
     var g/eax: grapheme <- read-grapheme stream
-    compare g, 0xffffffff  # end-of-file
+    compare g, 0xffffffff/end-of-file
     break-if-=
     draw-grapheme screen, g, xcurr, ycurr, color
     xcurr <- increment
@@ -263,7 +263,7 @@ fn draw-int32-hex-wrapping-right-then-down-over-full-screen screen: (addr screen
   var x2/eax: int <- copy 0
   var y2/ecx: int <- copy 0
   x2, y2 <- screen-size screen  # width, height
-  x2, y2 <- draw-int32-hex-wrapping-right-then-down screen, n, 0, 0, x2, y2, x, y, color
+  x2, y2 <- draw-int32-hex-wrapping-right-then-down screen, n, 0/xmin, 0/ymin, x2, y2, x, y, color
   return x2, y2  # cursor-x, cursor-y
 }
 
@@ -286,7 +286,7 @@ fn draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen:
   var width/eax: int <- copy 0
   var height/ecx: int <- copy 0
   width, height <- screen-size screen
-  draw-int32-hex-wrapping-right-then-down-from-cursor screen, n, 0, 0, width, height, color
+  draw-int32-hex-wrapping-right-then-down-from-cursor screen, n, 0/xmin, 0/ymin, width, height, color
 }
 
 fn draw-int32-decimal-wrapping-right-then-down screen: (addr screen), n: int, xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int -> _/eax: int, _/ecx: int {
@@ -300,7 +300,7 @@ fn draw-int32-decimal-wrapping-right-then-down screen: (addr screen), n: int, xm
     compare ycurr, ymax
     break-if->=
     var g/eax: grapheme <- read-grapheme stream
-    compare g, 0xffffffff  # end-of-file
+    compare g, 0xffffffff/end-of-file
     break-if-=
     xcurr <- increment
     compare xcurr, xmax
@@ -322,7 +322,7 @@ fn draw-int32-decimal-wrapping-right-then-down screen: (addr screen), n: int, xm
   ycurr <- copy y
   {
     var g/eax: grapheme <- read-grapheme stream
-    compare g, 0xffffffff  # end-of-file
+    compare g, 0xffffffff/end-of-file
     break-if-=
     draw-grapheme screen, g, xcurr, ycurr, color
     xcurr <- increment
@@ -342,7 +342,7 @@ fn draw-int32-decimal-wrapping-right-then-down-over-full-screen screen: (addr sc
   var x2/eax: int <- copy 0
   var y2/ecx: int <- copy 0
   x2, y2 <- screen-size screen  # width, height
-  x2, y2 <- draw-int32-decimal-wrapping-right-then-down screen, n, 0, 0, x2, y2, x, y, color
+  x2, y2 <- draw-int32-decimal-wrapping-right-then-down screen, n, 0/xmin, 0/ymin, x2, y2, x, y, color
   return x2, y2  # cursor-x, cursor-y
 }
 
@@ -365,7 +365,7 @@ fn draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen scre
   var width/eax: int <- copy 0
   var height/ecx: int <- copy 0
   width, height <- screen-size screen
-  draw-int32-decimal-wrapping-right-then-down-from-cursor screen, n, 0, 0, width, height, color
+  draw-int32-decimal-wrapping-right-then-down-from-cursor screen, n, 0/xmin, 0/ymin, width, height, color
 }
 
 ## Text direction: down then right
@@ -383,7 +383,7 @@ fn draw-text-downward screen: (addr screen), text: (addr array byte), x: int, y:
     compare ycurr, ymax
     break-if->
     var g/eax: grapheme <- read-grapheme stream
-    compare g, 0xffffffff  # end-of-file
+    compare g, 0xffffffff/end-of-file
     break-if-=
     ycurr <- increment
     loop
@@ -398,7 +398,7 @@ fn draw-text-downward screen: (addr screen), text: (addr array byte), x: int, y:
   ycurr <- copy y
   {
     var g/eax: grapheme <- read-grapheme stream
-    compare g, 0xffffffff  # end-of-file
+    compare g, 0xffffffff/end-of-file
     break-if-=
     draw-grapheme screen, g, x, ycurr, color
     ycurr <- increment
@@ -430,7 +430,7 @@ fn draw-text-wrapping-down-then-right screen: (addr screen), text: (addr array b
     compare xcurr, xmax
     break-if->=
     var g/eax: grapheme <- read-grapheme stream
-    compare g, 0xffffffff  # end-of-file
+    compare g, 0xffffffff/end-of-file
     break-if-=
     ycurr <- increment
     compare ycurr, ymax
@@ -452,7 +452,7 @@ fn draw-text-wrapping-down-then-right screen: (addr screen), text: (addr array b
   ycurr <- copy y
   {
     var g/eax: grapheme <- read-grapheme stream
-    compare g, 0xffffffff  # end-of-file
+    compare g, 0xffffffff/end-of-file
     break-if-=
     draw-grapheme screen, g, xcurr, ycurr, color
     ycurr <- increment
@@ -472,7 +472,7 @@ fn draw-text-wrapping-down-then-right-over-full-screen screen: (addr screen), te
   var x2/eax: int <- copy 0
   var y2/ecx: int <- copy 0
   x2, y2 <- screen-size screen  # width, height
-  x2, y2 <- draw-text-wrapping-down-then-right screen, text, 0, 0, x2, y2, x, y, color
+  x2, y2 <- draw-text-wrapping-down-then-right screen, text, 0/xmin, 0/ymin, x2, y2, x, y, color
   return x2, y2  # cursor-x, cursor-y
 }
 
@@ -495,5 +495,5 @@ fn draw-text-wrapping-down-then-right-from-cursor-over-full-screen screen: (addr
   var width/eax: int <- copy 0
   var height/ecx: int <- copy 0
   width, height <- screen-size screen
-  draw-text-wrapping-down-then-right-from-cursor screen, text, 0, 0, width, height, color
+  draw-text-wrapping-down-then-right-from-cursor screen, text, 0/xmin, 0/ymin, width, height, color
 }
diff --git a/baremetal/502test.mu b/baremetal/502test.mu
index af7a73ff..2683d206 100644
--- a/baremetal/502test.mu
+++ b/baremetal/502test.mu
@@ -4,13 +4,13 @@ fn check-ints-equal _a: int, b: int, msg: (addr array byte) {
   compare a, b
   {
     break-if-=
-    draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, msg, 3  # 3=cyan
+    draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, msg, 3/cyan
     count-test-failure
     return
   }
   {
     break-if-!=
-    draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ".", 3  # 3=cyan
+    draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ".", 3/cyan
   }
 }
 
diff --git a/baremetal/504test-screen.mu b/baremetal/504test-screen.mu
index 614edd9d..07efcc7f 100644
--- a/baremetal/504test-screen.mu
+++ b/baremetal/504test-screen.mu
@@ -5,7 +5,7 @@
 # Tab characters (that translate into multiple screen cells) not supported.
 
 fn check-screen-row screen: (addr screen), y: int, expected: (addr array byte), msg: (addr array byte) {
-  check-screen-row-from screen, y, 0, expected, msg
+  check-screen-row-from screen, y, 0/row, expected, msg
 }
 
 fn check-screen-row-from screen-on-stack: (addr screen), x: int, y: int, expected: (addr array byte), msg: (addr array byte) {
@@ -35,23 +35,23 @@ fn check-screen-row-from screen-on-stack: (addr screen), x: int, y: int, expecte
       compare g, expected-grapheme
       {
         break-if-!=
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ".", 3  # 3=cyan
+        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ".", 3/cyan
         break $check-screen-row-from:compare-graphemes
       }
       # otherwise print an error
       count-test-failure
-      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, msg, 3  # 3=cyan
-      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ": expected '", 3
-      draw-grapheme-at-cursor 0, expected-grapheme, 3
-      move-cursor-rightward-and-downward 0, 0, 0x80  # screen-width
-      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, "' at (", 3
-      draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, x, 3
-      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ", ", 3
-      draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, y, 3
-      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ") but observed '", 3
-      draw-grapheme-at-cursor 0, g, 3
-      move-cursor-rightward-and-downward 0, 0, 0x80  # screen-width
-      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, "'", 3
+      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, msg, 3/cyan
+      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ": expected '", 3
+      draw-grapheme-at-cursor 0/screen, expected-grapheme, 3/cyan
+      move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
+      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "' at (", 3
+      draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, x, 3
+      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ", ", 3
+      draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, y, 3
+      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ") but observed '", 3
+      draw-grapheme-at-cursor 0/screen, g, 3/cyan
+      move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
+      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "'", 3
     }
     idx <- increment
     increment x
@@ -62,7 +62,7 @@ fn check-screen-row-from screen-on-stack: (addr screen), x: int, y: int, expecte
 # various variants by screen-cell attribute; spaces in the 'expected' data should not match the attribute
 
 fn check-screen-row-in-color screen: (addr screen), fg: int, y: int, expected: (addr array byte), msg: (addr array byte) {
-  check-screen-row-in-color-from screen, fg, y, 0, expected, msg
+  check-screen-row-in-color-from screen, fg, y, 0/x, expected, msg
 }
 
 fn check-screen-row-in-color-from screen-on-stack: (addr screen), fg: int, y: int, x: int, expected: (addr array byte), msg: (addr array byte) {
@@ -102,46 +102,46 @@ fn check-screen-row-in-color-from screen-on-stack: (addr screen), fg: int, y: in
         compare g, expected-grapheme
         {
           break-if-!=
-          draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ".", 3  # 3=cyan
+          draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ".", 3/cyan
           break $check-screen-row-in-color-from:compare-graphemes
         }
         # otherwise print an error
         count-test-failure
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, msg, 3  # 3=cyan
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ": expected '", 3
-        draw-grapheme-at-cursor 0, expected-grapheme, 3
-        move-cursor-rightward-and-downward 0, 0, 0x80  # screen-width
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, "' at (", 3
-        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, x, 3
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ", ", 3
-        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, y, 3
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ") but observed '", 3
-        draw-grapheme-at-cursor 0, g, 3
-        move-cursor-rightward-and-downward 0, 0, 0x80  # screen-width
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, "'", 3
+        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, msg, 3/cyan
+        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ": expected '", 3
+        draw-grapheme-at-cursor 0/screen, expected-grapheme, 3/cyan
+        move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
+        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "' at (", 3
+        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, x, 3
+        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ", ", 3
+        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, y, 3
+        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ") but observed '", 3
+        draw-grapheme-at-cursor 0/screen, g, 3/cyan
+        move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
+        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "'", 3
       }
       $check-screen-row-in-color-from:compare-colors: {
         var color/eax: int <- screen-color-at-idx screen, idx
         compare fg, color
         {
           break-if-!=
-          draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ".", 3  # 3=cyan
+          draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ".", 3/cyan
           break $check-screen-row-in-color-from:compare-colors
         }
         # otherwise print an error
         count-test-failure
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, msg, 3  # 3=cyan
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ": expected '", 3
-        draw-grapheme-at-cursor 0, expected-grapheme, 3
-        move-cursor-rightward-and-downward 0, 0, 0x80  # screen-width
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, "' at (", 3
-        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, x, 3
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ", ", 3
-        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, y, 3
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ") in color ", 3
-        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, fg, 3
-        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, " but observed color ", 3
-        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, color, 3
+        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, msg, 3/cyan
+        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ": expected '", 3
+        draw-grapheme-at-cursor 0/screen, expected-grapheme, 3/cyan
+        move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
+        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "' at (", 3
+        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, x, 3
+        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ", ", 3
+        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, y, 3
+        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ") in color ", 3
+        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, fg, 3
+        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, " but observed color ", 3
+        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, color, 3
       }
     }
     idx <- increment
@@ -154,15 +154,15 @@ fn test-draw-single-grapheme {
   var screen-on-stack: screen
   var screen/esi: (addr screen) <- address screen-on-stack
   initialize-screen screen, 5, 4
-  var c/eax: grapheme <- copy 0x61  # 'a'
-  draw-grapheme screen, c, 0, 0, 1  # color=1
-  check-screen-row screen, 0, "a", "F - test-draw-single-grapheme"  # top-left corner of the screen
+  var c/eax: grapheme <- copy 0x61/a
+  draw-grapheme screen, c, 0/x, 0/y, 1/color
+  check-screen-row screen, 0/row, "a", "F - test-draw-single-grapheme"  # top-left corner of the screen
 }
 
 fn test-draw-multiple-graphemes {
   var screen-on-stack: screen
   var screen/esi: (addr screen) <- address screen-on-stack
-  initialize-screen screen, 0x10, 4
-  draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "Hello, 世界", 1  # color=1
-  check-screen-row screen, 0, "Hello, 世界", "F - test-draw-multiple-graphemes"
+  initialize-screen screen, 0x10/rows, 4/cols
+  draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "Hello, 世界", 1/color
+  check-screen-row screen, 0/screen, "Hello, 世界", "F - test-draw-multiple-graphemes"
 }
diff --git a/baremetal/ex2.mu b/baremetal/ex2.mu
index 1662fa84..adc905e9 100644
--- a/baremetal/ex2.mu
+++ b/baremetal/ex2.mu
@@ -13,11 +13,11 @@
 fn main {
   var y/eax: int <- copy 0
   {
-    compare y, 0x300  # screen-height = 768
+    compare y, 0x300/screen-height=768
     break-if->=
     var x/edx: int <- copy 0
     {
-      compare x, 0x400  # screen-width = 1024
+      compare x, 0x400/screen-width=1024
       break-if->=
       var color/ecx: int <- copy x
       color <- and 0xff
diff --git a/baremetal/ex3.mu b/baremetal/ex3.mu
index 56e16bd3..e174ca22 100644
--- a/baremetal/ex3.mu
+++ b/baremetal/ex3.mu
@@ -15,12 +15,12 @@ fn main {
   var x/ecx: int <- copy 0
   var y/edx: int <- copy 0
   {
-    var key/eax: byte <- read-key 0  # real keyboard
+    var key/eax: byte <- read-key 0/keyboard
     compare key, 0
     loop-if-=  # busy wait
-    pixel-on-real-screen x, y, 0x31  # green
+    pixel-on-real-screen x, y, 0x31/green
     x <- increment
-    compare x, 0x400  # screen-width
+    compare x, 0x400/screen-width=1024
     {
       break-if-<
       y <- increment
diff --git a/baremetal/ex4.mu b/baremetal/ex4.mu
index 8a3e285e..2c09d15a 100644
--- a/baremetal/ex4.mu
+++ b/baremetal/ex4.mu
@@ -10,6 +10,6 @@
 # Expected output: letter 'A' in green near the top-left corner of screen
 
 fn main {
-  var g/eax: grapheme <- copy 0x41  # 'A'
-  draw-grapheme 0, g, 2, 1, 0xa  # x of 2 graphemes = 16px from top-left; y of 1 grapheme = 16px down from top-left
+  var g/eax: grapheme <- copy 0x41/A
+  draw-grapheme 0/screen, g, 2/row, 1/col, 0xa/fg
 }
diff --git a/baremetal/ex5.mu b/baremetal/ex5.mu
index ac7a9abe..1f3bea10 100644
--- a/baremetal/ex5.mu
+++ b/baremetal/ex5.mu
@@ -11,6 +11,6 @@
 # Expected output: text in green near the top-left corner of screen
 
 fn main {
-  var dummy/eax: int <- draw-text-rightward 0, "hello from baremetal Mu!", 0x10, 0x400, 0x10, 0xa  # xmax = end of screen, plenty of space
-  dummy <- draw-text-rightward 0, "you shouldn't see this", 0x10, 0xa0, 0x30, 0x3  # xmax = 0xa0, which is too narrow
+  var dummy/eax: int <- draw-text-rightward 0/screen, "hello from baremetal Mu!", 0x10/x, 0x400/xmax, 0x10/y, 0xa/color
+  dummy <- draw-text-rightward 0/screen, "you shouldn't see this", 0x10/x, 0xa0/xmax, 0x30/y, 0x3/color  # xmax is too narrow
 }
diff --git a/baremetal/ex6.mu b/baremetal/ex6.mu
index 304867f6..d209e3f6 100644
--- a/baremetal/ex6.mu
+++ b/baremetal/ex6.mu
@@ -14,19 +14,19 @@ fn main {
   draw-box-on-real-screen 0xf, 0x1f, 0x79, 0x51, 0x4
   var x/eax: int <- copy 0x20
   var y/ecx: int <- copy 0x20
-  x, y <- draw-text-wrapping-right-then-down 0, "hello ",     0x10, 0x20, 0x78, 0x50, x, y, 0xa  # (0x10, 0x20) -> (0x78, 0x50)
-  x, y <- draw-text-wrapping-right-then-down 0, "from ",      0x10, 0x20, 0x78, 0x50, x, y, 0xa
-  x, y <- draw-text-wrapping-right-then-down 0, "baremetal ", 0x10, 0x20, 0x78, 0x50, x, y, 0xa
-  x, y <- draw-text-wrapping-right-then-down 0, "Mu!",        0x10, 0x20, 0x78, 0x50, x, y, 0xa
+  x, y <- draw-text-wrapping-right-then-down 0/screen, "hello ",     0x10/xmin, 0x20/ymin, 0x78/xmax, 0x50/ymax, x, y, 0xa/color
+  x, y <- draw-text-wrapping-right-then-down 0/screen, "from ",      0x10/xmin, 0x20/ymin, 0x78/xmax, 0x50/ymax, x, y, 0xa/color
+  x, y <- draw-text-wrapping-right-then-down 0/screen, "baremetal ", 0x10/xmin, 0x20/ymin, 0x78/xmax, 0x50/ymax, x, y, 0xa/color
+  x, y <- draw-text-wrapping-right-then-down 0/screen, "Mu!",        0x10/xmin, 0x20/ymin, 0x78/xmax, 0x50/ymax, x, y, 0xa/color
 
   # drawing at the cursor in multiple directions
-  draw-text-wrapping-down-then-right-from-cursor-over-full-screen 0, "abc", 0xa
-  draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, "def", 0xa
+  draw-text-wrapping-down-then-right-from-cursor-over-full-screen 0/screen, "abc", 0xa
+  draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "def", 0xa
 
   # test drawing near the edge
-  x <- draw-text-rightward 0, "R", 0x3f8, 0x400, 0x100, 0xa  # 0x400 = screen-width
-  draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, "wrapped from R", 0xa
+  x <- draw-text-rightward 0/screen, "R", 0x3f8/x, 0x400/xmax=screen-width, 0x100/y, 0xa/color
+  draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "wrapped from R", 0xa
 
-  x <- draw-text-downward 0, "D", 0x100, 0x2f0, 0x300, 0xa  # 0x300 = screen-height
-  draw-text-wrapping-down-then-right-from-cursor-over-full-screen 0, "wrapped from D", 0xa
+  x <- draw-text-downward 0/screen, "D", 0x100/x, 0x2f0/y, 0x300/ymax=screen-height, 0xa/color
+  draw-text-wrapping-down-then-right-from-cursor-over-full-screen 0/screen, "wrapped from D", 0xa
 }
diff --git a/baremetal/ex7.mu b/baremetal/ex7.mu
index e50099c4..82529644 100644
--- a/baremetal/ex7.mu
+++ b/baremetal/ex7.mu
@@ -12,36 +12,36 @@
 
 fn main {
   var space/eax: grapheme <- copy 0x20
-  set-cursor-position 0, 0, 0
+  set-cursor-position 0/screen, 0, 0
   {
-    show-cursor 0, space
-    var key/eax: byte <- read-key 0
+    show-cursor 0/screen, space
+    var key/eax: byte <- read-key 0/keyboard
     {
-      compare key, 0x68  # 'h'
+      compare key, 0x68/h
       break-if-!=
-      var g/eax: grapheme <- copy 0x2d  # '-'
-      draw-grapheme-at-cursor 0, g, 0x31
+      var g/eax: grapheme <- copy 0x2d/dash
+      draw-grapheme-at-cursor 0/screen, g, 0x31
       cursor-left 0
     }
     {
-      compare key, 0x6a  # 'j'
+      compare key, 0x6a/j
       break-if-!=
-      var g/eax: grapheme <- copy 0x7c  # '|'
-      draw-grapheme-at-cursor 0, g, 0x31
+      var g/eax: grapheme <- copy 0x7c/vertical-bar
+      draw-grapheme-at-cursor 0/screen, g, 0x31
       cursor-down 0
     }
     {
-      compare key, 0x6b  # 'k'
+      compare key, 0x6b/k
       break-if-!=
-      var g/eax: grapheme <- copy 0x7c  # '|'
-      draw-grapheme-at-cursor 0, g, 0x31
+      var g/eax: grapheme <- copy 0x7c/vertical-bar
+      draw-grapheme-at-cursor 0/screen, g, 0x31
       cursor-up 0
     }
     {
-      compare key, 0x6c  # 'l'
+      compare key, 0x6c/l
       break-if-!=
-      var g/eax: grapheme <- copy 0x2d  # '-'
-      draw-grapheme-at-cursor 0, g, 0x31
+      var g/eax: grapheme <- copy 0x2d/dash
+      draw-grapheme-at-cursor 0/screen, g, 0x31
       cursor-right 0
     }
     loop
diff --git a/baremetal/rpn.mu b/baremetal/rpn.mu
index 30289c11..b309409f 100644
--- a/baremetal/rpn.mu
+++ b/baremetal/rpn.mu
@@ -23,31 +23,31 @@ fn main -> _/ebx: int {
   # read-eval-print loop
   {
     # print prompt
-    var x/eax: int <- draw-text-rightward 0, "> ", 0, 0x80, y, 3
-    set-cursor-position 0, x, y
+    var x/eax: int <- draw-text-rightward 0/screen, "> ", 0/x, 0x80/xmax, y, 3/cyan
+    set-cursor-position 0/screen, x, y
     # read line from keyboard
     clear-stream in
     {
-      show-cursor 0, space
-      var key/eax: byte <- read-key 0
-      compare key, 0xa  # newline
+      show-cursor 0/screen, space
+      var key/eax: byte <- read-key 0/keyboard
+      compare key, 0xa/newline
       break-if-=
       compare key, 0
       loop-if-=
       var key2/eax: int <- copy key
       append-byte in, key2
       var g/eax: grapheme <- copy key2
-      draw-grapheme-at-cursor 0, g, 0xf
+      draw-grapheme-at-cursor 0/screen, g, 0xf
       cursor-right 0
       loop
     }
     # clear cursor
-    draw-grapheme-at-cursor 0, space, 3  # 3=foreground color, which is never used
+    draw-grapheme-at-cursor 0/screen, space, 3/fg/never-used
     # parse and eval
     var out/eax: int <- simplify in
     # print
     y <- increment
-    out, y <- draw-int32-decimal-wrapping-right-then-down 0, out, 0, y, 0x80, 0x30, 0, y, 7
+    out, y <- draw-int32-decimal-wrapping-right-then-down 0/screen, out, 0/xmin, y, 0x80/xmax, 0x30/ymax, 0/x, y, 7/fg
     # newline
     y <- increment
     #