https://github.com/akkartik/mu/blob/master/apps/tile/box.mu
  1 fn draw-box screen: (addr screen), row1: int, col1: int, row2: int, col2: int {
  2   draw-horizontal-line screen, row1, col1, col2
  3   draw-vertical-line screen, row1, row2, col1
  4   draw-horizontal-line screen, row2, col1, col2
  5   draw-vertical-line screen, row1, row2, col2
  6   draw-top-left-corner screen, row1, col1
  7   draw-top-right-corner screen, row1, col2
  8   draw-bottom-left-corner screen, row2, col1
  9   draw-bottom-right-corner screen, row2, col2
 10 }
 11 
 12 fn draw-hatching screen: (addr screen), row1: int, col1: int, row2: int, col2: int {
 13   var c/eax: int <- copy col1
 14   var r1/ecx: int <- copy row1
 15   r1 <- increment
 16   c <- add 2
 17   {
 18     compare c, col2
 19     break-if->=
 20     draw-vertical-line screen, r1, row2, c
 21     c <- add 2
 22     loop
 23   }
 24 }
 25 
 26 fn draw-horizontal-line screen: (addr screen), row: int, col1: int, col2: int {
 27   var col/eax: int <- copy col1
 28   move-cursor screen, row, col
 29   {
 30     compare col, col2
 31     break-if->=
 32     print-code-point screen, 0x2500
 33     col <- increment
 34     loop
 35   }
 36 }
 37 
 38 fn draw-vertical-line screen: (addr screen), row1: int, row2: int, col: int {
 39   var row/eax: int <- copy row1
 40   {
 41     compare row, row2
 42     break-if->=
 43     move-cursor screen, row, col
 44     print-code-point screen, 0x2502
 45     row <- increment
 46     loop
 47   }
 48 }
 49 
 50 fn draw-top-left-corner screen: (addr screen), row: int, col: int {
 51   move-cursor screen, row, col
 52   print-code-point screen, 0x250c
 53 }
 54 
 55 fn draw-top-right-corner screen: (addr screen), row: int, col: int {
 56   move-cursor screen, row, col
 57   print-code-point screen, 0x2510
 58 }
 59 
 60 fn draw-bottom-left-corner screen: (addr screen), row: int, col: int {
 61   move-cursor screen, row, col
 62   print-code-point screen, 0x2514
 63 }
 64 
 65 fn draw-bottom-right-corner screen: (addr screen), row: int, col: int {
 66   move-cursor screen, row, col
 67   print-code-point screen, 0x2518
 68 }
 69 
 70 # erase parts of screen the slow way
 71 fn clear-rect screen: (addr screen), row1: int, col1: int, row2: int, col2: int {
 72   var i/eax: int <- copy row1
 73   {
 74     compare i, row2
 75     break-if->
 76     var j/ecx: int <- copy col1
 77     move-cursor screen, i, j
 78     {
 79       compare j, col2
 80       break-if->
 81       print-grapheme screen 0x20  # space
 82       j <- increment
 83       loop
 84     }
 85     i <- increment
 86     loop
 87   }
 88 }
 89 
 90 fn clear-rect2 screen: (addr screen), row1: int, col1: int, w: int, h: int {
 91   var i/eax: int <- copy 0
 92   var curr-row/esi: int <- copy row1
 93   {
 94     compare i, w
 95     break-if->=
 96     move-cursor screen, curr-row, col1
 97     var j/ecx: int <- copy 0
 98     {
 99       compare j, h
100       break-if->=
101       print-grapheme screen 0x20  # space
102       j <- increment
103       loop
104     }
105     i <- increment
106     curr-row <- increment
107     loop
108   }
109 }