From 372367f59a897162912d0646158bdea1e07d6e66 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 26 Jun 2021 20:55:36 -0700 Subject: html: better highlighting for int registers --- html/linux/advent2020/1a.mu.html | 31 ++++++------ html/linux/advent2020/1b.mu.html | 29 ++++++----- html/linux/advent2020/2a.mu.html | 39 ++++++++------- html/linux/advent2020/2b.mu.html | 39 ++++++++------- html/linux/advent2020/3a.mu.html | 35 +++++++------ html/linux/advent2020/3b.mu.html | 47 +++++++++--------- html/linux/advent2020/4a.mu.html | 27 +++++----- html/linux/advent2020/4b.mu.html | 103 +++++++++++++++++++-------------------- html/linux/advent2020/5a.mu.html | 29 ++++++----- html/linux/advent2020/5b.mu.html | 33 ++++++------- 10 files changed, 201 insertions(+), 211 deletions(-) (limited to 'html/linux/advent2020') diff --git a/html/linux/advent2020/1a.mu.html b/html/linux/advent2020/1a.mu.html index bcd2afb7..4355df49 100644 --- a/html/linux/advent2020/1a.mu.html +++ b/html/linux/advent2020/1a.mu.html @@ -14,20 +14,19 @@ pre { white-space: pre-wrap; font-family: monospace; color: #000000; background- body { font-size:12pt; font-family: monospace; color: #000000; background-color: #ffffd7; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } +.PreProc { color: #c000c0; } +.muRegEdx { color: #af5f00; } +.Special { color: #ff6060; } .LineNr { } -.Delimiter { color: #c000c0; } -.CommentedCode { color: #8a8a8a; } -.muRegEsi { color: #87d787; } -.muRegEdi { color: #87ffd7; } +.muRegEsi { color: #005faf; } +.muRegEbx { color: #5f00ff; } .Constant { color: #008787; } -.Special { color: #ff6060; } -.PreProc { color: #c000c0; } +.muRegEdi { color: #00af00; } +.muRegEcx { color: #870000; } +.Delimiter { color: #c000c0; } .muFunction { color: #af5f00; text-decoration: underline; } +.CommentedCode { color: #8a8a8a; } .muComment { color: #005faf; } -.muRegEax { color: #875f00; } -.muRegEcx { color: #af875f; } -.muRegEdx { color: #878700; } -.muRegEbx { color: #8787af; } --> @@ -91,12 +90,12 @@ if ('onhashchange' in window) { 26 clear-stream line 27 read-line-from-real-keyboard line 28 # if line is empty (not even a newline), quit -29 var done?/eax: boolean <- stream-empty? line +29 var done?/eax: boolean <- stream-empty? line 30 compare done?, 0/false 31 break-if-!= 32 #? print-stream-to-real-screen line 33 # convert line to int and append it to numbers -34 var n/eax: int <- parse-decimal-int-from-stream line +34 var n/eax: int <- parse-decimal-int-from-stream line 35 #? print-int32-decimal 0, n 36 #? print-string 0, "\n" 37 var dest/ebx: (addr int) <- index numbers, numbers-index @@ -110,7 +109,7 @@ if ('onhashchange' in window) { 45 } 46 # phase 2: for each number in the array, check if 2020-it is in the rest of 47 # the array -48 var i/eax: int <- copy 0 +48 var i/eax: int <- copy 0 49 { 50 compare i, numbers-index 51 break-if->= @@ -120,7 +119,7 @@ if ('onhashchange' in window) { 55 var target/ecx: int <- copy 0x7e4 # 2020 56 target <- subtract *src 57 { -58 var found?/eax: boolean <- find-after numbers, i, target +58 var found?/eax: boolean <- find-after numbers, i, target 59 compare found?, 0/false 60 break-if-= 61 print-string 0, "found\n" @@ -139,11 +138,11 @@ if ('onhashchange' in window) { 74 return 1/not-found 75 } 76 -77 fn find-after _numbers: (addr array int), start: int, _target: int -> _/eax: boolean { +77 fn find-after _numbers: (addr array int), start: int, _target: int -> _/eax: boolean { 78 var numbers/esi: (addr array int) <- copy _numbers 79 var target/edi: int <- copy _target 80 var len/ecx: int <- length numbers -81 var i/eax: int <- copy start +81 var i/eax: int <- copy start 82 i <- increment 83 { 84 compare i, len diff --git a/html/linux/advent2020/1b.mu.html b/html/linux/advent2020/1b.mu.html index fffb43fd..fad9e60d 100644 --- a/html/linux/advent2020/1b.mu.html +++ b/html/linux/advent2020/1b.mu.html @@ -14,20 +14,19 @@ pre { white-space: pre-wrap; font-family: monospace; color: #000000; background- body { font-size:12pt; font-family: monospace; color: #000000; background-color: #ffffd7; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } +.PreProc { color: #c000c0; } +.muRegEdx { color: #af5f00; } +.Special { color: #ff6060; } .LineNr { } -.Delimiter { color: #c000c0; } -.CommentedCode { color: #8a8a8a; } -.muRegEsi { color: #87d787; } -.muRegEdi { color: #87ffd7; } +.muRegEsi { color: #005faf; } +.muRegEbx { color: #5f00ff; } .Constant { color: #008787; } -.Special { color: #ff6060; } -.PreProc { color: #c000c0; } +.muRegEdi { color: #00af00; } +.muRegEcx { color: #870000; } +.Delimiter { color: #c000c0; } .muFunction { color: #af5f00; text-decoration: underline; } +.CommentedCode { color: #8a8a8a; } .muComment { color: #005faf; } -.muRegEax { color: #875f00; } -.muRegEcx { color: #af875f; } -.muRegEdx { color: #878700; } -.muRegEbx { color: #8787af; } --> @@ -91,12 +90,12 @@ if ('onhashchange' in window) { 26 clear-stream line 27 read-line-from-real-keyboard line 28 # if line is empty (not even a newline), quit - 29 var done?/eax: boolean <- stream-empty? line + 29 var done?/eax: boolean <- stream-empty? line 30 compare done?, 0/false 31 break-if-!= 32 #? print-stream-to-real-screen line 33 # convert line to int and append it to numbers - 34 var n/eax: int <- parse-decimal-int-from-stream line + 34 var n/eax: int <- parse-decimal-int-from-stream line 35 #? print-int32-decimal 0, n 36 #? print-string 0, "\n" 37 var dest/ebx: (addr int) <- index numbers, numbers-index @@ -129,7 +128,7 @@ if ('onhashchange' in window) { 64 var src2/ecx: (addr int) <- index numbers, j 65 target <- subtract *src2 66 { - 67 var found?/eax: boolean <- find-after numbers, j, target + 67 var found?/eax: boolean <- find-after numbers, j, target 68 compare found?, 0/false 69 break-if-= 70 print-string 0, "found\n" @@ -155,11 +154,11 @@ if ('onhashchange' in window) { 90 return 1/not-found 91 } 92 - 93 fn find-after _numbers: (addr array int), start: int, _target: int -> _/eax: boolean { + 93 fn find-after _numbers: (addr array int), start: int, _target: int -> _/eax: boolean { 94 var numbers/esi: (addr array int) <- copy _numbers 95 var target/edi: int <- copy _target 96 var len/ecx: int <- length numbers - 97 var i/eax: int <- copy start + 97 var i/eax: int <- copy start 98 i <- increment 99 { 100 compare i, len diff --git a/html/linux/advent2020/2a.mu.html b/html/linux/advent2020/2a.mu.html index 825d7e12..e24a06ef 100644 --- a/html/linux/advent2020/2a.mu.html +++ b/html/linux/advent2020/2a.mu.html @@ -14,19 +14,18 @@ pre { white-space: pre-wrap; font-family: monospace; color: #000000; background- body { font-size:12pt; font-family: monospace; color: #000000; background-color: #ffffd7; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } -.muRegEdx { color: #878700; } -.muRegEsi { color: #87d787; } -.muComment { color: #005faf; } -.LineNr { } -.muRegEax { color: #875f00; } -.muRegEcx { color: #af875f; } +.PreProc { color: #c000c0; } +.muRegEdx { color: #af5f00; } .Special { color: #ff6060; } -.muRegEdi { color: #87ffd7; } +.LineNr { } +.muRegEsi { color: #005faf; } +.muRegEbx { color: #5f00ff; } +.Constant { color: #008787; } +.muRegEdi { color: #00af00; } +.muRegEcx { color: #870000; } .Delimiter { color: #c000c0; } .muFunction { color: #af5f00; text-decoration: underline; } -.muRegEbx { color: #8787af; } -.Constant { color: #008787; } -.PreProc { color: #c000c0; } +.muComment { color: #005faf; } --> @@ -83,19 +82,19 @@ if ('onhashchange' in window) { 19 clear-stream line 20 read-line-from-real-keyboard line 21 # if line is empty (not even a newline), quit -22 var done?/eax: boolean <- stream-empty? line +22 var done?/eax: boolean <- stream-empty? line 23 compare done?, 0/false 24 break-if-!= 25 print-stream-to-real-screen line 26 # slice = next-token(line, '-') 27 next-token line, 0x2d, slice 28 # start = parse-int(slice) -29 var _start/eax: int <- parse-decimal-int-from-slice slice +29 var _start/eax: int <- parse-decimal-int-from-slice slice 30 var start/ebx: int <- copy _start -31 var dash/eax: byte <- read-byte line # skip '-' +31 var dash/eax: byte <- read-byte line # skip '-' 32 # slice = next-token(line, ' ') 33 next-token line, 0x20, slice -34 var _end/eax: int <- parse-decimal-int-from-slice slice +34 var _end/eax: int <- parse-decimal-int-from-slice slice 35 var end/esi: int <- copy _end 36 print-int32-decimal 0, start 37 print-string 0, " " @@ -103,14 +102,14 @@ if ('onhashchange' in window) { 39 print-string 0, "\n" 40 # letter = next non-space 41 skip-chars-matching-whitespace line -42 var letter/eax: byte <- read-byte line +42 var letter/eax: byte <- read-byte line 43 # skip some stuff 44 { -45 var colon/eax: byte <- read-byte line # skip ':' +45 var colon/eax: byte <- read-byte line # skip ':' 46 } 47 skip-chars-matching-whitespace line 48 # now check the rest of the line -49 var valid?/eax: boolean <- valid? start, end, letter, line +49 var valid?/eax: boolean <- valid? start, end, letter, line 50 compare valid?, 0/false 51 { 52 break-if-= @@ -124,16 +123,16 @@ if ('onhashchange' in window) { 60 return 0 61 } 62 -63 fn valid? start: int, end: int, letter: byte, password: (addr stream byte) -> _/eax: boolean { +63 fn valid? start: int, end: int, letter: byte, password: (addr stream byte) -> _/eax: boolean { 64 var letter-count/edi: int <- copy 0 65 # for every c in password 66 # if (c == letter) 67 # ++letter-count 68 { -69 var done?/eax: boolean <- stream-empty? password +69 var done?/eax: boolean <- stream-empty? password 70 compare done?, 0/false 71 break-if-!= -72 var c/eax: byte <- read-byte password +72 var c/eax: byte <- read-byte password 73 compare c, letter 74 { 75 break-if-!= diff --git a/html/linux/advent2020/2b.mu.html b/html/linux/advent2020/2b.mu.html index 67198402..ff0a806f 100644 --- a/html/linux/advent2020/2b.mu.html +++ b/html/linux/advent2020/2b.mu.html @@ -14,20 +14,19 @@ pre { white-space: pre-wrap; font-family: monospace; color: #000000; background- body { font-size:12pt; font-family: monospace; color: #000000; background-color: #ffffd7; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } +.PreProc { color: #c000c0; } +.muRegEdx { color: #af5f00; } +.Special { color: #ff6060; } .LineNr { } -.Delimiter { color: #c000c0; } -.CommentedCode { color: #8a8a8a; } -.muRegEsi { color: #87d787; } -.muRegEdi { color: #87ffd7; } +.muRegEsi { color: #005faf; } +.muRegEbx { color: #5f00ff; } .Constant { color: #008787; } -.Special { color: #ff6060; } -.PreProc { color: #c000c0; } +.muRegEdi { color: #00af00; } +.muRegEcx { color: #870000; } +.Delimiter { color: #c000c0; } .muFunction { color: #af5f00; text-decoration: underline; } +.CommentedCode { color: #8a8a8a; } .muComment { color: #005faf; } -.muRegEax { color: #875f00; } -.muRegEcx { color: #af875f; } -.muRegEdx { color: #878700; } -.muRegEbx { color: #8787af; } --> @@ -84,19 +83,19 @@ if ('onhashchange' in window) { 19 clear-stream line 20 read-line-from-real-keyboard line 21 # if line is empty (not even a newline), quit - 22 var done?/eax: boolean <- stream-empty? line + 22 var done?/eax: boolean <- stream-empty? line 23 compare done?, 0/false 24 break-if-!= 25 print-stream-to-real-screen line 26 # slice = next-token(line, '-') 27 next-token line, 0x2d, slice 28 # pos1 = parse-int(slice) - 29 var _pos1/eax: int <- parse-decimal-int-from-slice slice + 29 var _pos1/eax: int <- parse-decimal-int-from-slice slice 30 var pos1/ebx: int <- copy _pos1 - 31 var dash/eax: byte <- read-byte line # skip '-' + 31 var dash/eax: byte <- read-byte line # skip '-' 32 # slice = next-token(line, ' ') 33 next-token line, 0x20, slice - 34 var _pos2/eax: int <- parse-decimal-int-from-slice slice + 34 var _pos2/eax: int <- parse-decimal-int-from-slice slice 35 var pos2/esi: int <- copy _pos2 36 print-int32-decimal 0, pos1 37 print-string 0, " " @@ -110,14 +109,14 @@ if ('onhashchange' in window) { 45 } 46 # letter = next non-space 47 skip-chars-matching-whitespace line - 48 var letter/eax: byte <- read-byte line + 48 var letter/eax: byte <- read-byte line 49 # skip some stuff 50 { - 51 var colon/eax: byte <- read-byte line # skip ':' + 51 var colon/eax: byte <- read-byte line # skip ':' 52 } 53 skip-chars-matching-whitespace line 54 # now check the rest of the line - 55 var valid?/eax: boolean <- valid? pos1, pos2, letter, line + 55 var valid?/eax: boolean <- valid? pos1, pos2, letter, line 56 compare valid?, 0/false 57 { 58 break-if-= @@ -134,7 +133,7 @@ if ('onhashchange' in window) { 69 # ideally password would be a random-access array 70 # we'll just track an index 71 # one benefit: we can easily start at 1 - 72 fn valid? pos1: int, pos2: int, letter: byte, password: (addr stream byte) -> _/eax: boolean { + 72 fn valid? pos1: int, pos2: int, letter: byte, password: (addr stream byte) -> _/eax: boolean { 73 var i/esi: int <- copy 1 74 var letter-count/edi: int <- copy 0 75 # while password stream isn't empty @@ -149,10 +148,10 @@ if ('onhashchange' in window) { 84 #? print-string 0, " " 85 #? print-int32-decimal 0, i 86 #? print-string 0, "\n" - 87 var done?/eax: boolean <- stream-empty? password + 87 var done?/eax: boolean <- stream-empty? password 88 compare done?, 0/false 89 break-if-!= - 90 var c/eax: byte <- read-byte password + 90 var c/eax: byte <- read-byte password 91 #? { 92 #? var c2/eax: int <- copy c 93 #? print-int32-decimal 0, c2 diff --git a/html/linux/advent2020/3a.mu.html b/html/linux/advent2020/3a.mu.html index 8e720f6f..cf125d84 100644 --- a/html/linux/advent2020/3a.mu.html +++ b/html/linux/advent2020/3a.mu.html @@ -14,20 +14,19 @@ pre { white-space: pre-wrap; font-family: monospace; color: #000000; background- body { font-size:12pt; font-family: monospace; color: #000000; background-color: #ffffd7; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } +.PreProc { color: #c000c0; } +.muRegEdx { color: #af5f00; } +.Special { color: #ff6060; } .LineNr { } -.Delimiter { color: #c000c0; } -.CommentedCode { color: #8a8a8a; } -.muRegEsi { color: #87d787; } -.muRegEdi { color: #87ffd7; } +.muRegEsi { color: #005faf; } +.muRegEbx { color: #5f00ff; } .Constant { color: #008787; } -.Special { color: #ff6060; } -.PreProc { color: #c000c0; } +.muRegEdi { color: #00af00; } +.muRegEcx { color: #870000; } +.Delimiter { color: #c000c0; } .muFunction { color: #af5f00; text-decoration: underline; } +.CommentedCode { color: #8a8a8a; } .muComment { color: #005faf; } -.muRegEax { color: #875f00; } -.muRegEcx { color: #af875f; } -.muRegEdx { color: #878700; } -.muRegEbx { color: #8787af; } --> @@ -90,7 +89,7 @@ if ('onhashchange' in window) { 25 clear-stream line 26 read-line-from-real-keyboard line 27 # if line is empty (not even a newline), quit - 28 var done?/eax: boolean <- stream-empty? line + 28 var done?/eax: boolean <- stream-empty? line 29 compare done?, 0/false 30 break-if-!= 31 # wastefully recompute width on every line @@ -98,7 +97,7 @@ if ('onhashchange' in window) { 33 copy-to width, 0 34 # turn each byte into a tree and append it 35 $main:line-loop: { - 36 var done?/eax: boolean <- stream-empty? line + 36 var done?/eax: boolean <- stream-empty? line 37 compare done?, 0/false 38 break-if-!= 39 #? print-int32-decimal 0, num-rows @@ -106,7 +105,7 @@ if ('onhashchange' in window) { 41 #? print-int32-decimal 0, width 42 #? print-string 0, "\n" 43 var dest/ebx: (addr int) <- index trees, trees-length - 44 var c/eax: byte <- read-byte line + 44 var c/eax: byte <- read-byte line 45 # newline comes only at end of line 46 compare c, 0xa/newline 47 break-if-= @@ -140,7 +139,7 @@ if ('onhashchange' in window) { 75 { 76 compare row, num-rows 77 break-if->= - 78 var curr/eax: int <- index2d trees, row, col, width + 78 var curr/eax: int <- index2d trees, row, col, width 79 compare curr, 0 80 { 81 break-if-= @@ -156,18 +155,18 @@ if ('onhashchange' in window) { 91 return 0 92 } 93 - 94 fn index2d _arr: (addr array int), _row: int, _col: int, width: int -> _/eax: int { + 94 fn index2d _arr: (addr array int), _row: int, _col: int, width: int -> _/eax: int { 95 # handle repeating columns of trees - 96 var dummy/eax: int <- copy 0 + 96 var dummy/eax: int <- copy 0 97 var col/edx: int <- copy 0 98 dummy, col <- integer-divide _col, width 99 # compute index -100 var index/eax: int <- copy _row +100 var index/eax: int <- copy _row 101 index <- multiply width 102 index <- add col 103 # look up array 104 var arr/esi: (addr array int) <- copy _arr -105 var src/eax: (addr int) <- index arr, index +105 var src/eax: (addr int) <- index arr, index 106 return *src 107 } diff --git a/html/linux/advent2020/3b.mu.html b/html/linux/advent2020/3b.mu.html index 07f1e4d5..6380194d 100644 --- a/html/linux/advent2020/3b.mu.html +++ b/html/linux/advent2020/3b.mu.html @@ -14,20 +14,19 @@ pre { white-space: pre-wrap; font-family: monospace; color: #000000; background- body { font-size:12pt; font-family: monospace; color: #000000; background-color: #ffffd7; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } +.PreProc { color: #c000c0; } +.muRegEdx { color: #af5f00; } +.Special { color: #ff6060; } .LineNr { } -.Delimiter { color: #c000c0; } -.CommentedCode { color: #8a8a8a; } -.muRegEsi { color: #87d787; } -.muRegEdi { color: #87ffd7; } +.muRegEsi { color: #005faf; } +.muRegEbx { color: #5f00ff; } .Constant { color: #008787; } -.Special { color: #ff6060; } -.PreProc { color: #c000c0; } +.muRegEdi { color: #00af00; } +.muRegEcx { color: #870000; } +.Delimiter { color: #c000c0; } .muFunction { color: #af5f00; text-decoration: underline; } +.CommentedCode { color: #8a8a8a; } .muComment { color: #005faf; } -.muRegEax { color: #875f00; } -.muRegEcx { color: #af875f; } -.muRegEdx { color: #878700; } -.muRegEbx { color: #8787af; } --> @@ -90,7 +89,7 @@ if ('onhashchange' in window) { 25 clear-stream line 26 read-line-from-real-keyboard line 27 # if line is empty (not even a newline), quit - 28 var done?/eax: boolean <- stream-empty? line + 28 var done?/eax: boolean <- stream-empty? line 29 compare done?, 0/false 30 break-if-!= 31 # wastefully recompute width on every line @@ -98,7 +97,7 @@ if ('onhashchange' in window) { 33 copy-to width, 0 34 # turn each byte into a tree and append it 35 $main:line-loop: { - 36 var done?/eax: boolean <- stream-empty? line + 36 var done?/eax: boolean <- stream-empty? line 37 compare done?, 0/false 38 break-if-!= 39 #? print-int32-decimal 0, num-rows @@ -106,7 +105,7 @@ if ('onhashchange' in window) { 41 #? print-int32-decimal 0, width 42 #? print-string 0, "\n" 43 var dest/ebx: (addr int) <- index trees, trees-length - 44 var c/eax: byte <- read-byte line + 44 var c/eax: byte <- read-byte line 45 # newline comes only at end of line 46 compare c, 0xa/newline 47 break-if-= @@ -131,23 +130,23 @@ if ('onhashchange' in window) { 66 } 67 # phase 2: compute 68 var product/edi: int <- copy 1 - 69 var result/eax: int <- num-trees-hit trees, width, num-rows, 1, 1 + 69 var result/eax: int <- num-trees-hit trees, width, num-rows, 1, 1 70 print-int32-decimal 0, result 71 print-string 0, " x " 72 product <- multiply result - 73 var result/eax: int <- num-trees-hit trees, width, num-rows, 3, 1 + 73 var result/eax: int <- num-trees-hit trees, width, num-rows, 3, 1 74 print-int32-decimal 0, result 75 print-string 0, " x " 76 product <- multiply result - 77 var result/eax: int <- num-trees-hit trees, width, num-rows, 5, 1 + 77 var result/eax: int <- num-trees-hit trees, width, num-rows, 5, 1 78 print-int32-decimal 0, result 79 print-string 0, " x " 80 product <- multiply result - 81 var result/eax: int <- num-trees-hit trees, width, num-rows, 7, 1 + 81 var result/eax: int <- num-trees-hit trees, width, num-rows, 7, 1 82 print-int32-decimal 0, result 83 print-string 0, " x " 84 product <- multiply result - 85 var result/eax: int <- num-trees-hit trees, width, num-rows, 1, 2 + 85 var result/eax: int <- num-trees-hit trees, width, num-rows, 1, 2 86 print-int32-decimal 0, result 87 print-string 0, " = " 88 product <- multiply result @@ -156,7 +155,7 @@ if ('onhashchange' in window) { 91 return 0 92 } 93 - 94 fn num-trees-hit trees: (addr array int), width: int, num-rows: int, right: int, down: int -> _/eax: int { + 94 fn num-trees-hit trees: (addr array int), width: int, num-rows: int, right: int, down: int -> _/eax: int { 95 #? print-string 0, "== " 96 #? print-int32-decimal 0, right 97 #? print-string 0, " " @@ -170,7 +169,7 @@ if ('onhashchange' in window) { 105 break-if->= 106 #? print-int32-decimal 0, col 107 #? print-string 0, "\n" -108 var curr/eax: int <- index2d trees, row, col, width +108 var curr/eax: int <- index2d trees, row, col, width 109 compare curr, 0 110 { 111 break-if-= @@ -183,21 +182,21 @@ if ('onhashchange' in window) { 118 return num-trees-hit 119 } 120 -121 fn index2d _arr: (addr array int), _row: int, _col: int, width: int -> _/eax: int { +121 fn index2d _arr: (addr array int), _row: int, _col: int, width: int -> _/eax: int { 122 # handle repeating columns of trees -123 var dummy/eax: int <- copy 0 +123 var dummy/eax: int <- copy 0 124 var col/edx: int <- copy 0 125 dummy, col <- integer-divide _col, width 126 #? print-string 0, " " 127 #? print-int32-decimal 0, col 128 #? print-string 0, "\n" 129 # compute index -130 var index/eax: int <- copy _row +130 var index/eax: int <- copy _row 131 index <- multiply width 132 index <- add col 133 # look up array 134 var arr/esi: (addr array int) <- copy _arr -135 var src/eax: (addr int) <- index arr, index +135 var src/eax: (addr int) <- index arr, index 136 return *src 137 } diff --git a/html/linux/advent2020/4a.mu.html b/html/linux/advent2020/4a.mu.html index df8cc64b..50008b4d 100644 --- a/html/linux/advent2020/4a.mu.html +++ b/html/linux/advent2020/4a.mu.html @@ -14,19 +14,18 @@ pre { white-space: pre-wrap; font-family: monospace; color: #000000; background- body { font-size:12pt; font-family: monospace; color: #000000; background-color: #ffffd7; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } -.muRegEcx { color: #af875f; } -.muComment { color: #005faf; } -.LineNr { } -.muRegEdx { color: #878700; } +.PreProc { color: #c000c0; } +.muRegEdx { color: #af5f00; } .Special { color: #ff6060; } -.muRegEsi { color: #87d787; } -.muRegEdi { color: #87ffd7; } +.LineNr { } +.Constant { color: #008787; } +.muRegEbx { color: #5f00ff; } +.muRegEsi { color: #005faf; } +.muRegEdi { color: #00af00; } +.muRegEcx { color: #870000; } .Delimiter { color: #c000c0; } .muFunction { color: #af5f00; text-decoration: underline; } -.muRegEbx { color: #8787af; } -.Constant { color: #008787; } -.PreProc { color: #c000c0; } -.muRegEax { color: #875f00; } +.muComment { color: #005faf; } --> @@ -84,13 +83,13 @@ if ('onhashchange' in window) { 20 clear-stream line 21 read-line-from-real-keyboard line 22 # if line is empty (not even a newline), quit -23 var done?/eax: boolean <- stream-empty? line +23 var done?/eax: boolean <- stream-empty? line 24 compare done?, 0/false 25 break-if-!= 26 print-stream-to-real-screen line 27 # if line has just a newline, process passport 28 skip-chars-matching-whitespace line -29 var new-passport?/eax: boolean <- stream-empty? line +29 var new-passport?/eax: boolean <- stream-empty? line 30 { 31 compare new-passport?, 0/false 32 break-if-= @@ -107,13 +106,13 @@ if ('onhashchange' in window) { 43 } 44 $main:word-loop: { 45 next-word line, slice -46 var done?/eax: boolean <- slice-empty? slice +46 var done?/eax: boolean <- slice-empty? slice 47 compare done?, 0/false 48 break-if-!= 49 print-string 0, " " 50 print-slice-to-real-screen slice 51 # treat cid as optional -52 var optional?/eax: boolean <- slice-starts-with? slice, "cid:" +52 var optional?/eax: boolean <- slice-starts-with? slice, "cid:" 53 compare optional?, 0/false 54 { 55 break-if-!= diff --git a/html/linux/advent2020/4b.mu.html b/html/linux/advent2020/4b.mu.html index 1c2ac0e0..b6fdafe5 100644 --- a/html/linux/advent2020/4b.mu.html +++ b/html/linux/advent2020/4b.mu.html @@ -14,19 +14,18 @@ pre { white-space: pre-wrap; font-family: monospace; color: #000000; background- body { font-size:12pt; font-family: monospace; color: #000000; background-color: #ffffd7; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } -.muRegEcx { color: #af875f; } -.muComment { color: #005faf; } -.LineNr { } -.muRegEdx { color: #878700; } +.PreProc { color: #c000c0; } +.muRegEdx { color: #af5f00; } .Special { color: #ff6060; } -.muRegEsi { color: #87d787; } -.muRegEdi { color: #87ffd7; } +.LineNr { } +.Constant { color: #008787; } +.muRegEbx { color: #5f00ff; } +.muRegEsi { color: #005faf; } +.muRegEdi { color: #00af00; } +.muRegEcx { color: #870000; } .Delimiter { color: #c000c0; } .muFunction { color: #af5f00; text-decoration: underline; } -.muRegEbx { color: #8787af; } -.Constant { color: #008787; } -.PreProc { color: #c000c0; } -.muRegEax { color: #875f00; } +.muComment { color: #005faf; } --> @@ -86,13 +85,13 @@ if ('onhashchange' in window) { 22 clear-stream line 23 read-line-from-real-keyboard line 24 # if line is empty (not even a newline), quit - 25 var done?/eax: boolean <- stream-empty? line + 25 var done?/eax: boolean <- stream-empty? line 26 compare done?, 0/false 27 break-if-!= 28 print-stream-to-real-screen line 29 # if line has just a newline, process passport 30 skip-chars-matching-whitespace line - 31 var new-passport?/eax: boolean <- stream-empty? line + 31 var new-passport?/eax: boolean <- stream-empty? line 32 { 33 compare new-passport?, 0/false 34 break-if-= @@ -109,18 +108,18 @@ if ('onhashchange' in window) { 45 } 46 $main:word-loop: { 47 skip-chars-matching-whitespace line - 48 var done?/eax: boolean <- stream-empty? line + 48 var done?/eax: boolean <- stream-empty? line 49 compare done?, 0/false 50 break-if-!= 51 next-token line, 0x3a, key-slice # ':' - 52 var dummy/eax: byte <- read-byte line # skip ':' + 52 var dummy/eax: byte <- read-byte line # skip ':' 53 next-raw-word line, val-slice 54 print-slice-to-real-screen key-slice 55 print-string 0, " : " 56 print-slice-to-real-screen val-slice 57 print-string 0, "\n" 58 # treat cid as optional - 59 var cid?/eax: boolean <- slice-equal? key-slice, "cid" + 59 var cid?/eax: boolean <- slice-equal? key-slice, "cid" 60 compare cid?, 0/false 61 loop-if-!= 62 # increment field count @@ -128,11 +127,11 @@ if ('onhashchange' in window) { 64 # - validate fields one by one, setting curr-passport-field-count to impossibly high value to signal invalid 65 # byr 66 { - 67 var byr?/eax: boolean <- slice-equal? key-slice, "byr" + 67 var byr?/eax: boolean <- slice-equal? key-slice, "byr" 68 compare byr?, 0/false 69 break-if-= 70 # 1920 <= byr <= 2002 - 71 var byr/eax: int <- parse-decimal-int-from-slice val-slice + 71 var byr/eax: int <- parse-decimal-int-from-slice val-slice 72 compare byr, 0x780 # 1920 73 { 74 break-if->= @@ -148,11 +147,11 @@ if ('onhashchange' in window) { 84 } 85 # iyr 86 { - 87 var iyr?/eax: boolean <- slice-equal? key-slice, "iyr" + 87 var iyr?/eax: boolean <- slice-equal? key-slice, "iyr" 88 compare iyr?, 0/false 89 break-if-= 90 # 2010 <= iyr <= 2020 - 91 var iyr/eax: int <- parse-decimal-int-from-slice val-slice + 91 var iyr/eax: int <- parse-decimal-int-from-slice val-slice 92 compare iyr, 0x7da # 2010 93 { 94 break-if->= @@ -168,11 +167,11 @@ if ('onhashchange' in window) { 104 } 105 # eyr 106 { -107 var eyr?/eax: boolean <- slice-equal? key-slice, "eyr" +107 var eyr?/eax: boolean <- slice-equal? key-slice, "eyr" 108 compare eyr?, 0/false 109 break-if-= 110 # 2020 <= eyr <= 2030 -111 var eyr/eax: int <- parse-decimal-int-from-slice val-slice +111 var eyr/eax: int <- parse-decimal-int-from-slice val-slice 112 compare eyr, 0x7e4 # 2020 113 { 114 break-if->= @@ -188,14 +187,14 @@ if ('onhashchange' in window) { 124 } 125 # hgt 126 { -127 var hgt?/eax: boolean <- slice-equal? key-slice, "hgt" +127 var hgt?/eax: boolean <- slice-equal? key-slice, "hgt" 128 compare hgt?, 0/false 129 break-if-= 130 # convert val 131 var s: (handle array byte) -132 var s2/eax: (addr handle array byte) <- address s +132 var s2/eax: (addr handle array byte) <- address s 133 _slice-to-string val-slice, s2 -134 var s3/eax: (addr array byte) <- lookup *s2 +134 var s3/eax: (addr array byte) <- lookup *s2 135 var s4/ebx: (addr array byte) <- copy s3 136 # check suffix 137 var start/edx: int <- length s4 @@ -204,17 +203,17 @@ if ('onhashchange' in window) { 140 var suffix-h: (handle array byte) 141 var suffix-ah/ecx: (addr handle array byte) <- address suffix-h 142 substring s4, start, 2, suffix-ah -143 var suffix/eax: (addr array byte) <- lookup *suffix-ah +143 var suffix/eax: (addr array byte) <- lookup *suffix-ah 144 { -145 var match?/eax: boolean <- string-equal? suffix, "in" +145 var match?/eax: boolean <- string-equal? suffix, "in" 146 compare match?, 0/false 147 break-if-= 148 # if suffix is "in", 59 <= val <= 96 149 var num-h: (handle array byte) 150 var num-ah/ecx: (addr handle array byte) <- address num-h 151 substring s4, 0, start, num-ah -152 var num/eax: (addr array byte) <- lookup *num-ah -153 var val/eax: int <- parse-decimal-int num +152 var num/eax: (addr array byte) <- lookup *num-ah +153 var val/eax: int <- parse-decimal-int num 154 compare val, 0x3b # 59 155 { 156 break-if->= @@ -230,15 +229,15 @@ if ('onhashchange' in window) { 166 loop $main:word-loop 167 } 168 { -169 var match?/eax: boolean <- string-equal? suffix, "cm" +169 var match?/eax: boolean <- string-equal? suffix, "cm" 170 compare match?, 0/false 171 break-if-= 172 # if suffix is "cm", 150 <= val <= 193 173 var num-h: (handle array byte) 174 var num-ah/ecx: (addr handle array byte) <- address num-h 175 substring s4, 0, start, num-ah -176 var num/eax: (addr array byte) <- lookup *num-ah -177 var val/eax: int <- parse-decimal-int num +176 var num/eax: (addr array byte) <- lookup *num-ah +177 var val/eax: int <- parse-decimal-int num 178 compare val, 0x96 # 150 179 { 180 break-if->= @@ -260,14 +259,14 @@ if ('onhashchange' in window) { 196 } 197 # hcl 198 { -199 var hcl?/eax: boolean <- slice-equal? key-slice, "hcl" +199 var hcl?/eax: boolean <- slice-equal? key-slice, "hcl" 200 compare hcl?, 0/false 201 break-if-= 202 # convert val 203 var s: (handle array byte) -204 var s2/eax: (addr handle array byte) <- address s +204 var s2/eax: (addr handle array byte) <- address s 205 _slice-to-string val-slice, s2 -206 var s3/eax: (addr array byte) <- lookup *s2 +206 var s3/eax: (addr array byte) <- lookup *s2 207 # check length 208 var len/ebx: int <- length s3 209 compare len, 7 @@ -279,8 +278,8 @@ if ('onhashchange' in window) { 215 } 216 # check first byte 217 { -218 var c/eax: (addr byte) <- index s3, 0 -219 var c2/eax: byte <- copy-byte *c +218 var c/eax: (addr byte) <- index s3, 0 +219 var c2/eax: byte <- copy-byte *c 220 compare c2, 0x23/hash 221 break-if-= 222 print-string 0, "invalid2\n" @@ -292,10 +291,10 @@ if ('onhashchange' in window) { 228 { 229 compare i, 7 230 break-if->= -231 var c/eax: (addr byte) <- index s3, i +231 var c/eax: (addr byte) <- index s3, i 232 { -233 var c2/eax: byte <- copy-byte *c -234 var valid?/eax: boolean <- hex-digit? c2 +233 var c2/eax: byte <- copy-byte *c +234 var valid?/eax: boolean <- hex-digit? c2 235 compare valid?, 0 236 loop-if-= $main:word-loop 237 } @@ -305,28 +304,28 @@ if ('onhashchange' in window) { 241 } 242 # ecl 243 { -244 var ecl?/eax: boolean <- slice-equal? key-slice, "ecl" +244 var ecl?/eax: boolean <- slice-equal? key-slice, "ecl" 245 compare ecl?, 0/false 246 break-if-= -247 var amb?/eax: boolean <- slice-equal? val-slice, "amb" +247 var amb?/eax: boolean <- slice-equal? val-slice, "amb" 248 compare amb?, 0/false 249 loop-if-!= $main:word-loop -250 var blu?/eax: boolean <- slice-equal? val-slice, "blu" +250 var blu?/eax: boolean <- slice-equal? val-slice, "blu" 251 compare blu?, 0/false 252 loop-if-!= $main:word-loop -253 var brn?/eax: boolean <- slice-equal? val-slice, "brn" +253 var brn?/eax: boolean <- slice-equal? val-slice, "brn" 254 compare brn?, 0/false 255 loop-if-!= $main:word-loop -256 var gry?/eax: boolean <- slice-equal? val-slice, "gry" +256 var gry?/eax: boolean <- slice-equal? val-slice, "gry" 257 compare gry?, 0/false 258 loop-if-!= $main:word-loop -259 var grn?/eax: boolean <- slice-equal? val-slice, "grn" +259 var grn?/eax: boolean <- slice-equal? val-slice, "grn" 260 compare grn?, 0/false 261 loop-if-!= $main:word-loop -262 var hzl?/eax: boolean <- slice-equal? val-slice, "hzl" +262 var hzl?/eax: boolean <- slice-equal? val-slice, "hzl" 263 compare hzl?, 0/false 264 loop-if-!= $main:word-loop -265 var oth?/eax: boolean <- slice-equal? val-slice, "oth" +265 var oth?/eax: boolean <- slice-equal? val-slice, "oth" 266 compare oth?, 0/false 267 loop-if-!= $main:word-loop 268 print-string 0, "invalid\n" @@ -334,16 +333,16 @@ if ('onhashchange' in window) { 270 } 271 # pid 272 { -273 var pid?/eax: boolean <- slice-equal? key-slice, "pid" +273 var pid?/eax: boolean <- slice-equal? key-slice, "pid" 274 compare pid?, 0/false 275 break-if-= 276 # convert val 277 var s: (handle array byte) -278 var s2/eax: (addr handle array byte) <- address s +278 var s2/eax: (addr handle array byte) <- address s 279 _slice-to-string val-slice, s2 -280 var s3/eax: (addr array byte) <- lookup *s2 +280 var s3/eax: (addr array byte) <- lookup *s2 281 # check length -282 var len/eax: int <- length s3 +282 var len/eax: int <- length s3 283 compare len, 9 284 { 285 break-if-= @@ -354,7 +353,7 @@ if ('onhashchange' in window) { 290 # check valid decimal int 291 # parse-decimal-int-from-slice currently returns 0 on invalid parse, 292 # which isn't ideal but suffices for our purposes -293 var val/eax: int <- parse-decimal-int-from-slice val-slice +293 var val/eax: int <- parse-decimal-int-from-slice val-slice 294 compare val, 0 295 { 296 break-if-> diff --git a/html/linux/advent2020/5a.mu.html b/html/linux/advent2020/5a.mu.html index 0c197443..65e52369 100644 --- a/html/linux/advent2020/5a.mu.html +++ b/html/linux/advent2020/5a.mu.html @@ -14,19 +14,18 @@ pre { white-space: pre-wrap; font-family: monospace; color: #000000; background- body { font-size:12pt; font-family: monospace; color: #000000; background-color: #ffffd7; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } -.muRegEdx { color: #878700; } -.muComment { color: #005faf; } -.CommentedCode { color: #8a8a8a; } -.LineNr { } -.muRegEcx { color: #af875f; } -.muRegEax { color: #875f00; } +.PreProc { color: #c000c0; } +.muRegEdx { color: #af5f00; } .Special { color: #ff6060; } -.muRegEdi { color: #87ffd7; } +.LineNr { } +.muRegEbx { color: #5f00ff; } +.Constant { color: #008787; } +.muRegEdi { color: #00af00; } +.muRegEcx { color: #870000; } .Delimiter { color: #c000c0; } .muFunction { color: #af5f00; text-decoration: underline; } -.muRegEbx { color: #8787af; } -.Constant { color: #008787; } -.PreProc { color: #c000c0; } +.CommentedCode { color: #8a8a8a; } +.muComment { color: #005faf; } --> @@ -82,11 +81,11 @@ if ('onhashchange' in window) { 18 read-line-from-real-keyboard line 19 print-stream-to-real-screen line 20 # if line is empty (not even a newline), quit -21 var done?/eax: boolean <- stream-empty? line +21 var done?/eax: boolean <- stream-empty? line 22 compare done?, 0/false 23 break-if-!= 24 # process line -25 var seat-id/eax: int <- convert-from-binary line +25 var seat-id/eax: int <- convert-from-binary line 26 compare seat-id, max-seat-id 27 { 28 break-if-<= @@ -99,13 +98,13 @@ if ('onhashchange' in window) { 35 return 0 36 } 37 -38 fn convert-from-binary in: (addr stream byte) -> _/eax: int { +38 fn convert-from-binary in: (addr stream byte) -> _/eax: int { 39 var result/edi: int <- copy 0 40 var i/ecx: int <- copy 9 # loop counter and also exponent 41 { 42 compare i, 0 43 break-if-< -44 var c/eax: byte <- read-byte in +44 var c/eax: byte <- read-byte in 45 #? print-string 0, "char: " 46 #? { 47 #? var c2/eax: int <- copy c @@ -126,7 +125,7 @@ if ('onhashchange' in window) { 62 #? print-string 0, "bit: " 63 #? print-int32-decimal 0, bit 64 #? print-string 0, "\n" -65 var bit-value/eax: int <- repeated-shift-left bit, i +65 var bit-value/eax: int <- repeated-shift-left bit, i 66 #? print-string 0, "bit value: " 67 #? print-int32-decimal 0, bit-value 68 #? print-string 0, "\n" diff --git a/html/linux/advent2020/5b.mu.html b/html/linux/advent2020/5b.mu.html index 8e8d6da9..c03039b9 100644 --- a/html/linux/advent2020/5b.mu.html +++ b/html/linux/advent2020/5b.mu.html @@ -14,19 +14,18 @@ pre { white-space: pre-wrap; font-family: monospace; color: #000000; background- body { font-size:12pt; font-family: monospace; color: #000000; background-color: #ffffd7; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } -.muRegEdx { color: #878700; } -.muComment { color: #005faf; } -.LineNr { } -.muRegEcx { color: #af875f; } +.PreProc { color: #c000c0; } +.muRegEdx { color: #af5f00; } .Special { color: #ff6060; } -.muRegEsi { color: #87d787; } -.muRegEax { color: #875f00; } +.LineNr { } +.muRegEsi { color: #005faf; } +.muRegEbx { color: #5f00ff; } +.Constant { color: #008787; } +.muRegEdi { color: #00af00; } +.muRegEcx { color: #870000; } .Delimiter { color: #c000c0; } .muFunction { color: #af5f00; text-decoration: underline; } -.muRegEbx { color: #8787af; } -.Constant { color: #008787; } -.PreProc { color: #c000c0; } -.muRegEdi { color: #87ffd7; } +.muComment { color: #005faf; } --> @@ -83,17 +82,17 @@ if ('onhashchange' in window) { 19 clear-stream line 20 read-line-from-real-keyboard line 21 # if line is empty (not even a newline), quit -22 var done?/eax: boolean <- stream-empty? line +22 var done?/eax: boolean <- stream-empty? line 23 compare done?, 0/false 24 break-if-!= 25 # process line -26 var seat-id/eax: int <- convert-from-binary line -27 var dest/eax: (addr int) <- index pass, seat-id +26 var seat-id/eax: int <- convert-from-binary line +27 var dest/eax: (addr int) <- index pass, seat-id 28 copy-to *dest, 1 29 loop 30 } 31 # phase 2: skip empty seats -32 var i/eax: int <- copy 0 +32 var i/eax: int <- copy 0 33 { 34 compare i, 0x400 35 break-if->= @@ -118,13 +117,13 @@ if ('onhashchange' in window) { 54 return 0 55 } 56 -57 fn convert-from-binary in: (addr stream byte) -> _/eax: int { +57 fn convert-from-binary in: (addr stream byte) -> _/eax: int { 58 var result/edi: int <- copy 0 59 var i/ecx: int <- copy 9 # loop counter and also exponent 60 { 61 compare i, 0 62 break-if-< -63 var c/eax: byte <- read-byte in +63 var c/eax: byte <- read-byte in 64 var bit/edx: int <- copy 0 65 { 66 compare c, 0x42/B @@ -136,7 +135,7 @@ if ('onhashchange' in window) { 72 break-if-!= 73 bit <- copy 1 74 } -75 var bit-value/eax: int <- repeated-shift-left bit, i +75 var bit-value/eax: int <- repeated-shift-left bit, i 76 result <- add bit-value 77 i <- decrement 78 loop -- cgit 1.4.1-2-gfad0