diff options
51 files changed, 662 insertions, 662 deletions
diff --git a/402time.mu b/402time.mu index 5407b6b7..fdb98c81 100644 --- a/402time.mu +++ b/402time.mu @@ -7,7 +7,7 @@ type timespec { # TODO: y2038 fn time -> _/eax: int { var t: timespec - var clock/ebx: int <- copy 0 # CLOCK_MONOTONIC + var clock/ebx: int <- copy 0/CLOCK_MONOTONIC var t-addr/ecx: (addr timespec) <- address t syscall_clock_gettime var t-secs-addr/ecx: (addr int) <- get t-addr, tv_sec @@ -18,7 +18,7 @@ fn time -> _/eax: int { # return time in nanoseconds since epoch fn ntime -> _/eax: int { var t: timespec - var clock/ebx: int <- copy 0 # CLOCK_MONOTONIC + var clock/ebx: int <- copy 0/CLOCK_MONOTONIC var t-addr/ecx: (addr timespec) <- address t syscall_clock_gettime var t-nsecs-addr/ecx: (addr int) <- get t-addr, tv_nsec diff --git a/403unicode.mu b/403unicode.mu index 94710be6..948e6618 100644 --- a/403unicode.mu +++ b/403unicode.mu @@ -159,7 +159,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 } @@ -237,7 +237,7 @@ fn test-read-grapheme { check-ints-equal n, 0x61, "F - test grapheme/0" var c/eax: grapheme <- read-grapheme s2 var n/eax: int <- copy c - check-ints-equal n, 0x92ce, "F - test grapheme/1" # greek capital letter beta + check-ints-equal n, 0x92ce/greek-capital-letter-beta, "F - test grapheme/1" var c/eax: grapheme <- read-grapheme s2 var n/eax: int <- copy c check-ints-equal n, 0x63, "F - test grapheme/2" diff --git a/405screen.mu b/405screen.mu index 0fd0f4e3..d009924e 100644 --- a/405screen.mu +++ b/405screen.mu @@ -1174,264 +1174,264 @@ fn check-screen-row-in-blinking-from screen-on-stack: (addr screen), row-idx: in fn test-print-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' + initialize-screen screen, 5/rows, 4/cols + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c - check-screen-row screen, 1, "a", "F - test-print-single-grapheme" # top-left corner of the screen + check-screen-row screen, 1/row, "a", "F - test-print-single-grapheme" # top-left corner of the screen } fn test-print-multiple-graphemes { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 4 + initialize-screen screen, 5/rows, 4/cols print-string screen, "Hello, 世界" - check-screen-row screen, 1, "Hello, 世界", "F - test-print-multiple-graphemes" + check-screen-row screen, 1/row, "Hello, 世界", "F - test-print-multiple-graphemes" } fn test-move-cursor { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 4 + initialize-screen screen, 5/rows, 4/cols move-cursor screen, 1, 4 - var c/eax: grapheme <- copy 0x61 # 'a' + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c - check-screen-row screen, 1, " a", "F - test-move-cursor" # top row + check-screen-row screen, 1/row, " a", "F - test-move-cursor" # top row } fn test-move-cursor-zeroes { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 4 + initialize-screen screen, 5/rows, 4/cols move-cursor screen, 0, 0 - var c/eax: grapheme <- copy 0x61 # 'a' + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c - check-screen-row screen, 1, "a", "F - test-move-cursor-zeroes" # top-left corner of the screen + check-screen-row screen, 1/row, "a", "F - test-move-cursor-zeroes" # top-left corner of the screen } fn test-move-cursor-zero-row { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 4 + initialize-screen screen, 5/rows, 4/cols move-cursor screen, 0, 2 - var c/eax: grapheme <- copy 0x61 # 'a' + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c - check-screen-row screen, 1, " a", "F - test-move-cursor-zero-row" # top row + check-screen-row screen, 1/row, " a", "F - test-move-cursor-zero-row" # top row } fn test-move-cursor-zero-column { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 4 + initialize-screen screen, 5/rows, 4/cols move-cursor screen, 4, 0 - var c/eax: grapheme <- copy 0x61 # 'a' + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c - check-screen-row screen, 4, "a", "F - test-move-cursor-zero-column" + check-screen-row screen, 4/row, "a", "F - test-move-cursor-zero-column" } fn test-move-cursor-negative-row { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack initialize-screen screen, 5, 3 - move-cursor screen, -1, 2 # row -1 - var c/eax: grapheme <- copy 0x61 # 'a' + move-cursor screen, -1/row, 2/col + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c # no move - check-screen-row screen, 1, "a", "F - test-move-cursor-negative-row" + check-screen-row screen, 1/row, "a", "F - test-move-cursor-negative-row" } fn test-move-cursor-negative-column { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack initialize-screen screen, 5, 3 - move-cursor screen, 2, -1 # column -1 - var c/eax: grapheme <- copy 0x61 # 'a' + move-cursor screen, 2/row, -1/col + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c # no move - check-screen-row screen, 1, "a", "F - test-move-cursor-negative-column" + check-screen-row screen, 1/row, "a", "F - test-move-cursor-negative-column" } fn test-move-cursor-column-too-large { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 3 # 5 rows, 3 columns - move-cursor screen, 1, 4 # row 1, column 4 (overflow) - var c/eax: grapheme <- copy 0x61 # 'a' + initialize-screen screen, 5/rows, 3/cols + move-cursor screen, 1/row, 4/col + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c # top row is empty - check-screen-row screen, 1, " ", "F - test-move-cursor-column-too-large" + check-screen-row screen, 1/row, " ", "F - test-move-cursor-column-too-large" # character shows up on next row - check-screen-row screen, 2, "a", "F - test-move-cursor-column-too-large" + check-screen-row screen, 2/row, "a", "F - test-move-cursor-column-too-large" } fn test-move-cursor-column-too-large-saturates { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 3 # 5 rows, 3 columns - move-cursor screen, 1, 6 # row 1, column 6 (overflow) - var c/eax: grapheme <- copy 0x61 # 'a' + initialize-screen screen, 5/rows, 3/cols + move-cursor screen, 1/row, 6/col + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c # top row is empty - check-screen-row screen, 1, " ", "F - test-move-cursor-column-too-large-saturates" # top-left corner of the screen + check-screen-row screen, 1/row, " ", "F - test-move-cursor-column-too-large-saturates" # top-left corner of the screen # character shows up at the start of next row - check-screen-row screen, 2, "a", "F - test-move-cursor-column-too-large-saturates" # top-left corner of the screen + check-screen-row screen, 2/row, "a", "F - test-move-cursor-column-too-large-saturates" # top-left corner of the screen } fn test-move-cursor-row-too-large { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 3 # 5 rows - move-cursor screen, 6, 2 # row 6 (overflow) - var c/eax: grapheme <- copy 0x61 # 'a' + initialize-screen screen, 5/rows, 3/cols + move-cursor screen, 6/row, 2/col + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c # bottom row shows the character - check-screen-row screen, 5, " a", "F - test-move-cursor-row-too-large" + check-screen-row screen, 5/row, " a", "F - test-move-cursor-row-too-large" } fn test-move-cursor-row-too-large-saturates { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 3 # 5 rows - move-cursor screen, 9, 2 # row 9 (overflow) - var c/eax: grapheme <- copy 0x61 # 'a' + initialize-screen screen, 5/rows, 3/cols + move-cursor screen, 9/row, 2/col + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c # bottom row shows the character - check-screen-row screen, 5, " a", "F - test-move-cursor-row-too-large-saturates" + check-screen-row screen, 5/row, " a", "F - test-move-cursor-row-too-large-saturates" } fn test-check-screen-row-from { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 4 + initialize-screen screen, 5/rows, 4/cols move-cursor screen, 1, 4 - var c/eax: grapheme <- copy 0x61 # 'a' + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c - check-screen-row screen, 1, " a", "F - test-check-screen-row-from/baseline" - check-screen-row-from screen, 1, 4, "a", "F - test-check-screen-row-from" + check-screen-row screen, 1/row, " a", "F - test-check-screen-row-from/baseline" + check-screen-row-from screen, 1/row, 4/col, "a", "F - test-check-screen-row-from" } fn test-print-string-overflows-to-next-row { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 4 # 5 rows, 4 columns + initialize-screen screen, 5/rows, 4/cols print-string screen, "abcdefg" - check-screen-row screen, 1, "abcd", "F - test-print-string-overflows-to-next-row" - check-screen-row screen, 2, "efg", "F - test-print-string-overflows-to-next-row" + check-screen-row screen, 1/row, "abcd", "F - test-print-string-overflows-to-next-row" + check-screen-row screen, 2/row, "efg", "F - test-print-string-overflows-to-next-row" } fn test-check-screen-scrolls-on-overflow { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 4 + initialize-screen screen, 5/rows, 4/cols # single character starting at bottom right - move-cursor screen, 5, 4 - var c/eax: grapheme <- copy 0x61 # 'a' + move-cursor screen, 5/rows, 4/cols + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c - check-screen-row-from screen, 5, 4, "a", "F - test-check-screen-scrolls-on-overflow/baseline" # bottom-right corner of the screen + check-screen-row-from screen, 5/row, 4/col, "a", "F - test-check-screen-scrolls-on-overflow/baseline" # bottom-right corner of the screen # multiple characters starting at bottom right move-cursor screen, 5, 4 print-string screen, "ab" # screen scrolled up one row -#? check-screen-row screen, 1, " ", "F - test-check-screen-scrolls-on-overflow/x1" -#? check-screen-row screen, 2, " ", "F - test-check-screen-scrolls-on-overflow/x2" -#? check-screen-row screen, 3, " ", "F - test-check-screen-scrolls-on-overflow/x3" -#? check-screen-row screen, 4, " a", "F - test-check-screen-scrolls-on-overflow/x4" -#? check-screen-row screen, 5, "b ", "F - test-check-screen-scrolls-on-overflow/x5" - check-screen-row-from screen, 4, 4, "a", "F - test-check-screen-scrolls-on-overflow/1" - check-screen-row-from screen, 5, 1, "b", "F - test-check-screen-scrolls-on-overflow/2" +#? check-screen-row screen, 1/row, " ", "F - test-check-screen-scrolls-on-overflow/x1" +#? check-screen-row screen, 2/row, " ", "F - test-check-screen-scrolls-on-overflow/x2" +#? check-screen-row screen, 3/row, " ", "F - test-check-screen-scrolls-on-overflow/x3" +#? check-screen-row screen, 4/row, " a", "F - test-check-screen-scrolls-on-overflow/x4" +#? check-screen-row screen, 5/row, "b ", "F - test-check-screen-scrolls-on-overflow/x5" + check-screen-row-from screen, 4/row, 4/col, "a", "F - test-check-screen-scrolls-on-overflow/1" + check-screen-row-from screen, 5/row, 1/col, "b", "F - test-check-screen-scrolls-on-overflow/2" } fn test-check-screen-color { 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' + initialize-screen screen, 5/rows, 4/cols + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c - start-color screen, 1, 0 # foreground=1 - c <- copy 0x62 # 'b' + start-color screen, 1/fg, 0/bg + c <- copy 0x62/b print-grapheme screen, c - start-color screen, 0, 0 # back to default - c <- copy 0x63 # 'c' + start-color screen, 0/fg, 7/bg + c <- copy 0x63/c print-grapheme screen, c - check-screen-row-in-color screen, 0, 1, "a c", "F - test-check-screen-color" + check-screen-row-in-color screen, 0/fg, 1/row, "a c", "F - test-check-screen-color" } fn test-check-screen-background-color { 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' + initialize-screen screen, 5/rows, 4/cols + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c - start-color screen, 0, 1 # background=1 - c <- copy 0x62 # 'b' + start-color screen, 0/fg, 1/bg + c <- copy 0x62/b print-grapheme screen, c - start-color screen, 0, 7 # back to default - c <- copy 0x63 # 'c' + start-color screen, 0/fg, 7/bg + c <- copy 0x63/c print-grapheme screen, c - check-screen-row-in-background-color screen, 7, 1, "a c", "F - test-check-screen-background-color" + check-screen-row-in-background-color screen, 7/bg, 1/row, "a c", "F - test-check-screen-background-color" } fn test-check-screen-bold { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 4 + initialize-screen screen, 5/rows, 4/cols start-bold screen - var c/eax: grapheme <- copy 0x61 # 'a' + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c reset-formatting screen - c <- copy 0x62 # 'b' + c <- copy 0x62/b print-grapheme screen, c start-bold screen - c <- copy 0x63 # 'c' + c <- copy 0x63/c print-grapheme screen, c - check-screen-row-in-bold screen, 1, "a c", "F - test-check-screen-bold" + check-screen-row-in-bold screen, 1/row, "a c", "F - test-check-screen-bold" } fn test-check-screen-underline { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 4 + initialize-screen screen, 5/rows, 4/cols start-underline screen - var c/eax: grapheme <- copy 0x61 # 'a' + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c reset-formatting screen - c <- copy 0x62 # 'b' + c <- copy 0x62/b print-grapheme screen, c start-underline screen - c <- copy 0x63 # 'c' + c <- copy 0x63/c print-grapheme screen, c - check-screen-row-in-underline screen, 1, "a c", "F - test-check-screen-underline" + check-screen-row-in-underline screen, 1/row, "a c", "F - test-check-screen-underline" } fn test-check-screen-reverse { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 4 + initialize-screen screen, 5/rows, 4/cols start-reverse-video screen - var c/eax: grapheme <- copy 0x61 # 'a' + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c reset-formatting screen - c <- copy 0x62 # 'b' + c <- copy 0x62/b print-grapheme screen, c start-reverse-video screen - c <- copy 0x63 # 'c' + c <- copy 0x63/c print-grapheme screen, c - check-screen-row-in-reverse screen, 1, "a c", "F - test-check-screen-reverse" + check-screen-row-in-reverse screen, 1/row, "a c", "F - test-check-screen-reverse" } fn test-check-screen-blinking { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack - initialize-screen screen, 5, 4 + initialize-screen screen, 5/rows, 4/cols start-blinking screen - var c/eax: grapheme <- copy 0x61 # 'a' + var c/eax: grapheme <- copy 0x61/a print-grapheme screen, c reset-formatting screen - c <- copy 0x62 # 'b' + c <- copy 0x62/b print-grapheme screen, c start-blinking screen - c <- copy 0x63 # 'c' + c <- copy 0x63/c print-grapheme screen, c - check-screen-row-in-blinking screen, 1, "a c", "F - test-check-screen-blinking" + check-screen-row-in-blinking screen, 1/row, "a c", "F - test-check-screen-blinking" } #? fn main -> _/ebx: int { diff --git a/407right-justify.mu b/407right-justify.mu index 5cb9e8d6..b7322ae5 100644 --- a/407right-justify.mu +++ b/407right-justify.mu @@ -6,7 +6,7 @@ fn print-int32-decimal-right-justified screen: (addr screen), n: int, _width: in { compare n-width, width break-if->= - print-grapheme screen, 0x20 # space + print-grapheme screen, 0x20/space width <- decrement loop } diff --git a/410file.mu b/410file.mu index 970407cf..86dac7bd 100644 --- a/410file.mu +++ b/410file.mu @@ -7,7 +7,7 @@ fn read-lines in: (addr buffered-file), out: (addr handle array (handle array by clear-stream line-a read-line-buffered in, line-a var done?/eax: boolean <- stream-empty? line-a - compare done?, 0 # false + compare done?, 0/false break-if-!= #? print-string 0, "AAA\n" var h: (handle array byte) diff --git a/411string.mu b/411string.mu index c16de016..cf0471ac 100644 --- a/411string.mu +++ b/411string.mu @@ -13,7 +13,7 @@ fn substring in: (addr array byte), start: int, len: int, out-ah: (addr handle a break-if->= { var dummy/eax: grapheme <- read-grapheme in-stream-addr - compare dummy, 0xffffffff # end-of-file + compare dummy, 0xffffffff/end-of-file break-if-= $substring:core } i <- increment @@ -26,7 +26,7 @@ fn substring in: (addr array byte), start: int, len: int, out-ah: (addr handle a break-if->= { var g/eax: grapheme <- read-grapheme in-stream-addr - compare g, 0xffffffff # end-of-file + compare g, 0xffffffff/end-of-file break-if-= $substring:core write-grapheme out-stream-addr, g } diff --git a/412print-float-decimal.mu b/412print-float-decimal.mu index f41cbe37..67470f1f 100644 --- a/412print-float-decimal.mu +++ b/412print-float-decimal.mu @@ -471,7 +471,7 @@ fn print-float-buffer screen: (addr screen), _buf: (addr array byte), n: int, dp } var curr-a/ecx: (addr byte) <- index buf, i var curr/ecx: byte <- copy-byte *curr-a - curr <- add 0x30 # '0' + curr <- add 0x30/0 var curr-grapheme/ecx: grapheme <- copy curr print-grapheme screen, curr-grapheme i <- increment @@ -494,7 +494,7 @@ fn print-float-buffer-in-scientific-notation screen: (addr screen), _buf: (addr } var curr-a/ecx: (addr byte) <- index buf, i var curr/ecx: byte <- copy-byte *curr-a - curr <- add 0x30 # '0' + curr <- add 0x30/0 var curr-grapheme/ecx: grapheme <- copy curr print-grapheme screen, curr-grapheme # @@ -514,22 +514,22 @@ fn float-size in: float, precision: int -> _/eax: int { compare bits, 0 { break-if-!= - return 1 # "0" + return 1 # for "0" } compare bits, 0x80000000 { break-if-!= - return 2 # "-0" + return 2 # for "-0" } compare bits, 0x7f800000 { break-if-!= - return 3 # "Inf" + return 3 # for "Inf" } compare bits, 0xff800000 { break-if-!= - return 4 # "-Inf" + return 4 # for "-Inf" } var exponent/ecx: int <- copy bits exponent <- shift-right 0x17 # 23 bits of mantissa @@ -538,7 +538,7 @@ fn float-size in: float, precision: int -> _/eax: int { compare exponent, 0x80 { break-if-!= - return 3 # "NaN" + return 3 # for "NaN" } # - regular numbers # v = 1.mantissa (in base 2) << 0x17 @@ -636,7 +636,7 @@ fn test-check-buffer-contains { var arr: (array byte 4) var a/esi: (addr array byte) <- address arr var b/eax: (addr byte) <- index a, 0 - var c/ecx: byte <- copy 0x61 # 'a' + var c/ecx: byte <- copy 0x61/a copy-byte-to *b, c check-buffer-contains a, "a", "F - test-check-buffer-contains" check-buffer-contains "a", "a", "F - test-check-buffer-contains/null" # no null check when arrays have same length diff --git a/apps/advent2020/1a.mu b/apps/advent2020/1a.mu index 05aa58bf..67fdc358 100644 --- a/apps/advent2020/1a.mu +++ b/apps/advent2020/1a.mu @@ -27,7 +27,7 @@ fn main -> _/ebx: int { read-line-from-real-keyboard line # if line is empty (not even a newline), quit var done?/eax: boolean <- stream-empty? line - compare done?, 0 # false + compare done?, 0/false break-if-!= #? print-stream-to-real-screen line # convert line to int and append it to numbers @@ -56,7 +56,7 @@ fn main -> _/ebx: int { target <- subtract *src { var found?/eax: boolean <- find-after numbers, i, target - compare found?, 0 # false + compare found?, 0/false break-if-= print-string 0, "found\n" print-int32-decimal 0, *src @@ -66,12 +66,12 @@ fn main -> _/ebx: int { target <- multiply *src print-int32-decimal 0, target print-string 0, "\n" - return 0 # success + return 0/success } i <- increment loop } - return 1 # not found + return 1/not-found } fn find-after _numbers: (addr array int), start: int, _target: int -> _/eax: boolean { @@ -88,10 +88,10 @@ fn find-after _numbers: (addr array int), start: int, _target: int -> _/eax: boo compare *src, target { break-if-!= - return 1 # true + return 1/true } i <- increment loop } - return 0 # false + return 0/false } diff --git a/apps/advent2020/1b.mu b/apps/advent2020/1b.mu index aa2d21f1..a638d228 100644 --- a/apps/advent2020/1b.mu +++ b/apps/advent2020/1b.mu @@ -27,7 +27,7 @@ fn main -> _/ebx: int { read-line-from-real-keyboard line # if line is empty (not even a newline), quit var done?/eax: boolean <- stream-empty? line - compare done?, 0 # false + compare done?, 0/false break-if-!= #? print-stream-to-real-screen line # convert line to int and append it to numbers @@ -65,7 +65,7 @@ fn main -> _/ebx: int { target <- subtract *src2 { var found?/eax: boolean <- find-after numbers, j, target - compare found?, 0 # false + compare found?, 0/false break-if-= print-string 0, "found\n" print-int32-decimal 0, *src @@ -78,7 +78,7 @@ fn main -> _/ebx: int { target <- multiply *src2 print-int32-decimal 0, target print-string 0, "\n" - return 0 # success + return 0/success } } j <- increment @@ -87,7 +87,7 @@ fn main -> _/ebx: int { i <- increment loop } - return 1 # not found + return 1/not-found } fn find-after _numbers: (addr array int), start: int, _target: int -> _/eax: boolean { @@ -104,10 +104,10 @@ fn find-after _numbers: (addr array int), start: int, _target: int -> _/eax: boo compare *src, target { break-if-!= - return 1 # true + return 1/true } i <- increment loop } - return 0 # false + return 0/false } diff --git a/apps/advent2020/2a.mu b/apps/advent2020/2a.mu index aad94be4..dc67b94a 100644 --- a/apps/advent2020/2a.mu +++ b/apps/advent2020/2a.mu @@ -20,7 +20,7 @@ fn main -> _/ebx: int { read-line-from-real-keyboard line # if line is empty (not even a newline), quit var done?/eax: boolean <- stream-empty? line - compare done?, 0 # false + compare done?, 0/false break-if-!= print-stream-to-real-screen line # slice = next-token(line, '-') @@ -47,7 +47,7 @@ fn main -> _/ebx: int { skip-chars-matching-whitespace line # now check the rest of the line var is-valid?/eax: boolean <- is-valid? start, end, letter, line - compare is-valid?, 0 # false + compare is-valid?, 0/false { break-if-= print-string 0, "valid!\n" @@ -67,7 +67,7 @@ fn is-valid? start: int, end: int, letter: byte, password: (addr stream byte) -> # ++letter-count { var done?/eax: boolean <- stream-empty? password - compare done?, 0 # false + compare done?, 0/false break-if-!= var c/eax: byte <- read-byte password compare c, letter @@ -81,12 +81,12 @@ fn is-valid? start: int, end: int, letter: byte, password: (addr stream byte) -> compare letter-count, start { break-if->= - return 0 # false + return 0/false } compare letter-count, end { break-if-<= - return 0 # false + return 0/false } - return 1 # true + return 1/true } diff --git a/apps/advent2020/2b.mu b/apps/advent2020/2b.mu index 116029b0..13f60f0f 100644 --- a/apps/advent2020/2b.mu +++ b/apps/advent2020/2b.mu @@ -20,7 +20,7 @@ fn main -> _/ebx: int { read-line-from-real-keyboard line # if line is empty (not even a newline), quit var done?/eax: boolean <- stream-empty? line - compare done?, 0 # false + compare done?, 0/false break-if-!= print-stream-to-real-screen line # slice = next-token(line, '-') @@ -53,7 +53,7 @@ fn main -> _/ebx: int { skip-chars-matching-whitespace line # now check the rest of the line var is-valid?/eax: boolean <- is-valid? pos1, pos2, letter, line - compare is-valid?, 0 # false + compare is-valid?, 0/false { break-if-= print-string 0, "valid!\n" @@ -85,7 +85,7 @@ fn is-valid? pos1: int, pos2: int, letter: byte, password: (addr stream byte) -> #? print-int32-decimal 0, i #? print-string 0, "\n" var done?/eax: boolean <- stream-empty? password - compare done?, 0 # false + compare done?, 0/false break-if-!= var c/eax: byte <- read-byte password #? { @@ -116,7 +116,7 @@ fn is-valid? pos1: int, pos2: int, letter: byte, password: (addr stream byte) -> compare letter-count, 1 { break-if-!= - return 1 # true + return 1/true } - return 0 # false + return 0/false } diff --git a/apps/advent2020/3a.mu b/apps/advent2020/3a.mu index 777a7be0..76bda961 100644 --- a/apps/advent2020/3a.mu +++ b/apps/advent2020/3a.mu @@ -26,7 +26,7 @@ fn main -> _/ebx: int { read-line-from-real-keyboard line # if line is empty (not even a newline), quit var done?/eax: boolean <- stream-empty? line - compare done?, 0 # false + compare done?, 0/false break-if-!= # wastefully recompute width on every line # zero error-checking; we assume input lines are all equally long @@ -34,7 +34,7 @@ fn main -> _/ebx: int { # turn each byte into a tree and append it $main:line-loop: { var done?/eax: boolean <- stream-empty? line - compare done?, 0 # false + compare done?, 0/false break-if-!= #? print-int32-decimal 0, num-rows #? print-string 0, " " @@ -43,10 +43,10 @@ fn main -> _/ebx: int { var dest/ebx: (addr int) <- index trees, trees-length var c/eax: byte <- read-byte line # newline comes only at end of line - compare c, 0xa # newline + compare c, 0xa/newline break-if-= # '#' = tree - compare c, 0x23 # '#' + compare c, 0x23/hash { break-if-!= copy-to *dest, 1 diff --git a/apps/advent2020/3b.mu b/apps/advent2020/3b.mu index 531d18fb..fcc9261a 100644 --- a/apps/advent2020/3b.mu +++ b/apps/advent2020/3b.mu @@ -26,7 +26,7 @@ fn main -> _/ebx: int { read-line-from-real-keyboard line # if line is empty (not even a newline), quit var done?/eax: boolean <- stream-empty? line - compare done?, 0 # false + compare done?, 0/false break-if-!= # wastefully recompute width on every line # zero error-checking; we assume input lines are all equally long @@ -34,7 +34,7 @@ fn main -> _/ebx: int { # turn each byte into a tree and append it $main:line-loop: { var done?/eax: boolean <- stream-empty? line - compare done?, 0 # false + compare done?, 0/false break-if-!= #? print-int32-decimal 0, num-rows #? print-string 0, " " @@ -43,10 +43,10 @@ fn main -> _/ebx: int { var dest/ebx: (addr int) <- index trees, trees-length var c/eax: byte <- read-byte line # newline comes only at end of line - compare c, 0xa # newline + compare c, 0xa/newline break-if-= # '#' = tree - compare c, 0x23 # '#' + compare c, 0x23/hash { break-if-!= copy-to *dest, 1 diff --git a/apps/advent2020/4a.mu b/apps/advent2020/4a.mu index 59dada2b..e645da24 100644 --- a/apps/advent2020/4a.mu +++ b/apps/advent2020/4a.mu @@ -21,14 +21,14 @@ fn main -> _/ebx: int { read-line-from-real-keyboard line # if line is empty (not even a newline), quit var done?/eax: boolean <- stream-empty? line - compare done?, 0 # false + compare done?, 0/false break-if-!= print-stream-to-real-screen line # if line has just a newline, process passport skip-chars-matching-whitespace line var new-passport?/eax: boolean <- stream-empty? line { - compare new-passport?, 0 # false + compare new-passport?, 0/false break-if-= compare curr-passport-field-count, 7 { @@ -44,13 +44,13 @@ fn main -> _/ebx: int { $main:word-loop: { next-word line, slice var done?/eax: boolean <- slice-empty? slice - compare done?, 0 # false + compare done?, 0/false break-if-!= print-string 0, " " print-slice-to-real-screen slice # treat cid as optional var optional?/eax: boolean <- slice-starts-with? slice, "cid:" - compare optional?, 0 # false + compare optional?, 0/false { break-if-!= # otherwise assume there are no invalid fields and no duplicate fields diff --git a/apps/advent2020/4b.mu b/apps/advent2020/4b.mu index 8625ff93..1ab29456 100644 --- a/apps/advent2020/4b.mu +++ b/apps/advent2020/4b.mu @@ -23,14 +23,14 @@ fn main -> _/ebx: int { read-line-from-real-keyboard line # if line is empty (not even a newline), quit var done?/eax: boolean <- stream-empty? line - compare done?, 0 # false + compare done?, 0/false break-if-!= print-stream-to-real-screen line # if line has just a newline, process passport skip-chars-matching-whitespace line var new-passport?/eax: boolean <- stream-empty? line { - compare new-passport?, 0 # false + compare new-passport?, 0/false break-if-= compare curr-passport-field-count, 7 { @@ -46,7 +46,7 @@ fn main -> _/ebx: int { $main:word-loop: { skip-chars-matching-whitespace line var done?/eax: boolean <- stream-empty? line - compare done?, 0 # false + compare done?, 0/false break-if-!= next-token line, 0x3a, key-slice # ':' var dummy/eax: byte <- read-byte line # skip ':' @@ -57,7 +57,7 @@ fn main -> _/ebx: int { print-string 0, "\n" # treat cid as optional var cid?/eax: boolean <- slice-equal? key-slice, "cid" - compare cid?, 0 # false + compare cid?, 0/false loop-if-!= # increment field count curr-passport-field-count <- increment @@ -65,7 +65,7 @@ fn main -> _/ebx: int { # byr { var byr?/eax: boolean <- slice-equal? key-slice, "byr" - compare byr?, 0 # false + compare byr?, 0/false break-if-= # 1920 <= byr <= 2002 var byr/eax: int <- parse-decimal-int-from-slice val-slice @@ -85,7 +85,7 @@ fn main -> _/ebx: int { # iyr { var iyr?/eax: boolean <- slice-equal? key-slice, "iyr" - compare iyr?, 0 # false + compare iyr?, 0/false break-if-= # 2010 <= iyr <= 2020 var iyr/eax: int <- parse-decimal-int-from-slice val-slice @@ -105,7 +105,7 @@ fn main -> _/ebx: int { # eyr { var eyr?/eax: boolean <- slice-equal? key-slice, "eyr" - compare eyr?, 0 # false + compare eyr?, 0/false break-if-= # 2020 <= eyr <= 2030 var eyr/eax: int <- parse-decimal-int-from-slice val-slice @@ -125,7 +125,7 @@ fn main -> _/ebx: int { # hgt { var hgt?/eax: boolean <- slice-equal? key-slice, "hgt" - compare hgt?, 0 # false + compare hgt?, 0/false break-if-= # convert val var s: (handle array byte) @@ -143,7 +143,7 @@ fn main -> _/ebx: int { var suffix/eax: (addr array byte) <- lookup *suffix-ah { var match?/eax: boolean <- string-equal? suffix, "in" - compare match?, 0 # false + compare match?, 0/false break-if-= # if suffix is "in", 59 <= val <= 96 var num-h: (handle array byte) @@ -167,7 +167,7 @@ fn main -> _/ebx: int { } { var match?/eax: boolean <- string-equal? suffix, "cm" - compare match?, 0 # false + compare match?, 0/false break-if-= # if suffix is "cm", 150 <= val <= 193 var num-h: (handle array byte) @@ -197,7 +197,7 @@ fn main -> _/ebx: int { # hcl { var hcl?/eax: boolean <- slice-equal? key-slice, "hcl" - compare hcl?, 0 # false + compare hcl?, 0/false break-if-= # convert val var s: (handle array byte) @@ -217,7 +217,7 @@ fn main -> _/ebx: int { { var c/eax: (addr byte) <- index s3, 0 var c2/eax: byte <- copy-byte *c - compare c2, 0x23 # '#' + compare c2, 0x23/hash break-if-= print-string 0, "invalid2\n" curr-passport-field-count <- copy 8 @@ -242,28 +242,28 @@ fn main -> _/ebx: int { # ecl { var ecl?/eax: boolean <- slice-equal? key-slice, "ecl" - compare ecl?, 0 # false + compare ecl?, 0/false break-if-= var amb?/eax: boolean <- slice-equal? val-slice, "amb" - compare amb?, 0 # false + compare amb?, 0/false loop-if-!= $main:word-loop var blu?/eax: boolean <- slice-equal? val-slice, "blu" - compare blu?, 0 # false + compare blu?, 0/false loop-if-!= $main:word-loop var brn?/eax: boolean <- slice-equal? val-slice, "brn" - compare brn?, 0 # false + compare brn?, 0/false loop-if-!= $main:word-loop var gry?/eax: boolean <- slice-equal? val-slice, "gry" - compare gry?, 0 # false + compare gry?, 0/false loop-if-!= $main:word-loop var grn?/eax: boolean <- slice-equal? val-slice, "grn" - compare grn?, 0 # false + compare grn?, 0/false loop-if-!= $main:word-loop var hzl?/eax: boolean <- slice-equal? val-slice, "hzl" - compare hzl?, 0 # false + compare hzl?, 0/false loop-if-!= $main:word-loop var oth?/eax: boolean <- slice-equal? val-slice, "oth" - compare oth?, 0 # false + compare oth?, 0/false loop-if-!= $main:word-loop print-string 0, "invalid\n" curr-passport-field-count <- copy 8 @@ -271,7 +271,7 @@ fn main -> _/ebx: int { # pid { var pid?/eax: boolean <- slice-equal? key-slice, "pid" - compare pid?, 0 # false + compare pid?, 0/false break-if-= # convert val var s: (handle array byte) diff --git a/apps/advent2020/5a.mu b/apps/advent2020/5a.mu index f933dd16..5a456608 100644 --- a/apps/advent2020/5a.mu +++ b/apps/advent2020/5a.mu @@ -19,7 +19,7 @@ fn main -> _/ebx: int { print-stream-to-real-screen line # if line is empty (not even a newline), quit var done?/eax: boolean <- stream-empty? line - compare done?, 0 # false + compare done?, 0/false break-if-!= # process line var seat-id/eax: int <- convert-from-binary line @@ -50,12 +50,12 @@ fn convert-from-binary in: (addr stream byte) -> _/eax: int { #? print-string 0, "\n" var bit/edx: int <- copy 0 { - compare c, 0x42 # 'B' + compare c, 0x42/B break-if-!= bit <- copy 1 } { - compare c, 0x52 # 'R' + compare c, 0x52/R break-if-!= bit <- copy 1 } diff --git a/apps/advent2020/5b.mu b/apps/advent2020/5b.mu index 215b0a66..fbc0d618 100644 --- a/apps/advent2020/5b.mu +++ b/apps/advent2020/5b.mu @@ -20,7 +20,7 @@ fn main -> _/ebx: int { read-line-from-real-keyboard line # if line is empty (not even a newline), quit var done?/eax: boolean <- stream-empty? line - compare done?, 0 # false + compare done?, 0/false break-if-!= # process line var seat-id/eax: int <- convert-from-binary line @@ -63,12 +63,12 @@ fn convert-from-binary in: (addr stream byte) -> _/eax: int { var c/eax: byte <- read-byte in var bit/edx: int <- copy 0 { - compare c, 0x42 # 'B' + compare c, 0x42/B break-if-!= bit <- copy 1 } { - compare c, 0x52 # 'R' + compare c, 0x52/R break-if-!= bit <- copy 1 } diff --git a/apps/arith.mu b/apps/arith.mu index 20e29e91..3183cd31 100644 --- a/apps/arith.mu +++ b/apps/arith.mu @@ -35,19 +35,19 @@ fn main -> _/ebx: int { enable-keyboard-immediate-mode var look/esi: grapheme <- copy 0 # lookahead var n/eax: int <- copy 0 # result of each expression - print-string 0, "press ctrl-c or ctrl-d to exit\n" + print-string 0/screen, "press ctrl-c or ctrl-d to exit\n" # read-eval-print loop { # print prompt - print-string 0, "> " + print-string 0/screen, "> " # read and eval n, look <- simplify # we explicitly thread 'look' everywhere # if (look == 0) break compare look, 0 break-if-= # print - print-int32-decimal 0, n - print-string 0, "\n" + print-int32-decimal 0/screen, n + print-string 0/screen, "\n" # loop } @@ -74,7 +74,7 @@ fn expression _look: grapheme -> _/eax: int, _/esi: grapheme { look <- skip-spaces look { var continue?/eax: boolean <- is-add-or-sub? look - compare continue?, 0 # false + compare continue?, 0/false break-if-= $expression:loop } # read operator @@ -91,13 +91,13 @@ fn expression _look: grapheme -> _/eax: int, _/esi: grapheme { # reduce $expression:perform-op: { { - compare op, 0x2b # '+' + compare op, 0x2b/+ break-if-!= result <- add second break $expression:perform-op } { - compare op, 0x2d # '-' + compare op, 0x2d/minus break-if-!= result <- subtract second break $expression:perform-op @@ -120,7 +120,7 @@ fn term _look: grapheme -> _/eax: int, _/esi: grapheme { look <- skip-spaces look { var continue?/eax: boolean <- is-mul-or-div? look - compare continue?, 0 # false + compare continue?, 0/false break-if-= $term:loop } # read operator @@ -137,13 +137,13 @@ fn term _look: grapheme -> _/eax: int, _/esi: grapheme { # reduce $term:perform-op: { { - compare op, 0x2a # '*' + compare op, 0x2a/* break-if-!= result <- multiply second break $term:perform-op } #? { -#? compare op, 0x2f # '/' +#? compare op, 0x2f/slash #? break-if-!= #? result <- divide second # not in Mu yet #? break $term:perform-op @@ -158,7 +158,7 @@ fn factor _look: grapheme -> _/eax: int, _/esi: grapheme { var look/esi: grapheme <- copy _look # should be a no-op look <- skip-spaces look # if next char is not '(', parse a number - compare look, 0x28 # '(' + compare look, 0x28/open-paren { break-if-= var result/eax: int <- copy 0 @@ -175,31 +175,31 @@ fn factor _look: grapheme -> _/eax: int, _/esi: grapheme { } fn is-mul-or-div? c: grapheme -> _/eax: boolean { - compare c, 0x2a # '*' + compare c, 0x2a/* { break-if-!= - return 1 # true + return 1/true } - compare c, 0x2f # '/' + compare c, 0x2f/slash { break-if-!= - return 1 # true + return 1/true } - return 0 # false + return 0/false } fn is-add-or-sub? c: grapheme -> _/eax: boolean { - compare c, 0x2b # '+' + compare c, 0x2b/+ { break-if-!= - return 1 # true + return 1/true } - compare c, 0x2d # '-' + compare c, 0x2d/minus { break-if-!= - return 1 # true + return 1/true } - return 0 # false + return 0/false } fn operator _look: grapheme -> _/ecx: grapheme, _/esi: grapheme { @@ -219,7 +219,7 @@ fn num _look: grapheme -> _/eax: int, _/esi: grapheme { look <- get-char # done? var digit?/eax: boolean <- is-decimal-digit? look - compare digit?, 0 # false + compare digit?, 0/false break-if-= # result *= 10 { @@ -251,7 +251,7 @@ fn get-char -> _/esi: grapheme { compare look, 4 { break-if-!= - print-string 0, "^D\n" + print-string 0/screen, "^D\n" syscall_exit } return look diff --git a/apps/browse/main.mu b/apps/browse/main.mu index 91eb46e0..5b4f2e06 100644 --- a/apps/browse/main.mu +++ b/apps/browse/main.mu @@ -50,7 +50,7 @@ fn interactive fs: (addr buffered-file) { { render paginated-screen, fs var key/eax: grapheme <- read-key-from-real-keyboard - compare key, 0x71 # 'q' + compare key, 0x71/'q' loop-if-!= } enable-keyboard-type-mode @@ -71,7 +71,7 @@ fn test-render-multicolumn-text { # output screen var pg: paginated-screen var pg-addr/ecx: (addr paginated-screen) <- address pg - initialize-fake-paginated-screen pg-addr, 3, 6, 2, 1, 1 # 3 rows, 6 columns, 2 pages * 2 columns each + initialize-fake-paginated-screen pg-addr, 3/rows, 6/cols, 2/page-width, 1/top-margin, 1/left-margin # render pg-addr, in var screen-ah/eax: (addr handle screen) <- get pg, screen @@ -90,7 +90,7 @@ fn test-render-heading-text { # output screen var pg: paginated-screen var pg-addr/ecx: (addr paginated-screen) <- address pg - initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1 # 6 columns, single page + initialize-fake-paginated-screen pg-addr, 8/rows, 6/cols, 5/page-width, 1/top-margin, 1/left-margin # render pg-addr, in var screen-ah/eax: (addr handle screen) <- get pg, screen @@ -110,7 +110,7 @@ fn test-render-bold-text { # output screen var pg: paginated-screen var pg-addr/ecx: (addr paginated-screen) <- address pg - initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1 # 6 columns, single page + initialize-fake-paginated-screen pg-addr, 8/rows, 6/cols, 5/page-width, 1/top-margin, 1/left-margin # render pg-addr, in var screen-ah/eax: (addr handle screen) <- get pg, screen @@ -130,7 +130,7 @@ fn test-render-pseudoitalic-text { # output screen var pg: paginated-screen var pg-addr/ecx: (addr paginated-screen) <- address pg - initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1 # 6 columns, single page + initialize-fake-paginated-screen pg-addr, 8/rows, 6/cols, 5/page-width, 1/top-margin, 1/left-margin # render pg-addr, in var screen-ah/eax: (addr handle screen) <- get pg, screen @@ -148,7 +148,7 @@ fn test-render-asterisk-in-text { # output screen var pg: paginated-screen var pg-addr/ecx: (addr paginated-screen) <- address pg - initialize-fake-paginated-screen pg-addr, 8, 6, 5, 1, 1 # 6 columns, single page + initialize-fake-paginated-screen pg-addr, 8/nrows, 6/cols, 5/page-width, 1/top-margin, 1/left-margin # render pg-addr, in var screen-ah/eax: (addr handle screen) <- get pg, screen @@ -158,38 +158,38 @@ fn test-render-asterisk-in-text { } fn render-normal screen: (addr paginated-screen), fs: (addr buffered-file) { - var newline-seen?/esi: boolean <- copy 0 # false - var start-of-paragraph?/edi: boolean <- copy 1 # true + var newline-seen?/esi: boolean <- copy 0/false + var start-of-paragraph?/edi: boolean <- copy 1/true var previous-grapheme/ebx: grapheme <- copy 0 $render-normal:loop: { # if done-drawing?(screen) break var done?/eax: boolean <- done-drawing? screen - compare done?, 0 # false + compare done?, 0/false break-if-!= var c/eax: grapheme <- read-grapheme-buffered fs $render-normal:loop-body: { # if (c == EOF) break - compare c, 0xffffffff # EOF marker + compare c, 0xffffffff/end-of-file break-if-= $render-normal:loop ## if (c == newline) perform some fairly sophisticated parsing for soft newlines - compare c, 0xa # newline + compare c, 0xa/newline { break-if-!= # if it's the first newline, buffer it compare newline-seen?, 0 { break-if-!= - newline-seen? <- copy 1 # true + newline-seen? <- copy 1/true break $render-normal:loop-body } # otherwise render two newlines { break-if-= - add-grapheme screen, 0xa # newline - add-grapheme screen, 0xa # newline - newline-seen? <- copy 0 # false - start-of-paragraph? <- copy 1 # true + add-grapheme screen, 0xa/newline + add-grapheme screen, 0xa/newline + newline-seen? <- copy 0/false + start-of-paragraph? <- copy 1/true break $render-normal:loop-body } } @@ -197,16 +197,16 @@ $render-normal:loop-body: { compare start-of-paragraph?, 0 { break-if-= - compare c, 0x23 # '#' + compare c, 0x23/'#' { break-if-!= render-header-line screen, fs - newline-seen? <- copy 1 # true + newline-seen? <- copy 1/true break $render-normal:loop-body } } # c is not a newline - start-of-paragraph? <- copy 0 # false + start-of-paragraph? <- copy 0/false # if c is unprintable (particularly a '\r' CR), skip it compare c, 0x20 loop-if-< $render-normal:loop @@ -214,17 +214,17 @@ $render-normal:loop-body: { # newline (hard newline). # If there's a newline buffered and c is not a newline or space, print a # space (soft newline). - compare newline-seen?, 0 # false + compare newline-seen?, 0/false $render-normal:flush-buffered-newline: { break-if-= - newline-seen? <- copy 0 # false + newline-seen? <- copy 0/false { compare c, 0x20 break-if-!= - add-grapheme screen, 0xa # newline + add-grapheme screen, 0xa/newline break $render-normal:flush-buffered-newline } - add-grapheme screen, 0x20 # space + add-grapheme screen, 0x20/space # fall through to print c } ## end soft newline support @@ -232,27 +232,27 @@ $render-normal:flush-buffered-newline: { $render-normal:whitespace-separated-regions: { # if previous-grapheme wasn't whitespace, skip this block { - compare previous-grapheme, 0x20 # space + compare previous-grapheme, 0x20/space break-if-= - compare previous-grapheme, 0xa # newline + compare previous-grapheme, 0xa/newline break-if-= break $render-normal:whitespace-separated-regions } # if (c == '*') switch to bold - compare c, 0x2a # '*' + compare c, 0x2a/* { break-if-!= - start-color-on-paginated-screen screen, 0xec, 7 # 236 = darkish gray + start-color-on-paginated-screen screen, 0xec/fg=darkish-grey, 7/bg=white start-bold-on-paginated-screen screen render-until-asterisk screen, fs normal-text screen break $render-normal:loop-body } # if (c == '_') switch to bold - compare c, 0x5f # '_' + compare c, 0x5f/_ { break-if-!= - start-color-on-paginated-screen screen, 0xec, 7 # 236 = darkish gray + start-color-on-paginated-screen screen, 0xec/fg=darkish-grey, 7/bg=white start-bold-on-paginated-screen screen render-until-underscore screen, fs normal-text screen @@ -276,13 +276,13 @@ $render-header-line:body: { # if done-drawing?(screen) return { var done?/eax: boolean <- done-drawing? screen - compare done?, 0 # false + compare done?, 0/false break-if-!= $render-header-line:body } # c <- read-grapheme-buffered fs # if (c != '#') break - compare c, 0x23 # '#' + compare c, 0x23/'#' break-if-!= # header-level <- increment @@ -294,16 +294,16 @@ $render-header-line:body: { # if done-drawing?(screen) break { var done?/eax: boolean <- done-drawing? screen - compare done?, 0 # false + compare done?, 0/false break-if-!= } # c <- read-grapheme-buffered fs # if (c == EOF) break - compare c, 0xffffffff # EOF marker + compare c, 0xffffffff/end-of-file break-if-= # if (c == newline) break - compare c, 0xa # newline + compare c, 0xa/newline break-if-= # add-grapheme screen, c @@ -350,15 +350,15 @@ fn render-until-asterisk screen: (addr paginated-screen), fs: (addr buffered-fil { # if done-drawing?(screen) break var done?/eax: boolean <- done-drawing? screen - compare done?, 0 # false + compare done?, 0/false break-if-!= # var c/eax: grapheme <- read-grapheme-buffered fs # if (c == EOF) break - compare c, 0xffffffff # EOF marker + compare c, 0xffffffff/end-of-file break-if-= # if (c == '*') break - compare c, 0x2a # '*' + compare c, 0x2a/'*' break-if-= # add-grapheme screen, c @@ -371,15 +371,15 @@ fn render-until-underscore screen: (addr paginated-screen), fs: (addr buffered-f { # if done-drawing?(screen) break var done?/eax: boolean <- done-drawing? screen - compare done?, 0 # false + compare done?, 0/false break-if-!= # var c/eax: grapheme <- read-grapheme-buffered fs # if (c == EOF) break - compare c, 0xffffffff # EOF marker + compare c, 0xffffffff/end-of-file break-if-= # if (c == '_') break - compare c, 0x5f # '_' + compare c, 0x5f/'_' break-if-= # add-grapheme screen, c @@ -390,5 +390,5 @@ fn render-until-underscore screen: (addr paginated-screen), fs: (addr buffered-f fn normal-text screen: (addr paginated-screen) { reset-formatting-on-paginated-screen screen - start-color-on-paginated-screen screen, 0xec, 7 # 236 = darkish gray + start-color-on-paginated-screen screen, 0xec/fg=darkish-grey, 7/bg=white } diff --git a/apps/browse/paginated-screen.mu b/apps/browse/paginated-screen.mu index 783a1cac..f4579d95 100644 --- a/apps/browse/paginated-screen.mu +++ b/apps/browse/paginated-screen.mu @@ -132,7 +132,7 @@ fn done-drawing? _self: (addr paginated-screen) -> _/eax: boolean { $done-drawing:first-page?: { compare first-col, *tmp break-if-!= - return 0 # false + return 0/false } # return self->rightcol > self->ncols + 1 tmp <- get self, ncols @@ -147,9 +147,9 @@ fn done-drawing? _self: (addr paginated-screen) -> _/eax: boolean { compare *tmp, max { break-if-> - return 0 # false + return 0/false } - return 1 # true + return 1/true } fn add-grapheme _self: (addr paginated-screen), c: grapheme { @@ -159,7 +159,7 @@ fn add-grapheme _self: (addr paginated-screen), c: grapheme { $add-grapheme:body: { var self/esi: (addr paginated-screen) <- copy _self { - compare c, 0xa # newline + compare c, 0xa/newline break-if-!= next-line self reposition-cursor self @@ -189,10 +189,10 @@ $add-grapheme:body: { fn test-print-grapheme-on-paginated-screen { var pg-on-stack: paginated-screen var pg/eax: (addr paginated-screen) <- address pg-on-stack - initialize-fake-paginated-screen pg, 3, 0xa, 0xa, 0, 0 + initialize-fake-paginated-screen pg, 3/rows, 0xa/cols, 0xa/page-width, 0, 0 start-drawing pg { - var c/ecx: grapheme <- copy 0x61 # 'a' + var c/ecx: grapheme <- copy 0x61/a add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? @@ -206,32 +206,32 @@ fn test-print-grapheme-on-paginated-screen { fn test-print-single-page { var pg-on-stack: paginated-screen var pg/eax: (addr paginated-screen) <- address pg-on-stack - initialize-fake-paginated-screen pg, 2, 4, 2, 0, 0 # 2 rows, 4 columns, 2 pages * 2 columns each + initialize-fake-paginated-screen pg, 2/rows, 4/cols, 2/page-width, 0, 0 start-drawing pg # pages at columns [1, 3), [3, 5) { - var c/ecx: grapheme <- copy 0x61 # 'a' + var c/ecx: grapheme <- copy 0x61/a add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page/done-1" } { - var c/ecx: grapheme <- copy 0x62 # 'b' + var c/ecx: grapheme <- copy 0x62/b add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page/done-2" } { - var c/ecx: grapheme <- copy 0x63 # 'c' + var c/ecx: grapheme <- copy 0x63/c add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page/done-3" } { - var c/ecx: grapheme <- copy 0x64 # 'd' + var c/ecx: grapheme <- copy 0x64/d add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? @@ -247,38 +247,38 @@ fn test-print-single-page { fn test-print-single-page-narrower-than-page-width { var pg-on-stack: paginated-screen var pg/eax: (addr paginated-screen) <- address pg-on-stack - initialize-fake-paginated-screen pg, 2, 4, 5, 0, 0 # 2 rows, 4 columns, 5-column pages + initialize-fake-paginated-screen pg, 2/rows, 4/cols, 5/page-width, 0, 0 start-drawing pg { - var c/ecx: grapheme <- copy 0x61 # 'a' + var c/ecx: grapheme <- copy 0x61/a add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width/done-1" } { - var c/ecx: grapheme <- copy 0x62 # 'b' + var c/ecx: grapheme <- copy 0x62/b add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width/done-2" } { - var c/ecx: grapheme <- copy 0x63 # 'c' + var c/ecx: grapheme <- copy 0x63/c add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width/done-3" } { - var c/ecx: grapheme <- copy 0x64 # 'd' + var c/ecx: grapheme <- copy 0x64/d add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width/done-4" } { - var c/ecx: grapheme <- copy 0x65 # 'e' + var c/ecx: grapheme <- copy 0x65/e add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? @@ -294,38 +294,38 @@ fn test-print-single-page-narrower-than-page-width { fn test-print-single-page-narrower-than-page-width-with-margin { var pg-on-stack: paginated-screen var pg/eax: (addr paginated-screen) <- address pg-on-stack - initialize-fake-paginated-screen pg, 2, 4, 5, 0, 1 # 2 rows, 4 columns, 5-column pages, left margin + initialize-fake-paginated-screen pg, 2/rows, 4/cols, 5/page-width, 0/top-margin, 1/left-margin start-drawing pg { - var c/ecx: grapheme <- copy 0x61 # 'a' + var c/ecx: grapheme <- copy 0x61/a add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width-with-margin/done-1" } { - var c/ecx: grapheme <- copy 0x62 # 'b' + var c/ecx: grapheme <- copy 0x62/b add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width-with-margin/done-2" } { - var c/ecx: grapheme <- copy 0x63 # 'c' + var c/ecx: grapheme <- copy 0x63/c add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width-with-margin/done-3" } { - var c/ecx: grapheme <- copy 0x64 # 'd' + var c/ecx: grapheme <- copy 0x64/d add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-single-page-narrower-than-page-width-with-margin/done-4" } { - var c/ecx: grapheme <- copy 0x65 # 'e' + var c/ecx: grapheme <- copy 0x65/e add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? @@ -341,31 +341,31 @@ fn test-print-single-page-narrower-than-page-width-with-margin { fn test-print-multiple-pages { var pg-on-stack: paginated-screen var pg/eax: (addr paginated-screen) <- address pg-on-stack - initialize-fake-paginated-screen pg, 2, 2, 1, 0, 0 # 2 rows, 2 columns, 2 pages * 1 column each + initialize-fake-paginated-screen pg, 2/rows, 2/cols, 1/page-width, 0, 0 start-drawing pg { - var c/ecx: grapheme <- copy 0x61 # 'a' + var c/ecx: grapheme <- copy 0x61/a add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages/done-1" } { - var c/ecx: grapheme <- copy 0x62 # 'b' + var c/ecx: grapheme <- copy 0x62/b add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages/done-2" } { - var c/ecx: grapheme <- copy 0x63 # 'c' + var c/ecx: grapheme <- copy 0x63/c add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages/done-3" } { - var c/ecx: grapheme <- copy 0x64 # 'd' + var c/ecx: grapheme <- copy 0x64/d add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? @@ -381,59 +381,59 @@ fn test-print-multiple-pages { fn test-print-multiple-pages-2 { var pg-on-stack: paginated-screen var pg/eax: (addr paginated-screen) <- address pg-on-stack - initialize-fake-paginated-screen pg, 2, 4, 2, 0, 0 # 2 rows, 4 columns, 2 pages * 2 columns each + initialize-fake-paginated-screen pg, 2/rows, 4/cols, 2/page-width, 0, 0 start-drawing pg { - var c/ecx: grapheme <- copy 0x61 # 'a' + var c/ecx: grapheme <- copy 0x61/a add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-2/done-1" } { - var c/ecx: grapheme <- copy 0x62 # 'b' + var c/ecx: grapheme <- copy 0x62/b add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-2/done-2" } { - var c/ecx: grapheme <- copy 0x63 # 'c' + var c/ecx: grapheme <- copy 0x63/c add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-2/done-3" } { - var c/ecx: grapheme <- copy 0x64 # 'd' + var c/ecx: grapheme <- copy 0x64/d add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-2/done-4" } { - var c/ecx: grapheme <- copy 0x65 # 'e' + var c/ecx: grapheme <- copy 0x65/e add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-2/done-5" } { - var c/ecx: grapheme <- copy 0x66 # 'f' + var c/ecx: grapheme <- copy 0x66/f add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-2/done-6" } { - var c/ecx: grapheme <- copy 0x67 # 'g' + var c/ecx: grapheme <- copy 0x67/g add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-2/done-7" } { - var c/ecx: grapheme <- copy 0x68 # 'h' + var c/ecx: grapheme <- copy 0x68/h add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? @@ -449,59 +449,59 @@ fn test-print-multiple-pages-2 { fn test-print-multiple-pages-with-margins { var pg-on-stack: paginated-screen var pg/eax: (addr paginated-screen) <- address pg-on-stack - initialize-fake-paginated-screen pg, 3, 6, 2, 1, 1 # 3 rows, 5 columns, 2 pages * 2 columns each + initialize-fake-paginated-screen pg, 3/rows, 6/cols, 2/page-width, 1/top-margin, 1/left-margin start-drawing pg { - var c/ecx: grapheme <- copy 0x61 # 'a' + var c/ecx: grapheme <- copy 0x61/a add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-with-margins/grapheme-1" } { - var c/ecx: grapheme <- copy 0x62 # 'b' + var c/ecx: grapheme <- copy 0x62/b add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-with-margins/grapheme-2" } { - var c/ecx: grapheme <- copy 0x63 # 'c' + var c/ecx: grapheme <- copy 0x63/c add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-with-margins/grapheme-3" } { - var c/ecx: grapheme <- copy 0x64 # 'd' + var c/ecx: grapheme <- copy 0x64/d add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-with-margins/grapheme-4" } { - var c/ecx: grapheme <- copy 0x65 # 'e' + var c/ecx: grapheme <- copy 0x65/e add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-with-margins/grapheme-5" } { - var c/ecx: grapheme <- copy 0x66 # 'f' + var c/ecx: grapheme <- copy 0x66/f add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-with-margins/grapheme-6" } { - var c/ecx: grapheme <- copy 0x67 # 'g' + var c/ecx: grapheme <- copy 0x67/g add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? check-ints-equal done, 0, "F - test-print-multiple-pages-with-margins/grapheme-7" } { - var c/ecx: grapheme <- copy 0x68 # 'h' + var c/ecx: grapheme <- copy 0x68/h add-grapheme pg, c var done?/eax: boolean <- done-drawing? pg var done/eax: int <- copy done? diff --git a/apps/hello.mu b/apps/hello.mu index 5a656b96..9e8fdb6f 100644 --- a/apps/hello.mu +++ b/apps/hello.mu @@ -5,6 +5,6 @@ # $ ./a.elf fn main -> _/ebx: int { - print-string 0, "Hello world!\n" + print-string 0/screen, "Hello world!\n" return 0 } diff --git a/apps/parse-int.mu b/apps/parse-int.mu index fb32c106..5bef26ab 100644 --- a/apps/parse-int.mu +++ b/apps/parse-int.mu @@ -13,7 +13,7 @@ fn main _args: (addr array addr array byte) -> _/ebx: int { compare n, 1 { break-if-> - print-string 0, "usage: parse-int <integer>\n" + print-string 0/screen, "usage: parse-int <integer>\n" return 1 } # otherwise parse the first arg as an integer diff --git a/apps/print-file.mu b/apps/print-file.mu index f04713c0..57e044dc 100644 --- a/apps/print-file.mu +++ b/apps/print-file.mu @@ -13,7 +13,7 @@ fn main _args: (addr array addr array byte) -> _/ebx: int { compare n, 1 { break-if-> - print-string 0, "usage: cat <filename>\n" + print-string 0/screen, "usage: cat <filename>\n" return 0 } { @@ -22,16 +22,16 @@ fn main _args: (addr array addr array byte) -> _/ebx: int { var in: (handle buffered-file) { var addr-in/eax: (addr handle buffered-file) <- address in - open *filename, 0, addr-in + open *filename, 0/read-only, addr-in } var _in-addr/eax: (addr buffered-file) <- lookup in var in-addr/ecx: (addr buffered-file) <- copy _in-addr { var c/eax: byte <- read-byte-buffered in-addr - compare c, 0xffffffff # EOF marker + compare c, 0xffffffff/end-of-file break-if-= var g/eax: grapheme <- copy c - print-grapheme 0, g + print-grapheme 0/screen, g loop } } diff --git a/apps/rpn.mu b/apps/rpn.mu index b1c66021..762d9605 100644 --- a/apps/rpn.mu +++ b/apps/rpn.mu @@ -29,11 +29,11 @@ fn main -> _/ebx: int { var in-storage: (stream byte 0x100) var in/esi: (addr stream byte) <- address in-storage - print-string 0, "press ctrl-c or ctrl-d to exit\n" + print-string 0/screen, "press ctrl-c or ctrl-d to exit\n" # read-eval-print loop { # print prompt - print-string 0, "> " + print-string 0/screen, "> " # read line clear-stream in read-line-from-real-keyboard in @@ -43,8 +43,8 @@ fn main -> _/ebx: int { # parse and eval var out/eax: int <- simplify in # print - print-int32-decimal 0, out - print-string 0, "\n" + print-int32-decimal 0/screen, out + print-string 0/screen, "\n" # loop } diff --git a/apps/texture.mu b/apps/texture.mu index 1eaf892d..4cfd3bbe 100644 --- a/apps/texture.mu +++ b/apps/texture.mu @@ -11,12 +11,12 @@ fn main -> _/ebx: int { #? var height/edi: int <- copy 0xe1 # 225; aspect ratio 16:9 var width/esi: int <- copy 0xff var height/edi: int <- copy 0xff - print-string 0, "P3\n" - print-int32-decimal 0, width - print-string 0, " " - print-int32-decimal 0, height - print-string 0, "\n" - print-string 0, "255\n" # color depth + print-string 0/screen, "P3\n" + print-int32-decimal 0/screen, width + print-string 0/screen, " " + print-int32-decimal 0/screen, height + print-string 0/screen, "\n" + print-string 0/screen, "255\n" # color depth var row/ecx: int <- copy 0 { compare row, height @@ -31,23 +31,23 @@ fn main -> _/ebx: int { tmp <- and 0x7f tmp <- add 0x80 tmp <- copy 0xff - print-int32-decimal 0, tmp - print-string 0, " " + print-int32-decimal 0/screen, tmp + print-string 0/screen, " " # g tmp <- copy row tmp <- multiply col tmp <- and 0x7f tmp <- add 0x80 #? tmp <- copy 0xcf - print-int32-decimal 0, tmp - print-string 0, " " + print-int32-decimal 0/screen, tmp + print-string 0/screen, " " # b tmp <- copy row tmp <- multiply col tmp <- and 0x7f tmp <- add 0x80 - print-int32-decimal 0, tmp - print-string 0, "\n" + print-int32-decimal 0/screen, tmp + print-string 0/screen, "\n" col <- increment loop } diff --git a/apps/tile/box.mu b/apps/tile/box.mu index c4fa4ad2..859d0b8e 100644 --- a/apps/tile/box.mu +++ b/apps/tile/box.mu @@ -78,7 +78,7 @@ fn clear-rect screen: (addr screen), row1: int, col1: int, row2: int, col2: int { compare j, col2 break-if-> - print-grapheme screen 0x20 # space + print-grapheme screen 0x20/space j <- increment loop } @@ -98,7 +98,7 @@ fn clear-rect2 screen: (addr screen), row1: int, col1: int, w: int, h: int { { compare j, h break-if->= - print-grapheme screen 0x20 # space + print-grapheme screen 0x20/space j <- increment loop } diff --git a/apps/tile/data.mu b/apps/tile/data.mu index 6968d880..d711e7d7 100644 --- a/apps/tile/data.mu +++ b/apps/tile/data.mu @@ -248,7 +248,7 @@ fn function-body functions: (addr handle function), _word: (addr handle word), o var curr-name-ah/eax: (addr handle array byte) <- get curr, name var curr-name/eax: (addr array byte) <- lookup *curr-name-ah var found?/eax: boolean <- string-equal? curr-name, function-name - compare found?, 0 # false + compare found?, 0/false { break-if-= var src/eax: (addr handle line) <- get curr, body @@ -333,16 +333,16 @@ fn find-in-call-paths call-paths: (addr handle call-path), needle: (addr handle { var curr-data/eax: (addr handle call-path-element) <- get curr, data var match?/eax: boolean <- call-path-element-match? curr-data, needle - compare match?, 0 # false + compare match?, 0/false { break-if-= - return 1 # true + return 1/true } } curr-ah <- get curr, next loop } - return 0 # false + return 0/false } fn call-path-element-match? _x: (addr handle call-path-element), _y: (addr handle call-path-element) -> _/eax: boolean { @@ -355,17 +355,17 @@ fn call-path-element-match? _x: (addr handle call-path-element), _y: (addr handl compare x, y { break-if-!= - return 1 # true + return 1/true } compare x, 0 { break-if-!= - return 0 # false + return 0/false } compare y, 0 { break-if-!= - return 0 # false + return 0/false } # compare word addresses, not contents var x-data-ah/ecx: (addr handle word) <- get x, word @@ -382,7 +382,7 @@ fn call-path-element-match? _x: (addr handle call-path-element), _y: (addr handl compare x-data, y-data { break-if-= - return 0 # false + return 0/false } var x-next/ecx: (addr handle call-path-element) <- get x, next var y-next/eax: (addr handle call-path-element) <- get y, next @@ -437,7 +437,7 @@ fn delete-in-call-path list: (addr handle call-path), needle: (addr handle call- { var curr-data/eax: (addr handle call-path-element) <- get curr, data var match?/eax: boolean <- call-path-element-match? curr-data, needle - compare match?, 0 # false + compare match?, 0/false { break-if-= var next-ah/ecx: (addr handle call-path) <- get curr, next diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu index 3517e0ef..de771dee 100644 --- a/apps/tile/environment.mu +++ b/apps/tile/environment.mu @@ -106,14 +106,14 @@ fn process-goto-dialog _self: (addr environment), key: grapheme { var self/esi: (addr environment) <- copy _self var fn-name-ah/edi: (addr handle word) <- get self, partial-function-name # if 'esc' pressed, cancel goto - compare key, 0x1b # esc + compare key, 0x1b/esc $process-goto-dialog:cancel: { break-if-!= clear-object fn-name-ah return } # if 'enter' pressed, location function and set cursor to it - compare key, 0xa # enter + compare key, 0xa/enter $process-goto-dialog:commit: { break-if-!= #? print-string 0, "jump\n" @@ -127,13 +127,13 @@ fn process-goto-dialog _self: (addr environment), key: grapheme { return } # - compare key, 0x7f # del (backspace on Macs) + compare key, 0x7f/del # backspace on Macs $process-goto-dialog:backspace: { break-if-!= # if not at start, delete grapheme before cursor var fn-name/eax: (addr word) <- lookup *fn-name-ah var at-start?/eax: boolean <- cursor-at-start? fn-name - compare at-start?, 0 # false + compare at-start?, 0/false { break-if-!= var fn-name/eax: (addr word) <- lookup *fn-name-ah @@ -144,7 +144,7 @@ fn process-goto-dialog _self: (addr environment), key: grapheme { # otherwise insert key within current word var print?/eax: boolean <- real-grapheme? key $process-goto-dialog:real-grapheme: { - compare print?, 0 # false + compare print?, 0/false break-if-= var fn-name/eax: (addr word) <- lookup *fn-name-ah add-grapheme-to-word fn-name, key @@ -165,13 +165,13 @@ fn process-function-edit _self: (addr environment), _function: (addr function), var cursor-word-ah/ebx: (addr handle word) <- get function, cursor-word var _cursor-word/eax: (addr word) <- lookup *cursor-word-ah var cursor-word/ecx: (addr word) <- copy _cursor-word - compare key, 0x445b1b # left-arrow + compare key, 0x445b1b/left-arrow $process-function-edit:key-left-arrow: { break-if-!= #? print-string 0, "left-arrow\n" # if not at start, move left within current word var at-start?/eax: boolean <- cursor-at-start? cursor-word - compare at-start?, 0 # false + compare at-start?, 0/false { break-if-!= #? print-string 0, "cursor left within word\n" @@ -190,12 +190,12 @@ fn process-function-edit _self: (addr environment), _function: (addr function), } return } - compare key, 0x435b1b # right-arrow + compare key, 0x435b1b/right-arrow $process-function-edit:key-right-arrow: { break-if-!= # if not at end, move right within current word var at-end?/eax: boolean <- cursor-at-end? cursor-word - compare at-end?, 0 # false + compare at-end?, 0/false { break-if-!= cursor-right cursor-word @@ -213,7 +213,7 @@ fn process-function-edit _self: (addr environment), _function: (addr function), return } # word-based motions - compare key, 2 # ctrl-b + compare key, 2/ctrl-b $process-function-edit:prev-word: { break-if-!= # jump to previous word if possible @@ -227,7 +227,7 @@ fn process-function-edit _self: (addr environment), _function: (addr function), } return } - compare key, 6 # ctrl-f + compare key, 6/ctrl-f $process-function-edit:next-word: { break-if-!= # jump to previous word if possible @@ -242,7 +242,7 @@ fn process-function-edit _self: (addr environment), _function: (addr function), return } # line-based motions - compare key, 1 # ctrl-a + compare key, 1/ctrl-a $process-function-edit:start-of-line: { break-if-!= # move cursor to start of first word @@ -254,7 +254,7 @@ fn process-function-edit _self: (addr environment), _function: (addr function), cursor-to-start body-contents return } - compare key, 5 # ctrl-e + compare key, 5/ctrl-e $process-function-edit:end-of-line: { break-if-!= # move cursor to end of final word @@ -268,7 +268,7 @@ fn process-function-edit _self: (addr environment), _function: (addr function), return } # bounce to another function - compare key, 7 # ctrl-g + compare key, 7/ctrl-g $process-function-edit:goto-function: { break-if-!= # initialize dialog to name function to jump to @@ -279,7 +279,7 @@ fn process-function-edit _self: (addr environment), _function: (addr function), return } # bounce to sandbox - compare key, 9 # tab + compare key, 9/tab $process-function-edit:goto-sandbox: { break-if-!= var function-ah/eax: (addr handle function) <- get self, cursor-function @@ -287,12 +287,12 @@ fn process-function-edit _self: (addr environment), _function: (addr function), return } # editing the current function - compare key, 0x7f # del (backspace on Macs) + compare key, 0x7f/del # backspace on Macs $process-function-edit:backspace: { break-if-!= # if not at start of some word, delete grapheme before cursor within current word var at-start?/eax: boolean <- cursor-at-start? cursor-word - compare at-start?, 0 # false + compare at-start?, 0/false { break-if-!= delete-before-cursor cursor-word @@ -310,14 +310,14 @@ fn process-function-edit _self: (addr environment), _function: (addr function), } return } - compare key, 0x20 # space + compare key, 0x20/space $process-function-edit:space: { break-if-!= #? print-string 0, "space\n" # if cursor is at start of word, insert word before { var at-start?/eax: boolean <- cursor-at-start? cursor-word - compare at-start?, 0 # false + compare at-start?, 0/false break-if-= var prev-word-ah/eax: (addr handle word) <- get cursor-word, prev append-word prev-word-ah @@ -329,10 +329,10 @@ fn process-function-edit _self: (addr environment), _function: (addr function), # TODO: support string escaping { var first-grapheme/eax: grapheme <- first-grapheme cursor-word - compare first-grapheme, 0x22 # double quote + compare first-grapheme, 0x22/double-quote break-if-!= var final-grapheme/eax: grapheme <- grapheme-before-cursor cursor-word - compare final-grapheme, 0x22 # double quote + compare final-grapheme, 0x22/double-quote break-if-= break $process-function-edit:space } @@ -340,10 +340,10 @@ fn process-function-edit _self: (addr environment), _function: (addr function), # TODO: support nested arrays { var first-grapheme/eax: grapheme <- first-grapheme cursor-word - compare first-grapheme, 0x5b # '[' + compare first-grapheme, 0x5b/[ break-if-!= var final-grapheme/eax: grapheme <- grapheme-before-cursor cursor-word - compare final-grapheme, 0x5d # ']' + compare final-grapheme, 0x5d/] break-if-= break $process-function-edit:space } @@ -354,7 +354,7 @@ fn process-function-edit _self: (addr environment), _function: (addr function), copy-object next-word-ah, cursor-word-ah # if cursor is at end of word, that's all var at-end?/eax: boolean <- cursor-at-end? cursor-word - compare at-end?, 0 # false + compare at-end?, 0/false { break-if-= return @@ -366,7 +366,7 @@ fn process-function-edit _self: (addr environment), _function: (addr function), var next-word/ebx: (addr word) <- copy _next-word { var at-end?/eax: boolean <- cursor-at-end? cursor-word - compare at-end?, 0 # false + compare at-end?, 0/false break-if-!= var g/eax: grapheme <- pop-after-cursor cursor-word add-grapheme-to-word next-word, g @@ -379,7 +379,7 @@ fn process-function-edit _self: (addr environment), _function: (addr function), var g/edx: grapheme <- copy key var print?/eax: boolean <- real-grapheme? key $process-function-edit:real-grapheme: { - compare print?, 0 # false + compare print?, 0/false break-if-= add-grapheme-to-word cursor-word, g return @@ -421,13 +421,13 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key var cursor-word-ah/ebx: (addr handle word) <- get cursor-call-path, word var _cursor-word/eax: (addr word) <- lookup *cursor-word-ah var cursor-word/ecx: (addr word) <- copy _cursor-word - compare key, 0x445b1b # left-arrow + compare key, 0x445b1b/left-arrow $process-sandbox-edit:key-left-arrow: { break-if-!= #? print-string 0, "left-arrow\n" # if not at start, move left within current word var at-start?/eax: boolean <- cursor-at-start? cursor-word - compare at-start?, 0 # false + compare at-start?, 0/false { break-if-!= #? print-string 0, "cursor left within word\n" @@ -439,7 +439,7 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key var cursor-call-path/esi: (addr handle call-path-element) <- get sandbox, cursor-call-path var expanded-words/edx: (addr handle call-path) <- get sandbox, expanded-words var curr-word-is-expanded?/eax: boolean <- find-in-call-paths expanded-words, cursor-call-path - compare curr-word-is-expanded?, 0 # false + compare curr-word-is-expanded?, 0/false break-if-= # update cursor-call-path #? print-string 0, "curr word is expanded\n" @@ -519,12 +519,12 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key } return } - compare key, 0x435b1b # right-arrow + compare key, 0x435b1b/right-arrow $process-sandbox-edit:key-right-arrow: { break-if-!= # if not at end, move right within current word var at-end?/eax: boolean <- cursor-at-end? cursor-word - compare at-end?, 0 # false + compare at-end?, 0/false { break-if-!= #? print-string 0, "a\n" @@ -564,7 +564,7 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key { var expanded-words/eax: (addr handle call-path) <- get sandbox, expanded-words var curr-word-is-expanded?/eax: boolean <- find-in-call-paths expanded-words, cursor-call-path - compare curr-word-is-expanded?, 0 # false + compare curr-word-is-expanded?, 0/false break-if-= $process-sandbox-edit:key-right-arrow-next-word-is-call-expanded } var callee-h: (handle function) @@ -588,14 +588,14 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key } return } - compare key, 0xa # enter + compare key, 0xa/enter { break-if-!= # toggle display of subsidiary stack toggle-cursor-word sandbox return } - compare key, 0xc # ctrl-l + compare key, 0xc/ctrl-l $process-sandbox-edit:new-line: { break-if-!= # new line in sandbox @@ -603,7 +603,7 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key return } # word-based motions - compare key, 2 # ctrl-b + compare key, 2/ctrl-b $process-sandbox-edit:prev-word: { break-if-!= # jump to previous word at same level @@ -638,7 +638,7 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key return } } - compare key, 6 # ctrl-f + compare key, 6/ctrl-f $process-sandbox-edit:next-word: { break-if-!= #? print-string 0, "AA\n" @@ -666,7 +666,7 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key copy-object caller-cursor-element-ah, cursor-call-path-ah return } - compare key, 7 # ctrl-g + compare key, 7/ctrl-g $process-sandbox-edit:goto-function: { break-if-!= # initialize dialog to name function to jump to @@ -677,7 +677,7 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key return } # line-based motions - compare key, 1 # ctrl-a + compare key, 1/ctrl-a $process-sandbox-edit:start-of-line: { break-if-!= # move cursor up past all calls and to start of line @@ -693,7 +693,7 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key # but we don't expect to see zero-arg functions first-up return } - compare key, 5 # ctrl-e + compare key, 5/ctrl-e $process-sandbox-edit:end-of-line: { break-if-!= # move cursor up past all calls and to start of line @@ -709,7 +709,7 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key # so the final word is always guaranteed to be at the top-level return } - compare key, 0x15 # ctrl-u + compare key, 0x15/ctrl-u $process-sandbox-edit:clear-line: { break-if-!= # clear line in sandbox @@ -727,12 +727,12 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key return } # - remaining keys only work at the top row outside any function calls - compare key, 0x7f # del (backspace on Macs) + compare key, 0x7f/del # backspace on Macs $process-sandbox-edit:backspace: { break-if-!= # if not at start of some word, delete grapheme before cursor within current word var at-start?/eax: boolean <- cursor-at-start? cursor-word - compare at-start?, 0 # false + compare at-start?, 0/false { break-if-!= delete-before-cursor cursor-word @@ -751,14 +751,14 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key } return } - compare key, 0x20 # space + compare key, 0x20/space $process-sandbox-edit:space: { break-if-!= #? print-string 0, "space\n" # if cursor is at start of word, insert word before { var at-start?/eax: boolean <- cursor-at-start? cursor-word - compare at-start?, 0 # false + compare at-start?, 0/false break-if-= var prev-word-ah/eax: (addr handle word) <- get cursor-word, prev append-word prev-word-ah @@ -770,10 +770,10 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key # TODO: support string escaping { var first-grapheme/eax: grapheme <- first-grapheme cursor-word - compare first-grapheme, 0x22 # double quote + compare first-grapheme, 0x22/double-quote break-if-!= var final-grapheme/eax: grapheme <- grapheme-before-cursor cursor-word - compare final-grapheme, 0x22 # double quote + compare final-grapheme, 0x22/double-quote break-if-= break $process-sandbox-edit:space } @@ -781,10 +781,10 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key # TODO: support nested arrays { var first-grapheme/eax: grapheme <- first-grapheme cursor-word - compare first-grapheme, 0x5b # '[' + compare first-grapheme, 0x5b/[ break-if-!= var final-grapheme/eax: grapheme <- grapheme-before-cursor cursor-word - compare final-grapheme, 0x5d # ']' + compare final-grapheme, 0x5d/] break-if-= break $process-sandbox-edit:space } @@ -795,7 +795,7 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key increment-final-element cursor-call-path # if cursor is at end of word, that's all var at-end?/eax: boolean <- cursor-at-end? cursor-word - compare at-end?, 0 # false + compare at-end?, 0/false { break-if-= return @@ -807,7 +807,7 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key var next-word/ebx: (addr word) <- copy _next-word { var at-end?/eax: boolean <- cursor-at-end? cursor-word - compare at-end?, 0 # false + compare at-end?, 0/false break-if-!= var g/eax: grapheme <- pop-after-cursor cursor-word add-grapheme-to-word next-word, g @@ -816,7 +816,7 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key cursor-to-start next-word return } - compare key, 0xe # ctrl-n + compare key, 0xe/ctrl-n $process:rename-word: { break-if-!= # TODO: ensure current word is not a function @@ -827,7 +827,7 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key initialize-word new-name return } - compare key, 4 # ctrl-d + compare key, 4/ctrl-d $process:define-function: { break-if-!= # define function out of line at cursor @@ -841,7 +841,7 @@ fn process-sandbox-edit _self: (addr environment), _sandbox: (addr sandbox), key var g/edx: grapheme <- copy key var print?/eax: boolean <- real-grapheme? key $process-sandbox-edit:real-grapheme: { - compare print?, 0 # false + compare print?, 0/false break-if-= add-grapheme-to-word cursor-word, g return @@ -856,14 +856,14 @@ fn process-sandbox-rename _sandbox: (addr sandbox), key: grapheme { var sandbox/esi: (addr sandbox) <- copy _sandbox var new-name-ah/edi: (addr handle word) <- get sandbox, partial-name-for-cursor-word # if 'esc' pressed, cancel rename - compare key, 0x1b # esc + compare key, 0x1b/esc $process-sandbox-rename:cancel: { break-if-!= clear-object new-name-ah return } # if 'enter' pressed, perform rename - compare key, 0xa # enter + compare key, 0xa/enter $process-sandbox-rename:commit: { break-if-!= #? print-string 0, "rename\n" @@ -911,7 +911,7 @@ fn process-sandbox-rename _sandbox: (addr sandbox), key: grapheme { { var new-name/eax: (addr word) <- lookup *new-name-ah cursor-to-start new-name - add-grapheme-to-word new-name, 0x3d # '=' + add-grapheme-to-word new-name, 0x3d/= } # append name to new line chain-words new-line-word-ah, new-name-ah @@ -938,13 +938,13 @@ fn process-sandbox-rename _sandbox: (addr sandbox), key: grapheme { return } # - compare key, 0x7f # del (backspace on Macs) + compare key, 0x7f/del # backspace on Macs $process-sandbox-rename:backspace: { break-if-!= # if not at start, delete grapheme before cursor var new-name/eax: (addr word) <- lookup *new-name-ah var at-start?/eax: boolean <- cursor-at-start? new-name - compare at-start?, 0 # false + compare at-start?, 0/false { break-if-!= var new-name/eax: (addr word) <- lookup *new-name-ah @@ -955,7 +955,7 @@ fn process-sandbox-rename _sandbox: (addr sandbox), key: grapheme { # otherwise insert key within current word var print?/eax: boolean <- real-grapheme? key $process-sandbox-rename:real-grapheme: { - compare print?, 0 # false + compare print?, 0/false break-if-= var new-name/eax: (addr word) <- lookup *new-name-ah add-grapheme-to-word new-name, key @@ -972,14 +972,14 @@ fn process-sandbox-define _sandbox: (addr sandbox), functions: (addr handle func var sandbox/esi: (addr sandbox) <- copy _sandbox var new-name-ah/edi: (addr handle word) <- get sandbox, partial-name-for-function # if 'esc' pressed, cancel define - compare key, 0x1b # esc + compare key, 0x1b/esc $process-sandbox-define:cancel: { break-if-!= clear-object new-name-ah return } # if 'enter' pressed, perform define - compare key, 0xa # enter + compare key, 0xa/enter $process-sandbox-define:commit: { break-if-!= #? print-string 0, "define\n" @@ -1030,13 +1030,13 @@ fn process-sandbox-define _sandbox: (addr sandbox), functions: (addr handle func return } # - compare key, 0x7f # del (backspace on Macs) + compare key, 0x7f/del # backspace on Macs $process-sandbox-define:backspace: { break-if-!= # if not at start, delete grapheme before cursor var new-name/eax: (addr word) <- lookup *new-name-ah var at-start?/eax: boolean <- cursor-at-start? new-name - compare at-start?, 0 # false + compare at-start?, 0/false { break-if-!= var new-name/eax: (addr word) <- lookup *new-name-ah @@ -1047,7 +1047,7 @@ fn process-sandbox-define _sandbox: (addr sandbox), functions: (addr handle func # otherwise insert key within current word var print?/eax: boolean <- real-grapheme? key $process-sandbox-define:real-grapheme: { - compare print?, 0 # false + compare print?, 0/false break-if-= var new-name/eax: (addr word) <- lookup *new-name-ah add-grapheme-to-word new-name, key @@ -1079,16 +1079,16 @@ fn copy-unbound-words-to-args _functions: (addr handle function) { # is it a number? { var is-int?/eax: boolean <- word-is-decimal-integer? curr - compare is-int?, 0 # false + compare is-int?, 0/false break-if-!= $copy-unbound-words-to-args:loop-iter } # is it a pre-existing function? var bound?/ebx: boolean <- bound-function? curr, functions-ah - compare bound?, 0 # false + compare bound?, 0/false break-if-!= # is it already bound as an arg? var dup?/ebx: boolean <- arg-exists? _functions, curr # _functions = target-ah - compare dup?, 0 # false + compare dup?, 0/false break-if-!= $copy-unbound-words-to-args:loop-iter # push copy of curr before dest-ah var rest-h: (handle word) @@ -1104,88 +1104,88 @@ fn copy-unbound-words-to-args _functions: (addr handle function) { } fn bound-function? w: (addr word), functions-ah: (addr handle function) -> _/ebx: boolean { - var result/ebx: boolean <- copy 1 # true + var result/ebx: boolean <- copy 1/true { ## numbers # if w == "+" return true var subresult/eax: boolean <- word-equal? w, "+" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= # if w == "-" return true subresult <- word-equal? w, "-" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= # if w == "*" return true subresult <- word-equal? w, "*" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= # if w == "/" return true subresult <- word-equal? w, "/" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= # if w == "sqrt" return true subresult <- word-equal? w, "sqrt" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= ## strings/arrays # if w == "len" return true subresult <- word-equal? w, "len" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= ## files # if w == "open" return true subresult <- word-equal? w, "open" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= # if w == "read" return true subresult <- word-equal? w, "read" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= # if w == "slurp" return true subresult <- word-equal? w, "slurp" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= # if w == "lines" return true subresult <- word-equal? w, "lines" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= ## screens # if w == "fake-screen" return true subresult <- word-equal? w, "fake-screen" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= # if w == "print" return true subresult <- word-equal? w, "print" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= # if w == "move" return true subresult <- word-equal? w, "move" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= # if w == "up" return true subresult <- word-equal? w, "up" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= # if w == "down" return true subresult <- word-equal? w, "down" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= # if w == "left" return true subresult <- word-equal? w, "left" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= # if w == "right" return true subresult <- word-equal? w, "right" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= ## hacks # if w == "dup" return true subresult <- word-equal? w, "dup" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= # if w == "swap" return true subresult <- word-equal? w, "swap" - compare subresult, 0 # false + compare subresult, 0/false break-if-!= # return w in functions var out-h: (handle function) @@ -1244,7 +1244,7 @@ fn toggle-cursor-word _sandbox: (addr sandbox) { #? print-string 0, "expanded words:\n" #? dump-call-paths 0, expanded-words var already-expanded?/eax: boolean <- find-in-call-paths expanded-words, cursor-call-path - compare already-expanded?, 0 # false + compare already-expanded?, 0/false { break-if-!= #? print-string 0, "expand\n" @@ -1322,7 +1322,7 @@ fn render _env: (addr environment) { render-functions screen, *sep-col, env # sandbox var repl-col/ecx: int <- copy *sep-col - repl-col <- add 2 # repl-margin-left + repl-col <- add 2/repl-margin-left var cursor-sandbox-ah/eax: (addr handle sandbox) <- get env, cursor-sandbox var cursor-sandbox/eax: (addr sandbox) <- lookup *cursor-sandbox-ah # bindings @@ -1410,7 +1410,7 @@ fn render-goto-dialog screen: (addr screen), _env: (addr environment) { var env/esi: (addr environment) <- copy _env var goto-function-mode-ah?/eax: (addr handle word) <- get env, partial-function-name var goto-function-mode?/eax: (addr word) <- lookup *goto-function-mode-ah? - compare goto-function-mode?, 0 # false + compare goto-function-mode?, 0/false break-if-= # clear a space for the dialog var top-row/ebx: int <- copy 3 @@ -1542,7 +1542,7 @@ fn render-rename-dialog screen: (addr screen), _sandbox: (addr sandbox) { var sandbox/edi: (addr sandbox) <- copy _sandbox var rename-word-mode-ah?/ecx: (addr handle word) <- get sandbox, partial-name-for-cursor-word var rename-word-mode?/eax: (addr word) <- lookup *rename-word-mode-ah? - compare rename-word-mode?, 0 # false + compare rename-word-mode?, 0/false break-if-= # clear a space for the dialog var cursor-row/ebx: (addr int) <- get sandbox, cursor-row @@ -1588,7 +1588,7 @@ fn render-define-dialog screen: (addr screen), _sandbox: (addr sandbox) { var sandbox/edi: (addr sandbox) <- copy _sandbox var define-function-mode-ah?/ecx: (addr handle word) <- get sandbox, partial-name-for-function var define-function-mode?/eax: (addr word) <- lookup *define-function-mode-ah? - compare define-function-mode?, 0 # false + compare define-function-mode?, 0/false break-if-= # clear a space for the dialog var cursor-row/ebx: (addr int) <- get sandbox, cursor-row @@ -1656,7 +1656,7 @@ fn render-line-without-stack screen: (addr screen), _line: (addr line), curr-row { var max-width/eax: int <- word-length curr-word curr-col <- add max-width - curr-col <- add 1 # margin-right + curr-col <- add 1/margin-right } # cache cursor column if necessary { @@ -1739,7 +1739,7 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding { #? print-string 0, "check sub\n" var display-subsidiary-stack?/eax: boolean <- find-in-call-paths expanded-words, curr-path - compare display-subsidiary-stack?, 0 # false + compare display-subsidiary-stack?, 0/false break-if-= $render-line:subsidiary } #? print-string 0, "render subsidiary stack\n" @@ -1796,7 +1796,7 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding drop-from-call-path-element curr-path # move-cursor screen, top-row, curr-col - print-code-point screen, 0x21d7 # ⇗ + print-code-point screen, 0x21d7/⇗ # curr-col <- add 2 decrement top-row @@ -1815,7 +1815,7 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding $render-line:cache-cursor-column: { { var found?/eax: boolean <- call-path-element-match? curr-path, cursor-call-path - compare found?, 0 # false + compare found?, 0/false break-if-= $render-line:cache-cursor-column } var dest/edi: (addr int) <- copy cursor-row-addr @@ -1863,7 +1863,7 @@ fn render-column screen: (addr screen), functions: (addr handle function), bindi # compute stack var stack: value-stack var stack-addr/edi: (addr value-stack) <- address stack - initialize-value-stack stack-addr, 0x10 # max-words + initialize-value-stack stack-addr, 0x10/max-words # copy bindings var bindings2-storage: table var bindings2/ebx: (addr table) <- address bindings2-storage @@ -1873,10 +1873,10 @@ fn render-column screen: (addr screen), functions: (addr handle function), bindi evaluate functions, bindings2, first-line, final-word, stack-addr # indent stack var indented-col/ebx: int <- copy left-col - indented-col <- add 1 # margin-right + indented-col <- add 1/margin-right # render stack var curr-row/edx: int <- copy top-row - curr-row <- add 2 # stack-margin-top + curr-row <- add 2/stack-margin-top { var top-addr/ecx: (addr int) <- get stack-addr, top compare *top-addr, 0 @@ -1887,7 +1887,7 @@ fn render-column screen: (addr screen), functions: (addr handle function), bindi var top/ecx: int <- copy *top-addr var dest-offset/ecx: (offset value) <- compute-offset data, top var val/eax: (addr value) <- index data, dest-offset - render-value-at screen, curr-row, indented-col, val, 1 # top-level + render-value-at screen, curr-row, indented-col, val, 1/top-level=true { var width/eax: int <- value-width val, 1 compare width, max-width @@ -1916,7 +1916,7 @@ fn render-column screen: (addr screen), functions: (addr handle function), bindi # post-process right-col var right-col/ecx: int <- copy left-col right-col <- add max-width - right-col <- add 1 # margin-right + right-col <- add 1/margin-right #? print-int32-decimal 0, left-col #? print-string 0, " => " #? print-int32-decimal 0, right-col @@ -2086,7 +2086,7 @@ fn render-functions screen: (addr screen), right-col: int, _env: (addr environme break-if-= row, dummy-col <- render-function-right-aligned screen, row, right-col, curr functions <- get curr, next - row <- add 1 # inter-function-margin + row <- add 1/inter-function-margin loop } } @@ -2095,7 +2095,7 @@ fn render-functions screen: (addr screen), right-col: int, _env: (addr environme # return row, col printed until fn render-function-right-aligned screen: (addr screen), row: int, right-col: int, f: (addr function) -> _/ecx: int, _/edx: int { var col/edx: int <- copy right-col - col <- subtract 1 # function-right-margin + col <- subtract 1/function-right-margin var col2/ebx: int <- copy col var width/eax: int <- function-width f col <- subtract width @@ -2103,15 +2103,15 @@ fn render-function-right-aligned screen: (addr screen), row: int, right-col: int var height/eax: int <- function-height f new-row <- add height new-row <- decrement - col <- subtract 1 # function-left-padding + col <- subtract 1/function-left-padding start-color screen, 0, 0xf7 clear-rect screen, row, col, new-row, col2 col <- add 1 #? var dummy/eax: grapheme <- read-key-from-real-keyboard render-function screen, row, col, f - new-row <- add 1 # function-bottom-margin - col <- subtract 1 # function-left-padding - col <- subtract 1 # function-left-margin + new-row <- add 1/function-bottom-margin + col <- subtract 1/function-left-padding + col <- subtract 1/function-left-margin reset-formatting screen return new-row, col } @@ -2149,33 +2149,33 @@ fn real-grapheme? g: grapheme -> _/eax: boolean { compare g, 0xa { break-if-!= - return 1 # true + return 1/true } # if g == tab return true compare g, 9 { break-if-!= - return 1 # true + return 1/true } # if g < 32 return false compare g, 0x20 { break-if->= - return 0 # false + return 0/false } # if g <= 255 return true compare g, 0xff { break-if-> - return 1 # true + return 1/true } # if (g&0xff == Esc) it's an escape sequence and-with g, 0xff - compare g, 0x1b # Esc + compare g, 0x1b/esc { break-if-!= - return 0 # false + return 0/false } # otherwise return true - return 1 # true + return 1/true } diff --git a/apps/tile/float-stack.mu b/apps/tile/float-stack.mu index 58a13ef4..146995e7 100644 --- a/apps/tile/float-stack.mu +++ b/apps/tile/float-stack.mu @@ -52,9 +52,9 @@ fn float-stack-empty? _self: (addr float-stack) -> _/eax: boolean { compare *top-addr, 0 { break-if-!= - return 1 # true + return 1/true } - return 0 # false + return 0/false } fn float-stack-length _self: (addr float-stack) -> _/eax: int { diff --git a/apps/tile/gap-buffer.mu b/apps/tile/gap-buffer.mu index 4d71789d..b5a690ec 100644 --- a/apps/tile/gap-buffer.mu +++ b/apps/tile/gap-buffer.mu @@ -6,9 +6,9 @@ type gap-buffer { fn initialize-gap-buffer _self: (addr gap-buffer) { var self/esi: (addr gap-buffer) <- copy _self var left/eax: (addr grapheme-stack) <- get self, left - initialize-grapheme-stack left, 0x10 # max-word-size + initialize-grapheme-stack left, 0x10/max-word-size var right/eax: (addr grapheme-stack) <- get self, right - initialize-grapheme-stack right, 0x10 # max-word-size + initialize-grapheme-stack right, 0x10/max-word-size } # just for tests @@ -19,7 +19,7 @@ fn initialize-gap-buffer-with self: (addr gap-buffer), s: (addr array byte) { write stream, s { var done?/eax: boolean <- stream-empty? stream - compare done?, 0 # false + compare done?, 0/false break-if-!= var g/eax: grapheme <- read-grapheme stream add-grapheme-at-gap self, g @@ -244,7 +244,7 @@ fn gap-buffer-equal? _self: (addr gap-buffer), s: (addr array byte) -> _/eax: bo # compare left var left/edx: (addr grapheme-stack) <- get self, left var result/eax: boolean <- prefix-match? left, expected-stream - compare result, 0 # false + compare result, 0/false { break-if-!= return result @@ -252,7 +252,7 @@ fn gap-buffer-equal? _self: (addr gap-buffer), s: (addr array byte) -> _/eax: bo # compare right var right/edx: (addr grapheme-stack) <- get self, right result <- suffix-match? right, expected-stream - compare result, 0 # false + compare result, 0/false { break-if-!= return result @@ -267,7 +267,7 @@ fn test-gap-buffer-equal-from-end? { var g/esi: (addr gap-buffer) <- address _g initialize-gap-buffer g # - var c/eax: grapheme <- copy 0x61 # 'a' + var c/eax: grapheme <- copy 0x61/a add-grapheme-at-gap g, c add-grapheme-at-gap g, c add-grapheme-at-gap g, c @@ -282,7 +282,7 @@ fn test-gap-buffer-equal-from-middle? { var g/esi: (addr gap-buffer) <- address _g initialize-gap-buffer g # - var c/eax: grapheme <- copy 0x61 # 'a' + var c/eax: grapheme <- copy 0x61/a add-grapheme-at-gap g, c add-grapheme-at-gap g, c add-grapheme-at-gap g, c @@ -298,7 +298,7 @@ fn test-gap-buffer-equal-from-start? { var g/esi: (addr gap-buffer) <- address _g initialize-gap-buffer g # - var c/eax: grapheme <- copy 0x61 # 'a' + var c/eax: grapheme <- copy 0x61/a add-grapheme-at-gap g, c add-grapheme-at-gap g, c add-grapheme-at-gap g, c @@ -334,7 +334,7 @@ fn gap-buffer-is-decimal-integer? _self: (addr gap-buffer) -> _/eax: boolean { var curr/ecx: (addr grapheme-stack) <- get self, left var result/eax: boolean <- grapheme-stack-is-decimal-integer? curr { - compare result, 0 # false + compare result, 0/false break-if-= curr <- get self, right result <- grapheme-stack-is-decimal-integer? curr diff --git a/apps/tile/grapheme-stack.mu b/apps/tile/grapheme-stack.mu index 8b123331..e0d40ecc 100644 --- a/apps/tile/grapheme-stack.mu +++ b/apps/tile/grapheme-stack.mu @@ -23,9 +23,9 @@ fn grapheme-stack-empty? _self: (addr grapheme-stack) -> _/eax: boolean { compare *top, 0 { break-if-!= - return 1 # true + return 1/true } - return 0 # false + return 0/false } fn push-grapheme-stack _self: (addr grapheme-stack), _val: grapheme { @@ -131,7 +131,7 @@ fn prefix-match? _self: (addr grapheme-stack), s: (addr stream byte) -> _/eax: b { compare expected, *curr-a break-if-= - return 0 # false + return 0/false } } i <- increment @@ -160,7 +160,7 @@ fn suffix-match? _self: (addr grapheme-stack), s: (addr stream byte) -> _/eax: b { compare expected, *curr-a break-if-= - return 0 # false + return 0/false } } i <- decrement @@ -176,13 +176,13 @@ fn grapheme-stack-is-decimal-integer? _self: (addr grapheme-stack) -> _/eax: boo var data/edx: (addr array grapheme) <- copy _data var top-addr/ecx: (addr int) <- get self, top var i/ebx: int <- copy 0 - var result/eax: boolean <- copy 1 # true + var result/eax: boolean <- copy 1/true $grapheme-stack-is-integer?:loop: { compare i, *top-addr break-if->= var g/edx: (addr grapheme) <- index data, i result <- is-decimal-digit? *g - compare result, 0 # false + compare result, 0/false break-if-= i <- increment loop diff --git a/apps/tile/main.mu b/apps/tile/main.mu index 120913c4..e0daaf1b 100644 --- a/apps/tile/main.mu +++ b/apps/tile/main.mu @@ -7,7 +7,7 @@ fn main args-on-stack: (addr array addr array byte) -> _/ebx: int { # if single arg is 'test', run tests var tmp/ecx: (addr addr array byte) <- index args, 1 var tmp2/eax: boolean <- string-equal? *tmp, "test" - compare tmp2, 0 # false + compare tmp2, 0/false { break-if-= run-tests @@ -15,7 +15,7 @@ fn main args-on-stack: (addr array addr array byte) -> _/ebx: int { } # if single arg is 'screen', run in full-screen mode tmp2 <- string-equal? *tmp, "screen" - compare tmp2, 0 # false + compare tmp2, 0/false { break-if-= interactive @@ -23,7 +23,7 @@ fn main args-on-stack: (addr array addr array byte) -> _/ebx: int { } # if single arg is 'type', run in typewriter mode tmp2 <- string-equal? *tmp, "type" - compare tmp2, 0 # false + compare tmp2, 0/false { break-if-= repl @@ -31,7 +31,7 @@ fn main args-on-stack: (addr array addr array byte) -> _/ebx: int { } # if single arg is 'test' ... tmp2 <- string-equal? *tmp, "test2" - compare tmp2, 0 # false + compare tmp2, 0/false { break-if-= test @@ -55,7 +55,7 @@ fn interactive { { render env var key/eax: grapheme <- read-key-from-real-keyboard - compare key, 0x11 # 'ctrl-q' + compare key, 0x11/ctrl-q break-if-= process env, key loop @@ -77,7 +77,7 @@ fn process-all env: (addr environment), cmds: (addr array byte) { write cmds-stream-a, cmds { var done?/eax: boolean <- stream-empty? cmds-stream-a - compare done?, 0 # false + compare done?, 0/false break-if-!= var g/eax: grapheme <- read-grapheme cmds-stream-a process env, g @@ -95,7 +95,7 @@ fn repl { clear-stream line read-line-from-real-keyboard line var done?/eax: boolean <- stream-empty? line - compare done?, 0 # false + compare done?, 0/false break-if-!= # parse var env-storage: environment @@ -103,7 +103,7 @@ fn repl { initialize-environment env { var done?/eax: boolean <- stream-empty? line - compare done?, 0 # false + compare done?, 0/false break-if-!= var g/eax: grapheme <- read-grapheme line process env, g @@ -117,7 +117,7 @@ fn repl { # print var empty?/eax: boolean <- value-stack-empty? stack { - compare empty?, 0 # false + compare empty?, 0/false break-if-!= var result/xmm0: float <- pop-number-from-value-stack stack print-float-decimal-approximate 0, result, 3 diff --git a/apps/tile/rpn.mu b/apps/tile/rpn.mu index 219e9b09..bf81308b 100644 --- a/apps/tile/rpn.mu +++ b/apps/tile/rpn.mu @@ -90,7 +90,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var target-val/edx: (addr value) <- index data, dest-offset # check target-val is a string or array var target-type-addr/eax: (addr int) <- get target-val, type - compare *target-type-addr, 1 # string + compare *target-type-addr, 1/string { break-if-!= # compute length @@ -100,14 +100,14 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var result-f/xmm0: float <- convert result # save result into target-val var type-addr/eax: (addr int) <- get target-val, type - copy-to *type-addr, 0 # int + copy-to *type-addr, 0/int var target-string-ah/eax: (addr handle array byte) <- get target-val, text-data clear-object target-string-ah var target/eax: (addr float) <- get target-val, number-data copy-to *target, result-f break $evaluate:process-word } - compare *target-type-addr, 2 # array of ints + compare *target-type-addr, 2/array { break-if-!= # compute length @@ -117,7 +117,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var result-f/xmm0: float <- convert result # save result into target-val var type-addr/eax: (addr int) <- get target-val, type - copy-to *type-addr, 0 # int + copy-to *type-addr, 0/int var target-array-ah/eax: (addr handle array value) <- get target-val, array-data clear-object target-array-ah var target/eax: (addr float) <- get target-val, number-data @@ -143,7 +143,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var target-val/edx: (addr value) <- index data, dest-offset # check target-val is a string var target-type-addr/eax: (addr int) <- get target-val, type - compare *target-type-addr, 1 # string + compare *target-type-addr, 1/string break-if-!= # open target-val as a filename and save the handle in target-val var src-ah/eax: (addr handle array byte) <- get target-val, text-data @@ -152,7 +152,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: open src, 0, result-ah # write? = false # save result into target-val var type-addr/eax: (addr int) <- get target-val, type - copy-to *type-addr, 3 # file + copy-to *type-addr, 3/file var target-string-ah/eax: (addr handle array byte) <- get target-val, text-data var filename-ah/ecx: (addr handle array byte) <- get target-val, filename copy-object target-string-ah, filename-ah @@ -176,7 +176,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var target-val/edx: (addr value) <- index data, dest-offset # check target-val is a file var target-type-addr/eax: (addr int) <- get target-val, type - compare *target-type-addr, 3 # file + compare *target-type-addr, 3/file break-if-!= # read a line from the file and save in target-val # read target-val as a filename and save the handle in target-val @@ -189,7 +189,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: stream-to-array s-addr, target # save result into target-val var type-addr/eax: (addr int) <- get target-val, type - copy-to *type-addr, 1 # string + copy-to *type-addr, 1/string var target-file-ah/eax: (addr handle buffered-file) <- get target-val, file-data clear-object target-file-ah break $evaluate:process-word @@ -211,7 +211,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var target-val/edx: (addr value) <- index data, dest-offset # check target-val is a file var target-type-addr/eax: (addr int) <- get target-val, type - compare *target-type-addr, 3 # file + compare *target-type-addr, 3/file break-if-!= # slurp all contents from file and save in target-val # read target-val as a filename and save the handle in target-val @@ -224,7 +224,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: stream-to-array s-addr, target # save result into target-val var type-addr/eax: (addr int) <- get target-val, type - copy-to *type-addr, 1 # string + copy-to *type-addr, 1/string var target-file-ah/eax: (addr handle buffered-file) <- get target-val, file-data clear-object target-file-ah break $evaluate:process-word @@ -246,7 +246,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var target-val/edx: (addr value) <- index data, dest-offset # check target-val is a file var target-type-addr/eax: (addr int) <- get target-val, type - compare *target-type-addr, 3 # file + compare *target-type-addr, 3/file break-if-!= # read all lines from file and save as an array of strings in target-val # read target-val as a filename and save the handle in target-val @@ -269,7 +269,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: save-lines h, target # save result into target-val var type-addr/eax: (addr int) <- get target-val, type - copy-to *type-addr, 2 # array + copy-to *type-addr, 2/array var target-file-ah/eax: (addr handle buffered-file) <- get target-val, file-data var empty-file: (handle buffered-file) copy-handle empty-file, target-file-ah @@ -306,7 +306,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var dest-offset/edx: (offset value) <- compute-offset data, top var target-val/edx: (addr value) <- index data, dest-offset var type/eax: (addr int) <- get target-val, type - copy-to *type, 4 # screen + copy-to *type, 4/screen var dest/eax: (addr handle screen) <- get target-val, screen-data copy-handle screen-h, dest break $evaluate:process-word @@ -338,7 +338,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var dest-offset/edx: (offset value) <- compute-offset data, top var target-val/edx: (addr value) <- index data, dest-offset var type/eax: (addr int) <- get target-val, type - compare *type, 4 # screen + compare *type, 4/screen break-if-!= # print string to target screen var dest-ah/eax: (addr handle screen) <- get target-val, screen-data @@ -370,7 +370,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var target-offset/eax: (offset value) <- compute-offset data, top var target-val/ebx: (addr value) <- index data, target-offset var type/eax: (addr int) <- get target-val, type - compare *type, 4 # screen + compare *type, 4/screen break-if-!= var target-ah/eax: (addr handle screen) <- get target-val, screen-data var target/eax: (addr screen) <- lookup *target-ah @@ -399,7 +399,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var target-offset/eax: (offset value) <- compute-offset data, top var target-val/ebx: (addr value) <- index data, target-offset var type/eax: (addr int) <- get target-val, type - compare *type, 4 # screen + compare *type, 4/screen break-if-!= var target-ah/eax: (addr handle screen) <- get target-val, screen-data var _target/eax: (addr screen) <- lookup *target-ah @@ -442,7 +442,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var target-offset/eax: (offset value) <- compute-offset data, top var target-val/ebx: (addr value) <- index data, target-offset var type/eax: (addr int) <- get target-val, type - compare *type, 4 # screen + compare *type, 4/screen break-if-!= var target-ah/eax: (addr handle screen) <- get target-val, screen-data var _target/eax: (addr screen) <- lookup *target-ah @@ -487,7 +487,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var target-offset/eax: (offset value) <- compute-offset data, top var target-val/ebx: (addr value) <- index data, target-offset var type/eax: (addr int) <- get target-val, type - compare *type, 4 # screen + compare *type, 4/screen break-if-!= var target-ah/eax: (addr handle screen) <- get target-val, screen-data var _target/eax: (addr screen) <- lookup *target-ah @@ -531,7 +531,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var target-offset/eax: (offset value) <- compute-offset data, top var target-val/ebx: (addr value) <- index data, target-offset var type/eax: (addr int) <- get target-val, type - compare *type, 4 # screen + compare *type, 4/screen break-if-!= var target-ah/eax: (addr handle screen) <- get target-val, screen-data var _target/eax: (addr screen) <- lookup *target-ah @@ -610,10 +610,10 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: ### if curr-stream defines a binding, save top of stack to bindings { var done?/eax: boolean <- stream-empty? curr-stream - compare done?, 0 # false + compare done?, 0/false break-if-!= var new-byte/eax: byte <- read-byte curr-stream - compare new-byte, 0x3d # '=' + compare new-byte, 0x3d/= break-if-!= # pop target-val from out var out2/esi: (addr value-stack) <- copy out @@ -665,10 +665,10 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: ### if the word starts with a quote and ends with a quote, turn it into a string { var start/eax: byte <- stream-first curr-stream - compare start, 0x22 # double-quote + compare start, 0x22/double-quote break-if-!= var end/eax: byte <- stream-final curr-stream - compare end, 0x22 # double-quote + compare end, 0x22/double-quote break-if-!= var h: (handle array byte) var s/eax: (addr handle array byte) <- address h @@ -679,10 +679,10 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: ### if the word starts with a '[' and ends with a ']', turn it into an array { var start/eax: byte <- stream-first curr-stream - compare start, 0x5b # '[' + compare start, 0x5b/[ break-if-!= var end/eax: byte <- stream-final curr-stream - compare end, 0x5d # ']' + compare end, 0x5d/] break-if-!= # wastefully create a new input string to strip quotes var h: (handle array value) @@ -781,7 +781,7 @@ fn find-function first: (addr handle function), name: (addr stream byte), out: ( var curr-name-ah/eax: (addr handle array byte) <- get f, name var curr-name/eax: (addr array byte) <- lookup *curr-name-ah var done?/eax: boolean <- stream-data-equal? name, curr-name - compare done?, 0 # false + compare done?, 0/false { break-if-= copy-handle *curr, out diff --git a/apps/tile/surface.mu b/apps/tile/surface.mu index cd54b5b4..2e353022 100644 --- a/apps/tile/surface.mu +++ b/apps/tile/surface.mu @@ -262,10 +262,10 @@ fn num-lines in: (addr array byte) -> _/ecx: int { var result/ecx: int <- copy 1 { var done?/eax: boolean <- stream-empty? s-addr - compare done?, 0 # false + compare done?, 0/false break-if-!= var g/eax: grapheme <- read-grapheme s-addr - compare g, 0xa # newline + compare g, 0xa/newline loop-if-!= result <- increment loop @@ -280,10 +280,10 @@ fn first-line-length in: (addr array byte) -> _/edx: int { var result/edx: int <- copy 0 { var done?/eax: boolean <- stream-empty? s-addr - compare done?, 0 # false + compare done?, 0/false break-if-!= var g/eax: grapheme <- read-grapheme s-addr - compare g, 0xa # newline + compare g, 0xa/newline break-if-= result <- increment loop @@ -299,10 +299,10 @@ fn fill-in _out: (addr array screen-cell), in: (addr array byte) { var idx/ecx: int <- copy 0 { var done?/eax: boolean <- stream-empty? s-addr - compare done?, 0 # false + compare done?, 0/false break-if-!= var g/eax: grapheme <- read-grapheme s-addr - compare g, 0xa # newline + compare g, 0xa/newline loop-if-= var offset/edx: (offset screen-cell) <- compute-offset out, idx var dest/edx: (addr screen-cell) <- index out, offset diff --git a/apps/tile/table.mu b/apps/tile/table.mu index 899408e1..9c03117b 100644 --- a/apps/tile/table.mu +++ b/apps/tile/table.mu @@ -123,7 +123,7 @@ fn lookup-binding _self: (addr table), key: (addr array byte), out: (addr handle compare target3, 0 break-if-= $lookup-binding:loop var is-match?/eax: boolean <- string-equal? target3, key - compare is-match?, 0 # false + compare is-match?, 0/false break-if-= # found var target/eax: (addr handle value) <- get target-bind, value diff --git a/apps/tile/value-stack.mu b/apps/tile/value-stack.mu index e437f616..886b4037 100644 --- a/apps/tile/value-stack.mu +++ b/apps/tile/value-stack.mu @@ -33,7 +33,7 @@ fn push-number-to-value-stack _self: (addr value-stack), _val: float { copy-to *dest-addr2, val increment *top-addr var type-addr/eax: (addr int) <- get dest-addr, type - copy-to *type-addr, 0 # number + copy-to *type-addr, 0/number } fn push-string-to-value-stack _self: (addr value-stack), val: (handle array byte) { @@ -53,7 +53,7 @@ fn push-string-to-value-stack _self: (addr value-stack), val: (handle array byte #? print-int32-hex 0, foo #? } #? print-string 0, "\n" - copy-to *dest-addr3, 1 # type string + copy-to *dest-addr3, 1/string increment *top-addr } @@ -69,7 +69,7 @@ fn push-array-to-value-stack _self: (addr value-stack), val: (handle array value copy-handle val, dest-addr2 # update type var dest-addr3/eax: (addr int) <- get dest-addr, type - copy-to *dest-addr3, 2 # type array + copy-to *dest-addr3, 2/array increment *top-addr } @@ -111,9 +111,9 @@ fn value-stack-empty? _self: (addr value-stack) -> _/eax: boolean { compare *top, 0 { break-if-!= - return 1 # true + return 1/true } - return 0 # false + return 0/false } fn value-stack-length _self: (addr value-stack) -> _/eax: int { @@ -142,7 +142,7 @@ fn save-lines in-h: (handle array (handle array byte)), _out-ah: (addr handle ar var dest/eax: (addr handle array byte) <- get dest-val, text-data copy-object src, dest var type/edx: (addr int) <- get dest-val, type - copy-to *type, 1 # string + copy-to *type, 1/string i <- increment loop } diff --git a/apps/tile/value.mu b/apps/tile/value.mu index 912f9ffa..8bd01676 100644 --- a/apps/tile/value.mu +++ b/apps/tile/value.mu @@ -3,7 +3,7 @@ fn render-value-at screen: (addr screen), row: int, col: int, _val: (addr value) var val/esi: (addr value) <- copy _val var val-type/ecx: (addr int) <- get val, type # per-type rendering logic goes here - compare *val-type, 1 # string + compare *val-type, 1/string { break-if-!= var val-ah/eax: (addr handle array byte) <- get val, text-data @@ -17,18 +17,18 @@ fn render-value-at screen: (addr screen), row: int, col: int, _val: (addr value) var truncated-string/eax: (addr array byte) <- lookup *truncated-ah var len/edx: int <- length truncated-string start-color screen, 0xf2, 7 - print-code-point screen, 0x275d # open-quote + print-code-point screen, 0x275d/open-quote print-string screen, truncated-string compare len, orig-len { break-if-= - print-code-point screen, 0x2026 # ellipses + print-code-point screen, 0x2026/ellipses } - print-code-point screen, 0x275e # close-quote + print-code-point screen, 0x275e/close-quote reset-formatting screen return } - compare *val-type, 2 # array + compare *val-type, 2/array { break-if-!= var val-ah/eax: (addr handle array value) <- get val, array-data @@ -36,7 +36,7 @@ fn render-value-at screen: (addr screen), row: int, col: int, _val: (addr value) render-array-at screen, row, col, val-array return } - compare *val-type, 3 # file + compare *val-type, 3/file { break-if-!= var val-ah/eax: (addr handle buffered-file) <- get val, file-data @@ -46,7 +46,7 @@ fn render-value-at screen: (addr screen), row: int, col: int, _val: (addr value) print-string screen, " FILE " return } - compare *val-type, 4 # screen + compare *val-type, 4/screen { break-if-!= #? print-string 0, "render-screen" @@ -90,15 +90,15 @@ fn render-number screen: (addr screen), val: float, top-level?: boolean { fg <- copy 0 } start-color screen, fg, bg - print-grapheme screen, 0x20 # space + print-grapheme screen, 0x20/space print-float-decimal-approximate screen, val, 3 - print-grapheme screen, 0x20 # space + print-grapheme screen, 0x20/space } fn render-array-at screen: (addr screen), row: int, col: int, _a: (addr array value) { start-color screen, 0xf2, 7 # don't surround in spaces - print-grapheme screen, 0x5b # '[' + print-grapheme screen, 0x5b/[ increment col var a/esi: (addr array value) <- copy _a var max/ecx: int <- length a @@ -122,7 +122,7 @@ fn render-array-at screen: (addr screen), row: int, col: int, _a: (addr array va i <- increment loop } - print-grapheme screen, 0x5d # ']' + print-grapheme screen, 0x5d/] } fn render-screen screen: (addr screen), row: int, col: int, _target-screen: (addr screen) { @@ -183,57 +183,57 @@ fn print-screen-cell-of-fake-screen screen: (addr screen), _target: (addr screen { compare g, 0 break-if-!= - g <- copy 0x20 # space + g <- copy 0x20/space } print-grapheme screen, g reset-formatting screen } fn print-upper-border screen: (addr screen), width: int { - print-code-point screen, 0x250c # top-left corner + print-code-point screen, 0x250c/top-left-corner var i/eax: int <- copy 0 { compare i, width break-if->= - print-code-point screen, 0x2500 # horizontal line + print-code-point screen, 0x2500/horizontal-line i <- increment loop } - print-code-point screen, 0x2510 # top-right corner + print-code-point screen, 0x2510/top-right-corner } fn print-lower-border screen: (addr screen), width: int { - print-code-point screen, 0x2514 # bottom-left corner + print-code-point screen, 0x2514/bottom-left-corner var i/eax: int <- copy 0 { compare i, width break-if->= - print-code-point screen, 0x2500 # horizontal line + print-code-point screen, 0x2500/horizontal-line i <- increment loop } - print-code-point screen, 0x2518 # bottom-right corner + print-code-point screen, 0x2518/bottom-right-corner } fn value-width _v: (addr value), top-level: boolean -> _/eax: int { var v/esi: (addr value) <- copy _v var type/eax: (addr int) <- get v, type { - compare *type, 0 # int + compare *type, 0/int break-if-!= var v-num/edx: (addr float) <- get v, number-data var result/eax: int <- float-size *v-num, 3 return result } { - compare *type, 1 # string + compare *type, 1/string break-if-!= var s-ah/eax: (addr handle array byte) <- get v, text-data var s/eax: (addr array byte) <- lookup *s-ah compare s, 0 break-if-= var result/eax: int <- length s - compare result, 0xd # max string size + compare result, 0xd/max-string-size { break-if-<= result <- copy 0xd @@ -241,7 +241,7 @@ fn value-width _v: (addr value), top-level: boolean -> _/eax: int { # if it's a nested string, include space for quotes # we don't do this for the top-level, where the quotes will overflow # into surrounding padding. - compare top-level, 0 # false + compare top-level, 0/false { break-if-!= result <- add 2 @@ -249,7 +249,7 @@ fn value-width _v: (addr value), top-level: boolean -> _/eax: int { return result } { - compare *type, 2 # array + compare *type, 2/array break-if-!= var a-ah/eax: (addr handle array value) <- get v, array-data var a/eax: (addr array value) <- lookup *a-ah @@ -259,7 +259,7 @@ fn value-width _v: (addr value), top-level: boolean -> _/eax: int { return result } { - compare *type, 3 # file handle + compare *type, 3/file break-if-!= var f-ah/eax: (addr handle buffered-file) <- get v, file-data var f/eax: (addr buffered-file) <- lookup *f-ah @@ -269,7 +269,7 @@ fn value-width _v: (addr value), top-level: boolean -> _/eax: int { return 4 } { - compare *type, 4 # screen + compare *type, 4/screen break-if-!= var screen-ah/eax: (addr handle screen) <- get v, screen-data var screen/eax: (addr screen) <- lookup *screen-ah @@ -315,13 +315,13 @@ fn value-height _v: (addr value) -> _/eax: int { var v/esi: (addr value) <- copy _v var type/eax: (addr int) <- get v, type { - compare *type, 3 # file handle + compare *type, 3/file break-if-!= # TODO: visualizing file handles return 1 } { - compare *type, 4 # screen + compare *type, 4/screen break-if-!= var screen-ah/eax: (addr handle screen) <- get v, screen-data var screen/eax: (addr screen) <- lookup *screen-ah @@ -351,7 +351,7 @@ fn deep-copy-value _src: (addr value), _dest: (addr value) { copy-object src-n, dest-n return } - compare *type, 1 # string + compare *type, 1/string { break-if-!= #? print-string 0, "string value\n" @@ -361,7 +361,7 @@ fn deep-copy-value _src: (addr value), _dest: (addr value) { copy-array-object src, dest-ah return } - compare *type, 2 # array + compare *type, 2/array { break-if-!= #? print-string 0, "array value\n" @@ -389,7 +389,7 @@ fn deep-copy-value _src: (addr value), _dest: (addr value) { copy-array-object src, dest-ah return } - compare *type, 3 # file + compare *type, 3/file { break-if-!= #? print-string 0, "file value\n" @@ -404,7 +404,7 @@ fn deep-copy-value _src: (addr value), _dest: (addr value) { copy-file src-file, dest-file-ah, src-filename return } - compare *type, 4 # screen + compare *type, 4/screen { break-if-!= #? print-string 0, "screen value\n" diff --git a/apps/tile/word.mu b/apps/tile/word.mu index 2d776caf..224c876c 100644 --- a/apps/tile/word.mu +++ b/apps/tile/word.mu @@ -61,7 +61,7 @@ fn move-word-contents _src-ah: (addr handle word), _dest-ah: (addr handle word) var src-stack/ecx: (addr grapheme-stack) <- get src-data, right { var done?/eax: boolean <- grapheme-stack-empty? src-stack - compare done?, 0 # false + compare done?, 0/false break-if-!= var g/eax: grapheme <- pop-grapheme-stack src-stack #? print-grapheme 0, g @@ -520,7 +520,7 @@ fn word-exists? _haystack-ah: (addr handle word), _needle: (addr word) -> _/ebx: compare curr, 0 { break-if-!= - return 0 # false + return 0/false } # check curr var curr-name-storage: (handle array byte) @@ -531,7 +531,7 @@ fn word-exists? _haystack-ah: (addr handle word), _needle: (addr word) -> _/ebx: compare found?, 0 { break-if-= - return 1 # true + return 1/true } # recurse var curr/eax: (addr word) <- lookup *haystack-ah @@ -550,7 +550,7 @@ fn word-list-length words: (addr handle word) -> _/eax: int { { var word-len/eax: int <- word-length curr result <- add word-len - result <- add 1 # inter-word-margin + result <- add 1/inter-word-margin } curr-ah <- get curr, next loop @@ -566,12 +566,12 @@ fn parse-words in: (addr array byte), out-ah: (addr handle word) { var cursor-word-ah/ebx: (addr handle word) <- copy out-ah $parse-words:loop: { var done?/eax: boolean <- stream-empty? in-stream-a - compare done?, 0 # false + compare done?, 0/false break-if-!= var _g/eax: grapheme <- read-grapheme in-stream-a var g/ecx: grapheme <- copy _g # if not space, insert - compare g, 0x20 # space + compare g, 0x20/space { break-if-= var cursor-word/eax: (addr word) <- lookup *cursor-word-ah diff --git a/apps/tui.mu b/apps/tui.mu index 7dad7d1b..c58a82c6 100644 --- a/apps/tui.mu +++ b/apps/tui.mu @@ -9,26 +9,26 @@ fn main -> _/ebx: int { var ncols/ecx: int <- copy 0 nrows, ncols <- screen-size 0 enable-screen-grid-mode - move-cursor 0, 5, 0x22 - start-color 0, 1, 0x7a - start-blinking 0 - print-string 0, "Hello world!" - reset-formatting 0 - move-cursor 0, 6, 0x22 - print-string 0, "tty dimensions: " - print-int32-hex 0, nrows - print-string 0, " rows, " - print-int32-hex 0, ncols - print-string 0, " rows\n" + move-cursor 0/screen, 5/row, 0x22/col + start-color 0/screen, 1/fg, 0x7a/bg + start-blinking 0/screen + print-string 0/screen, "Hello world!" + reset-formatting 0/screen + move-cursor 0/screen, 6/row, 0x22/col + print-string 0/screen, "tty dimensions: " + print-int32-hex 0/screen, nrows + print-string 0/screen, " rows, " + print-int32-hex 0/screen, ncols + print-string 0/screen, " rows\n" - print-string 0, "press a key to see its code: " + print-string 0/screen, "press a key to see its code: " enable-keyboard-immediate-mode var x/eax: grapheme <- read-key-from-real-keyboard enable-keyboard-type-mode enable-screen-type-mode - print-string 0, "You pressed " + print-string 0/screen, "You pressed " var x-int/eax: int <- copy x - print-int32-hex 0, x-int - print-string 0, "\n" + print-int32-hex 0/screen, x-int + print-string 0/screen, "\n" return 0 } 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 # |