diff options
author | Kartik Agaram <vc@akkartik.com> | 2021-08-30 09:21:52 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2021-08-30 09:21:52 -0700 |
commit | 61ec86b71928afc4a7b0a9c787ba88d5b4b3040b (patch) | |
tree | 1c3da9ed40fa8bb36adb081e6dc538dfebf87afd /html/apps | |
parent | a479f0d0837be5fec7e92ef806cc50b9c17ed50c (diff) | |
download | mu-61ec86b71928afc4a7b0a9c787ba88d5b4b3040b.tar.gz |
.
Diffstat (limited to 'html/apps')
-rw-r--r-- | html/apps/color-game.mu.html | 10 | ||||
-rw-r--r-- | html/apps/colors.mu.html | 429 | ||||
-rw-r--r-- | html/apps/ex1.mu.html | 14 | ||||
-rw-r--r-- | html/apps/ex10.mu.html | 68 | ||||
-rw-r--r-- | html/apps/ex11.mu.html | 508 | ||||
-rw-r--r-- | html/apps/ex12.mu.html | 42 | ||||
-rw-r--r-- | html/apps/ex14.mu.html | 90 | ||||
-rw-r--r-- | html/apps/ex2.mu.html | 42 | ||||
-rw-r--r-- | html/apps/ex3.mu.html | 46 | ||||
-rw-r--r-- | html/apps/ex4.mu.html | 16 | ||||
-rw-r--r-- | html/apps/ex5.mu.html | 16 | ||||
-rw-r--r-- | html/apps/ex6.mu.html | 50 | ||||
-rw-r--r-- | html/apps/ex7.mu.html | 78 | ||||
-rw-r--r-- | html/apps/ex8.mu.html | 4 | ||||
-rw-r--r-- | html/apps/ex9.mu.html | 79 | ||||
-rw-r--r-- | html/apps/hest-life.mu.html | 48 | ||||
-rw-r--r-- | html/apps/mandelbrot-fixed.mu.html | 4 | ||||
-rw-r--r-- | html/apps/mandelbrot-silhouette.mu.html | 6 | ||||
-rw-r--r-- | html/apps/mandelbrot.mu.html | 4 | ||||
-rw-r--r-- | html/apps/rpn.mu.html | 233 |
20 files changed, 929 insertions, 858 deletions
diff --git a/html/apps/color-game.mu.html b/html/apps/color-game.mu.html index 7838733a..e96285ac 100644 --- a/html/apps/color-game.mu.html +++ b/html/apps/color-game.mu.html @@ -66,17 +66,17 @@ if ('onhashchange' in window) { <span id="L3" class="LineNr"> 3 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='color-game.mu.html#L3'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> <span id="L4" class="LineNr"> 4 </span> <span class="PreProc">var</span> second-buffer: <a href='../500fake-screen.mu.html#L14'>screen</a> <span id="L5" class="LineNr"> 5 </span> <span class="PreProc">var</span> second-screen/<span class="muRegEdi">edi</span>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>) <span class="Special"><-</span> address second-buffer -<span id="L6" class="LineNr"> 6 </span> <a href='../500fake-screen.mu.html#L33'>initialize-screen</a> second-screen, <span class="Constant">0x80</span>, <span class="Constant">0x30</span>, <span class="Constant">1</span>/include-pixels +<span id="L6" class="LineNr"> 6 </span> <a href='../500fake-screen.mu.html#L32'>initialize-screen</a> second-screen, <span class="Constant">0x80</span>, <span class="Constant">0x30</span>, <span class="Constant">1</span>/include-pixels <span id="L7" class="LineNr"> 7 </span> <span class="PreProc">var</span> leftx/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy <span class="Constant">0x80</span> <span id="L8" class="LineNr"> 8 </span> <span class="PreProc">var</span> rightx/<span class="muRegEbx">ebx</span>: int <span class="Special"><-</span> copy <span class="Constant">0x380</span> <span id="L9" class="LineNr"> 9 </span> <span class="Delimiter">{</span> <span id="L10" class="LineNr">10 </span> compare leftx, rightx <span id="L11" class="LineNr">11 </span> <span class="PreProc">break-if->=</span> -<span id="L12" class="LineNr">12 </span> <a href='../500fake-screen.mu.html#L251'>clear-screen</a> second-screen +<span id="L12" class="LineNr">12 </span> <a href='../500fake-screen.mu.html#L307'>clear-screen</a> second-screen <span id="L13" class="LineNr">13 </span> <span class="muComment"># interesting value: 9/blue with 0xe/yellow</span> <span id="L14" class="LineNr">14 </span> <a href='color-game.mu.html#L31'>color-field</a> second-screen, leftx <span class="Constant">0x40</span>/y, <span class="Constant">0x40</span>/width <span class="Constant">0x40</span>/height, <span class="Constant">1</span>/blue <span id="L15" class="LineNr">15 </span> <a href='color-game.mu.html#L31'>color-field</a> second-screen, rightx <span class="Constant">0x41</span>/y, <span class="Constant">0x40</span>/width <span class="Constant">0x40</span>/height, <span class="Constant">2</span>/green -<span id="L16" class="LineNr">16 </span> <a href='../500fake-screen.mu.html#L548'>copy-pixels</a> second-screen, <a href='../500fake-screen.mu.html#L14'>screen</a> +<span id="L16" class="LineNr">16 </span> <a href='../500fake-screen.mu.html#L620'>copy-pixels</a> second-screen, <a href='../500fake-screen.mu.html#L14'>screen</a> <span id="L17" class="LineNr">17 </span> <span class="muComment"># on the first iteration, give everyone a chance to make their guess</span> <span id="L18" class="LineNr">18 </span> <span class="Delimiter">{</span> <span id="L19" class="LineNr">19 </span> compare leftx, <span class="Constant">0x80</span> @@ -104,7 +104,7 @@ if ('onhashchange' in window) { <span id="L41" class="LineNr">41 </span> <span class="Delimiter">{</span> <span id="L42" class="LineNr">42 </span> compare x, xmax <span id="L43" class="LineNr">43 </span> <span class="PreProc">break-if->=</span> -<span id="L44" class="LineNr">44 </span> <a href='../500fake-screen.mu.html#L483'>pixel</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, x, y, color +<span id="L44" class="LineNr">44 </span> <a href='../500fake-screen.mu.html#L557'>pixel</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, x, y, color <span id="L45" class="LineNr">45 </span> x <span class="Special"><-</span> add <span class="Constant">2</span> <span id="L46" class="LineNr">46 </span> <span class="PreProc">loop</span> <span id="L47" class="LineNr">47 </span> <span class="Delimiter">}</span> @@ -116,7 +116,7 @@ if ('onhashchange' in window) { <span id="L53" class="LineNr">53 </span> <span class="Delimiter">{</span> <span id="L54" class="LineNr">54 </span> compare x, xmax <span id="L55" class="LineNr">55 </span> <span class="PreProc">break-if->=</span> -<span id="L56" class="LineNr">56 </span> <a href='../500fake-screen.mu.html#L483'>pixel</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, x, y, color +<span id="L56" class="LineNr">56 </span> <a href='../500fake-screen.mu.html#L557'>pixel</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, x, y, color <span id="L57" class="LineNr">57 </span> x <span class="Special"><-</span> add <span class="Constant">2</span> <span id="L58" class="LineNr">58 </span> <span class="PreProc">loop</span> <span id="L59" class="LineNr">59 </span> <span class="Delimiter">}</span> diff --git a/html/apps/colors.mu.html b/html/apps/colors.mu.html index 07a1aca3..4952798c 100644 --- a/html/apps/colors.mu.html +++ b/html/apps/colors.mu.html @@ -78,11 +78,11 @@ if ('onhashchange' in window) { <span id="L15" class="LineNr"> 15 </span> <span class="PreProc">var</span> in/<span class="muRegEsi">esi</span>: (addr stream byte) <span class="Special"><-</span> address in-storage <span id="L16" class="LineNr"> 16 </span> <span class="Delimiter">{</span> <span id="L17" class="LineNr"> 17 </span> <span class="muComment"># print prompt</span> -<span id="L18" class="LineNr"> 18 </span> <span class="PreProc">var</span> x/eax: int <span class="Special"><-</span> <a href='../501draw-text.mu.html#L100'>draw-text-rightward</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"Enter 3 hex bytes for r, g, b (lowercase; no 0x prefix) separated by a single space> "</span>, <span class="Constant">0x10</span>/x, <span class="Constant">0x80</span>/xmax, <span class="Constant">0x28</span>/y, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L18" class="LineNr"> 18 </span> <span class="PreProc">var</span> x/eax: int <span class="Special"><-</span> <a href='../501draw-text.mu.html#L106'>draw-text-rightward</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"Enter 3 hex bytes for r, g, b (lowercase; no 0x prefix) separated by a single space> "</span>, <span class="Constant">0x10</span>/x, <span class="Constant">0x80</span>/xmax, <span class="Constant">0x28</span>/y, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg <span id="L19" class="LineNr"> 19 </span> <span class="muComment"># read line from keyboard</span> <span id="L20" class="LineNr"> 20 </span> <a href='../106stream.subx.html#L20'>clear-stream</a> in <span id="L21" class="LineNr"> 21 </span> <span class="Delimiter">{</span> -<span id="L22" class="LineNr"> 22 </span> <a href='../500fake-screen.mu.html#L237'>draw-cursor</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x20</span>/space +<span id="L22" class="LineNr"> 22 </span> <a href='../500fake-screen.mu.html#L293'>draw-cursor</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x20</span>/space <span id="L23" class="LineNr"> 23 </span> <span class="PreProc">var</span> key/eax: byte <span class="Special"><-</span> <a href='../102keyboard.subx.html#L21'>read-key</a> keyboard <span id="L24" class="LineNr"> 24 </span> compare key, <span class="Constant">0xa</span>/newline <span id="L25" class="LineNr"> 25 </span> <span class="PreProc">break-if-=</span> @@ -90,219 +90,218 @@ if ('onhashchange' in window) { <span id="L27" class="LineNr"> 27 </span> <span class="PreProc">loop-if-=</span> <span id="L28" class="LineNr"> 28 </span> <span class="PreProc">var</span> key2/eax: int <span class="Special"><-</span> copy key <span id="L29" class="LineNr"> 29 </span> <a href='../115write-byte.subx.html#L12'>append-byte</a> in, key2 -<span id="L30" class="LineNr"> 30 </span> <span class="PreProc">var</span> g/eax: grapheme <span class="Special"><-</span> copy key2 -<span id="L31" class="LineNr"> 31 </span> <a href='../501draw-text.mu.html#L84'>draw-grapheme-at-cursor</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, g, <span class="Constant">0xf</span>/fg, <span class="Constant">0</span>/bg -<span id="L32" class="LineNr"> 32 </span> <a href='../501draw-text.mu.html#L16'>move-cursor-right</a> <span class="Constant">0</span> -<span id="L33" class="LineNr"> 33 </span> <span class="PreProc">loop</span> -<span id="L34" class="LineNr"> 34 </span> <span class="Delimiter">}</span> -<span id="L35" class="LineNr"> 35 </span> <a href='../500fake-screen.mu.html#L251'>clear-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a> -<span id="L36" class="LineNr"> 36 </span> <span class="muComment"># parse</span> -<span id="L37" class="LineNr"> 37 </span> <span class="PreProc">var</span> a/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L38" class="LineNr"> 38 </span> <span class="PreProc">var</span> b/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L39" class="LineNr"> 39 </span> <span class="PreProc">var</span> c/<span class="muRegEbx">ebx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L40" class="LineNr"> 40 </span> <span class="muComment"># a, b, c = r, g, b</span> -<span id="L41" class="LineNr"> 41 </span> a, b, c <span class="Special"><-</span> <a href='colors.mu.html#L65'>parse</a> in -<span id="L42" class="LineNr"> 42 </span><span class="CommentedCode">#? set-cursor-position screen, 0x10/x, 0x1a/y</span> -<span id="L43" class="LineNr"> 43 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, a, 7/fg, 0/bg</span> -<span id="L44" class="LineNr"> 44 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> -<span id="L45" class="LineNr"> 45 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, b, 7/fg, 0/bg</span> -<span id="L46" class="LineNr"> 46 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> -<span id="L47" class="LineNr"> 47 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, c, 7/fg, 0/bg</span> -<span id="L48" class="LineNr"> 48 </span> a, b, c <span class="Special"><-</span> <a href='../505colors.mu.html#L51'>hsl</a> a, b, c -<span id="L49" class="LineNr"> 49 </span> <span class="muComment"># return all colors in the same quadrant in h, s and l</span> -<span id="L50" class="LineNr"> 50 </span> <a href='colors.mu.html#L189'>print-nearby-colors</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, a, b, c -<span id="L51" class="LineNr"> 51 </span> <span class="muComment"># another metric</span> -<span id="L52" class="LineNr"> 52 </span> <span class="PreProc">var</span> color/eax: int <span class="Special"><-</span> <a href='../505colors.mu.html#L260'>nearest-color-euclidean-hsl</a> a, b, c -<span id="L53" class="LineNr"> 53 </span> <a href='../500fake-screen.mu.html#L190'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x10</span>/x, <span class="Constant">0x26</span>/y -<span id="L54" class="LineNr"> 54 </span> <a href='../501draw-text.mu.html#L276'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"nearest (euclidean, h/s/l): "</span>, <span class="Constant">0xf</span>/fg, <span class="Constant">0</span>/bg -<span id="L55" class="LineNr"> 55 </span> <a href='../501draw-text.mu.html#L384'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, color, <span class="Constant">7</span>/fg, <span class="Constant">0</span>/bg -<span id="L56" class="LineNr"> 56 </span> <a href='../501draw-text.mu.html#L276'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">" "</span>, <span class="Constant">0xf</span>/fg, <span class="Constant">0</span>/bg -<span id="L57" class="LineNr"> 57 </span> <a href='../501draw-text.mu.html#L276'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">" "</span>, <span class="Constant">0</span>/fg, color -<span id="L58" class="LineNr"> 58 </span> <span class="muComment">#</span> -<span id="L59" class="LineNr"> 59 </span> <span class="PreProc">loop</span> -<span id="L60" class="LineNr"> 60 </span> <span class="Delimiter">}</span> -<span id="L61" class="LineNr"> 61 </span><span class="Delimiter">}</span> -<span id="L62" class="LineNr"> 62 </span> -<span id="L63" class="LineNr"> 63 </span><span class="muComment"># read exactly 3 words in a single line</span> -<span id="L64" class="LineNr"> 64 </span><span class="muComment"># Each word consists of exactly 1 or 2 hex bytes. No hex prefix.</span> -<span id="L65" class="LineNr"> 65 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='colors.mu.html#L65'>parse</a></span> in: (addr stream byte)<span class="PreProc"> -> </span>_/<span class="muRegEcx">ecx</span>: int, _/<span class="muRegEdx">edx</span>: int, _/<span class="muRegEbx">ebx</span>: int <span class="Delimiter">{</span> -<span id="L66" class="LineNr"> 66 </span> <span class="muComment"># read first byte of r</span> -<span id="L67" class="LineNr"> 67 </span> <span class="PreProc">var</span> tmp/eax: byte <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in -<span id="L68" class="LineNr"> 68 </span> <span class="Delimiter">{</span> -<span id="L69" class="LineNr"> 69 </span> <span class="PreProc">var</span> valid?/eax: boolean <span class="Special"><-</span> <a href='../118parse-hex-int.subx.html#L701'>hex-digit?</a> tmp -<span id="L70" class="LineNr"> 70 </span> compare valid?, <span class="Constant">0</span>/false -<span id="L71" class="LineNr"> 71 </span> <span class="PreProc">break-if-!=</span> -<span id="L72" class="LineNr"> 72 </span> <a href='../317abort.subx.html#L5'>abort</a> <span class="Constant">"invalid byte 0 of r"</span> -<span id="L73" class="LineNr"> 73 </span> <span class="Delimiter">}</span> -<span id="L74" class="LineNr"> 74 </span> tmp <span class="Special"><-</span> <a href='colors.mu.html#L176'>fast-hex-digit-value</a> tmp -<span id="L75" class="LineNr"> 75 </span> <span class="PreProc">var</span> r/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy tmp -<span id="L76" class="LineNr"> 76 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x10/y</span> -<span id="L77" class="LineNr"> 77 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, r, 7/fg, 0/bg</span> -<span id="L78" class="LineNr"> 78 </span> <span class="muComment"># read second byte of r</span> -<span id="L79" class="LineNr"> 79 </span> tmp <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in -<span id="L80" class="LineNr"> 80 </span> <span class="Delimiter">{</span> -<span id="L81" class="LineNr"> 81 </span> <span class="Delimiter">{</span> -<span id="L82" class="LineNr"> 82 </span> <span class="PreProc">var</span> valid?/eax: boolean <span class="Special"><-</span> <a href='../118parse-hex-int.subx.html#L701'>hex-digit?</a> tmp -<span id="L83" class="LineNr"> 83 </span> compare valid?, <span class="Constant">0</span>/false -<span id="L84" class="LineNr"> 84 </span> <span class="Delimiter">}</span> -<span id="L85" class="LineNr"> 85 </span> <span class="PreProc">break-if-=</span> -<span id="L86" class="LineNr"> 86 </span> r <span class="Special"><-</span> shift-left <span class="Constant">4</span> -<span id="L87" class="LineNr"> 87 </span> tmp <span class="Special"><-</span> <a href='colors.mu.html#L176'>fast-hex-digit-value</a> tmp -<span id="L88" class="LineNr"> 88 </span><span class="CommentedCode">#? {</span> -<span id="L89" class="LineNr"> 89 </span><span class="CommentedCode">#? var foo/eax: int <- copy tmp</span> -<span id="L90" class="LineNr"> 90 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x11/y</span> -<span id="L91" class="LineNr"> 91 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, foo, 7/fg, 0/bg</span> -<span id="L92" class="LineNr"> 92 </span><span class="CommentedCode">#? }</span> -<span id="L93" class="LineNr"> 93 </span> r <span class="Special"><-</span> add tmp -<span id="L94" class="LineNr"> 94 </span><span class="CommentedCode">#? {</span> -<span id="L95" class="LineNr"> 95 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x12/y</span> -<span id="L96" class="LineNr"> 96 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, r, 7/fg, 0/bg</span> -<span id="L97" class="LineNr"> 97 </span><span class="CommentedCode">#? }</span> -<span id="L98" class="LineNr"> 98 </span> tmp <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in <span class="muComment"># skip space</span> -<span id="L99" class="LineNr"> 99 </span> <span class="Delimiter">}</span> -<span id="L100" class="LineNr">100 </span> <span class="muComment"># read first byte of g</span> -<span id="L101" class="LineNr">101 </span> <span class="PreProc">var</span> tmp/eax: byte <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in -<span id="L102" class="LineNr">102 </span> <span class="Delimiter">{</span> -<span id="L103" class="LineNr">103 </span> <span class="PreProc">var</span> valid?/eax: boolean <span class="Special"><-</span> <a href='../118parse-hex-int.subx.html#L701'>hex-digit?</a> tmp -<span id="L104" class="LineNr">104 </span> compare valid?, <span class="Constant">0</span>/false -<span id="L105" class="LineNr">105 </span> <span class="PreProc">break-if-!=</span> -<span id="L106" class="LineNr">106 </span> <a href='../317abort.subx.html#L5'>abort</a> <span class="Constant">"invalid byte 0 of g"</span> -<span id="L107" class="LineNr">107 </span> <span class="Delimiter">}</span> -<span id="L108" class="LineNr">108 </span> tmp <span class="Special"><-</span> <a href='colors.mu.html#L176'>fast-hex-digit-value</a> tmp -<span id="L109" class="LineNr">109 </span> <span class="PreProc">var</span> g/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy tmp -<span id="L110" class="LineNr">110 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x13/y</span> -<span id="L111" class="LineNr">111 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, g, 7/fg, 0/bg</span> -<span id="L112" class="LineNr">112 </span> <span class="muComment"># read second byte of g</span> -<span id="L113" class="LineNr">113 </span> tmp <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in -<span id="L114" class="LineNr">114 </span> <span class="Delimiter">{</span> -<span id="L115" class="LineNr">115 </span> <span class="Delimiter">{</span> -<span id="L116" class="LineNr">116 </span> <span class="PreProc">var</span> valid?/eax: boolean <span class="Special"><-</span> <a href='../118parse-hex-int.subx.html#L701'>hex-digit?</a> tmp -<span id="L117" class="LineNr">117 </span> compare valid?, <span class="Constant">0</span>/false -<span id="L118" class="LineNr">118 </span> <span class="Delimiter">}</span> -<span id="L119" class="LineNr">119 </span> <span class="PreProc">break-if-=</span> -<span id="L120" class="LineNr">120 </span> g <span class="Special"><-</span> shift-left <span class="Constant">4</span> -<span id="L121" class="LineNr">121 </span> tmp <span class="Special"><-</span> <a href='colors.mu.html#L176'>fast-hex-digit-value</a> tmp -<span id="L122" class="LineNr">122 </span><span class="CommentedCode">#? {</span> -<span id="L123" class="LineNr">123 </span><span class="CommentedCode">#? var foo/eax: int <- copy tmp</span> -<span id="L124" class="LineNr">124 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x14/y</span> -<span id="L125" class="LineNr">125 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, foo, 7/fg, 0/bg</span> -<span id="L126" class="LineNr">126 </span><span class="CommentedCode">#? }</span> -<span id="L127" class="LineNr">127 </span> g <span class="Special"><-</span> add tmp -<span id="L128" class="LineNr">128 </span><span class="CommentedCode">#? {</span> -<span id="L129" class="LineNr">129 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x15/y</span> -<span id="L130" class="LineNr">130 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, g, 7/fg, 0/bg</span> -<span id="L131" class="LineNr">131 </span><span class="CommentedCode">#? }</span> -<span id="L132" class="LineNr">132 </span> tmp <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in <span class="muComment"># skip space</span> -<span id="L133" class="LineNr">133 </span> <span class="Delimiter">}</span> -<span id="L134" class="LineNr">134 </span> <span class="muComment"># read first byte of b</span> -<span id="L135" class="LineNr">135 </span> <span class="PreProc">var</span> tmp/eax: byte <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in -<span id="L136" class="LineNr">136 </span> <span class="Delimiter">{</span> -<span id="L137" class="LineNr">137 </span> <span class="PreProc">var</span> valid?/eax: boolean <span class="Special"><-</span> <a href='../118parse-hex-int.subx.html#L701'>hex-digit?</a> tmp -<span id="L138" class="LineNr">138 </span> compare valid?, <span class="Constant">0</span>/false -<span id="L139" class="LineNr">139 </span> <span class="PreProc">break-if-!=</span> -<span id="L140" class="LineNr">140 </span> <a href='../317abort.subx.html#L5'>abort</a> <span class="Constant">"invalid byte 0 of b"</span> -<span id="L141" class="LineNr">141 </span> <span class="Delimiter">}</span> -<span id="L142" class="LineNr">142 </span> tmp <span class="Special"><-</span> <a href='colors.mu.html#L176'>fast-hex-digit-value</a> tmp -<span id="L143" class="LineNr">143 </span> <span class="PreProc">var</span> b/<span class="muRegEbx">ebx</span>: int <span class="Special"><-</span> copy tmp -<span id="L144" class="LineNr">144 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x16/y</span> -<span id="L145" class="LineNr">145 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, b, 7/fg, 0/bg</span> -<span id="L146" class="LineNr">146 </span> <span class="muComment"># read second byte of b</span> -<span id="L147" class="LineNr">147 </span> <span class="Delimiter">{</span> -<span id="L148" class="LineNr">148 </span> <span class="Delimiter">{</span> -<span id="L149" class="LineNr">149 </span> <span class="PreProc">var</span> done?/eax: boolean <span class="Special"><-</span> <a href='../309stream.subx.html#L6'>stream-empty?</a> in -<span id="L150" class="LineNr">150 </span> compare done?, <span class="Constant">0</span>/false -<span id="L151" class="LineNr">151 </span> <span class="Delimiter">}</span> -<span id="L152" class="LineNr">152 </span> <span class="PreProc">break-if-!=</span> -<span id="L153" class="LineNr">153 </span> tmp <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in -<span id="L154" class="LineNr">154 </span> <span class="Delimiter">{</span> -<span id="L155" class="LineNr">155 </span> <span class="PreProc">var</span> valid?/eax: boolean <span class="Special"><-</span> <a href='../118parse-hex-int.subx.html#L701'>hex-digit?</a> tmp -<span id="L156" class="LineNr">156 </span> compare valid?, <span class="Constant">0</span>/false -<span id="L157" class="LineNr">157 </span> <span class="Delimiter">}</span> -<span id="L158" class="LineNr">158 </span> <span class="PreProc">break-if-=</span> -<span id="L159" class="LineNr">159 </span> b <span class="Special"><-</span> shift-left <span class="Constant">4</span> -<span id="L160" class="LineNr">160 </span> tmp <span class="Special"><-</span> <a href='colors.mu.html#L176'>fast-hex-digit-value</a> tmp -<span id="L161" class="LineNr">161 </span><span class="CommentedCode">#? {</span> -<span id="L162" class="LineNr">162 </span><span class="CommentedCode">#? var foo/eax: int <- copy tmp</span> -<span id="L163" class="LineNr">163 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x17/y</span> -<span id="L164" class="LineNr">164 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, foo, 7/fg, 0/bg</span> -<span id="L165" class="LineNr">165 </span><span class="CommentedCode">#? }</span> -<span id="L166" class="LineNr">166 </span> b <span class="Special"><-</span> add tmp -<span id="L167" class="LineNr">167 </span><span class="CommentedCode">#? {</span> -<span id="L168" class="LineNr">168 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x18/y</span> -<span id="L169" class="LineNr">169 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, b, 7/fg, 0/bg</span> -<span id="L170" class="LineNr">170 </span><span class="CommentedCode">#? }</span> -<span id="L171" class="LineNr">171 </span> <span class="Delimiter">}</span> -<span id="L172" class="LineNr">172 </span> <span class="PreProc">return</span> r, g, b -<span id="L173" class="LineNr">173 </span><span class="Delimiter">}</span> -<span id="L174" class="LineNr">174 </span> -<span id="L175" class="LineNr">175 </span><span class="muComment"># no error checking</span> -<span id="L176" class="LineNr">176 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='colors.mu.html#L176'>fast-hex-digit-value</a></span> in: byte<span class="PreProc"> -> </span>_/eax: byte <span class="Delimiter">{</span> -<span id="L177" class="LineNr">177 </span> <span class="PreProc">var</span> result/eax: byte <span class="Special"><-</span> copy in -<span id="L178" class="LineNr">178 </span> compare result, <span class="Constant">0x39</span> -<span id="L179" class="LineNr">179 </span> <span class="Delimiter">{</span> -<span id="L180" class="LineNr">180 </span> <span class="PreProc">break-if-></span> -<span id="L181" class="LineNr">181 </span> result <span class="Special"><-</span> subtract <span class="Constant">0x30</span>/<span class="Constant">0</span> -<span id="L182" class="LineNr">182 </span> <span class="PreProc">return</span> result -<span id="L183" class="LineNr">183 </span> <span class="Delimiter">}</span> -<span id="L184" class="LineNr">184 </span> result <span class="Special"><-</span> subtract <span class="Constant">0x61</span>/a -<span id="L185" class="LineNr">185 </span> result <span class="Special"><-</span> add <span class="Constant">0xa</span>/<span class="Constant">10</span> -<span id="L186" class="LineNr">186 </span> <span class="PreProc">return</span> result -<span id="L187" class="LineNr">187 </span><span class="Delimiter">}</span> -<span id="L188" class="LineNr">188 </span> -<span id="L189" class="LineNr">189 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='colors.mu.html#L189'>print-nearby-colors</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), h: int, s: int, l: int <span class="Delimiter">{</span> -<span id="L190" class="LineNr">190 </span><span class="CommentedCode">#? set-cursor-position screen, 0x10/x, 0x1c/y</span> -<span id="L191" class="LineNr">191 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, h, 7/fg, 0/bg</span> -<span id="L192" class="LineNr">192 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> -<span id="L193" class="LineNr">193 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, s, 7/fg, 0/bg</span> -<span id="L194" class="LineNr">194 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> -<span id="L195" class="LineNr">195 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, l, 7/fg, 0/bg</span> -<span id="L196" class="LineNr">196 </span> <span class="muComment"># save just top 2 bits of each, so that we narrow down to 1/64th of the volume</span> -<span id="L197" class="LineNr">197 </span> shift-right h, <span class="Constant">6</span> -<span id="L198" class="LineNr">198 </span> shift-right s, <span class="Constant">6</span> -<span id="L199" class="LineNr">199 </span> shift-right l, <span class="Constant">6</span> -<span id="L200" class="LineNr">200 </span><span class="CommentedCode">#? set-cursor-position screen, 0x10/x, 0x1/y</span> -<span id="L201" class="LineNr">201 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, h, 7/fg, 0/bg</span> -<span id="L202" class="LineNr">202 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> -<span id="L203" class="LineNr">203 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, s, 7/fg, 0/bg</span> -<span id="L204" class="LineNr">204 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> -<span id="L205" class="LineNr">205 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, l, 7/fg, 0/bg</span> -<span id="L206" class="LineNr">206 </span> <span class="PreProc">var</span> a/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L207" class="LineNr">207 </span> <span class="PreProc">var</span> b/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L208" class="LineNr">208 </span> <span class="PreProc">var</span> c/<span class="muRegEbx">ebx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L209" class="LineNr">209 </span> <span class="PreProc">var</span> color/eax: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L210" class="LineNr">210 </span> <span class="PreProc">var</span> y/<span class="muRegEsi">esi</span>: int <span class="Special"><-</span> copy <span class="Constant">2</span> -<span id="L211" class="LineNr">211 </span> <span class="Delimiter">{</span> -<span id="L212" class="LineNr">212 </span> compare color, <span class="Constant">0x100</span> -<span id="L213" class="LineNr">213 </span> <span class="PreProc">break-if->=</span> -<span id="L214" class="LineNr">214 </span> a, b, c <span class="Special"><-</span> <a href='../316colors.subx.html#L7'>color-rgb</a> color -<span id="L215" class="LineNr">215 </span> a, b, c <span class="Special"><-</span> <a href='../505colors.mu.html#L51'>hsl</a> a, b, c -<span id="L216" class="LineNr">216 </span> a <span class="Special"><-</span> shift-right <span class="Constant">6</span> -<span id="L217" class="LineNr">217 </span> b <span class="Special"><-</span> shift-right <span class="Constant">6</span> -<span id="L218" class="LineNr">218 </span> c <span class="Special"><-</span> shift-right <span class="Constant">6</span> -<span id="L219" class="LineNr">219 </span> <span class="Delimiter">{</span> -<span id="L220" class="LineNr">220 </span> compare a, h -<span id="L221" class="LineNr">221 </span> <span class="PreProc">break-if-!=</span> -<span id="L222" class="LineNr">222 </span> compare b, s -<span id="L223" class="LineNr">223 </span> <span class="PreProc">break-if-!=</span> -<span id="L224" class="LineNr">224 </span> compare c, l -<span id="L225" class="LineNr">225 </span> <span class="PreProc">break-if-!=</span> -<span id="L226" class="LineNr">226 </span> <a href='../500fake-screen.mu.html#L190'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x10</span>/x, y -<span id="L227" class="LineNr">227 </span> <a href='../501draw-text.mu.html#L384'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, color, <span class="Constant">7</span>/fg, <span class="Constant">0</span>/bg -<span id="L228" class="LineNr">228 </span> <a href='../500fake-screen.mu.html#L190'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x14</span>/x, y -<span id="L229" class="LineNr">229 </span> <a href='../501draw-text.mu.html#L276'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">" "</span>, <span class="Constant">7</span>/fg, <span class="Constant">0</span>/bg -<span id="L230" class="LineNr">230 </span> <a href='../501draw-text.mu.html#L276'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">" "</span>, <span class="Constant">0</span>/fg, color -<span id="L231" class="LineNr">231 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> -<span id="L232" class="LineNr">232 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, a, 7/fg, 0/bg</span> -<span id="L233" class="LineNr">233 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> -<span id="L234" class="LineNr">234 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, b, 7/fg, 0/bg</span> -<span id="L235" class="LineNr">235 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> -<span id="L236" class="LineNr">236 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, c, 7/fg, 0/bg</span> -<span id="L237" class="LineNr">237 </span> y <span class="Special"><-</span> increment -<span id="L238" class="LineNr">238 </span> <span class="Delimiter">}</span> -<span id="L239" class="LineNr">239 </span> color <span class="Special"><-</span> increment -<span id="L240" class="LineNr">240 </span> <span class="PreProc">loop</span> -<span id="L241" class="LineNr">241 </span> <span class="Delimiter">}</span> -<span id="L242" class="LineNr">242 </span><span class="Delimiter">}</span> +<span id="L30" class="LineNr"> 30 </span> <span class="PreProc">var</span> c/eax: code-point <span class="Special"><-</span> copy key2 <span class="muComment"># TODO: unicode input</span> +<span id="L31" class="LineNr"> 31 </span> <a href='../501draw-text.mu.html#L84'>draw-code-point-at-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, c, <span class="Constant">0xf</span>/fg, <span class="Constant">0</span>/bg +<span id="L32" class="LineNr"> 32 </span> <span class="PreProc">loop</span> +<span id="L33" class="LineNr"> 33 </span> <span class="Delimiter">}</span> +<span id="L34" class="LineNr"> 34 </span> <a href='../500fake-screen.mu.html#L307'>clear-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a> +<span id="L35" class="LineNr"> 35 </span> <span class="muComment"># parse</span> +<span id="L36" class="LineNr"> 36 </span> <span class="PreProc">var</span> a/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L37" class="LineNr"> 37 </span> <span class="PreProc">var</span> b/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L38" class="LineNr"> 38 </span> <span class="PreProc">var</span> c/<span class="muRegEbx">ebx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L39" class="LineNr"> 39 </span> <span class="muComment"># a, b, c = r, g, b</span> +<span id="L40" class="LineNr"> 40 </span> a, b, c <span class="Special"><-</span> <a href='colors.mu.html#L64'>parse</a> in +<span id="L41" class="LineNr"> 41 </span><span class="CommentedCode">#? set-cursor-position screen, 0x10/x, 0x1a/y</span> +<span id="L42" class="LineNr"> 42 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, a, 7/fg, 0/bg</span> +<span id="L43" class="LineNr"> 43 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> +<span id="L44" class="LineNr"> 44 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, b, 7/fg, 0/bg</span> +<span id="L45" class="LineNr"> 45 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> +<span id="L46" class="LineNr"> 46 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, c, 7/fg, 0/bg</span> +<span id="L47" class="LineNr"> 47 </span> a, b, c <span class="Special"><-</span> <a href='../505colors.mu.html#L51'>hsl</a> a, b, c +<span id="L48" class="LineNr"> 48 </span> <span class="muComment"># return all colors in the same quadrant in h, s and l</span> +<span id="L49" class="LineNr"> 49 </span> <a href='colors.mu.html#L188'>print-nearby-colors</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, a, b, c +<span id="L50" class="LineNr"> 50 </span> <span class="muComment"># another metric</span> +<span id="L51" class="LineNr"> 51 </span> <span class="PreProc">var</span> color/eax: int <span class="Special"><-</span> <a href='../505colors.mu.html#L260'>nearest-color-euclidean-hsl</a> a, b, c +<span id="L52" class="LineNr"> 52 </span> <a href='../500fake-screen.mu.html#L246'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x10</span>/x, <span class="Constant">0x26</span>/y +<span id="L53" class="LineNr"> 53 </span> <a href='../501draw-text.mu.html#L284'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"nearest (euclidean, h/s/l): "</span>, <span class="Constant">0xf</span>/fg, <span class="Constant">0</span>/bg +<span id="L54" class="LineNr"> 54 </span> <a href='../501draw-text.mu.html#L394'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, color, <span class="Constant">7</span>/fg, <span class="Constant">0</span>/bg +<span id="L55" class="LineNr"> 55 </span> <a href='../501draw-text.mu.html#L284'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">" "</span>, <span class="Constant">0xf</span>/fg, <span class="Constant">0</span>/bg +<span id="L56" class="LineNr"> 56 </span> <a href='../501draw-text.mu.html#L284'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">" "</span>, <span class="Constant">0</span>/fg, color +<span id="L57" class="LineNr"> 57 </span> <span class="muComment">#</span> +<span id="L58" class="LineNr"> 58 </span> <span class="PreProc">loop</span> +<span id="L59" class="LineNr"> 59 </span> <span class="Delimiter">}</span> +<span id="L60" class="LineNr"> 60 </span><span class="Delimiter">}</span> +<span id="L61" class="LineNr"> 61 </span> +<span id="L62" class="LineNr"> 62 </span><span class="muComment"># read exactly 3 words in a single line</span> +<span id="L63" class="LineNr"> 63 </span><span class="muComment"># Each word consists of exactly 1 or 2 hex bytes. No hex prefix.</span> +<span id="L64" class="LineNr"> 64 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='colors.mu.html#L64'>parse</a></span> in: (addr stream byte)<span class="PreProc"> -> </span>_/<span class="muRegEcx">ecx</span>: int, _/<span class="muRegEdx">edx</span>: int, _/<span class="muRegEbx">ebx</span>: int <span class="Delimiter">{</span> +<span id="L65" class="LineNr"> 65 </span> <span class="muComment"># read first byte of r</span> +<span id="L66" class="LineNr"> 66 </span> <span class="PreProc">var</span> tmp/eax: byte <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in +<span id="L67" class="LineNr"> 67 </span> <span class="Delimiter">{</span> +<span id="L68" class="LineNr"> 68 </span> <span class="PreProc">var</span> valid?/eax: boolean <span class="Special"><-</span> <a href='../118parse-hex-int.subx.html#L701'>hex-digit?</a> tmp +<span id="L69" class="LineNr"> 69 </span> compare valid?, <span class="Constant">0</span>/false +<span id="L70" class="LineNr"> 70 </span> <span class="PreProc">break-if-!=</span> +<span id="L71" class="LineNr"> 71 </span> <a href='../317abort.subx.html#L5'>abort</a> <span class="Constant">"invalid byte 0 of r"</span> +<span id="L72" class="LineNr"> 72 </span> <span class="Delimiter">}</span> +<span id="L73" class="LineNr"> 73 </span> tmp <span class="Special"><-</span> <a href='colors.mu.html#L175'>fast-hex-digit-value</a> tmp +<span id="L74" class="LineNr"> 74 </span> <span class="PreProc">var</span> r/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy tmp +<span id="L75" class="LineNr"> 75 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x10/y</span> +<span id="L76" class="LineNr"> 76 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, r, 7/fg, 0/bg</span> +<span id="L77" class="LineNr"> 77 </span> <span class="muComment"># read second byte of r</span> +<span id="L78" class="LineNr"> 78 </span> tmp <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in +<span id="L79" class="LineNr"> 79 </span> <span class="Delimiter">{</span> +<span id="L80" class="LineNr"> 80 </span> <span class="Delimiter">{</span> +<span id="L81" class="LineNr"> 81 </span> <span class="PreProc">var</span> valid?/eax: boolean <span class="Special"><-</span> <a href='../118parse-hex-int.subx.html#L701'>hex-digit?</a> tmp +<span id="L82" class="LineNr"> 82 </span> compare valid?, <span class="Constant">0</span>/false +<span id="L83" class="LineNr"> 83 </span> <span class="Delimiter">}</span> +<span id="L84" class="LineNr"> 84 </span> <span class="PreProc">break-if-=</span> +<span id="L85" class="LineNr"> 85 </span> r <span class="Special"><-</span> shift-left <span class="Constant">4</span> +<span id="L86" class="LineNr"> 86 </span> tmp <span class="Special"><-</span> <a href='colors.mu.html#L175'>fast-hex-digit-value</a> tmp +<span id="L87" class="LineNr"> 87 </span><span class="CommentedCode">#? {</span> +<span id="L88" class="LineNr"> 88 </span><span class="CommentedCode">#? var foo/eax: int <- copy tmp</span> +<span id="L89" class="LineNr"> 89 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x11/y</span> +<span id="L90" class="LineNr"> 90 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, foo, 7/fg, 0/bg</span> +<span id="L91" class="LineNr"> 91 </span><span class="CommentedCode">#? }</span> +<span id="L92" class="LineNr"> 92 </span> r <span class="Special"><-</span> add tmp +<span id="L93" class="LineNr"> 93 </span><span class="CommentedCode">#? {</span> +<span id="L94" class="LineNr"> 94 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x12/y</span> +<span id="L95" class="LineNr"> 95 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, r, 7/fg, 0/bg</span> +<span id="L96" class="LineNr"> 96 </span><span class="CommentedCode">#? }</span> +<span id="L97" class="LineNr"> 97 </span> tmp <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in <span class="muComment"># skip space</span> +<span id="L98" class="LineNr"> 98 </span> <span class="Delimiter">}</span> +<span id="L99" class="LineNr"> 99 </span> <span class="muComment"># read first byte of g</span> +<span id="L100" class="LineNr">100 </span> <span class="PreProc">var</span> tmp/eax: byte <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in +<span id="L101" class="LineNr">101 </span> <span class="Delimiter">{</span> +<span id="L102" class="LineNr">102 </span> <span class="PreProc">var</span> valid?/eax: boolean <span class="Special"><-</span> <a href='../118parse-hex-int.subx.html#L701'>hex-digit?</a> tmp +<span id="L103" class="LineNr">103 </span> compare valid?, <span class="Constant">0</span>/false +<span id="L104" class="LineNr">104 </span> <span class="PreProc">break-if-!=</span> +<span id="L105" class="LineNr">105 </span> <a href='../317abort.subx.html#L5'>abort</a> <span class="Constant">"invalid byte 0 of g"</span> +<span id="L106" class="LineNr">106 </span> <span class="Delimiter">}</span> +<span id="L107" class="LineNr">107 </span> tmp <span class="Special"><-</span> <a href='colors.mu.html#L175'>fast-hex-digit-value</a> tmp +<span id="L108" class="LineNr">108 </span> <span class="PreProc">var</span> g/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy tmp +<span id="L109" class="LineNr">109 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x13/y</span> +<span id="L110" class="LineNr">110 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, g, 7/fg, 0/bg</span> +<span id="L111" class="LineNr">111 </span> <span class="muComment"># read second byte of g</span> +<span id="L112" class="LineNr">112 </span> tmp <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in +<span id="L113" class="LineNr">113 </span> <span class="Delimiter">{</span> +<span id="L114" class="LineNr">114 </span> <span class="Delimiter">{</span> +<span id="L115" class="LineNr">115 </span> <span class="PreProc">var</span> valid?/eax: boolean <span class="Special"><-</span> <a href='../118parse-hex-int.subx.html#L701'>hex-digit?</a> tmp +<span id="L116" class="LineNr">116 </span> compare valid?, <span class="Constant">0</span>/false +<span id="L117" class="LineNr">117 </span> <span class="Delimiter">}</span> +<span id="L118" class="LineNr">118 </span> <span class="PreProc">break-if-=</span> +<span id="L119" class="LineNr">119 </span> g <span class="Special"><-</span> shift-left <span class="Constant">4</span> +<span id="L120" class="LineNr">120 </span> tmp <span class="Special"><-</span> <a href='colors.mu.html#L175'>fast-hex-digit-value</a> tmp +<span id="L121" class="LineNr">121 </span><span class="CommentedCode">#? {</span> +<span id="L122" class="LineNr">122 </span><span class="CommentedCode">#? var foo/eax: int <- copy tmp</span> +<span id="L123" class="LineNr">123 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x14/y</span> +<span id="L124" class="LineNr">124 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, foo, 7/fg, 0/bg</span> +<span id="L125" class="LineNr">125 </span><span class="CommentedCode">#? }</span> +<span id="L126" class="LineNr">126 </span> g <span class="Special"><-</span> add tmp +<span id="L127" class="LineNr">127 </span><span class="CommentedCode">#? {</span> +<span id="L128" class="LineNr">128 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x15/y</span> +<span id="L129" class="LineNr">129 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, g, 7/fg, 0/bg</span> +<span id="L130" class="LineNr">130 </span><span class="CommentedCode">#? }</span> +<span id="L131" class="LineNr">131 </span> tmp <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in <span class="muComment"># skip space</span> +<span id="L132" class="LineNr">132 </span> <span class="Delimiter">}</span> +<span id="L133" class="LineNr">133 </span> <span class="muComment"># read first byte of b</span> +<span id="L134" class="LineNr">134 </span> <span class="PreProc">var</span> tmp/eax: byte <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in +<span id="L135" class="LineNr">135 </span> <span class="Delimiter">{</span> +<span id="L136" class="LineNr">136 </span> <span class="PreProc">var</span> valid?/eax: boolean <span class="Special"><-</span> <a href='../118parse-hex-int.subx.html#L701'>hex-digit?</a> tmp +<span id="L137" class="LineNr">137 </span> compare valid?, <span class="Constant">0</span>/false +<span id="L138" class="LineNr">138 </span> <span class="PreProc">break-if-!=</span> +<span id="L139" class="LineNr">139 </span> <a href='../317abort.subx.html#L5'>abort</a> <span class="Constant">"invalid byte 0 of b"</span> +<span id="L140" class="LineNr">140 </span> <span class="Delimiter">}</span> +<span id="L141" class="LineNr">141 </span> tmp <span class="Special"><-</span> <a href='colors.mu.html#L175'>fast-hex-digit-value</a> tmp +<span id="L142" class="LineNr">142 </span> <span class="PreProc">var</span> b/<span class="muRegEbx">ebx</span>: int <span class="Special"><-</span> copy tmp +<span id="L143" class="LineNr">143 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x16/y</span> +<span id="L144" class="LineNr">144 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, b, 7/fg, 0/bg</span> +<span id="L145" class="LineNr">145 </span> <span class="muComment"># read second byte of b</span> +<span id="L146" class="LineNr">146 </span> <span class="Delimiter">{</span> +<span id="L147" class="LineNr">147 </span> <span class="Delimiter">{</span> +<span id="L148" class="LineNr">148 </span> <span class="PreProc">var</span> done?/eax: boolean <span class="Special"><-</span> <a href='../309stream.subx.html#L6'>stream-empty?</a> in +<span id="L149" class="LineNr">149 </span> compare done?, <span class="Constant">0</span>/false +<span id="L150" class="LineNr">150 </span> <span class="Delimiter">}</span> +<span id="L151" class="LineNr">151 </span> <span class="PreProc">break-if-!=</span> +<span id="L152" class="LineNr">152 </span> tmp <span class="Special"><-</span> <a href='../112read-byte.subx.html#L13'>read-byte</a> in +<span id="L153" class="LineNr">153 </span> <span class="Delimiter">{</span> +<span id="L154" class="LineNr">154 </span> <span class="PreProc">var</span> valid?/eax: boolean <span class="Special"><-</span> <a href='../118parse-hex-int.subx.html#L701'>hex-digit?</a> tmp +<span id="L155" class="LineNr">155 </span> compare valid?, <span class="Constant">0</span>/false +<span id="L156" class="LineNr">156 </span> <span class="Delimiter">}</span> +<span id="L157" class="LineNr">157 </span> <span class="PreProc">break-if-=</span> +<span id="L158" class="LineNr">158 </span> b <span class="Special"><-</span> shift-left <span class="Constant">4</span> +<span id="L159" class="LineNr">159 </span> tmp <span class="Special"><-</span> <a href='colors.mu.html#L175'>fast-hex-digit-value</a> tmp +<span id="L160" class="LineNr">160 </span><span class="CommentedCode">#? {</span> +<span id="L161" class="LineNr">161 </span><span class="CommentedCode">#? var foo/eax: int <- copy tmp</span> +<span id="L162" class="LineNr">162 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x17/y</span> +<span id="L163" class="LineNr">163 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, foo, 7/fg, 0/bg</span> +<span id="L164" class="LineNr">164 </span><span class="CommentedCode">#? }</span> +<span id="L165" class="LineNr">165 </span> b <span class="Special"><-</span> add tmp +<span id="L166" class="LineNr">166 </span><span class="CommentedCode">#? {</span> +<span id="L167" class="LineNr">167 </span><span class="CommentedCode">#? set-cursor-position 0/screen, 0x10/x, 0x18/y</span> +<span id="L168" class="LineNr">168 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, b, 7/fg, 0/bg</span> +<span id="L169" class="LineNr">169 </span><span class="CommentedCode">#? }</span> +<span id="L170" class="LineNr">170 </span> <span class="Delimiter">}</span> +<span id="L171" class="LineNr">171 </span> <span class="PreProc">return</span> r, g, b +<span id="L172" class="LineNr">172 </span><span class="Delimiter">}</span> +<span id="L173" class="LineNr">173 </span> +<span id="L174" class="LineNr">174 </span><span class="muComment"># no error checking</span> +<span id="L175" class="LineNr">175 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='colors.mu.html#L175'>fast-hex-digit-value</a></span> in: byte<span class="PreProc"> -> </span>_/eax: byte <span class="Delimiter">{</span> +<span id="L176" class="LineNr">176 </span> <span class="PreProc">var</span> result/eax: byte <span class="Special"><-</span> copy in +<span id="L177" class="LineNr">177 </span> compare result, <span class="Constant">0x39</span> +<span id="L178" class="LineNr">178 </span> <span class="Delimiter">{</span> +<span id="L179" class="LineNr">179 </span> <span class="PreProc">break-if-></span> +<span id="L180" class="LineNr">180 </span> result <span class="Special"><-</span> subtract <span class="Constant">0x30</span>/<span class="Constant">0</span> +<span id="L181" class="LineNr">181 </span> <span class="PreProc">return</span> result +<span id="L182" class="LineNr">182 </span> <span class="Delimiter">}</span> +<span id="L183" class="LineNr">183 </span> result <span class="Special"><-</span> subtract <span class="Constant">0x61</span>/a +<span id="L184" class="LineNr">184 </span> result <span class="Special"><-</span> add <span class="Constant">0xa</span>/<span class="Constant">10</span> +<span id="L185" class="LineNr">185 </span> <span class="PreProc">return</span> result +<span id="L186" class="LineNr">186 </span><span class="Delimiter">}</span> +<span id="L187" class="LineNr">187 </span> +<span id="L188" class="LineNr">188 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='colors.mu.html#L188'>print-nearby-colors</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), h: int, s: int, l: int <span class="Delimiter">{</span> +<span id="L189" class="LineNr">189 </span><span class="CommentedCode">#? set-cursor-position screen, 0x10/x, 0x1c/y</span> +<span id="L190" class="LineNr">190 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, h, 7/fg, 0/bg</span> +<span id="L191" class="LineNr">191 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> +<span id="L192" class="LineNr">192 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, s, 7/fg, 0/bg</span> +<span id="L193" class="LineNr">193 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> +<span id="L194" class="LineNr">194 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, l, 7/fg, 0/bg</span> +<span id="L195" class="LineNr">195 </span> <span class="muComment"># save just top 2 bits of each, so that we narrow down to 1/64th of the volume</span> +<span id="L196" class="LineNr">196 </span> shift-right h, <span class="Constant">6</span> +<span id="L197" class="LineNr">197 </span> shift-right s, <span class="Constant">6</span> +<span id="L198" class="LineNr">198 </span> shift-right l, <span class="Constant">6</span> +<span id="L199" class="LineNr">199 </span><span class="CommentedCode">#? set-cursor-position screen, 0x10/x, 0x1/y</span> +<span id="L200" class="LineNr">200 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, h, 7/fg, 0/bg</span> +<span id="L201" class="LineNr">201 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> +<span id="L202" class="LineNr">202 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, s, 7/fg, 0/bg</span> +<span id="L203" class="LineNr">203 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> +<span id="L204" class="LineNr">204 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, l, 7/fg, 0/bg</span> +<span id="L205" class="LineNr">205 </span> <span class="PreProc">var</span> a/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L206" class="LineNr">206 </span> <span class="PreProc">var</span> b/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L207" class="LineNr">207 </span> <span class="PreProc">var</span> c/<span class="muRegEbx">ebx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L208" class="LineNr">208 </span> <span class="PreProc">var</span> color/eax: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L209" class="LineNr">209 </span> <span class="PreProc">var</span> y/<span class="muRegEsi">esi</span>: int <span class="Special"><-</span> copy <span class="Constant">2</span> +<span id="L210" class="LineNr">210 </span> <span class="Delimiter">{</span> +<span id="L211" class="LineNr">211 </span> compare color, <span class="Constant">0x100</span> +<span id="L212" class="LineNr">212 </span> <span class="PreProc">break-if->=</span> +<span id="L213" class="LineNr">213 </span> a, b, c <span class="Special"><-</span> <a href='../316colors.subx.html#L7'>color-rgb</a> color +<span id="L214" class="LineNr">214 </span> a, b, c <span class="Special"><-</span> <a href='../505colors.mu.html#L51'>hsl</a> a, b, c +<span id="L215" class="LineNr">215 </span> a <span class="Special"><-</span> shift-right <span class="Constant">6</span> +<span id="L216" class="LineNr">216 </span> b <span class="Special"><-</span> shift-right <span class="Constant">6</span> +<span id="L217" class="LineNr">217 </span> c <span class="Special"><-</span> shift-right <span class="Constant">6</span> +<span id="L218" class="LineNr">218 </span> <span class="Delimiter">{</span> +<span id="L219" class="LineNr">219 </span> compare a, h +<span id="L220" class="LineNr">220 </span> <span class="PreProc">break-if-!=</span> +<span id="L221" class="LineNr">221 </span> compare b, s +<span id="L222" class="LineNr">222 </span> <span class="PreProc">break-if-!=</span> +<span id="L223" class="LineNr">223 </span> compare c, l +<span id="L224" class="LineNr">224 </span> <span class="PreProc">break-if-!=</span> +<span id="L225" class="LineNr">225 </span> <a href='../500fake-screen.mu.html#L246'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x10</span>/x, y +<span id="L226" class="LineNr">226 </span> <a href='../501draw-text.mu.html#L394'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, color, <span class="Constant">7</span>/fg, <span class="Constant">0</span>/bg +<span id="L227" class="LineNr">227 </span> <a href='../500fake-screen.mu.html#L246'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x14</span>/x, y +<span id="L228" class="LineNr">228 </span> <a href='../501draw-text.mu.html#L284'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">" "</span>, <span class="Constant">7</span>/fg, <span class="Constant">0</span>/bg +<span id="L229" class="LineNr">229 </span> <a href='../501draw-text.mu.html#L284'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">" "</span>, <span class="Constant">0</span>/fg, color +<span id="L230" class="LineNr">230 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> +<span id="L231" class="LineNr">231 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, a, 7/fg, 0/bg</span> +<span id="L232" class="LineNr">232 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> +<span id="L233" class="LineNr">233 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, b, 7/fg, 0/bg</span> +<span id="L234" class="LineNr">234 </span><span class="CommentedCode">#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, " ", 7/fg, 0/bg</span> +<span id="L235" class="LineNr">235 </span><span class="CommentedCode">#? draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen screen, c, 7/fg, 0/bg</span> +<span id="L236" class="LineNr">236 </span> y <span class="Special"><-</span> increment +<span id="L237" class="LineNr">237 </span> <span class="Delimiter">}</span> +<span id="L238" class="LineNr">238 </span> color <span class="Special"><-</span> increment +<span id="L239" class="LineNr">239 </span> <span class="PreProc">loop</span> +<span id="L240" class="LineNr">240 </span> <span class="Delimiter">}</span> +<span id="L241" class="LineNr">241 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/apps/ex1.mu.html b/html/apps/ex1.mu.html index efd726ec..16aee038 100644 --- a/html/apps/ex1.mu.html +++ b/html/apps/ex1.mu.html @@ -60,14 +60,12 @@ if ('onhashchange' in window) { <span id="L4" class="LineNr"> 4 </span><span class="muComment"># ./translate apps/ex1.mu # emits code.img</span> <span id="L5" class="LineNr"> 5 </span><span class="muComment"># To run:</span> <span id="L6" class="LineNr"> 6 </span><span class="muComment"># qemu-system-i386 code.img</span> -<span id="L7" class="LineNr"> 7 </span><span class="muComment"># Or:</span> -<span id="L8" class="LineNr"> 8 </span><span class="muComment"># bochs -f bochsrc # bochsrc loads code.img</span> -<span id="L9" class="LineNr"> 9 </span><span class="muComment">#</span> -<span id="L10" class="LineNr">10 </span><span class="muComment"># Expected output: blank screen with no errors</span> -<span id="L11" class="LineNr">11 </span> -<span id="L12" class="LineNr">12 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex1.mu.html#L12'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> -<span id="L13" class="LineNr">13 </span> <span class="PreProc">loop</span> -<span id="L14" class="LineNr">14 </span><span class="Delimiter">}</span> +<span id="L7" class="LineNr"> 7 </span><span class="muComment">#</span> +<span id="L8" class="LineNr"> 8 </span><span class="muComment"># Expected output: blank screen with no errors</span> +<span id="L9" class="LineNr"> 9 </span> +<span id="L10" class="LineNr">10 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex1.mu.html#L10'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> +<span id="L11" class="LineNr">11 </span> <span class="PreProc">loop</span> +<span id="L12" class="LineNr">12 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/apps/ex10.mu.html b/html/apps/ex10.mu.html index a5f8b085..ffab815d 100644 --- a/html/apps/ex10.mu.html +++ b/html/apps/ex10.mu.html @@ -63,42 +63,40 @@ if ('onhashchange' in window) { <span id="L4" class="LineNr"> 4 </span><span class="muComment"># ./translate apps/ex10.mu # emits code.img</span> <span id="L5" class="LineNr"> 5 </span><span class="muComment"># To run:</span> <span id="L6" class="LineNr"> 6 </span><span class="muComment"># qemu-system-i386 code.img</span> -<span id="L7" class="LineNr"> 7 </span><span class="muComment"># Or:</span> -<span id="L8" class="LineNr"> 8 </span><span class="muComment"># bochs -f bochsrc # bochsrc loads code.img</span> -<span id="L9" class="LineNr"> 9 </span><span class="muComment">#</span> -<span id="L10" class="LineNr">10 </span><span class="muComment"># Expected output:</span> -<span id="L11" class="LineNr">11 </span><span class="muComment"># Values between -256 and +255 as you move the mouse over the window.</span> -<span id="L12" class="LineNr">12 </span><span class="muComment"># You might need to click on the window once.</span> -<span id="L13" class="LineNr">13 </span> -<span id="L14" class="LineNr">14 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex10.mu.html#L14'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> -<span id="L15" class="LineNr">15 </span> <span class="muComment"># repeatedly print out mouse driver results if non-zero</span> -<span id="L16" class="LineNr">16 </span> $main:event-loop: <span class="Delimiter">{</span> -<span id="L17" class="LineNr">17 </span> <span class="PreProc">var</span> dx/eax: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L18" class="LineNr">18 </span> <span class="PreProc">var</span> dy/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L19" class="LineNr">19 </span> dx, dy <span class="Special"><-</span> read-mouse-event -<span id="L20" class="LineNr">20 </span> <span class="Delimiter">{</span> -<span id="L21" class="LineNr">21 </span> compare dx, <span class="Constant">0</span> +<span id="L7" class="LineNr"> 7 </span><span class="muComment">#</span> +<span id="L8" class="LineNr"> 8 </span><span class="muComment"># Expected output:</span> +<span id="L9" class="LineNr"> 9 </span><span class="muComment"># Values between -256 and +255 as you move the mouse over the window.</span> +<span id="L10" class="LineNr">10 </span><span class="muComment"># You might need to click on the window once.</span> +<span id="L11" class="LineNr">11 </span> +<span id="L12" class="LineNr">12 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex10.mu.html#L12'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> +<span id="L13" class="LineNr">13 </span> <span class="muComment"># repeatedly print out mouse driver results if non-zero</span> +<span id="L14" class="LineNr">14 </span> $main:event-loop: <span class="Delimiter">{</span> +<span id="L15" class="LineNr">15 </span> <span class="PreProc">var</span> dx/eax: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L16" class="LineNr">16 </span> <span class="PreProc">var</span> dy/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L17" class="LineNr">17 </span> dx, dy <span class="Special"><-</span> read-mouse-event +<span id="L18" class="LineNr">18 </span> <span class="Delimiter">{</span> +<span id="L19" class="LineNr">19 </span> compare dx, <span class="Constant">0</span> +<span id="L20" class="LineNr">20 </span> <span class="PreProc">break-if-!=</span> +<span id="L21" class="LineNr">21 </span> compare dy, <span class="Constant">0</span> <span id="L22" class="LineNr">22 </span> <span class="PreProc">break-if-!=</span> -<span id="L23" class="LineNr">23 </span> compare dy, <span class="Constant">0</span> -<span id="L24" class="LineNr">24 </span> <span class="PreProc">break-if-!=</span> -<span id="L25" class="LineNr">25 </span> <span class="PreProc">loop</span> $main:event-loop -<span id="L26" class="LineNr">26 </span> <span class="Delimiter">}</span> -<span id="L27" class="LineNr">27 </span> <span class="Delimiter">{</span> -<span id="L28" class="LineNr">28 </span> <span class="PreProc">var</span> dummy1/eax: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L29" class="LineNr">29 </span> <span class="PreProc">var</span> dummy2/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L30" class="LineNr">30 </span> dummy1, dummy2 <span class="Special"><-</span> <a href='../501draw-text.mu.html#L253'>draw-text-wrapping-right-then-down-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">" "</span>, <span class="Constant">0</span>/x, <span class="Constant">0x10</span>/y, <span class="Constant">0x31</span>/fg, <span class="Constant">0</span>/bg -<span id="L31" class="LineNr">31 </span> <span class="Delimiter">}</span> -<span id="L32" class="LineNr">32 </span> <span class="Delimiter">{</span> -<span id="L33" class="LineNr">33 </span> <span class="PreProc">var</span> dummy/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L34" class="LineNr">34 </span> dx, dummy <span class="Special"><-</span> <a href='../501draw-text.mu.html#L361'>draw-int32-decimal-wrapping-right-then-down-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, dx, <span class="Constant">0</span>/x, <span class="Constant">0x10</span>/y, <span class="Constant">0x31</span>/fg, <span class="Constant">0</span>/bg -<span id="L35" class="LineNr">35 </span> <span class="Delimiter">}</span> -<span id="L36" class="LineNr">36 </span> <span class="Delimiter">{</span> -<span id="L37" class="LineNr">37 </span> <span class="PreProc">var</span> dummy/eax: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L38" class="LineNr">38 </span> dummy, dy <span class="Special"><-</span> <a href='../501draw-text.mu.html#L361'>draw-int32-decimal-wrapping-right-then-down-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, dy, <span class="Constant">5</span>/x, <span class="Constant">0x10</span>/y, <span class="Constant">0x31</span>/fg, <span class="Constant">0</span>/bg -<span id="L39" class="LineNr">39 </span> <span class="Delimiter">}</span> -<span id="L40" class="LineNr">40 </span> <span class="PreProc">loop</span> -<span id="L41" class="LineNr">41 </span> <span class="Delimiter">}</span> -<span id="L42" class="LineNr">42 </span><span class="Delimiter">}</span> +<span id="L23" class="LineNr">23 </span> <span class="PreProc">loop</span> $main:event-loop +<span id="L24" class="LineNr">24 </span> <span class="Delimiter">}</span> +<span id="L25" class="LineNr">25 </span> <span class="Delimiter">{</span> +<span id="L26" class="LineNr">26 </span> <span class="PreProc">var</span> dummy1/eax: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L27" class="LineNr">27 </span> <span class="PreProc">var</span> dummy2/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L28" class="LineNr">28 </span> dummy1, dummy2 <span class="Special"><-</span> <a href='../501draw-text.mu.html#L261'>draw-text-wrapping-right-then-down-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">" "</span>, <span class="Constant">0</span>/x, <span class="Constant">0x10</span>/y, <span class="Constant">0x31</span>/fg, <span class="Constant">0</span>/bg +<span id="L29" class="LineNr">29 </span> <span class="Delimiter">}</span> +<span id="L30" class="LineNr">30 </span> <span class="Delimiter">{</span> +<span id="L31" class="LineNr">31 </span> <span class="PreProc">var</span> dummy/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L32" class="LineNr">32 </span> dx, dummy <span class="Special"><-</span> <a href='../501draw-text.mu.html#L371'>draw-int32-decimal-wrapping-right-then-down-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, dx, <span class="Constant">0</span>/x, <span class="Constant">0x10</span>/y, <span class="Constant">0x31</span>/fg, <span class="Constant">0</span>/bg +<span id="L33" class="LineNr">33 </span> <span class="Delimiter">}</span> +<span id="L34" class="LineNr">34 </span> <span class="Delimiter">{</span> +<span id="L35" class="LineNr">35 </span> <span class="PreProc">var</span> dummy/eax: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L36" class="LineNr">36 </span> dummy, dy <span class="Special"><-</span> <a href='../501draw-text.mu.html#L371'>draw-int32-decimal-wrapping-right-then-down-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, dy, <span class="Constant">5</span>/x, <span class="Constant">0x10</span>/y, <span class="Constant">0x31</span>/fg, <span class="Constant">0</span>/bg +<span id="L37" class="LineNr">37 </span> <span class="Delimiter">}</span> +<span id="L38" class="LineNr">38 </span> <span class="PreProc">loop</span> +<span id="L39" class="LineNr">39 </span> <span class="Delimiter">}</span> +<span id="L40" class="LineNr">40 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/apps/ex11.mu.html b/html/apps/ex11.mu.html index 70b84f9e..406265ba 100644 --- a/html/apps/ex11.mu.html +++ b/html/apps/ex11.mu.html @@ -67,261 +67,259 @@ if ('onhashchange' in window) { <span id="L4" class="LineNr"> 4 </span><span class="muComment"># ./translate apps/ex11.mu # emits code.img</span> <span id="L5" class="LineNr"> 5 </span><span class="muComment"># To run:</span> <span id="L6" class="LineNr"> 6 </span><span class="muComment"># qemu-system-i386 code.img</span> -<span id="L7" class="LineNr"> 7 </span><span class="muComment"># Or:</span> -<span id="L8" class="LineNr"> 8 </span><span class="muComment"># bochs -f bochsrc # bochsrc loads code.img</span> -<span id="L9" class="LineNr"> 9 </span><span class="muComment">#</span> -<span id="L10" class="LineNr"> 10 </span><span class="muComment"># Expected output: a spline with 3 control points. Use `Tab` to switch cursor</span> -<span id="L11" class="LineNr"> 11 </span><span class="muComment"># between control points, and arrow keys to move the control point at the</span> -<span id="L12" class="LineNr"> 12 </span><span class="muComment"># cursor.</span> -<span id="L13" class="LineNr"> 13 </span> -<span id="L14" class="LineNr"> 14 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L14'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> -<span id="L15" class="LineNr"> 15 </span> <span class="PreProc">var</span> env-storage: <a href='ex11.mu.html#L25'>environment</a> -<span id="L16" class="LineNr"> 16 </span> <span class="PreProc">var</span> env/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Special"><-</span> address env-storage -<span id="L17" class="LineNr"> 17 </span> <a href='ex11.mu.html#L233'>initialize-environment</a> env, <span class="Constant">0x200</span> <span class="Constant">0x20</span>, <span class="Constant">0x180</span> <span class="Constant">0x90</span>, <span class="Constant">0x180</span> <span class="Constant">0x160</span> -<span id="L18" class="LineNr"> 18 </span> <span class="Delimiter">{</span> -<span id="L19" class="LineNr"> 19 </span> <a href='ex11.mu.html#L37'>render</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, env -<span id="L20" class="LineNr"> 20 </span> <a href='ex11.mu.html#L101'>edit</a> keyboard, env -<span id="L21" class="LineNr"> 21 </span> <span class="PreProc">loop</span> -<span id="L22" class="LineNr"> 22 </span> <span class="Delimiter">}</span> -<span id="L23" class="LineNr"> 23 </span><span class="Delimiter">}</span> -<span id="L24" class="LineNr"> 24 </span> -<span id="L25" class="LineNr"> 25 </span><span class="PreProc">type</span> <a href='ex11.mu.html#L25'>environment</a> <span class="Delimiter">{</span> -<span id="L26" class="LineNr"> 26 </span> p0: (handle <a href='ex11.mu.html#L32'>point</a>) -<span id="L27" class="LineNr"> 27 </span> p1: (handle <a href='ex11.mu.html#L32'>point</a>) -<span id="L28" class="LineNr"> 28 </span> p2: (handle <a href='ex11.mu.html#L32'>point</a>) -<span id="L29" class="LineNr"> 29 </span> <a href='ex11.mu.html#L77'>cursor</a>: (handle <a href='ex11.mu.html#L32'>point</a>) <span class="muComment"># one of p0, p1 or p2</span> -<span id="L30" class="LineNr"> 30 </span><span class="Delimiter">}</span> -<span id="L31" class="LineNr"> 31 </span> -<span id="L32" class="LineNr"> 32 </span><span class="PreProc">type</span> <a href='ex11.mu.html#L32'>point</a> <span class="Delimiter">{</span> -<span id="L33" class="LineNr"> 33 </span> x: int -<span id="L34" class="LineNr"> 34 </span> y: int -<span id="L35" class="LineNr"> 35 </span><span class="Delimiter">}</span> -<span id="L36" class="LineNr"> 36 </span> -<span id="L37" class="LineNr"> 37 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L37'>render</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), _self: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Delimiter">{</span> -<span id="L38" class="LineNr"> 38 </span> <a href='../500fake-screen.mu.html#L251'>clear-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a> -<span id="L39" class="LineNr"> 39 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Special"><-</span> copy _self -<span id="L40" class="LineNr"> 40 </span> <span class="PreProc">var</span> tmp-ah/<span class="muRegEcx">ecx</span>: (addr handle <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> get self, p0 -<span id="L41" class="LineNr"> 41 </span> <span class="PreProc">var</span> tmp/eax: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *tmp-ah -<span id="L42" class="LineNr"> 42 </span> <span class="PreProc">var</span> p0/<span class="muRegEbx">ebx</span>: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> copy tmp -<span id="L43" class="LineNr"> 43 </span> tmp-ah <span class="Special"><-</span> get self, p1 -<span id="L44" class="LineNr"> 44 </span> tmp <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *tmp-ah -<span id="L45" class="LineNr"> 45 </span> <span class="PreProc">var</span> p1/<span class="muRegEdx">edx</span>: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> copy tmp -<span id="L46" class="LineNr"> 46 </span> tmp-ah <span class="Special"><-</span> get self, p2 -<span id="L47" class="LineNr"> 47 </span> tmp <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *tmp-ah -<span id="L48" class="LineNr"> 48 </span> <span class="PreProc">var</span> p2/<span class="muRegEcx">ecx</span>: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> copy tmp -<span id="L49" class="LineNr"> 49 </span> <span class="muComment"># control lines</span> -<span id="L50" class="LineNr"> 50 </span> <a href='ex11.mu.html#L216'>line</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, p0, p1, <span class="Constant">7</span>/color -<span id="L51" class="LineNr"> 51 </span> <a href='ex11.mu.html#L216'>line</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, p1, p2, <span class="Constant">7</span>/color -<span id="L52" class="LineNr"> 52 </span> <span class="muComment"># curve above control lines</span> -<span id="L53" class="LineNr"> 53 </span> <a href='ex11.mu.html#L64'>bezier</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, p0, p1, p2, <span class="Constant">0xc</span>/color -<span id="L54" class="LineNr"> 54 </span> <span class="muComment"># points above curve</span> -<span id="L55" class="LineNr"> 55 </span> <a href='ex11.mu.html#L226'>disc</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, p0, <span class="Constant">3</span>/radius, <span class="Constant">7</span>/color <span class="Constant">0xf</span>/border -<span id="L56" class="LineNr"> 56 </span> <a href='ex11.mu.html#L226'>disc</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, p1, <span class="Constant">3</span>/radius, <span class="Constant">7</span>/color <span class="Constant">0xf</span>/border -<span id="L57" class="LineNr"> 57 </span> <a href='ex11.mu.html#L226'>disc</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, p2, <span class="Constant">3</span>/radius, <span class="Constant">7</span>/color <span class="Constant">0xf</span>/border -<span id="L58" class="LineNr"> 58 </span> <span class="muComment"># cursor last of all</span> -<span id="L59" class="LineNr"> 59 </span> <span class="PreProc">var</span> cursor-ah/eax: (addr handle <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> get self, <a href='ex11.mu.html#L77'>cursor</a> -<span id="L60" class="LineNr"> 60 </span> <span class="PreProc">var</span> <a href='ex11.mu.html#L77'>cursor</a>/eax: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *cursor-ah -<span id="L61" class="LineNr"> 61 </span> <a href='ex11.mu.html#L77'>cursor</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <a href='ex11.mu.html#L77'>cursor</a>, <span class="Constant">0xa</span>/side, <span class="Constant">3</span>/color -<span id="L62" class="LineNr"> 62 </span><span class="Delimiter">}</span> -<span id="L63" class="LineNr"> 63 </span> -<span id="L64" class="LineNr"> 64 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L64'>bezier</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), _p0: (addr <a href='ex11.mu.html#L32'>point</a>), _p1: (addr <a href='ex11.mu.html#L32'>point</a>), _p2: (addr <a href='ex11.mu.html#L32'>point</a>), color: int <span class="Delimiter">{</span> -<span id="L65" class="LineNr"> 65 </span> <span class="PreProc">var</span> p0/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> copy _p0 -<span id="L66" class="LineNr"> 66 </span> <span class="PreProc">var</span> x0/<span class="muRegEcx">ecx</span>: (addr int) <span class="Special"><-</span> get p0, x -<span id="L67" class="LineNr"> 67 </span> <span class="PreProc">var</span> y0/<span class="muRegEdx">edx</span>: (addr int) <span class="Special"><-</span> get p0, y -<span id="L68" class="LineNr"> 68 </span> <span class="PreProc">var</span> p1/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> copy _p1 -<span id="L69" class="LineNr"> 69 </span> <span class="PreProc">var</span> x1/<span class="muRegEbx">ebx</span>: (addr int) <span class="Special"><-</span> get p1, x -<span id="L70" class="LineNr"> 70 </span> <span class="PreProc">var</span> y1/eax: (addr int) <span class="Special"><-</span> get p1, y -<span id="L71" class="LineNr"> 71 </span> <span class="PreProc">var</span> p2/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> copy _p2 -<span id="L72" class="LineNr"> 72 </span> <span class="PreProc">var</span> x2/<span class="muRegEdi">edi</span>: (addr int) <span class="Special"><-</span> get p2, x -<span id="L73" class="LineNr"> 73 </span> <span class="PreProc">var</span> y2/<span class="muRegEsi">esi</span>: (addr int) <span class="Special"><-</span> get p2, y -<span id="L74" class="LineNr"> 74 </span> <a href='../509bezier.mu.html#L14'>draw-monotonic-bezier</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, *x0 *y0, *x1 *y1, *x2 *y2, color -<span id="L75" class="LineNr"> 75 </span><span class="Delimiter">}</span> -<span id="L76" class="LineNr"> 76 </span> -<span id="L77" class="LineNr"> 77 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L77'>cursor</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), _p: (addr <a href='ex11.mu.html#L32'>point</a>), side: int, color: int <span class="Delimiter">{</span> -<span id="L78" class="LineNr"> 78 </span> <span class="PreProc">var</span> half-side/eax: int <span class="Special"><-</span> copy side -<span id="L79" class="LineNr"> 79 </span> half-side <span class="Special"><-</span> shift-right <span class="Constant">1</span> -<span id="L80" class="LineNr"> 80 </span> <span class="PreProc">var</span> p/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> copy _p -<span id="L81" class="LineNr"> 81 </span> <span class="PreProc">var</span> x-a/<span class="muRegEcx">ecx</span>: (addr int) <span class="Special"><-</span> get p, x -<span id="L82" class="LineNr"> 82 </span> <span class="PreProc">var</span> left-x/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy *x-a -<span id="L83" class="LineNr"> 83 </span> left-x <span class="Special"><-</span> subtract half-side -<span id="L84" class="LineNr"> 84 </span> <span class="PreProc">var</span> y-a/<span class="muRegEdx">edx</span>: (addr int) <span class="Special"><-</span> get p, y -<span id="L85" class="LineNr"> 85 </span> <span class="PreProc">var</span> top-y/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy *y-a -<span id="L86" class="LineNr"> 86 </span> top-y <span class="Special"><-</span> subtract half-side -<span id="L87" class="LineNr"> 87 </span> <span class="PreProc">var</span> max/eax: int <span class="Special"><-</span> copy left-x -<span id="L88" class="LineNr"> 88 </span> max <span class="Special"><-</span> add side -<span id="L89" class="LineNr"> 89 </span> <a href='../507line.mu.html#L64'>draw-horizontal-line</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, top-y, left-x, max, color -<span id="L90" class="LineNr"> 90 </span> max <span class="Special"><-</span> copy top-y -<span id="L91" class="LineNr"> 91 </span> max <span class="Special"><-</span> add side -<span id="L92" class="LineNr"> 92 </span> <a href='../507line.mu.html#L75'>draw-vertical-line</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, left-x, top-y, max, color -<span id="L93" class="LineNr"> 93 </span> <span class="PreProc">var</span> right-x/<span class="muRegEbx">ebx</span>: int <span class="Special"><-</span> copy left-x -<span id="L94" class="LineNr"> 94 </span> right-x <span class="Special"><-</span> add side -<span id="L95" class="LineNr"> 95 </span> <a href='../507line.mu.html#L75'>draw-vertical-line</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, right-x, top-y, max, color -<span id="L96" class="LineNr"> 96 </span> <span class="PreProc">var</span> bottom-y/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy top-y -<span id="L97" class="LineNr"> 97 </span> bottom-y <span class="Special"><-</span> add side -<span id="L98" class="LineNr"> 98 </span> <a href='../507line.mu.html#L64'>draw-horizontal-line</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, bottom-y, left-x, right-x, color -<span id="L99" class="LineNr"> 99 </span><span class="Delimiter">}</span> -<span id="L100" class="LineNr">100 </span> -<span id="L101" class="LineNr">101 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L101'>edit</a></span> keyboard: (addr keyboard), _self: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Delimiter">{</span> -<span id="L102" class="LineNr">102 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Special"><-</span> copy _self -<span id="L103" class="LineNr">103 </span> <span class="PreProc">var</span> key/eax: byte <span class="Special"><-</span> <a href='../102keyboard.subx.html#L21'>read-key</a> keyboard -<span id="L104" class="LineNr">104 </span> compare key, <span class="Constant">0</span> -<span id="L105" class="LineNr">105 </span> <span class="PreProc">loop-if-=</span> -<span id="L106" class="LineNr">106 </span> <span class="Delimiter">{</span> -<span id="L107" class="LineNr">107 </span> compare key, <span class="Constant">9</span>/tab -<span id="L108" class="LineNr">108 </span> <span class="PreProc">break-if-!=</span> -<span id="L109" class="LineNr">109 </span> <a href='ex11.mu.html#L138'>toggle-cursor</a> self -<span id="L110" class="LineNr">110 </span> <span class="PreProc">return</span> -<span id="L111" class="LineNr">111 </span> <span class="Delimiter">}</span> -<span id="L112" class="LineNr">112 </span> <span class="Delimiter">{</span> -<span id="L113" class="LineNr">113 </span> compare key, <span class="Constant">0x80</span>/left-arrow -<span id="L114" class="LineNr">114 </span> <span class="PreProc">break-if-!=</span> -<span id="L115" class="LineNr">115 </span> <a href='ex11.mu.html#L168'>cursor-left</a> self -<span id="L116" class="LineNr">116 </span> <span class="PreProc">return</span> -<span id="L117" class="LineNr">117 </span> <span class="Delimiter">}</span> -<span id="L118" class="LineNr">118 </span> <span class="Delimiter">{</span> -<span id="L119" class="LineNr">119 </span> compare key, <span class="Constant">0x83</span>/right-arrow -<span id="L120" class="LineNr">120 </span> <span class="PreProc">break-if-!=</span> -<span id="L121" class="LineNr">121 </span> <a href='ex11.mu.html#L180'>cursor-right</a> self -<span id="L122" class="LineNr">122 </span> <span class="PreProc">return</span> -<span id="L123" class="LineNr">123 </span> <span class="Delimiter">}</span> -<span id="L124" class="LineNr">124 </span> <span class="Delimiter">{</span> -<span id="L125" class="LineNr">125 </span> compare key, <span class="Constant">0x81</span>/down-arrow -<span id="L126" class="LineNr">126 </span> <span class="PreProc">break-if-!=</span> -<span id="L127" class="LineNr">127 </span> <a href='ex11.mu.html#L204'>cursor-down</a> self -<span id="L128" class="LineNr">128 </span> <span class="PreProc">return</span> -<span id="L129" class="LineNr">129 </span> <span class="Delimiter">}</span> -<span id="L130" class="LineNr">130 </span> <span class="Delimiter">{</span> -<span id="L131" class="LineNr">131 </span> compare key, <span class="Constant">0x82</span>/up-arrow -<span id="L132" class="LineNr">132 </span> <span class="PreProc">break-if-!=</span> -<span id="L133" class="LineNr">133 </span> <a href='ex11.mu.html#L192'>cursor-up</a> self -<span id="L134" class="LineNr">134 </span> <span class="PreProc">return</span> -<span id="L135" class="LineNr">135 </span> <span class="Delimiter">}</span> -<span id="L136" class="LineNr">136 </span><span class="Delimiter">}</span> -<span id="L137" class="LineNr">137 </span> -<span id="L138" class="LineNr">138 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L138'>toggle-cursor</a></span> _self: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Delimiter">{</span> -<span id="L139" class="LineNr">139 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Special"><-</span> copy _self -<span id="L140" class="LineNr">140 </span> <span class="PreProc">var</span> cursor-ah/<span class="muRegEdi">edi</span>: (addr handle <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> get self, <a href='ex11.mu.html#L77'>cursor</a> -<span id="L141" class="LineNr">141 </span> <span class="PreProc">var</span> p0-ah/<span class="muRegEcx">ecx</span>: (addr handle <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> get self, p0 -<span id="L142" class="LineNr">142 </span> <span class="PreProc">var</span> p1-ah/<span class="muRegEdx">edx</span>: (addr handle <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> get self, p1 -<span id="L143" class="LineNr">143 </span> <span class="PreProc">var</span> p2-ah/<span class="muRegEbx">ebx</span>: (addr handle <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> get self, p2 -<span id="L144" class="LineNr">144 </span> <span class="Delimiter">{</span> -<span id="L145" class="LineNr">145 </span> <span class="PreProc">var</span> p0?/eax: boolean <span class="Special"><-</span> <a href='../120allocate.subx.html#L460'>handle-equal?</a> *p0-ah, *cursor-ah -<span id="L146" class="LineNr">146 </span> compare p0?, <span class="Constant">0</span>/false -<span id="L147" class="LineNr">147 </span> <span class="PreProc">break-if-=</span> -<span id="L148" class="LineNr">148 </span> copy-object p1-ah, cursor-ah -<span id="L149" class="LineNr">149 </span> <span class="PreProc">return</span> -<span id="L150" class="LineNr">150 </span> <span class="Delimiter">}</span> -<span id="L151" class="LineNr">151 </span> <span class="Delimiter">{</span> -<span id="L152" class="LineNr">152 </span> <span class="PreProc">var</span> p1?/eax: boolean <span class="Special"><-</span> <a href='../120allocate.subx.html#L460'>handle-equal?</a> *p1-ah, *cursor-ah -<span id="L153" class="LineNr">153 </span> compare p1?, <span class="Constant">0</span>/false -<span id="L154" class="LineNr">154 </span> <span class="PreProc">break-if-=</span> -<span id="L155" class="LineNr">155 </span> copy-object p2-ah, cursor-ah -<span id="L156" class="LineNr">156 </span> <span class="PreProc">return</span> -<span id="L157" class="LineNr">157 </span> <span class="Delimiter">}</span> -<span id="L158" class="LineNr">158 </span> <span class="Delimiter">{</span> -<span id="L159" class="LineNr">159 </span> <span class="PreProc">var</span> p2?/eax: boolean <span class="Special"><-</span> <a href='../120allocate.subx.html#L460'>handle-equal?</a> *p2-ah, *cursor-ah -<span id="L160" class="LineNr">160 </span> compare p2?, <span class="Constant">0</span>/false -<span id="L161" class="LineNr">161 </span> <span class="PreProc">break-if-=</span> -<span id="L162" class="LineNr">162 </span> copy-object p0-ah, cursor-ah -<span id="L163" class="LineNr">163 </span> <span class="PreProc">return</span> -<span id="L164" class="LineNr">164 </span> <span class="Delimiter">}</span> -<span id="L165" class="LineNr">165 </span> <a href='../317abort.subx.html#L5'>abort</a> <span class="Constant">"lost cursor"</span> -<span id="L166" class="LineNr">166 </span><span class="Delimiter">}</span> -<span id="L167" class="LineNr">167 </span> -<span id="L168" class="LineNr">168 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L168'>cursor-left</a></span> _self: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Delimiter">{</span> -<span id="L169" class="LineNr">169 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Special"><-</span> copy _self -<span id="L170" class="LineNr">170 </span> <span class="PreProc">var</span> cursor-ah/<span class="muRegEsi">esi</span>: (addr handle <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> get self, <a href='ex11.mu.html#L77'>cursor</a> -<span id="L171" class="LineNr">171 </span> <span class="PreProc">var</span> <a href='ex11.mu.html#L77'>cursor</a>/eax: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *cursor-ah -<span id="L172" class="LineNr">172 </span> <span class="PreProc">var</span> cursor-x/eax: (addr int) <span class="Special"><-</span> get <a href='ex11.mu.html#L77'>cursor</a>, x -<span id="L173" class="LineNr">173 </span> compare *cursor-x, <span class="Constant">0x20</span> -<span id="L174" class="LineNr">174 </span> <span class="Delimiter">{</span> -<span id="L175" class="LineNr">175 </span> <span class="PreProc">break-if-<</span> -<span id="L176" class="LineNr">176 </span> subtract-from *cursor-x, <span class="Constant">0x20</span> -<span id="L177" class="LineNr">177 </span> <span class="Delimiter">}</span> -<span id="L178" class="LineNr">178 </span><span class="Delimiter">}</span> -<span id="L179" class="LineNr">179 </span> -<span id="L180" class="LineNr">180 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L180'>cursor-right</a></span> _self: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Delimiter">{</span> -<span id="L181" class="LineNr">181 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Special"><-</span> copy _self -<span id="L182" class="LineNr">182 </span> <span class="PreProc">var</span> cursor-ah/<span class="muRegEsi">esi</span>: (addr handle <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> get self, <a href='ex11.mu.html#L77'>cursor</a> -<span id="L183" class="LineNr">183 </span> <span class="PreProc">var</span> <a href='ex11.mu.html#L77'>cursor</a>/eax: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *cursor-ah -<span id="L184" class="LineNr">184 </span> <span class="PreProc">var</span> cursor-x/eax: (addr int) <span class="Special"><-</span> get <a href='ex11.mu.html#L77'>cursor</a>, x -<span id="L185" class="LineNr">185 </span> compare *cursor-x, <span class="Constant">0x3f0</span> -<span id="L186" class="LineNr">186 </span> <span class="Delimiter">{</span> -<span id="L187" class="LineNr">187 </span> <span class="PreProc">break-if-></span> -<span id="L188" class="LineNr">188 </span> add-to *cursor-x, <span class="Constant">0x20</span> -<span id="L189" class="LineNr">189 </span> <span class="Delimiter">}</span> -<span id="L190" class="LineNr">190 </span><span class="Delimiter">}</span> -<span id="L191" class="LineNr">191 </span> -<span id="L192" class="LineNr">192 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L192'>cursor-up</a></span> _self: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Delimiter">{</span> -<span id="L193" class="LineNr">193 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Special"><-</span> copy _self -<span id="L194" class="LineNr">194 </span> <span class="PreProc">var</span> cursor-ah/<span class="muRegEsi">esi</span>: (addr handle <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> get self, <a href='ex11.mu.html#L77'>cursor</a> -<span id="L195" class="LineNr">195 </span> <span class="PreProc">var</span> <a href='ex11.mu.html#L77'>cursor</a>/eax: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *cursor-ah -<span id="L196" class="LineNr">196 </span> <span class="PreProc">var</span> cursor-y/eax: (addr int) <span class="Special"><-</span> get <a href='ex11.mu.html#L77'>cursor</a>, y -<span id="L197" class="LineNr">197 </span> compare *cursor-y, <span class="Constant">0x20</span> -<span id="L198" class="LineNr">198 </span> <span class="Delimiter">{</span> -<span id="L199" class="LineNr">199 </span> <span class="PreProc">break-if-<</span> -<span id="L200" class="LineNr">200 </span> subtract-from *cursor-y, <span class="Constant">0x20</span> -<span id="L201" class="LineNr">201 </span> <span class="Delimiter">}</span> -<span id="L202" class="LineNr">202 </span><span class="Delimiter">}</span> -<span id="L203" class="LineNr">203 </span> -<span id="L204" class="LineNr">204 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L204'>cursor-down</a></span> _self: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Delimiter">{</span> -<span id="L205" class="LineNr">205 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Special"><-</span> copy _self -<span id="L206" class="LineNr">206 </span> <span class="PreProc">var</span> cursor-ah/<span class="muRegEsi">esi</span>: (addr handle <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> get self, <a href='ex11.mu.html#L77'>cursor</a> -<span id="L207" class="LineNr">207 </span> <span class="PreProc">var</span> <a href='ex11.mu.html#L77'>cursor</a>/eax: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *cursor-ah -<span id="L208" class="LineNr">208 </span> <span class="PreProc">var</span> cursor-y/eax: (addr int) <span class="Special"><-</span> get <a href='ex11.mu.html#L77'>cursor</a>, y -<span id="L209" class="LineNr">209 </span> compare *cursor-y, <span class="Constant">0x2f0</span> -<span id="L210" class="LineNr">210 </span> <span class="Delimiter">{</span> -<span id="L211" class="LineNr">211 </span> <span class="PreProc">break-if-></span> -<span id="L212" class="LineNr">212 </span> add-to *cursor-y, <span class="Constant">0x20</span> -<span id="L213" class="LineNr">213 </span> <span class="Delimiter">}</span> -<span id="L214" class="LineNr">214 </span><span class="Delimiter">}</span> -<span id="L215" class="LineNr">215 </span> -<span id="L216" class="LineNr">216 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L216'>line</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), _p0: (addr <a href='ex11.mu.html#L32'>point</a>), _p1: (addr <a href='ex11.mu.html#L32'>point</a>), color: int <span class="Delimiter">{</span> -<span id="L217" class="LineNr">217 </span> <span class="PreProc">var</span> p0/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> copy _p0 -<span id="L218" class="LineNr">218 </span> <span class="PreProc">var</span> x0/<span class="muRegEcx">ecx</span>: (addr int) <span class="Special"><-</span> get p0, x -<span id="L219" class="LineNr">219 </span> <span class="PreProc">var</span> y0/<span class="muRegEdx">edx</span>: (addr int) <span class="Special"><-</span> get p0, y -<span id="L220" class="LineNr">220 </span> <span class="PreProc">var</span> p1/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> copy _p1 -<span id="L221" class="LineNr">221 </span> <span class="PreProc">var</span> x1/<span class="muRegEbx">ebx</span>: (addr int) <span class="Special"><-</span> get p1, x -<span id="L222" class="LineNr">222 </span> <span class="PreProc">var</span> y1/eax: (addr int) <span class="Special"><-</span> get p1, y -<span id="L223" class="LineNr">223 </span> <a href='../507line.mu.html#L1'>draw-line</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, *x0 *y0, *x1 *y1, color -<span id="L224" class="LineNr">224 </span><span class="Delimiter">}</span> -<span id="L225" class="LineNr">225 </span> -<span id="L226" class="LineNr">226 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L226'>disc</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), _p: (addr <a href='ex11.mu.html#L32'>point</a>), radius: int, color: int, border-color: int <span class="Delimiter">{</span> -<span id="L227" class="LineNr">227 </span> <span class="PreProc">var</span> p/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> copy _p -<span id="L228" class="LineNr">228 </span> <span class="PreProc">var</span> x/<span class="muRegEcx">ecx</span>: (addr int) <span class="Special"><-</span> get p, x -<span id="L229" class="LineNr">229 </span> <span class="PreProc">var</span> y/<span class="muRegEdx">edx</span>: (addr int) <span class="Special"><-</span> get p, y -<span id="L230" class="LineNr">230 </span> <a href='../508circle.mu.html#L80'>draw-disc</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, *x *y, radius, color, border-color -<span id="L231" class="LineNr">231 </span><span class="Delimiter">}</span> -<span id="L232" class="LineNr">232 </span> -<span id="L233" class="LineNr">233 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L233'>initialize-environment</a></span> _self: (addr <a href='ex11.mu.html#L25'>environment</a>), x0: int, y0: int, x1: int, y1: int, x2: int, y2: int <span class="Delimiter">{</span> -<span id="L234" class="LineNr">234 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L25'>environment</a>) <span class="Special"><-</span> copy _self -<span id="L235" class="LineNr">235 </span> <span class="PreProc">var</span> p0-ah/eax: (addr handle <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> get self, p0 -<span id="L236" class="LineNr">236 </span> <a href='../120allocate.subx.html#L43'>allocate</a> p0-ah -<span id="L237" class="LineNr">237 </span> <span class="PreProc">var</span> p0/eax: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *p0-ah -<span id="L238" class="LineNr">238 </span> <a href='ex11.mu.html#L253'>initialize-point</a> p0, x0 y0 -<span id="L239" class="LineNr">239 </span> <span class="PreProc">var</span> p1-ah/eax: (addr handle <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> get self, p1 -<span id="L240" class="LineNr">240 </span> <a href='../120allocate.subx.html#L43'>allocate</a> p1-ah -<span id="L241" class="LineNr">241 </span> <span class="PreProc">var</span> p1/eax: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *p1-ah -<span id="L242" class="LineNr">242 </span> <a href='ex11.mu.html#L253'>initialize-point</a> p1, x1 y1 -<span id="L243" class="LineNr">243 </span> <span class="PreProc">var</span> p2-ah/eax: (addr handle <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> get self, p2 -<span id="L244" class="LineNr">244 </span> <a href='../120allocate.subx.html#L43'>allocate</a> p2-ah -<span id="L245" class="LineNr">245 </span> <span class="PreProc">var</span> p2/eax: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *p2-ah -<span id="L246" class="LineNr">246 </span> <a href='ex11.mu.html#L253'>initialize-point</a> p2, x2 y2 -<span id="L247" class="LineNr">247 </span> <span class="muComment"># cursor initially at p0</span> -<span id="L248" class="LineNr">248 </span> <span class="PreProc">var</span> cursor-ah/<span class="muRegEdi">edi</span>: (addr handle <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> get self, <a href='ex11.mu.html#L77'>cursor</a> -<span id="L249" class="LineNr">249 </span> <span class="PreProc">var</span> src-ah/<span class="muRegEsi">esi</span>: (addr handle <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> get self, p0 -<span id="L250" class="LineNr">250 </span> copy-object src-ah, cursor-ah -<span id="L251" class="LineNr">251 </span><span class="Delimiter">}</span> -<span id="L252" class="LineNr">252 </span> -<span id="L253" class="LineNr">253 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L253'>initialize-point</a></span> _p: (addr <a href='ex11.mu.html#L32'>point</a>), x: int, y: int <span class="Delimiter">{</span> -<span id="L254" class="LineNr">254 </span> <span class="PreProc">var</span> p/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L32'>point</a>) <span class="Special"><-</span> copy _p -<span id="L255" class="LineNr">255 </span> <span class="PreProc">var</span> dest/eax: (addr int) <span class="Special"><-</span> get p, x -<span id="L256" class="LineNr">256 </span> <span class="PreProc">var</span> src/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy x -<span id="L257" class="LineNr">257 </span> copy-to *dest, src -<span id="L258" class="LineNr">258 </span> dest <span class="Special"><-</span> get p, y -<span id="L259" class="LineNr">259 </span> src <span class="Special"><-</span> copy y -<span id="L260" class="LineNr">260 </span> copy-to *dest, src -<span id="L261" class="LineNr">261 </span><span class="Delimiter">}</span> +<span id="L7" class="LineNr"> 7 </span><span class="muComment">#</span> +<span id="L8" class="LineNr"> 8 </span><span class="muComment"># Expected output: a spline with 3 control points. Use `Tab` to switch cursor</span> +<span id="L9" class="LineNr"> 9 </span><span class="muComment"># between control points, and arrow keys to move the control point at the</span> +<span id="L10" class="LineNr"> 10 </span><span class="muComment"># cursor.</span> +<span id="L11" class="LineNr"> 11 </span> +<span id="L12" class="LineNr"> 12 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L12'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> +<span id="L13" class="LineNr"> 13 </span> <span class="PreProc">var</span> env-storage: <a href='ex11.mu.html#L23'>environment</a> +<span id="L14" class="LineNr"> 14 </span> <span class="PreProc">var</span> env/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Special"><-</span> address env-storage +<span id="L15" class="LineNr"> 15 </span> <a href='ex11.mu.html#L231'>initialize-environment</a> env, <span class="Constant">0x200</span> <span class="Constant">0x20</span>, <span class="Constant">0x180</span> <span class="Constant">0x90</span>, <span class="Constant">0x180</span> <span class="Constant">0x160</span> +<span id="L16" class="LineNr"> 16 </span> <span class="Delimiter">{</span> +<span id="L17" class="LineNr"> 17 </span> <a href='ex11.mu.html#L35'>render</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, env +<span id="L18" class="LineNr"> 18 </span> <a href='ex11.mu.html#L99'>edit</a> keyboard, env +<span id="L19" class="LineNr"> 19 </span> <span class="PreProc">loop</span> +<span id="L20" class="LineNr"> 20 </span> <span class="Delimiter">}</span> +<span id="L21" class="LineNr"> 21 </span><span class="Delimiter">}</span> +<span id="L22" class="LineNr"> 22 </span> +<span id="L23" class="LineNr"> 23 </span><span class="PreProc">type</span> <a href='ex11.mu.html#L23'>environment</a> <span class="Delimiter">{</span> +<span id="L24" class="LineNr"> 24 </span> p0: (handle <a href='ex11.mu.html#L30'>point</a>) +<span id="L25" class="LineNr"> 25 </span> p1: (handle <a href='ex11.mu.html#L30'>point</a>) +<span id="L26" class="LineNr"> 26 </span> p2: (handle <a href='ex11.mu.html#L30'>point</a>) +<span id="L27" class="LineNr"> 27 </span> <a href='ex11.mu.html#L75'>cursor</a>: (handle <a href='ex11.mu.html#L30'>point</a>) <span class="muComment"># one of p0, p1 or p2</span> +<span id="L28" class="LineNr"> 28 </span><span class="Delimiter">}</span> +<span id="L29" class="LineNr"> 29 </span> +<span id="L30" class="LineNr"> 30 </span><span class="PreProc">type</span> <a href='ex11.mu.html#L30'>point</a> <span class="Delimiter">{</span> +<span id="L31" class="LineNr"> 31 </span> x: int +<span id="L32" class="LineNr"> 32 </span> y: int +<span id="L33" class="LineNr"> 33 </span><span class="Delimiter">}</span> +<span id="L34" class="LineNr"> 34 </span> +<span id="L35" class="LineNr"> 35 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L35'>render</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), _self: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Delimiter">{</span> +<span id="L36" class="LineNr"> 36 </span> <a href='../500fake-screen.mu.html#L307'>clear-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a> +<span id="L37" class="LineNr"> 37 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Special"><-</span> copy _self +<span id="L38" class="LineNr"> 38 </span> <span class="PreProc">var</span> tmp-ah/<span class="muRegEcx">ecx</span>: (addr handle <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> get self, p0 +<span id="L39" class="LineNr"> 39 </span> <span class="PreProc">var</span> tmp/eax: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *tmp-ah +<span id="L40" class="LineNr"> 40 </span> <span class="PreProc">var</span> p0/<span class="muRegEbx">ebx</span>: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> copy tmp +<span id="L41" class="LineNr"> 41 </span> tmp-ah <span class="Special"><-</span> get self, p1 +<span id="L42" class="LineNr"> 42 </span> tmp <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *tmp-ah +<span id="L43" class="LineNr"> 43 </span> <span class="PreProc">var</span> p1/<span class="muRegEdx">edx</span>: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> copy tmp +<span id="L44" class="LineNr"> 44 </span> tmp-ah <span class="Special"><-</span> get self, p2 +<span id="L45" class="LineNr"> 45 </span> tmp <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *tmp-ah +<span id="L46" class="LineNr"> 46 </span> <span class="PreProc">var</span> p2/<span class="muRegEcx">ecx</span>: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> copy tmp +<span id="L47" class="LineNr"> 47 </span> <span class="muComment"># control lines</span> +<span id="L48" class="LineNr"> 48 </span> <a href='ex11.mu.html#L214'>line</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, p0, p1, <span class="Constant">7</span>/color +<span id="L49" class="LineNr"> 49 </span> <a href='ex11.mu.html#L214'>line</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, p1, p2, <span class="Constant">7</span>/color +<span id="L50" class="LineNr"> 50 </span> <span class="muComment"># curve above control lines</span> +<span id="L51" class="LineNr"> 51 </span> <a href='ex11.mu.html#L62'>bezier</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, p0, p1, p2, <span class="Constant">0xc</span>/color +<span id="L52" class="LineNr"> 52 </span> <span class="muComment"># points above curve</span> +<span id="L53" class="LineNr"> 53 </span> <a href='ex11.mu.html#L224'>disc</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, p0, <span class="Constant">3</span>/radius, <span class="Constant">7</span>/color <span class="Constant">0xf</span>/border +<span id="L54" class="LineNr"> 54 </span> <a href='ex11.mu.html#L224'>disc</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, p1, <span class="Constant">3</span>/radius, <span class="Constant">7</span>/color <span class="Constant">0xf</span>/border +<span id="L55" class="LineNr"> 55 </span> <a href='ex11.mu.html#L224'>disc</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, p2, <span class="Constant">3</span>/radius, <span class="Constant">7</span>/color <span class="Constant">0xf</span>/border +<span id="L56" class="LineNr"> 56 </span> <span class="muComment"># cursor last of all</span> +<span id="L57" class="LineNr"> 57 </span> <span class="PreProc">var</span> cursor-ah/eax: (addr handle <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> get self, <a href='ex11.mu.html#L75'>cursor</a> +<span id="L58" class="LineNr"> 58 </span> <span class="PreProc">var</span> <a href='ex11.mu.html#L75'>cursor</a>/eax: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *cursor-ah +<span id="L59" class="LineNr"> 59 </span> <a href='ex11.mu.html#L75'>cursor</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <a href='ex11.mu.html#L75'>cursor</a>, <span class="Constant">0xa</span>/side, <span class="Constant">3</span>/color +<span id="L60" class="LineNr"> 60 </span><span class="Delimiter">}</span> +<span id="L61" class="LineNr"> 61 </span> +<span id="L62" class="LineNr"> 62 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L62'>bezier</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), _p0: (addr <a href='ex11.mu.html#L30'>point</a>), _p1: (addr <a href='ex11.mu.html#L30'>point</a>), _p2: (addr <a href='ex11.mu.html#L30'>point</a>), color: int <span class="Delimiter">{</span> +<span id="L63" class="LineNr"> 63 </span> <span class="PreProc">var</span> p0/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> copy _p0 +<span id="L64" class="LineNr"> 64 </span> <span class="PreProc">var</span> x0/<span class="muRegEcx">ecx</span>: (addr int) <span class="Special"><-</span> get p0, x +<span id="L65" class="LineNr"> 65 </span> <span class="PreProc">var</span> y0/<span class="muRegEdx">edx</span>: (addr int) <span class="Special"><-</span> get p0, y +<span id="L66" class="LineNr"> 66 </span> <span class="PreProc">var</span> p1/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> copy _p1 +<span id="L67" class="LineNr"> 67 </span> <span class="PreProc">var</span> x1/<span class="muRegEbx">ebx</span>: (addr int) <span class="Special"><-</span> get p1, x +<span id="L68" class="LineNr"> 68 </span> <span class="PreProc">var</span> y1/eax: (addr int) <span class="Special"><-</span> get p1, y +<span id="L69" class="LineNr"> 69 </span> <span class="PreProc">var</span> p2/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> copy _p2 +<span id="L70" class="LineNr"> 70 </span> <span class="PreProc">var</span> x2/<span class="muRegEdi">edi</span>: (addr int) <span class="Special"><-</span> get p2, x +<span id="L71" class="LineNr"> 71 </span> <span class="PreProc">var</span> y2/<span class="muRegEsi">esi</span>: (addr int) <span class="Special"><-</span> get p2, y +<span id="L72" class="LineNr"> 72 </span> <a href='../509bezier.mu.html#L14'>draw-monotonic-bezier</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, *x0 *y0, *x1 *y1, *x2 *y2, color +<span id="L73" class="LineNr"> 73 </span><span class="Delimiter">}</span> +<span id="L74" class="LineNr"> 74 </span> +<span id="L75" class="LineNr"> 75 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L75'>cursor</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), _p: (addr <a href='ex11.mu.html#L30'>point</a>), side: int, color: int <span class="Delimiter">{</span> +<span id="L76" class="LineNr"> 76 </span> <span class="PreProc">var</span> half-side/eax: int <span class="Special"><-</span> copy side +<span id="L77" class="LineNr"> 77 </span> half-side <span class="Special"><-</span> shift-right <span class="Constant">1</span> +<span id="L78" class="LineNr"> 78 </span> <span class="PreProc">var</span> p/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> copy _p +<span id="L79" class="LineNr"> 79 </span> <span class="PreProc">var</span> x-a/<span class="muRegEcx">ecx</span>: (addr int) <span class="Special"><-</span> get p, x +<span id="L80" class="LineNr"> 80 </span> <span class="PreProc">var</span> left-x/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy *x-a +<span id="L81" class="LineNr"> 81 </span> left-x <span class="Special"><-</span> subtract half-side +<span id="L82" class="LineNr"> 82 </span> <span class="PreProc">var</span> y-a/<span class="muRegEdx">edx</span>: (addr int) <span class="Special"><-</span> get p, y +<span id="L83" class="LineNr"> 83 </span> <span class="PreProc">var</span> top-y/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy *y-a +<span id="L84" class="LineNr"> 84 </span> top-y <span class="Special"><-</span> subtract half-side +<span id="L85" class="LineNr"> 85 </span> <span class="PreProc">var</span> max/eax: int <span class="Special"><-</span> copy left-x +<span id="L86" class="LineNr"> 86 </span> max <span class="Special"><-</span> add side +<span id="L87" class="LineNr"> 87 </span> <a href='../507line.mu.html#L64'>draw-horizontal-line</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, top-y, left-x, max, color +<span id="L88" class="LineNr"> 88 </span> max <span class="Special"><-</span> copy top-y +<span id="L89" class="LineNr"> 89 </span> max <span class="Special"><-</span> add side +<span id="L90" class="LineNr"> 90 </span> <a href='../507line.mu.html#L75'>draw-vertical-line</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, left-x, top-y, max, color +<span id="L91" class="LineNr"> 91 </span> <span class="PreProc">var</span> right-x/<span class="muRegEbx">ebx</span>: int <span class="Special"><-</span> copy left-x +<span id="L92" class="LineNr"> 92 </span> right-x <span class="Special"><-</span> add side +<span id="L93" class="LineNr"> 93 </span> <a href='../507line.mu.html#L75'>draw-vertical-line</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, right-x, top-y, max, color +<span id="L94" class="LineNr"> 94 </span> <span class="PreProc">var</span> bottom-y/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy top-y +<span id="L95" class="LineNr"> 95 </span> bottom-y <span class="Special"><-</span> add side +<span id="L96" class="LineNr"> 96 </span> <a href='../507line.mu.html#L64'>draw-horizontal-line</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, bottom-y, left-x, right-x, color +<span id="L97" class="LineNr"> 97 </span><span class="Delimiter">}</span> +<span id="L98" class="LineNr"> 98 </span> +<span id="L99" class="LineNr"> 99 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L99'>edit</a></span> keyboard: (addr keyboard), _self: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Delimiter">{</span> +<span id="L100" class="LineNr">100 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Special"><-</span> copy _self +<span id="L101" class="LineNr">101 </span> <span class="PreProc">var</span> key/eax: byte <span class="Special"><-</span> <a href='../102keyboard.subx.html#L21'>read-key</a> keyboard +<span id="L102" class="LineNr">102 </span> compare key, <span class="Constant">0</span> +<span id="L103" class="LineNr">103 </span> <span class="PreProc">loop-if-=</span> +<span id="L104" class="LineNr">104 </span> <span class="Delimiter">{</span> +<span id="L105" class="LineNr">105 </span> compare key, <span class="Constant">9</span>/tab +<span id="L106" class="LineNr">106 </span> <span class="PreProc">break-if-!=</span> +<span id="L107" class="LineNr">107 </span> <a href='ex11.mu.html#L136'>toggle-cursor</a> self +<span id="L108" class="LineNr">108 </span> <span class="PreProc">return</span> +<span id="L109" class="LineNr">109 </span> <span class="Delimiter">}</span> +<span id="L110" class="LineNr">110 </span> <span class="Delimiter">{</span> +<span id="L111" class="LineNr">111 </span> compare key, <span class="Constant">0x80</span>/left-arrow +<span id="L112" class="LineNr">112 </span> <span class="PreProc">break-if-!=</span> +<span id="L113" class="LineNr">113 </span> <a href='ex11.mu.html#L166'>cursor-left</a> self +<span id="L114" class="LineNr">114 </span> <span class="PreProc">return</span> +<span id="L115" class="LineNr">115 </span> <span class="Delimiter">}</span> +<span id="L116" class="LineNr">116 </span> <span class="Delimiter">{</span> +<span id="L117" class="LineNr">117 </span> compare key, <span class="Constant">0x83</span>/right-arrow +<span id="L118" class="LineNr">118 </span> <span class="PreProc">break-if-!=</span> +<span id="L119" class="LineNr">119 </span> <a href='ex11.mu.html#L178'>cursor-right</a> self +<span id="L120" class="LineNr">120 </span> <span class="PreProc">return</span> +<span id="L121" class="LineNr">121 </span> <span class="Delimiter">}</span> +<span id="L122" class="LineNr">122 </span> <span class="Delimiter">{</span> +<span id="L123" class="LineNr">123 </span> compare key, <span class="Constant">0x81</span>/down-arrow +<span id="L124" class="LineNr">124 </span> <span class="PreProc">break-if-!=</span> +<span id="L125" class="LineNr">125 </span> <a href='ex11.mu.html#L202'>cursor-down</a> self +<span id="L126" class="LineNr">126 </span> <span class="PreProc">return</span> +<span id="L127" class="LineNr">127 </span> <span class="Delimiter">}</span> +<span id="L128" class="LineNr">128 </span> <span class="Delimiter">{</span> +<span id="L129" class="LineNr">129 </span> compare key, <span class="Constant">0x82</span>/up-arrow +<span id="L130" class="LineNr">130 </span> <span class="PreProc">break-if-!=</span> +<span id="L131" class="LineNr">131 </span> <a href='ex11.mu.html#L190'>cursor-up</a> self +<span id="L132" class="LineNr">132 </span> <span class="PreProc">return</span> +<span id="L133" class="LineNr">133 </span> <span class="Delimiter">}</span> +<span id="L134" class="LineNr">134 </span><span class="Delimiter">}</span> +<span id="L135" class="LineNr">135 </span> +<span id="L136" class="LineNr">136 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L136'>toggle-cursor</a></span> _self: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Delimiter">{</span> +<span id="L137" class="LineNr">137 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Special"><-</span> copy _self +<span id="L138" class="LineNr">138 </span> <span class="PreProc">var</span> cursor-ah/<span class="muRegEdi">edi</span>: (addr handle <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> get self, <a href='ex11.mu.html#L75'>cursor</a> +<span id="L139" class="LineNr">139 </span> <span class="PreProc">var</span> p0-ah/<span class="muRegEcx">ecx</span>: (addr handle <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> get self, p0 +<span id="L140" class="LineNr">140 </span> <span class="PreProc">var</span> p1-ah/<span class="muRegEdx">edx</span>: (addr handle <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> get self, p1 +<span id="L141" class="LineNr">141 </span> <span class="PreProc">var</span> p2-ah/<span class="muRegEbx">ebx</span>: (addr handle <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> get self, p2 +<span id="L142" class="LineNr">142 </span> <span class="Delimiter">{</span> +<span id="L143" class="LineNr">143 </span> <span class="PreProc">var</span> p0?/eax: boolean <span class="Special"><-</span> <a href='../120allocate.subx.html#L460'>handle-equal?</a> *p0-ah, *cursor-ah +<span id="L144" class="LineNr">144 </span> compare p0?, <span class="Constant">0</span>/false +<span id="L145" class="LineNr">145 </span> <span class="PreProc">break-if-=</span> +<span id="L146" class="LineNr">146 </span> copy-object p1-ah, cursor-ah +<span id="L147" class="LineNr">147 </span> <span class="PreProc">return</span> +<span id="L148" class="LineNr">148 </span> <span class="Delimiter">}</span> +<span id="L149" class="LineNr">149 </span> <span class="Delimiter">{</span> +<span id="L150" class="LineNr">150 </span> <span class="PreProc">var</span> p1?/eax: boolean <span class="Special"><-</span> <a href='../120allocate.subx.html#L460'>handle-equal?</a> *p1-ah, *cursor-ah +<span id="L151" class="LineNr">151 </span> compare p1?, <span class="Constant">0</span>/false +<span id="L152" class="LineNr">152 </span> <span class="PreProc">break-if-=</span> +<span id="L153" class="LineNr">153 </span> copy-object p2-ah, cursor-ah +<span id="L154" class="LineNr">154 </span> <span class="PreProc">return</span> +<span id="L155" class="LineNr">155 </span> <span class="Delimiter">}</span> +<span id="L156" class="LineNr">156 </span> <span class="Delimiter">{</span> +<span id="L157" class="LineNr">157 </span> <span class="PreProc">var</span> p2?/eax: boolean <span class="Special"><-</span> <a href='../120allocate.subx.html#L460'>handle-equal?</a> *p2-ah, *cursor-ah +<span id="L158" class="LineNr">158 </span> compare p2?, <span class="Constant">0</span>/false +<span id="L159" class="LineNr">159 </span> <span class="PreProc">break-if-=</span> +<span id="L160" class="LineNr">160 </span> copy-object p0-ah, cursor-ah +<span id="L161" class="LineNr">161 </span> <span class="PreProc">return</span> +<span id="L162" class="LineNr">162 </span> <span class="Delimiter">}</span> +<span id="L163" class="LineNr">163 </span> <a href='../317abort.subx.html#L5'>abort</a> <span class="Constant">"lost cursor"</span> +<span id="L164" class="LineNr">164 </span><span class="Delimiter">}</span> +<span id="L165" class="LineNr">165 </span> +<span id="L166" class="LineNr">166 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L166'>cursor-left</a></span> _self: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Delimiter">{</span> +<span id="L167" class="LineNr">167 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Special"><-</span> copy _self +<span id="L168" class="LineNr">168 </span> <span class="PreProc">var</span> cursor-ah/<span class="muRegEsi">esi</span>: (addr handle <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> get self, <a href='ex11.mu.html#L75'>cursor</a> +<span id="L169" class="LineNr">169 </span> <span class="PreProc">var</span> <a href='ex11.mu.html#L75'>cursor</a>/eax: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *cursor-ah +<span id="L170" class="LineNr">170 </span> <span class="PreProc">var</span> cursor-x/eax: (addr int) <span class="Special"><-</span> get <a href='ex11.mu.html#L75'>cursor</a>, x +<span id="L171" class="LineNr">171 </span> compare *cursor-x, <span class="Constant">0x20</span> +<span id="L172" class="LineNr">172 </span> <span class="Delimiter">{</span> +<span id="L173" class="LineNr">173 </span> <span class="PreProc">break-if-<</span> +<span id="L174" class="LineNr">174 </span> subtract-from *cursor-x, <span class="Constant">0x20</span> +<span id="L175" class="LineNr">175 </span> <span class="Delimiter">}</span> +<span id="L176" class="LineNr">176 </span><span class="Delimiter">}</span> +<span id="L177" class="LineNr">177 </span> +<span id="L178" class="LineNr">178 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L178'>cursor-right</a></span> _self: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Delimiter">{</span> +<span id="L179" class="LineNr">179 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Special"><-</span> copy _self +<span id="L180" class="LineNr">180 </span> <span class="PreProc">var</span> cursor-ah/<span class="muRegEsi">esi</span>: (addr handle <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> get self, <a href='ex11.mu.html#L75'>cursor</a> +<span id="L181" class="LineNr">181 </span> <span class="PreProc">var</span> <a href='ex11.mu.html#L75'>cursor</a>/eax: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *cursor-ah +<span id="L182" class="LineNr">182 </span> <span class="PreProc">var</span> cursor-x/eax: (addr int) <span class="Special"><-</span> get <a href='ex11.mu.html#L75'>cursor</a>, x +<span id="L183" class="LineNr">183 </span> compare *cursor-x, <span class="Constant">0x3f0</span> +<span id="L184" class="LineNr">184 </span> <span class="Delimiter">{</span> +<span id="L185" class="LineNr">185 </span> <span class="PreProc">break-if-></span> +<span id="L186" class="LineNr">186 </span> add-to *cursor-x, <span class="Constant">0x20</span> +<span id="L187" class="LineNr">187 </span> <span class="Delimiter">}</span> +<span id="L188" class="LineNr">188 </span><span class="Delimiter">}</span> +<span id="L189" class="LineNr">189 </span> +<span id="L190" class="LineNr">190 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L190'>cursor-up</a></span> _self: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Delimiter">{</span> +<span id="L191" class="LineNr">191 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Special"><-</span> copy _self +<span id="L192" class="LineNr">192 </span> <span class="PreProc">var</span> cursor-ah/<span class="muRegEsi">esi</span>: (addr handle <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> get self, <a href='ex11.mu.html#L75'>cursor</a> +<span id="L193" class="LineNr">193 </span> <span class="PreProc">var</span> <a href='ex11.mu.html#L75'>cursor</a>/eax: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *cursor-ah +<span id="L194" class="LineNr">194 </span> <span class="PreProc">var</span> cursor-y/eax: (addr int) <span class="Special"><-</span> get <a href='ex11.mu.html#L75'>cursor</a>, y +<span id="L195" class="LineNr">195 </span> compare *cursor-y, <span class="Constant">0x20</span> +<span id="L196" class="LineNr">196 </span> <span class="Delimiter">{</span> +<span id="L197" class="LineNr">197 </span> <span class="PreProc">break-if-<</span> +<span id="L198" class="LineNr">198 </span> subtract-from *cursor-y, <span class="Constant">0x20</span> +<span id="L199" class="LineNr">199 </span> <span class="Delimiter">}</span> +<span id="L200" class="LineNr">200 </span><span class="Delimiter">}</span> +<span id="L201" class="LineNr">201 </span> +<span id="L202" class="LineNr">202 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L202'>cursor-down</a></span> _self: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Delimiter">{</span> +<span id="L203" class="LineNr">203 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Special"><-</span> copy _self +<span id="L204" class="LineNr">204 </span> <span class="PreProc">var</span> cursor-ah/<span class="muRegEsi">esi</span>: (addr handle <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> get self, <a href='ex11.mu.html#L75'>cursor</a> +<span id="L205" class="LineNr">205 </span> <span class="PreProc">var</span> <a href='ex11.mu.html#L75'>cursor</a>/eax: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *cursor-ah +<span id="L206" class="LineNr">206 </span> <span class="PreProc">var</span> cursor-y/eax: (addr int) <span class="Special"><-</span> get <a href='ex11.mu.html#L75'>cursor</a>, y +<span id="L207" class="LineNr">207 </span> compare *cursor-y, <span class="Constant">0x2f0</span> +<span id="L208" class="LineNr">208 </span> <span class="Delimiter">{</span> +<span id="L209" class="LineNr">209 </span> <span class="PreProc">break-if-></span> +<span id="L210" class="LineNr">210 </span> add-to *cursor-y, <span class="Constant">0x20</span> +<span id="L211" class="LineNr">211 </span> <span class="Delimiter">}</span> +<span id="L212" class="LineNr">212 </span><span class="Delimiter">}</span> +<span id="L213" class="LineNr">213 </span> +<span id="L214" class="LineNr">214 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L214'>line</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), _p0: (addr <a href='ex11.mu.html#L30'>point</a>), _p1: (addr <a href='ex11.mu.html#L30'>point</a>), color: int <span class="Delimiter">{</span> +<span id="L215" class="LineNr">215 </span> <span class="PreProc">var</span> p0/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> copy _p0 +<span id="L216" class="LineNr">216 </span> <span class="PreProc">var</span> x0/<span class="muRegEcx">ecx</span>: (addr int) <span class="Special"><-</span> get p0, x +<span id="L217" class="LineNr">217 </span> <span class="PreProc">var</span> y0/<span class="muRegEdx">edx</span>: (addr int) <span class="Special"><-</span> get p0, y +<span id="L218" class="LineNr">218 </span> <span class="PreProc">var</span> p1/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> copy _p1 +<span id="L219" class="LineNr">219 </span> <span class="PreProc">var</span> x1/<span class="muRegEbx">ebx</span>: (addr int) <span class="Special"><-</span> get p1, x +<span id="L220" class="LineNr">220 </span> <span class="PreProc">var</span> y1/eax: (addr int) <span class="Special"><-</span> get p1, y +<span id="L221" class="LineNr">221 </span> <a href='../507line.mu.html#L1'>draw-line</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, *x0 *y0, *x1 *y1, color +<span id="L222" class="LineNr">222 </span><span class="Delimiter">}</span> +<span id="L223" class="LineNr">223 </span> +<span id="L224" class="LineNr">224 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L224'>disc</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), _p: (addr <a href='ex11.mu.html#L30'>point</a>), radius: int, color: int, border-color: int <span class="Delimiter">{</span> +<span id="L225" class="LineNr">225 </span> <span class="PreProc">var</span> p/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> copy _p +<span id="L226" class="LineNr">226 </span> <span class="PreProc">var</span> x/<span class="muRegEcx">ecx</span>: (addr int) <span class="Special"><-</span> get p, x +<span id="L227" class="LineNr">227 </span> <span class="PreProc">var</span> y/<span class="muRegEdx">edx</span>: (addr int) <span class="Special"><-</span> get p, y +<span id="L228" class="LineNr">228 </span> <a href='../508circle.mu.html#L80'>draw-disc</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, *x *y, radius, color, border-color +<span id="L229" class="LineNr">229 </span><span class="Delimiter">}</span> +<span id="L230" class="LineNr">230 </span> +<span id="L231" class="LineNr">231 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L231'>initialize-environment</a></span> _self: (addr <a href='ex11.mu.html#L23'>environment</a>), x0: int, y0: int, x1: int, y1: int, x2: int, y2: int <span class="Delimiter">{</span> +<span id="L232" class="LineNr">232 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L23'>environment</a>) <span class="Special"><-</span> copy _self +<span id="L233" class="LineNr">233 </span> <span class="PreProc">var</span> p0-ah/eax: (addr handle <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> get self, p0 +<span id="L234" class="LineNr">234 </span> <a href='../120allocate.subx.html#L43'>allocate</a> p0-ah +<span id="L235" class="LineNr">235 </span> <span class="PreProc">var</span> p0/eax: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *p0-ah +<span id="L236" class="LineNr">236 </span> <a href='ex11.mu.html#L251'>initialize-point</a> p0, x0 y0 +<span id="L237" class="LineNr">237 </span> <span class="PreProc">var</span> p1-ah/eax: (addr handle <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> get self, p1 +<span id="L238" class="LineNr">238 </span> <a href='../120allocate.subx.html#L43'>allocate</a> p1-ah +<span id="L239" class="LineNr">239 </span> <span class="PreProc">var</span> p1/eax: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *p1-ah +<span id="L240" class="LineNr">240 </span> <a href='ex11.mu.html#L251'>initialize-point</a> p1, x1 y1 +<span id="L241" class="LineNr">241 </span> <span class="PreProc">var</span> p2-ah/eax: (addr handle <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> get self, p2 +<span id="L242" class="LineNr">242 </span> <a href='../120allocate.subx.html#L43'>allocate</a> p2-ah +<span id="L243" class="LineNr">243 </span> <span class="PreProc">var</span> p2/eax: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *p2-ah +<span id="L244" class="LineNr">244 </span> <a href='ex11.mu.html#L251'>initialize-point</a> p2, x2 y2 +<span id="L245" class="LineNr">245 </span> <span class="muComment"># cursor initially at p0</span> +<span id="L246" class="LineNr">246 </span> <span class="PreProc">var</span> cursor-ah/<span class="muRegEdi">edi</span>: (addr handle <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> get self, <a href='ex11.mu.html#L75'>cursor</a> +<span id="L247" class="LineNr">247 </span> <span class="PreProc">var</span> src-ah/<span class="muRegEsi">esi</span>: (addr handle <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> get self, p0 +<span id="L248" class="LineNr">248 </span> copy-object src-ah, cursor-ah +<span id="L249" class="LineNr">249 </span><span class="Delimiter">}</span> +<span id="L250" class="LineNr">250 </span> +<span id="L251" class="LineNr">251 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex11.mu.html#L251'>initialize-point</a></span> _p: (addr <a href='ex11.mu.html#L30'>point</a>), x: int, y: int <span class="Delimiter">{</span> +<span id="L252" class="LineNr">252 </span> <span class="PreProc">var</span> p/<span class="muRegEsi">esi</span>: (addr <a href='ex11.mu.html#L30'>point</a>) <span class="Special"><-</span> copy _p +<span id="L253" class="LineNr">253 </span> <span class="PreProc">var</span> dest/eax: (addr int) <span class="Special"><-</span> get p, x +<span id="L254" class="LineNr">254 </span> <span class="PreProc">var</span> src/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy x +<span id="L255" class="LineNr">255 </span> copy-to *dest, src +<span id="L256" class="LineNr">256 </span> dest <span class="Special"><-</span> get p, y +<span id="L257" class="LineNr">257 </span> src <span class="Special"><-</span> copy y +<span id="L258" class="LineNr">258 </span> copy-to *dest, src +<span id="L259" class="LineNr">259 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/apps/ex12.mu.html b/html/apps/ex12.mu.html index ccaaa9d9..acd12fba 100644 --- a/html/apps/ex12.mu.html +++ b/html/apps/ex12.mu.html @@ -64,28 +64,26 @@ if ('onhashchange' in window) { <span id="L4" class="LineNr"> 4 </span><span class="muComment"># ./translate apps/ex12.mu # emits code.img</span> <span id="L5" class="LineNr"> 5 </span><span class="muComment"># To run:</span> <span id="L6" class="LineNr"> 6 </span><span class="muComment"># qemu-system-i386 code.img</span> -<span id="L7" class="LineNr"> 7 </span><span class="muComment"># Or:</span> -<span id="L8" class="LineNr"> 8 </span><span class="muComment"># bochs -f bochsrc # bochsrc loads code.img</span> -<span id="L9" class="LineNr"> 9 </span><span class="muComment">#</span> -<span id="L10" class="LineNr">10 </span><span class="muComment"># Expected output: text with slowly updating colors</span> -<span id="L11" class="LineNr">11 </span> -<span id="L12" class="LineNr">12 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex12.mu.html#L12'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> -<span id="L13" class="LineNr">13 </span> <span class="PreProc">var</span> fg/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L14" class="LineNr">14 </span> <span class="PreProc">var</span> prev-timer-counter/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L15" class="LineNr">15 </span> <span class="Delimiter">{</span> -<span id="L16" class="LineNr">16 </span> <span class="PreProc">var</span> dummy/eax: int <span class="Special"><-</span> <a href='../501draw-text.mu.html#L100'>draw-text-rightward</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"hello from baremetal Mu!"</span>, <span class="Constant">0x10</span>/x, <span class="Constant">0x400</span>/xmax, <span class="Constant">0x10</span>/y, fg, <span class="Constant">0</span>/bg -<span id="L17" class="LineNr">17 </span> <span class="muComment"># wait for timer to bump</span> -<span id="L18" class="LineNr">18 </span> <span class="Delimiter">{</span> -<span id="L19" class="LineNr">19 </span> <span class="PreProc">var</span> curr-timer-counter/eax: int <span class="Special"><-</span> <a href='../319timer.subx.html#L3'>timer-counter</a> -<span id="L20" class="LineNr">20 </span> compare curr-timer-counter, prev-timer-counter -<span id="L21" class="LineNr">21 </span> <span class="PreProc">loop-if-=</span> -<span id="L22" class="LineNr">22 </span> prev-timer-counter <span class="Special"><-</span> copy curr-timer-counter -<span id="L23" class="LineNr">23 </span> <span class="Delimiter">}</span> -<span id="L24" class="LineNr">24 </span> <span class="muComment"># switch color</span> -<span id="L25" class="LineNr">25 </span> fg <span class="Special"><-</span> increment -<span id="L26" class="LineNr">26 </span> <span class="PreProc">loop</span> -<span id="L27" class="LineNr">27 </span> <span class="Delimiter">}</span> -<span id="L28" class="LineNr">28 </span><span class="Delimiter">}</span> +<span id="L7" class="LineNr"> 7 </span><span class="muComment">#</span> +<span id="L8" class="LineNr"> 8 </span><span class="muComment"># Expected output: text with slowly updating colors</span> +<span id="L9" class="LineNr"> 9 </span> +<span id="L10" class="LineNr">10 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex12.mu.html#L10'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> +<span id="L11" class="LineNr">11 </span> <span class="PreProc">var</span> fg/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L12" class="LineNr">12 </span> <span class="PreProc">var</span> prev-timer-counter/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L13" class="LineNr">13 </span> <span class="Delimiter">{</span> +<span id="L14" class="LineNr">14 </span> <span class="PreProc">var</span> dummy/eax: int <span class="Special"><-</span> <a href='../501draw-text.mu.html#L106'>draw-text-rightward</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"hello from baremetal Mu!"</span>, <span class="Constant">0x10</span>/x, <span class="Constant">0x400</span>/xmax, <span class="Constant">0x10</span>/y, fg, <span class="Constant">0</span>/bg +<span id="L15" class="LineNr">15 </span> <span class="muComment"># wait for timer to bump</span> +<span id="L16" class="LineNr">16 </span> <span class="Delimiter">{</span> +<span id="L17" class="LineNr">17 </span> <span class="PreProc">var</span> curr-timer-counter/eax: int <span class="Special"><-</span> <a href='../319timer.subx.html#L3'>timer-counter</a> +<span id="L18" class="LineNr">18 </span> compare curr-timer-counter, prev-timer-counter +<span id="L19" class="LineNr">19 </span> <span class="PreProc">loop-if-=</span> +<span id="L20" class="LineNr">20 </span> prev-timer-counter <span class="Special"><-</span> copy curr-timer-counter +<span id="L21" class="LineNr">21 </span> <span class="Delimiter">}</span> +<span id="L22" class="LineNr">22 </span> <span class="muComment"># switch color</span> +<span id="L23" class="LineNr">23 </span> fg <span class="Special"><-</span> increment +<span id="L24" class="LineNr">24 </span> <span class="PreProc">loop</span> +<span id="L25" class="LineNr">25 </span> <span class="Delimiter">}</span> +<span id="L26" class="LineNr">26 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/apps/ex14.mu.html b/html/apps/ex14.mu.html new file mode 100644 index 00000000..5af8970f --- /dev/null +++ b/html/apps/ex14.mu.html @@ -0,0 +1,90 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<title>Mu - apps/ex14.mu</title> +<meta name="Generator" content="Vim/8.1"> +<meta name="plugin-version" content="vim8.1_v1"> +<meta name="syntax" content="none"> +<meta name="settings" content="number_lines,use_css,pre_wrap,no_foldcolumn,expand_tabs,line_ids,prevent_copy="> +<meta name="colorscheme" content="minimal-light"> +<style type="text/css"> +<!-- +pre { white-space: pre-wrap; font-family: monospace; color: #000000; background-color: #ffffd7; } +body { font-size:12pt; font-family: monospace; color: #000000; background-color: #ffffd7; } +a { color:inherit; } +* { font-size:12pt; font-size: 1em; } +.PreProc { color: #c000c0; } +.Special { color: #ff6060; } +.LineNr { } +.muRegEsi { color: #005faf; } +.Constant { color: #008787; } +.Delimiter { color: #c000c0; } +.muFunction { color: #af5f00; text-decoration: underline; } +.muComment { color: #005faf; } +--> +</style> + +<script type='text/javascript'> +<!-- + +/* function to open any folds containing a jumped-to line before jumping to it */ +function JumpToLine() +{ + var lineNum; + lineNum = window.location.hash; + lineNum = lineNum.substr(1); /* strip off '#' */ + + if (lineNum.indexOf('L') == -1) { + lineNum = 'L'+lineNum; + } + var lineElem = document.getElementById(lineNum); + /* Always jump to new location even if the line was hidden inside a fold, or + * we corrected the raw number to a line ID. + */ + if (lineElem) { + lineElem.scrollIntoView(true); + } + return true; +} +if ('onhashchange' in window) { + window.onhashchange = JumpToLine; +} + +--> +</script> +</head> +<body onload='JumpToLine();'> +<a href='https://github.com/akkartik/mu/blob/main/apps/ex14.mu'>https://github.com/akkartik/mu/blob/main/apps/ex14.mu</a> +<pre id='vimCodeElement'> +<span id="L1" class="LineNr"> 1 </span><span class="muComment"># Unicode demo</span> +<span id="L2" class="LineNr"> 2 </span><span class="muComment">#</span> +<span id="L3" class="LineNr"> 3 </span><span class="muComment"># Mu can't read Unicode from keyboard yet, so we'll read from disk and print</span> +<span id="L4" class="LineNr"> 4 </span><span class="muComment"># to screen.</span> +<span id="L5" class="LineNr"> 5 </span><span class="muComment">#</span> +<span id="L6" class="LineNr"> 6 </span><span class="muComment"># Steps for trying it out:</span> +<span id="L7" class="LineNr"> 7 </span><span class="muComment"># 1. Translate this example into a disk image code.img.</span> +<span id="L8" class="LineNr"> 8 </span><span class="muComment"># ./translate apps/ex14.mu</span> +<span id="L9" class="LineNr"> 9 </span><span class="muComment"># 2. Build a second disk image data.img containing some Unicode text.</span> +<span id="L10" class="LineNr">10 </span><span class="muComment"># dd if=/dev/zero of=data.img count=20160</span> +<span id="L11" class="LineNr">11 </span><span class="muComment"># echo 'நட' |dd of=data.img conv=notrunc</span> +<span id="L12" class="LineNr">12 </span><span class="muComment"># 3. Run:</span> +<span id="L13" class="LineNr">13 </span><span class="muComment"># qemu-system-i386 -hda code.img -hdb data.img</span> +<span id="L14" class="LineNr">14 </span><span class="muComment">#</span> +<span id="L15" class="LineNr">15 </span><span class="muComment"># Expected output: 'நட' in green near the top-left corner of screen</span> +<span id="L16" class="LineNr">16 </span><span class="muComment">#</span> +<span id="L17" class="LineNr">17 </span><span class="muComment"># Limitations:</span> +<span id="L18" class="LineNr">18 </span><span class="muComment"># - Utf-8 is the one true encoding.</span> +<span id="L19" class="LineNr">19 </span><span class="muComment"># - No keyboard support yet.</span> +<span id="L20" class="LineNr">20 </span><span class="muComment"># - Just single-code-point graphemes so far. No combiner characters, etc.</span> +<span id="L21" class="LineNr">21 </span> +<span id="L22" class="LineNr">22 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex14.mu.html#L22'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> +<span id="L23" class="LineNr">23 </span> <span class="PreProc">var</span> text-storage: (stream byte <span class="Constant">0x200</span>) +<span id="L24" class="LineNr">24 </span> <span class="PreProc">var</span> text/<span class="muRegEsi">esi</span>: (addr stream byte) <span class="Special"><-</span> address text-storage +<span id="L25" class="LineNr">25 </span> <a href='../510disk.mu.html#L1'>load-sectors</a> data-disk, <span class="Constant">0</span>/lba, <span class="Constant">1</span>/num-sectors, text +<span id="L26" class="LineNr">26 </span> <span class="PreProc">var</span> dummy/eax: int <span class="Special"><-</span> <a href='../501draw-text.mu.html#L117'>draw-stream-rightward</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, text, <span class="Constant">0</span>/x <span class="Constant">0x80</span>/xmax <span class="Constant">0</span>/y, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg +<span id="L27" class="LineNr">27 </span><span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/apps/ex2.mu.html b/html/apps/ex2.mu.html index 01d24f23..c97b54fe 100644 --- a/html/apps/ex2.mu.html +++ b/html/apps/ex2.mu.html @@ -64,28 +64,26 @@ if ('onhashchange' in window) { <span id="L4" class="LineNr"> 4 </span><span class="muComment"># ./translate apps/ex2.mu # emits code.img</span> <span id="L5" class="LineNr"> 5 </span><span class="muComment"># To run:</span> <span id="L6" class="LineNr"> 6 </span><span class="muComment"># qemu-system-i386 code.img</span> -<span id="L7" class="LineNr"> 7 </span><span class="muComment"># Or:</span> -<span id="L8" class="LineNr"> 8 </span><span class="muComment"># bochs -f bochsrc # bochsrc loads code.img</span> -<span id="L9" class="LineNr"> 9 </span> -<span id="L10" class="LineNr">10 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex2.mu.html#L10'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> -<span id="L11" class="LineNr">11 </span> <span class="PreProc">var</span> y/eax: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L12" class="LineNr">12 </span> <span class="Delimiter">{</span> -<span id="L13" class="LineNr">13 </span> compare y, <span class="Constant">0x300</span>/screen-height=<span class="Constant">768</span> -<span id="L14" class="LineNr">14 </span> <span class="PreProc">break-if->=</span> -<span id="L15" class="LineNr">15 </span> <span class="PreProc">var</span> x/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L16" class="LineNr">16 </span> <span class="Delimiter">{</span> -<span id="L17" class="LineNr">17 </span> compare x, <span class="Constant">0x400</span>/screen-width=<span class="Constant">1024</span> -<span id="L18" class="LineNr">18 </span> <span class="PreProc">break-if->=</span> -<span id="L19" class="LineNr">19 </span> <span class="PreProc">var</span> color/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy x -<span id="L20" class="LineNr">20 </span> color <span class="Special"><-</span> and <span class="Constant">0xff</span> -<span id="L21" class="LineNr">21 </span> <a href='../500fake-screen.mu.html#L483'>pixel</a> <a href='../500fake-screen.mu.html#L14'>screen</a> x, y, color -<span id="L22" class="LineNr">22 </span> x <span class="Special"><-</span> increment -<span id="L23" class="LineNr">23 </span> <span class="PreProc">loop</span> -<span id="L24" class="LineNr">24 </span> <span class="Delimiter">}</span> -<span id="L25" class="LineNr">25 </span> y <span class="Special"><-</span> increment -<span id="L26" class="LineNr">26 </span> <span class="PreProc">loop</span> -<span id="L27" class="LineNr">27 </span> <span class="Delimiter">}</span> -<span id="L28" class="LineNr">28 </span><span class="Delimiter">}</span> +<span id="L7" class="LineNr"> 7 </span> +<span id="L8" class="LineNr"> 8 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex2.mu.html#L8'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> +<span id="L9" class="LineNr"> 9 </span> <span class="PreProc">var</span> y/eax: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L10" class="LineNr">10 </span> <span class="Delimiter">{</span> +<span id="L11" class="LineNr">11 </span> compare y, <span class="Constant">0x300</span>/screen-height=<span class="Constant">768</span> +<span id="L12" class="LineNr">12 </span> <span class="PreProc">break-if->=</span> +<span id="L13" class="LineNr">13 </span> <span class="PreProc">var</span> x/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L14" class="LineNr">14 </span> <span class="Delimiter">{</span> +<span id="L15" class="LineNr">15 </span> compare x, <span class="Constant">0x400</span>/screen-width=<span class="Constant">1024</span> +<span id="L16" class="LineNr">16 </span> <span class="PreProc">break-if->=</span> +<span id="L17" class="LineNr">17 </span> <span class="PreProc">var</span> color/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy x +<span id="L18" class="LineNr">18 </span> color <span class="Special"><-</span> and <span class="Constant">0xff</span> +<span id="L19" class="LineNr">19 </span> <a href='../500fake-screen.mu.html#L557'>pixel</a> <a href='../500fake-screen.mu.html#L14'>screen</a> x, y, color +<span id="L20" class="LineNr">20 </span> x <span class="Special"><-</span> increment +<span id="L21" class="LineNr">21 </span> <span class="PreProc">loop</span> +<span id="L22" class="LineNr">22 </span> <span class="Delimiter">}</span> +<span id="L23" class="LineNr">23 </span> y <span class="Special"><-</span> increment +<span id="L24" class="LineNr">24 </span> <span class="PreProc">loop</span> +<span id="L25" class="LineNr">25 </span> <span class="Delimiter">}</span> +<span id="L26" class="LineNr">26 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/apps/ex3.mu.html b/html/apps/ex3.mu.html index 033b09df..268bd3d9 100644 --- a/html/apps/ex3.mu.html +++ b/html/apps/ex3.mu.html @@ -65,30 +65,28 @@ if ('onhashchange' in window) { <span id="L5" class="LineNr"> 5 </span><span class="muComment"># ./translate apps/ex3.mu # emits code.img</span> <span id="L6" class="LineNr"> 6 </span><span class="muComment"># To run:</span> <span id="L7" class="LineNr"> 7 </span><span class="muComment"># qemu-system-i386 code.img</span> -<span id="L8" class="LineNr"> 8 </span><span class="muComment"># Or:</span> -<span id="L9" class="LineNr"> 9 </span><span class="muComment"># bochs -f bochsrc # bochsrc loads code.img</span> -<span id="L10" class="LineNr">10 </span><span class="muComment">#</span> -<span id="L11" class="LineNr">11 </span><span class="muComment"># Expected output: a new green pixel starting from the top left corner of the</span> -<span id="L12" class="LineNr">12 </span><span class="muComment"># screen every time you press a key (letter or digit)</span> -<span id="L13" class="LineNr">13 </span> -<span id="L14" class="LineNr">14 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex3.mu.html#L14'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> -<span id="L15" class="LineNr">15 </span> <span class="PreProc">var</span> x/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L16" class="LineNr">16 </span> <span class="PreProc">var</span> y/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L17" class="LineNr">17 </span> <span class="Delimiter">{</span> -<span id="L18" class="LineNr">18 </span> <span class="PreProc">var</span> key/eax: byte <span class="Special"><-</span> <a href='../102keyboard.subx.html#L21'>read-key</a> keyboard -<span id="L19" class="LineNr">19 </span> compare key, <span class="Constant">0</span> -<span id="L20" class="LineNr">20 </span> <span class="PreProc">loop-if-=</span> <span class="muComment"># busy wait</span> -<span id="L21" class="LineNr">21 </span> <a href='../101screen.subx.html#L8'>pixel-on-real-screen</a> x, y, <span class="Constant">0x31</span>/green -<span id="L22" class="LineNr">22 </span> x <span class="Special"><-</span> increment -<span id="L23" class="LineNr">23 </span> compare x, <span class="Constant">0x400</span>/screen-width=<span class="Constant">1024</span> -<span id="L24" class="LineNr">24 </span> <span class="Delimiter">{</span> -<span id="L25" class="LineNr">25 </span> <span class="PreProc">break-if-<</span> -<span id="L26" class="LineNr">26 </span> y <span class="Special"><-</span> increment -<span id="L27" class="LineNr">27 </span> x <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L28" class="LineNr">28 </span> <span class="Delimiter">}</span> -<span id="L29" class="LineNr">29 </span> <span class="PreProc">loop</span> -<span id="L30" class="LineNr">30 </span> <span class="Delimiter">}</span> -<span id="L31" class="LineNr">31 </span><span class="Delimiter">}</span> +<span id="L8" class="LineNr"> 8 </span><span class="muComment">#</span> +<span id="L9" class="LineNr"> 9 </span><span class="muComment"># Expected output: a new green pixel starting from the top left corner of the</span> +<span id="L10" class="LineNr">10 </span><span class="muComment"># screen every time you press a key (letter or digit)</span> +<span id="L11" class="LineNr">11 </span> +<span id="L12" class="LineNr">12 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex3.mu.html#L12'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> +<span id="L13" class="LineNr">13 </span> <span class="PreProc">var</span> x/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L14" class="LineNr">14 </span> <span class="PreProc">var</span> y/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L15" class="LineNr">15 </span> <span class="Delimiter">{</span> +<span id="L16" class="LineNr">16 </span> <span class="PreProc">var</span> key/eax: byte <span class="Special"><-</span> <a href='../102keyboard.subx.html#L21'>read-key</a> keyboard +<span id="L17" class="LineNr">17 </span> compare key, <span class="Constant">0</span> +<span id="L18" class="LineNr">18 </span> <span class="PreProc">loop-if-=</span> <span class="muComment"># busy wait</span> +<span id="L19" class="LineNr">19 </span> <a href='../101screen.subx.html#L8'>pixel-on-real-screen</a> x, y, <span class="Constant">0x31</span>/green +<span id="L20" class="LineNr">20 </span> x <span class="Special"><-</span> increment +<span id="L21" class="LineNr">21 </span> compare x, <span class="Constant">0x400</span>/screen-width=<span class="Constant">1024</span> +<span id="L22" class="LineNr">22 </span> <span class="Delimiter">{</span> +<span id="L23" class="LineNr">23 </span> <span class="PreProc">break-if-<</span> +<span id="L24" class="LineNr">24 </span> y <span class="Special"><-</span> increment +<span id="L25" class="LineNr">25 </span> x <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L26" class="LineNr">26 </span> <span class="Delimiter">}</span> +<span id="L27" class="LineNr">27 </span> <span class="PreProc">loop</span> +<span id="L28" class="LineNr">28 </span> <span class="Delimiter">}</span> +<span id="L29" class="LineNr">29 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/apps/ex4.mu.html b/html/apps/ex4.mu.html index 9113dde4..89fca96e 100644 --- a/html/apps/ex4.mu.html +++ b/html/apps/ex4.mu.html @@ -15,8 +15,10 @@ body { font-size:12pt; font-family: monospace; color: #000000; background-color: a { color:inherit; } * { font-size:12pt; font-size: 1em; } .PreProc { color: #c000c0; } +.Special { color: #ff6060; } .LineNr { } .Constant { color: #008787; } +.CommentedCode { color: #8a8a8a; } .Delimiter { color: #c000c0; } .muFunction { color: #af5f00; text-decoration: underline; } .muComment { color: #005faf; } @@ -61,13 +63,13 @@ if ('onhashchange' in window) { <span id="L4" class="LineNr"> 4 </span><span class="muComment"># ./translate apps/ex4.mu # emits code.img</span> <span id="L5" class="LineNr"> 5 </span><span class="muComment"># To run:</span> <span id="L6" class="LineNr"> 6 </span><span class="muComment"># qemu-system-i386 code.img</span> -<span id="L7" class="LineNr"> 7 </span><span class="muComment"># Or:</span> -<span id="L8" class="LineNr"> 8 </span><span class="muComment"># bochs -f bochsrc # bochsrc loads code.img</span> -<span id="L9" class="LineNr"> 9 </span><span class="muComment">#</span> -<span id="L10" class="LineNr">10 </span><span class="muComment"># Expected output: letter 'A' in green near the top-left corner of screen</span> -<span id="L11" class="LineNr">11 </span> -<span id="L12" class="LineNr">12 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex4.mu.html#L12'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> -<span id="L13" class="LineNr">13 </span> <a href='../500fake-screen.mu.html#L130'>draw-code-point</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x41</span>/A, <span class="Constant">2</span>/row, <span class="Constant">1</span>/col, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg +<span id="L7" class="LineNr"> 7 </span><span class="muComment">#</span> +<span id="L8" class="LineNr"> 8 </span><span class="muComment"># Expected output: letter 'A' in green near the top-left corner of screen</span> +<span id="L9" class="LineNr"> 9 </span> +<span id="L10" class="LineNr">10 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex4.mu.html#L10'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> +<span id="L11" class="LineNr">11 </span> <span class="PreProc">var</span> dummy/eax: int <span class="Special"><-</span> <a href='../500fake-screen.mu.html#L92'>draw-code-point</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x41</span>/A, <span class="Constant">2</span>/row, <span class="Constant">1</span>/col, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg +<span id="L12" class="LineNr">12 </span> <span class="muComment"># wide glyph</span> +<span id="L13" class="LineNr">13 </span><span class="CommentedCode">#? var dummy/eax: int <- draw-code-point screen, 0x1b/esc, 2/row, 1/col, 0xa/fg, 0/bg</span> <span id="L14" class="LineNr">14 </span><span class="Delimiter">}</span> </pre> </body> diff --git a/html/apps/ex5.mu.html b/html/apps/ex5.mu.html index 76d992cf..8e4fc8de 100644 --- a/html/apps/ex5.mu.html +++ b/html/apps/ex5.mu.html @@ -63,15 +63,13 @@ if ('onhashchange' in window) { <span id="L5" class="LineNr"> 5 </span><span class="muComment"># ./translate apps/ex5.mu # emits code.img</span> <span id="L6" class="LineNr"> 6 </span><span class="muComment"># To run:</span> <span id="L7" class="LineNr"> 7 </span><span class="muComment"># qemu-system-i386 code.img</span> -<span id="L8" class="LineNr"> 8 </span><span class="muComment"># Or:</span> -<span id="L9" class="LineNr"> 9 </span><span class="muComment"># bochs -f bochsrc # bochsrc loads code.img</span> -<span id="L10" class="LineNr">10 </span><span class="muComment">#</span> -<span id="L11" class="LineNr">11 </span><span class="muComment"># Expected output: text in green near the top-left corner of screen</span> -<span id="L12" class="LineNr">12 </span> -<span id="L13" class="LineNr">13 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex5.mu.html#L13'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> -<span id="L14" class="LineNr">14 </span> <span class="PreProc">var</span> dummy/eax: int <span class="Special"><-</span> <a href='../501draw-text.mu.html#L100'>draw-text-rightward</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"hello from baremetal Mu!"</span>, <span class="Constant">0x10</span>/x, <span class="Constant">0x400</span>/xmax, <span class="Constant">0x10</span>/y, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg -<span id="L15" class="LineNr">15 </span> dummy <span class="Special"><-</span> <a href='../501draw-text.mu.html#L100'>draw-text-rightward</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"you shouldn't see this"</span>, <span class="Constant">0x10</span>/x, <span class="Constant">0xa0</span>/xmax, <span class="Constant">0x30</span>/y, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg <span class="muComment"># xmax is too narrow</span> -<span id="L16" class="LineNr">16 </span><span class="Delimiter">}</span> +<span id="L8" class="LineNr"> 8 </span><span class="muComment">#</span> +<span id="L9" class="LineNr"> 9 </span><span class="muComment"># Expected output: text in green near the top-left corner of screen</span> +<span id="L10" class="LineNr">10 </span> +<span id="L11" class="LineNr">11 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex5.mu.html#L11'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> +<span id="L12" class="LineNr">12 </span> <span class="PreProc">var</span> dummy/eax: int <span class="Special"><-</span> <a href='../501draw-text.mu.html#L106'>draw-text-rightward</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"hello from baremetal Mu!"</span>, <span class="Constant">0x10</span>/x, <span class="Constant">0x400</span>/xmax, <span class="Constant">0x10</span>/y, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg +<span id="L13" class="LineNr">13 </span> dummy <span class="Special"><-</span> <a href='../501draw-text.mu.html#L106'>draw-text-rightward</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"you shouldn't see this"</span>, <span class="Constant">0x10</span>/x, <span class="Constant">0xa0</span>/xmax, <span class="Constant">0x30</span>/y, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg <span class="muComment"># xmax is too narrow</span> +<span id="L14" class="LineNr">14 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/apps/ex6.mu.html b/html/apps/ex6.mu.html index 3d9ae0a2..c0af2711 100644 --- a/html/apps/ex6.mu.html +++ b/html/apps/ex6.mu.html @@ -63,32 +63,30 @@ if ('onhashchange' in window) { <span id="L4" class="LineNr"> 4 </span><span class="muComment"># ./translate apps/ex6.mu # emits code.img</span> <span id="L5" class="LineNr"> 5 </span><span class="muComment"># To run:</span> <span id="L6" class="LineNr"> 6 </span><span class="muComment"># qemu-system-i386 code.img</span> -<span id="L7" class="LineNr"> 7 </span><span class="muComment"># Or:</span> -<span id="L8" class="LineNr"> 8 </span><span class="muComment"># bochs -f bochsrc # bochsrc loads code.img</span> -<span id="L9" class="LineNr"> 9 </span><span class="muComment">#</span> -<span id="L10" class="LineNr">10 </span><span class="muComment"># Expected output: a box and text that doesn't overflow it</span> -<span id="L11" class="LineNr">11 </span> -<span id="L12" class="LineNr">12 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex6.mu.html#L12'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> -<span id="L13" class="LineNr">13 </span> <span class="muComment"># drawing text within a bounding box</span> -<span id="L14" class="LineNr">14 </span> <a href='../503manhattan-line.mu.html#L1'>draw-box-on-real-screen</a> <span class="Constant">0xf</span>, <span class="Constant">0x1f</span>, <span class="Constant">0x79</span>, <span class="Constant">0x51</span>, <span class="Constant">0x4</span> -<span id="L15" class="LineNr">15 </span> <span class="PreProc">var</span> x/eax: int <span class="Special"><-</span> copy <span class="Constant">0x20</span> -<span id="L16" class="LineNr">16 </span> <span class="PreProc">var</span> y/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0x20</span> -<span id="L17" class="LineNr">17 </span> x, y <span class="Special"><-</span> <a href='../501draw-text.mu.html#L174'>draw-text-wrapping-right-then-down</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"hello "</span>, <span class="Constant">0x10</span>/xmin, <span class="Constant">0x20</span>/ymin, <span class="Constant">0x78</span>/xmax, <span class="Constant">0x50</span>/ymax, x, y, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg -<span id="L18" class="LineNr">18 </span> x, y <span class="Special"><-</span> <a href='../501draw-text.mu.html#L174'>draw-text-wrapping-right-then-down</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"from "</span>, <span class="Constant">0x10</span>/xmin, <span class="Constant">0x20</span>/ymin, <span class="Constant">0x78</span>/xmax, <span class="Constant">0x50</span>/ymax, x, y, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg -<span id="L19" class="LineNr">19 </span> x, y <span class="Special"><-</span> <a href='../501draw-text.mu.html#L174'>draw-text-wrapping-right-then-down</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"baremetal "</span>, <span class="Constant">0x10</span>/xmin, <span class="Constant">0x20</span>/ymin, <span class="Constant">0x78</span>/xmax, <span class="Constant">0x50</span>/ymax, x, y, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg -<span id="L20" class="LineNr">20 </span> x, y <span class="Special"><-</span> <a href='../501draw-text.mu.html#L174'>draw-text-wrapping-right-then-down</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"Mu!"</span>, <span class="Constant">0x10</span>/xmin, <span class="Constant">0x20</span>/ymin, <span class="Constant">0x78</span>/xmax, <span class="Constant">0x50</span>/ymax, x, y, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg -<span id="L21" class="LineNr">21 </span> -<span id="L22" class="LineNr">22 </span> <span class="muComment"># drawing at the cursor in multiple directions</span> -<span id="L23" class="LineNr">23 </span> <a href='../501draw-text.mu.html#L490'>draw-text-wrapping-down-then-right-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"abc"</span>, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg -<span id="L24" class="LineNr">24 </span> <a href='../501draw-text.mu.html#L276'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"def"</span>, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg -<span id="L25" class="LineNr">25 </span> -<span id="L26" class="LineNr">26 </span> <span class="muComment"># test drawing near the edge</span> -<span id="L27" class="LineNr">27 </span> x <span class="Special"><-</span> <a href='../501draw-text.mu.html#L100'>draw-text-rightward</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"R"</span>, <span class="Constant">0x7f</span>/x, <span class="Constant">0x80</span>/xmax=screen-width, <span class="Constant">0x18</span>/y, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg -<span id="L28" class="LineNr">28 </span> <a href='../501draw-text.mu.html#L276'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"wrapped from R"</span>, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg -<span id="L29" class="LineNr">29 </span> -<span id="L30" class="LineNr">30 </span> x <span class="Special"><-</span> <a href='../501draw-text.mu.html#L396'>draw-text-downward</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"D"</span>, <span class="Constant">0x20</span>/x, <span class="Constant">0x2f</span>/y, <span class="Constant">0x30</span>/ymax=screen-height, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg -<span id="L31" class="LineNr">31 </span> <a href='../501draw-text.mu.html#L490'>draw-text-wrapping-down-then-right-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"wrapped from D"</span>, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg -<span id="L32" class="LineNr">32 </span><span class="Delimiter">}</span> +<span id="L7" class="LineNr"> 7 </span><span class="muComment">#</span> +<span id="L8" class="LineNr"> 8 </span><span class="muComment"># Expected output: a box and text that doesn't overflow it</span> +<span id="L9" class="LineNr"> 9 </span> +<span id="L10" class="LineNr">10 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex6.mu.html#L10'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> +<span id="L11" class="LineNr">11 </span> <span class="muComment"># drawing text within a bounding box</span> +<span id="L12" class="LineNr">12 </span> <a href='../503manhattan-line.mu.html#L1'>draw-box-on-real-screen</a> <span class="Constant">0xf</span>, <span class="Constant">0x1f</span>, <span class="Constant">0x79</span>, <span class="Constant">0x51</span>, <span class="Constant">0x4</span> +<span id="L13" class="LineNr">13 </span> <span class="PreProc">var</span> x/eax: int <span class="Special"><-</span> copy <span class="Constant">0x20</span> +<span id="L14" class="LineNr">14 </span> <span class="PreProc">var</span> y/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0x20</span> +<span id="L15" class="LineNr">15 </span> x, y <span class="Special"><-</span> <a href='../501draw-text.mu.html#L181'>draw-text-wrapping-right-then-down</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"hello "</span>, <span class="Constant">0x10</span>/xmin, <span class="Constant">0x20</span>/ymin, <span class="Constant">0x78</span>/xmax, <span class="Constant">0x50</span>/ymax, x, y, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg +<span id="L16" class="LineNr">16 </span> x, y <span class="Special"><-</span> <a href='../501draw-text.mu.html#L181'>draw-text-wrapping-right-then-down</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"from "</span>, <span class="Constant">0x10</span>/xmin, <span class="Constant">0x20</span>/ymin, <span class="Constant">0x78</span>/xmax, <span class="Constant">0x50</span>/ymax, x, y, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg +<span id="L17" class="LineNr">17 </span> x, y <span class="Special"><-</span> <a href='../501draw-text.mu.html#L181'>draw-text-wrapping-right-then-down</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"baremetal "</span>, <span class="Constant">0x10</span>/xmin, <span class="Constant">0x20</span>/ymin, <span class="Constant">0x78</span>/xmax, <span class="Constant">0x50</span>/ymax, x, y, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg +<span id="L18" class="LineNr">18 </span> x, y <span class="Special"><-</span> <a href='../501draw-text.mu.html#L181'>draw-text-wrapping-right-then-down</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"Mu!"</span>, <span class="Constant">0x10</span>/xmin, <span class="Constant">0x20</span>/ymin, <span class="Constant">0x78</span>/xmax, <span class="Constant">0x50</span>/ymax, x, y, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg +<span id="L19" class="LineNr">19 </span> +<span id="L20" class="LineNr">20 </span> <span class="muComment"># drawing at the cursor in multiple directions</span> +<span id="L21" class="LineNr">21 </span> <a href='../501draw-text.mu.html#L504'>draw-text-wrapping-down-then-right-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"abc"</span>, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg +<span id="L22" class="LineNr">22 </span> <a href='../501draw-text.mu.html#L284'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"def"</span>, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg +<span id="L23" class="LineNr">23 </span> +<span id="L24" class="LineNr">24 </span> <span class="muComment"># test drawing near the edge</span> +<span id="L25" class="LineNr">25 </span> x <span class="Special"><-</span> <a href='../501draw-text.mu.html#L106'>draw-text-rightward</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"R"</span>, <span class="Constant">0x7f</span>/x, <span class="Constant">0x80</span>/xmax=screen-width, <span class="Constant">0x18</span>/y, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg +<span id="L26" class="LineNr">26 </span> <a href='../501draw-text.mu.html#L284'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"wrapped from R"</span>, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg +<span id="L27" class="LineNr">27 </span> +<span id="L28" class="LineNr">28 </span> x <span class="Special"><-</span> <a href='../501draw-text.mu.html#L406'>draw-text-downward</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"D"</span>, <span class="Constant">0x20</span>/x, <span class="Constant">0x2f</span>/y, <span class="Constant">0x30</span>/ymax=screen-height, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg +<span id="L29" class="LineNr">29 </span> <a href='../501draw-text.mu.html#L504'>draw-text-wrapping-down-then-right-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"wrapped from D"</span>, <span class="Constant">0xa</span>/fg, <span class="Constant">0</span>/bg +<span id="L30" class="LineNr">30 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/apps/ex7.mu.html b/html/apps/ex7.mu.html index 416ced89..6dbd0e24 100644 --- a/html/apps/ex7.mu.html +++ b/html/apps/ex7.mu.html @@ -62,46 +62,44 @@ if ('onhashchange' in window) { <span id="L4" class="LineNr"> 4 </span><span class="muComment"># ./translate apps/ex7.mu # emits code.img</span> <span id="L5" class="LineNr"> 5 </span><span class="muComment"># To run:</span> <span id="L6" class="LineNr"> 6 </span><span class="muComment"># qemu-system-i386 code.img</span> -<span id="L7" class="LineNr"> 7 </span><span class="muComment"># Or:</span> -<span id="L8" class="LineNr"> 8 </span><span class="muComment"># bochs -f bochsrc # bochsrc loads code.img</span> -<span id="L9" class="LineNr"> 9 </span><span class="muComment">#</span> -<span id="L10" class="LineNr">10 </span><span class="muComment"># Expected output: an interactive game a bit like "snakes". Try pressing h, j,</span> -<span id="L11" class="LineNr">11 </span><span class="muComment"># k, l.</span> -<span id="L12" class="LineNr">12 </span> -<span id="L13" class="LineNr">13 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex7.mu.html#L13'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> -<span id="L14" class="LineNr">14 </span> <span class="PreProc">var</span> space/eax: grapheme <span class="Special"><-</span> copy <span class="Constant">0x20</span> -<span id="L15" class="LineNr">15 </span> <a href='../500fake-screen.mu.html#L190'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0</span>, <span class="Constant">0</span> -<span id="L16" class="LineNr">16 </span> <span class="Delimiter">{</span> -<span id="L17" class="LineNr">17 </span> <a href='../500fake-screen.mu.html#L237'>draw-cursor</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, space -<span id="L18" class="LineNr">18 </span> <span class="PreProc">var</span> key/eax: byte <span class="Special"><-</span> <a href='../102keyboard.subx.html#L21'>read-key</a> keyboard -<span id="L19" class="LineNr">19 </span> <span class="Delimiter">{</span> -<span id="L20" class="LineNr">20 </span> compare key, <span class="Constant">0x68</span>/h -<span id="L21" class="LineNr">21 </span> <span class="PreProc">break-if-!=</span> -<span id="L22" class="LineNr">22 </span> <a href='../501draw-text.mu.html#L92'>draw-code-point-at-cursor</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x2d</span>/dash, <span class="Constant">0x31</span>/fg, <span class="Constant">0</span>/bg -<span id="L23" class="LineNr">23 </span> <a href='../501draw-text.mu.html#L3'>move-cursor-left</a> <span class="Constant">0</span> -<span id="L24" class="LineNr">24 </span> <span class="Delimiter">}</span> -<span id="L25" class="LineNr">25 </span> <span class="Delimiter">{</span> -<span id="L26" class="LineNr">26 </span> compare key, <span class="Constant">0x6a</span>/j -<span id="L27" class="LineNr">27 </span> <span class="PreProc">break-if-!=</span> -<span id="L28" class="LineNr">28 </span> <a href='../501draw-text.mu.html#L92'>draw-code-point-at-cursor</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x7c</span>/vertical-bar, <span class="Constant">0x31</span>/fg, <span class="Constant">0</span>/bg -<span id="L29" class="LineNr">29 </span> <a href='../501draw-text.mu.html#L47'>move-cursor-down</a> <span class="Constant">0</span> -<span id="L30" class="LineNr">30 </span> <span class="Delimiter">}</span> -<span id="L31" class="LineNr">31 </span> <span class="Delimiter">{</span> -<span id="L32" class="LineNr">32 </span> compare key, <span class="Constant">0x6b</span>/k -<span id="L33" class="LineNr">33 </span> <span class="PreProc">break-if-!=</span> -<span id="L34" class="LineNr">34 </span> <a href='../501draw-text.mu.html#L92'>draw-code-point-at-cursor</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x7c</span>/vertical-bar, <span class="Constant">0x31</span>/fg, <span class="Constant">0</span>/bg -<span id="L35" class="LineNr">35 </span> <a href='../501draw-text.mu.html#L34'>move-cursor-up</a> <span class="Constant">0</span> -<span id="L36" class="LineNr">36 </span> <span class="Delimiter">}</span> -<span id="L37" class="LineNr">37 </span> <span class="Delimiter">{</span> -<span id="L38" class="LineNr">38 </span> compare key, <span class="Constant">0x6c</span>/l -<span id="L39" class="LineNr">39 </span> <span class="PreProc">break-if-!=</span> -<span id="L40" class="LineNr">40 </span> <span class="PreProc">var</span> g/eax: code-point <span class="Special"><-</span> copy <span class="Constant">0x2d</span>/dash -<span id="L41" class="LineNr">41 </span> <a href='../501draw-text.mu.html#L92'>draw-code-point-at-cursor</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x2d</span>/dash, <span class="Constant">0x31</span>/fg, <span class="Constant">0</span>/bg -<span id="L42" class="LineNr">42 </span> <a href='../501draw-text.mu.html#L16'>move-cursor-right</a> <span class="Constant">0</span> -<span id="L43" class="LineNr">43 </span> <span class="Delimiter">}</span> -<span id="L44" class="LineNr">44 </span> <span class="PreProc">loop</span> -<span id="L45" class="LineNr">45 </span> <span class="Delimiter">}</span> -<span id="L46" class="LineNr">46 </span><span class="Delimiter">}</span> +<span id="L7" class="LineNr"> 7 </span><span class="muComment">#</span> +<span id="L8" class="LineNr"> 8 </span><span class="muComment"># Expected output: an interactive game a bit like "snakes". Try pressing h, j,</span> +<span id="L9" class="LineNr"> 9 </span><span class="muComment"># k, l.</span> +<span id="L10" class="LineNr">10 </span> +<span id="L11" class="LineNr">11 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex7.mu.html#L11'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> +<span id="L12" class="LineNr">12 </span> <span class="PreProc">var</span> space/eax: grapheme <span class="Special"><-</span> copy <span class="Constant">0x20</span> +<span id="L13" class="LineNr">13 </span> <a href='../500fake-screen.mu.html#L246'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0</span>, <span class="Constant">0</span> +<span id="L14" class="LineNr">14 </span> <span class="Delimiter">{</span> +<span id="L15" class="LineNr">15 </span> <a href='../500fake-screen.mu.html#L293'>draw-cursor</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, space +<span id="L16" class="LineNr">16 </span> <span class="PreProc">var</span> key/eax: byte <span class="Special"><-</span> <a href='../102keyboard.subx.html#L21'>read-key</a> keyboard +<span id="L17" class="LineNr">17 </span> <span class="Delimiter">{</span> +<span id="L18" class="LineNr">18 </span> compare key, <span class="Constant">0x68</span>/h +<span id="L19" class="LineNr">19 </span> <span class="PreProc">break-if-!=</span> +<span id="L20" class="LineNr">20 </span> draw-code-point-at-cursor <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x2d</span>/dash, <span class="Constant">0x31</span>/fg, <span class="Constant">0</span>/bg +<span id="L21" class="LineNr">21 </span> <a href='../501draw-text.mu.html#L3'>move-cursor-left</a> <span class="Constant">0</span> +<span id="L22" class="LineNr">22 </span> <span class="Delimiter">}</span> +<span id="L23" class="LineNr">23 </span> <span class="Delimiter">{</span> +<span id="L24" class="LineNr">24 </span> compare key, <span class="Constant">0x6a</span>/j +<span id="L25" class="LineNr">25 </span> <span class="PreProc">break-if-!=</span> +<span id="L26" class="LineNr">26 </span> draw-code-point-at-cursor <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x7c</span>/vertical-bar, <span class="Constant">0x31</span>/fg, <span class="Constant">0</span>/bg +<span id="L27" class="LineNr">27 </span> <a href='../501draw-text.mu.html#L47'>move-cursor-down</a> <span class="Constant">0</span> +<span id="L28" class="LineNr">28 </span> <span class="Delimiter">}</span> +<span id="L29" class="LineNr">29 </span> <span class="Delimiter">{</span> +<span id="L30" class="LineNr">30 </span> compare key, <span class="Constant">0x6b</span>/k +<span id="L31" class="LineNr">31 </span> <span class="PreProc">break-if-!=</span> +<span id="L32" class="LineNr">32 </span> draw-code-point-at-cursor <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x7c</span>/vertical-bar, <span class="Constant">0x31</span>/fg, <span class="Constant">0</span>/bg +<span id="L33" class="LineNr">33 </span> <a href='../501draw-text.mu.html#L34'>move-cursor-up</a> <span class="Constant">0</span> +<span id="L34" class="LineNr">34 </span> <span class="Delimiter">}</span> +<span id="L35" class="LineNr">35 </span> <span class="Delimiter">{</span> +<span id="L36" class="LineNr">36 </span> compare key, <span class="Constant">0x6c</span>/l +<span id="L37" class="LineNr">37 </span> <span class="PreProc">break-if-!=</span> +<span id="L38" class="LineNr">38 </span> <span class="PreProc">var</span> g/eax: code-point <span class="Special"><-</span> copy <span class="Constant">0x2d</span>/dash +<span id="L39" class="LineNr">39 </span> draw-code-point-at-cursor <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x2d</span>/dash, <span class="Constant">0x31</span>/fg, <span class="Constant">0</span>/bg +<span id="L40" class="LineNr">40 </span> <a href='../501draw-text.mu.html#L16'>move-cursor-right</a> <span class="Constant">0</span> +<span id="L41" class="LineNr">41 </span> <span class="Delimiter">}</span> +<span id="L42" class="LineNr">42 </span> <span class="PreProc">loop</span> +<span id="L43" class="LineNr">43 </span> <span class="Delimiter">}</span> +<span id="L44" class="LineNr">44 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/apps/ex8.mu.html b/html/apps/ex8.mu.html index 1e920f16..429cddf4 100644 --- a/html/apps/ex8.mu.html +++ b/html/apps/ex8.mu.html @@ -61,8 +61,8 @@ if ('onhashchange' in window) { <span id="L3" class="LineNr"> 3 </span><span class="muComment"># To build a disk image:</span> <span id="L4" class="LineNr"> 4 </span><span class="muComment"># ./translate apps/ex8.mu # emits code.img</span> <span id="L5" class="LineNr"> 5 </span><span class="muComment"># To run:</span> -<span id="L6" class="LineNr"> 6 </span><span class="muComment"># bochs -f bochsrc # bochsrc loads code.img</span> -<span id="L7" class="LineNr"> 7 </span><span class="muComment"># Set a breakpoint at 0x7c00 and start stepping.</span> +<span id="L6" class="LineNr"> 6 </span><span class="muComment"># qemu-system-i386 code.img</span> +<span id="L7" class="LineNr"> 7 </span><span class="muComment"># You shouldn't see any exceptions.</span> <span id="L8" class="LineNr"> 8 </span> <span id="L9" class="LineNr"> 9 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex8.mu.html#L9'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> <span id="L10" class="LineNr">10 </span> <span class="PreProc">var</span> n/eax: int <span class="Special"><-</span> copy <span class="Constant">0</span> diff --git a/html/apps/ex9.mu.html b/html/apps/ex9.mu.html index 0c6e5028..891a510f 100644 --- a/html/apps/ex9.mu.html +++ b/html/apps/ex9.mu.html @@ -68,47 +68,46 @@ if ('onhashchange' in window) { <span id="L8" class="LineNr"> 8 </span><span class="muComment"># echo 'abc def ghi' |dd of=data.img conv=notrunc</span> <span id="L9" class="LineNr"> 9 </span><span class="muComment"># 3. Familiarize yourself with how the data disk looks within xxd:</span> <span id="L10" class="LineNr">10 </span><span class="muComment"># xxd data.img |head</span> -<span id="L11" class="LineNr">11 </span><span class="muComment"># 4. Run in an emulator, either Qemu or Bochs.</span> +<span id="L11" class="LineNr">11 </span><span class="muComment"># 4. Run:</span> <span id="L12" class="LineNr">12 </span><span class="muComment"># qemu-system-i386 -hda code.img -hdb data.img</span> -<span id="L13" class="LineNr">13 </span><span class="muComment"># bochs -f bochsrc.2disks</span> -<span id="L14" class="LineNr">14 </span><span class="muComment"># 5. Exit the emulator.</span> -<span id="L15" class="LineNr">15 </span><span class="muComment"># 6. Notice that the data disk now contains the word count of the original text.</span> -<span id="L16" class="LineNr">16 </span><span class="muComment"># xxd data.img |head</span> -<span id="L17" class="LineNr">17 </span> -<span id="L18" class="LineNr">18 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex9.mu.html#L18'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> -<span id="L19" class="LineNr">19 </span> <span class="PreProc">var</span> text-storage: (stream byte <span class="Constant">0x200</span>) -<span id="L20" class="LineNr">20 </span> <span class="PreProc">var</span> text/<span class="muRegEsi">esi</span>: (addr stream byte) <span class="Special"><-</span> address text-storage -<span id="L21" class="LineNr">21 </span> <a href='../510disk.mu.html#L1'>load-sectors</a> data-disk, <span class="Constant">0</span>/lba, <span class="Constant">1</span>/num-sectors, text -<span id="L22" class="LineNr">22 </span> -<span id="L23" class="LineNr">23 </span> <span class="PreProc">var</span> <a href='ex9.mu.html#L31'>word-count</a>/eax: int <span class="Special"><-</span> <a href='ex9.mu.html#L31'>word-count</a> text -<span id="L24" class="LineNr">24 </span> -<span id="L25" class="LineNr">25 </span> <span class="PreProc">var</span> result-storage: (stream byte <span class="Constant">0x10</span>) -<span id="L26" class="LineNr">26 </span> <span class="PreProc">var</span> result/<span class="muRegEdi">edi</span>: (addr stream byte) <span class="Special"><-</span> address result-storage -<span id="L27" class="LineNr">27 </span> <a href='../126write-int-decimal.subx.html#L8'>write-int32-decimal</a> result, <a href='ex9.mu.html#L31'>word-count</a> -<span id="L28" class="LineNr">28 </span> <a href='../510disk.mu.html#L23'>store-sectors</a> data-disk, <span class="Constant">0</span>/lba, <span class="Constant">1</span>/num-sectors, result -<span id="L29" class="LineNr">29 </span><span class="Delimiter">}</span> -<span id="L30" class="LineNr">30 </span> -<span id="L31" class="LineNr">31 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex9.mu.html#L31'>word-count</a></span> in: (addr stream byte)<span class="PreProc"> -> </span>_/eax: int <span class="Delimiter">{</span> -<span id="L32" class="LineNr">32 </span> <span class="PreProc">var</span> result/<span class="muRegEdi">edi</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L33" class="LineNr">33 </span> <span class="Delimiter">{</span> -<span id="L34" class="LineNr">34 </span> <span class="PreProc">var</span> done?/eax: boolean <span class="Special"><-</span> <a href='../309stream.subx.html#L6'>stream-empty?</a> in -<span id="L35" class="LineNr">35 </span> compare done?, <span class="Constant">0</span>/false -<span id="L36" class="LineNr">36 </span> <span class="PreProc">break-if-!=</span> -<span id="L37" class="LineNr">37 </span> <span class="PreProc">var</span> g/eax: grapheme <span class="Special"><-</span> <a href='../403unicode.mu.html#L92'>read-grapheme</a> in -<span id="L38" class="LineNr">38 </span> <span class="Delimiter">{</span> -<span id="L39" class="LineNr">39 </span> compare g, <span class="Constant">0x20</span>/space -<span id="L40" class="LineNr">40 </span> <span class="PreProc">break-if-!=</span> -<span id="L41" class="LineNr">41 </span> result <span class="Special"><-</span> increment -<span id="L42" class="LineNr">42 </span> <span class="Delimiter">}</span> -<span id="L43" class="LineNr">43 </span> <span class="Delimiter">{</span> -<span id="L44" class="LineNr">44 </span> compare g, <span class="Constant">0xa</span>/newline -<span id="L45" class="LineNr">45 </span> <span class="PreProc">break-if-!=</span> -<span id="L46" class="LineNr">46 </span> result <span class="Special"><-</span> increment -<span id="L47" class="LineNr">47 </span> <span class="Delimiter">}</span> -<span id="L48" class="LineNr">48 </span> <span class="PreProc">loop</span> -<span id="L49" class="LineNr">49 </span> <span class="Delimiter">}</span> -<span id="L50" class="LineNr">50 </span> <span class="PreProc">return</span> result -<span id="L51" class="LineNr">51 </span><span class="Delimiter">}</span> +<span id="L13" class="LineNr">13 </span><span class="muComment"># 5. Exit the emulator.</span> +<span id="L14" class="LineNr">14 </span><span class="muComment"># 6. Notice that the data disk now contains the word count of the original text.</span> +<span id="L15" class="LineNr">15 </span><span class="muComment"># xxd data.img |head</span> +<span id="L16" class="LineNr">16 </span> +<span id="L17" class="LineNr">17 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex9.mu.html#L17'>main</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), keyboard: (addr keyboard), data-disk: (addr disk) <span class="Delimiter">{</span> +<span id="L18" class="LineNr">18 </span> <span class="PreProc">var</span> text-storage: (stream byte <span class="Constant">0x200</span>) +<span id="L19" class="LineNr">19 </span> <span class="PreProc">var</span> text/<span class="muRegEsi">esi</span>: (addr stream byte) <span class="Special"><-</span> address text-storage +<span id="L20" class="LineNr">20 </span> <a href='../510disk.mu.html#L1'>load-sectors</a> data-disk, <span class="Constant">0</span>/lba, <span class="Constant">1</span>/num-sectors, text +<span id="L21" class="LineNr">21 </span> +<span id="L22" class="LineNr">22 </span> <span class="PreProc">var</span> <a href='ex9.mu.html#L30'>word-count</a>/eax: int <span class="Special"><-</span> <a href='ex9.mu.html#L30'>word-count</a> text +<span id="L23" class="LineNr">23 </span> +<span id="L24" class="LineNr">24 </span> <span class="PreProc">var</span> result-storage: (stream byte <span class="Constant">0x10</span>) +<span id="L25" class="LineNr">25 </span> <span class="PreProc">var</span> result/<span class="muRegEdi">edi</span>: (addr stream byte) <span class="Special"><-</span> address result-storage +<span id="L26" class="LineNr">26 </span> <a href='../126write-int-decimal.subx.html#L8'>write-int32-decimal</a> result, <a href='ex9.mu.html#L30'>word-count</a> +<span id="L27" class="LineNr">27 </span> <a href='../510disk.mu.html#L23'>store-sectors</a> data-disk, <span class="Constant">0</span>/lba, <span class="Constant">1</span>/num-sectors, result +<span id="L28" class="LineNr">28 </span><span class="Delimiter">}</span> +<span id="L29" class="LineNr">29 </span> +<span id="L30" class="LineNr">30 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex9.mu.html#L30'>word-count</a></span> in: (addr stream byte)<span class="PreProc"> -> </span>_/eax: int <span class="Delimiter">{</span> +<span id="L31" class="LineNr">31 </span> <span class="PreProc">var</span> result/<span class="muRegEdi">edi</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> +<span id="L32" class="LineNr">32 </span> <span class="Delimiter">{</span> +<span id="L33" class="LineNr">33 </span> <span class="PreProc">var</span> done?/eax: boolean <span class="Special"><-</span> <a href='../309stream.subx.html#L6'>stream-empty?</a> in +<span id="L34" class="LineNr">34 </span> compare done?, <span class="Constant">0</span>/false +<span id="L35" class="LineNr">35 </span> <span class="PreProc">break-if-!=</span> +<span id="L36" class="LineNr">36 </span> <span class="PreProc">var</span> g/eax: grapheme <span class="Special"><-</span> <a href='../403unicode.mu.html#L236'>read-grapheme</a> in +<span id="L37" class="LineNr">37 </span> <span class="Delimiter">{</span> +<span id="L38" class="LineNr">38 </span> compare g, <span class="Constant">0x20</span>/space +<span id="L39" class="LineNr">39 </span> <span class="PreProc">break-if-!=</span> +<span id="L40" class="LineNr">40 </span> result <span class="Special"><-</span> increment +<span id="L41" class="LineNr">41 </span> <span class="Delimiter">}</span> +<span id="L42" class="LineNr">42 </span> <span class="Delimiter">{</span> +<span id="L43" class="LineNr">43 </span> compare g, <span class="Constant">0xa</span>/newline +<span id="L44" class="LineNr">44 </span> <span class="PreProc">break-if-!=</span> +<span id="L45" class="LineNr">45 </span> result <span class="Special"><-</span> increment +<span id="L46" class="LineNr">46 </span> <span class="Delimiter">}</span> +<span id="L47" class="LineNr">47 </span> <span class="PreProc">loop</span> +<span id="L48" class="LineNr">48 </span> <span class="Delimiter">}</span> +<span id="L49" class="LineNr">49 </span> <span class="PreProc">return</span> result +<span id="L50" class="LineNr">50 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/apps/hest-life.mu.html b/html/apps/hest-life.mu.html index f6a7de88..3c781697 100644 --- a/html/apps/hest-life.mu.html +++ b/html/apps/hest-life.mu.html @@ -90,10 +90,10 @@ if ('onhashchange' in window) { <span id="L26" class="LineNr"> 26 </span> <a href='hest-life.mu.html#L718'>initialize-environment</a> env <span id="L27" class="LineNr"> 27 </span> <span class="PreProc">var</span> second-buffer: <a href='../500fake-screen.mu.html#L14'>screen</a> <span id="L28" class="LineNr"> 28 </span> <span class="PreProc">var</span> second-screen/<span class="muRegEdi">edi</span>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>) <span class="Special"><-</span> address second-buffer -<span id="L29" class="LineNr"> 29 </span> <a href='../500fake-screen.mu.html#L33'>initialize-screen</a> second-screen, <span class="Constant">0x80</span>, <span class="Constant">0x30</span>, <span class="Constant">1</span>/include-pixels +<span id="L29" class="LineNr"> 29 </span> <a href='../500fake-screen.mu.html#L32'>initialize-screen</a> second-screen, <span class="Constant">0x80</span>, <span class="Constant">0x30</span>, <span class="Constant">1</span>/include-pixels <span id="L30" class="LineNr"> 30 </span> <a href='hest-life.mu.html#L63'>render</a> second-screen, env -<span id="L31" class="LineNr"> 31 </span> <a href='../500fake-screen.mu.html#L588'>convert-graphemes-to-pixels</a> second-screen -<span id="L32" class="LineNr"> 32 </span> <a href='../500fake-screen.mu.html#L548'>copy-pixels</a> second-screen, <a href='../500fake-screen.mu.html#L14'>screen</a> +<span id="L31" class="LineNr"> 31 </span> convert-graphemes-to-pixels second-screen +<span id="L32" class="LineNr"> 32 </span> <a href='../500fake-screen.mu.html#L620'>copy-pixels</a> second-screen, <a href='../500fake-screen.mu.html#L14'>screen</a> <span id="L33" class="LineNr"> 33 </span> <span class="Delimiter">{</span> <span id="L34" class="LineNr"> 34 </span> <a href='hest-life.mu.html#L595'>edit</a> keyboard, env <span id="L35" class="LineNr"> 35 </span> <span class="PreProc">var</span> play?/eax: (addr boolean) <span class="Special"><-</span> get env, play? @@ -101,10 +101,10 @@ if ('onhashchange' in window) { <span id="L37" class="LineNr"> 37 </span> <span class="Delimiter">{</span> <span id="L38" class="LineNr"> 38 </span> <span class="PreProc">break-if-=</span> <span id="L39" class="LineNr"> 39 </span> <a href='hest-life.mu.html#L679'>step</a> env -<span id="L40" class="LineNr"> 40 </span> <a href='../500fake-screen.mu.html#L251'>clear-screen</a> second-screen +<span id="L40" class="LineNr"> 40 </span> <a href='../500fake-screen.mu.html#L307'>clear-screen</a> second-screen <span id="L41" class="LineNr"> 41 </span> <a href='hest-life.mu.html#L63'>render</a> second-screen, env -<span id="L42" class="LineNr"> 42 </span> <a href='../500fake-screen.mu.html#L588'>convert-graphemes-to-pixels</a> second-screen -<span id="L43" class="LineNr"> 43 </span> <a href='../500fake-screen.mu.html#L548'>copy-pixels</a> second-screen, <a href='../500fake-screen.mu.html#L14'>screen</a> +<span id="L42" class="LineNr"> 42 </span> convert-graphemes-to-pixels second-screen +<span id="L43" class="LineNr"> 43 </span> <a href='../500fake-screen.mu.html#L620'>copy-pixels</a> second-screen, <a href='../500fake-screen.mu.html#L14'>screen</a> <span id="L44" class="LineNr"> 44 </span> <span class="Delimiter">}</span> <span id="L45" class="LineNr"> 45 </span> <a href='hest-life.mu.html#L1019'>linger</a> <span id="L46" class="LineNr"> 46 </span> <span class="PreProc">loop</span> @@ -130,13 +130,13 @@ if ('onhashchange' in window) { <span id="L66" class="LineNr"> 66 </span> compare *zoom, <span class="Constant">0</span> <span id="L67" class="LineNr"> 67 </span> <span class="Delimiter">{</span> <span id="L68" class="LineNr"> 68 </span> <span class="PreProc">break-if-!=</span> -<span id="L69" class="LineNr"> 69 </span> <a href='../500fake-screen.mu.html#L251'>clear-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a> +<span id="L69" class="LineNr"> 69 </span> <a href='../500fake-screen.mu.html#L307'>clear-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a> <span id="L70" class="LineNr"> 70 </span> <a href='hest-life.mu.html#L92'>render0</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, self <span id="L71" class="LineNr"> 71 </span> <span class="Delimiter">}</span> <span id="L72" class="LineNr"> 72 </span> compare *zoom, <span class="Constant">1</span> <span id="L73" class="LineNr"> 73 </span> <span class="Delimiter">{</span> <span id="L74" class="LineNr"> 74 </span> <span class="PreProc">break-if-!=</span> -<span id="L75" class="LineNr"> 75 </span> <a href='../500fake-screen.mu.html#L251'>clear-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a> +<span id="L75" class="LineNr"> 75 </span> <a href='../500fake-screen.mu.html#L307'>clear-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a> <span id="L76" class="LineNr"> 76 </span> <a href='hest-life.mu.html#L212'>render1</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, self <span id="L77" class="LineNr"> 77 </span> <span class="Delimiter">}</span> <span id="L78" class="LineNr"> 78 </span> compare *zoom, <span class="Constant">4</span> @@ -146,8 +146,8 @@ if ('onhashchange' in window) { <span id="L82" class="LineNr"> 82 </span> <span class="Delimiter">}</span> <span id="L83" class="LineNr"> 83 </span> <span class="muComment"># clock</span> <span id="L84" class="LineNr"> 84 </span> <span class="PreProc">var</span> tick-a/eax: (addr int) <span class="Special"><-</span> get self, tick -<span id="L85" class="LineNr"> 85 </span> <a href='../500fake-screen.mu.html#L190'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x78</span>/x, <span class="Constant">0</span>/y -<span id="L86" class="LineNr"> 86 </span> <a href='../501draw-text.mu.html#L384'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, *tick-a, <span class="Constant">7</span>/fg <span class="Constant">0</span>/bg +<span id="L85" class="LineNr"> 85 </span> <a href='../500fake-screen.mu.html#L246'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x78</span>/x, <span class="Constant">0</span>/y +<span id="L86" class="LineNr"> 86 </span> <a href='../501draw-text.mu.html#L394'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, *tick-a, <span class="Constant">7</span>/fg <span class="Constant">0</span>/bg <span id="L87" class="LineNr"> 87 </span><span class="Delimiter">}</span> <span id="L88" class="LineNr"> 88 </span> <span id="L89" class="LineNr"> 89 </span><span class="muComment"># Lots of hardcoded constants for now.</span> @@ -180,8 +180,8 @@ if ('onhashchange' in window) { <span id="L116" class="LineNr"> 116 </span> <a href='../507line.mu.html#L86'>draw-rect</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x350</span>/xmin <span class="Constant">0x170</span>/ymin, <span class="Constant">0x370</span>/xmax <span class="Constant">0x190</span>/ymax, color <span id="L117" class="LineNr"> 117 </span> <span class="muComment"># sum node</span> <span id="L118" class="LineNr"> 118 </span> <a href='../507line.mu.html#L86'>draw-rect</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x170</span>/xsmin <span class="Constant">0x140</span>/ysmin, <span class="Constant">0x190</span>/xsmax <span class="Constant">0x160</span>/ysmax, <span class="Constant">0x40</span>/color -<span id="L119" class="LineNr"> 119 </span> <a href='../500fake-screen.mu.html#L190'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x2d</span>/scol, <span class="Constant">0x13</span>/srow -<span id="L120" class="LineNr"> 120 </span> <a href='../501draw-text.mu.html#L276'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"+"</span>, <span class="Constant">0xf</span>/color, <span class="Constant">0</span>/bg +<span id="L119" class="LineNr"> 119 </span> <a href='../500fake-screen.mu.html#L246'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x2d</span>/scol, <span class="Constant">0x13</span>/srow +<span id="L120" class="LineNr"> 120 </span> <a href='../501draw-text.mu.html#L284'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"+"</span>, <span class="Constant">0xf</span>/color, <span class="Constant">0</span>/bg <span id="L121" class="LineNr"> 121 </span> <span class="muComment"># conveyors from neighboring inputs to sum node</span> <span id="L122" class="LineNr"> 122 </span> <a href='../509bezier.mu.html#L14'>draw-monotonic-bezier</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0xa0</span>/x0 <span class="Constant">0x20</span>/y0, <span class="Constant">0x100</span>/x1 <span class="Constant">0x150</span>/ys, <span class="Constant">0x180</span>/xs <span class="Constant">0x150</span>/ys, <span class="Constant">4</span>/color <span id="L123" class="LineNr"> 123 </span> <a href='../509bezier.mu.html#L14'>draw-monotonic-bezier</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0xa0</span>/x0 <span class="Constant">0x180</span>/y0, <span class="Constant">0xc0</span>/x1 <span class="Constant">0x150</span>/ys, <span class="Constant">0x180</span>/xs <span class="Constant">0x150</span>/ys, <span class="Constant">4</span>/color @@ -193,8 +193,8 @@ if ('onhashchange' in window) { <span id="L129" class="LineNr"> 129 </span> <a href='../509bezier.mu.html#L14'>draw-monotonic-bezier</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x360</span>/x0 <span class="Constant">0x2e0</span>/y0, <span class="Constant">0x180</span>/x1 <span class="Constant">0x200</span>/y1, <span class="Constant">0x180</span>/xs <span class="Constant">0x150</span>/ys, <span class="Constant">4</span>/color <span id="L130" class="LineNr"> 130 </span> <span class="muComment"># filter node</span> <span id="L131" class="LineNr"> 131 </span> <a href='../507line.mu.html#L86'>draw-rect</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x200</span>/xfmin <span class="Constant">0x1c0</span>/yfmin, <span class="Constant">0x220</span>/xfmax <span class="Constant">0x1e0</span>/yfmax, <span class="Constant">0x31</span>/color -<span id="L132" class="LineNr"> 132 </span> <a href='../500fake-screen.mu.html#L190'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x40</span>/fcol, <span class="Constant">0x1b</span>/frow -<span id="L133" class="LineNr"> 133 </span> <a href='../501draw-text.mu.html#L276'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"?"</span>, <span class="Constant">0xf</span>/color, <span class="Constant">0</span>/bg +<span id="L132" class="LineNr"> 132 </span> <a href='../500fake-screen.mu.html#L246'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x40</span>/fcol, <span class="Constant">0x1b</span>/frow +<span id="L133" class="LineNr"> 133 </span> <a href='../501draw-text.mu.html#L284'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"?"</span>, <span class="Constant">0xf</span>/color, <span class="Constant">0</span>/bg <span id="L134" class="LineNr"> 134 </span> <span class="muComment"># conveyor from sum node to filter node</span> <span id="L135" class="LineNr"> 135 </span> <a href='../507line.mu.html#L1'>draw-line</a> <a href='../500fake-screen.mu.html#L14'>screen</a> <span class="Constant">0x180</span>/xs, <span class="Constant">0x150</span>/ys, <span class="Constant">0x210</span>/xf, <span class="Constant">0x1d0</span>/yf, <span class="Constant">0xa2</span>/color <span id="L136" class="LineNr"> 136 </span> <span class="muComment"># cell outputs at corners</span> @@ -251,9 +251,9 @@ if ('onhashchange' in window) { <span id="L187" class="LineNr"> 187 </span> <span class="PreProc">var</span> three-f/<span class="Constant">xmm0</span>: float <span class="Special"><-</span> convert three <span id="L188" class="LineNr"> 188 </span> u <span class="Special"><-</span> divide three-f <span id="L189" class="LineNr"> 189 </span> <a href='hest-life.mu.html#L588'>draw-linear-point</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, u, <span class="Constant">0x180</span>/xs, <span class="Constant">0x150</span>/ys, <span class="Constant">0x210</span>/xf, <span class="Constant">0x1d0</span>/yf, <span class="Constant">7</span>/color, <span class="Constant">4</span>/radius -<span id="L190" class="LineNr"> 190 </span> <a href='../500fake-screen.mu.html#L190'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x3a</span>/scol, <span class="Constant">0x18</span>/srow +<span id="L190" class="LineNr"> 190 </span> <a href='../500fake-screen.mu.html#L246'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x3a</span>/scol, <span class="Constant">0x18</span>/srow <span id="L191" class="LineNr"> 191 </span> <span class="PreProc">var</span> n/eax: int <span class="Special"><-</span> <a href='hest-life.mu.html#L953'>num-live-neighbors</a> self, <span class="Constant">0x80</span>/curx, <span class="Constant">0x60</span>/cury -<span id="L192" class="LineNr"> 192 </span> <a href='../501draw-text.mu.html#L384'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, n, <span class="Constant">0xf</span>/fg <span class="Constant">0</span>/bg +<span id="L192" class="LineNr"> 192 </span> <a href='../501draw-text.mu.html#L394'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, n, <span class="Constant">0xf</span>/fg <span class="Constant">0</span>/bg <span id="L193" class="LineNr"> 193 </span> <span class="PreProc">return</span> <span id="L194" class="LineNr"> 194 </span> <span class="Delimiter">}</span> <span id="L195" class="LineNr"> 195 </span> <span class="muComment"># final 7 time steps for updating output</span> @@ -369,17 +369,17 @@ if ('onhashchange' in window) { <span id="L305" class="LineNr"> 305 </span> <a href='../507line.mu.html#L86'>draw-rect</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x2a0</span>/xfmin <span class="Constant">0x218</span>/yfmin, <span class="Constant">0x2b0</span>/xfmax <span class="Constant">0x228</span>/yfmax, <span class="Constant">0x31</span>/color <span id="L306" class="LineNr"> 306 </span> <span class="muComment"># neighbor counts</span> <span id="L307" class="LineNr"> 307 </span> <span class="PreProc">var</span> n/eax: int <span class="Special"><-</span> <a href='hest-life.mu.html#L953'>num-live-neighbors</a> self, <span class="Constant">0x80</span>/curx, <span class="Constant">0x60</span>/cury -<span id="L308" class="LineNr"> 308 </span> <a href='../500fake-screen.mu.html#L190'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x2d</span>, <span class="Constant">0xe</span> -<span id="L309" class="LineNr"> 309 </span> <a href='../501draw-text.mu.html#L384'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, n, <span class="Constant">0xf</span>/fg <span class="Constant">0</span>/bg +<span id="L308" class="LineNr"> 308 </span> <a href='../500fake-screen.mu.html#L246'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x2d</span>, <span class="Constant">0xe</span> +<span id="L309" class="LineNr"> 309 </span> <a href='../501draw-text.mu.html#L394'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, n, <span class="Constant">0xf</span>/fg <span class="Constant">0</span>/bg <span id="L310" class="LineNr"> 310 </span> <span class="PreProc">var</span> n/eax: int <span class="Special"><-</span> <a href='hest-life.mu.html#L953'>num-live-neighbors</a> self, <span class="Constant">0x81</span>/curx, <span class="Constant">0x60</span>/cury -<span id="L311" class="LineNr"> 311 </span> <a href='../500fake-screen.mu.html#L190'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x52</span>, <span class="Constant">0xe</span> -<span id="L312" class="LineNr"> 312 </span> <a href='../501draw-text.mu.html#L384'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, n, <span class="Constant">0xf</span>/fg <span class="Constant">0</span>/bg +<span id="L311" class="LineNr"> 311 </span> <a href='../500fake-screen.mu.html#L246'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x52</span>, <span class="Constant">0xe</span> +<span id="L312" class="LineNr"> 312 </span> <a href='../501draw-text.mu.html#L394'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, n, <span class="Constant">0xf</span>/fg <span class="Constant">0</span>/bg <span id="L313" class="LineNr"> 313 </span> <span class="PreProc">var</span> n/eax: int <span class="Special"><-</span> <a href='hest-life.mu.html#L953'>num-live-neighbors</a> self, <span class="Constant">0x80</span>/curx, <span class="Constant">0x61</span>/cury -<span id="L314" class="LineNr"> 314 </span> <a href='../500fake-screen.mu.html#L190'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x2d</span>, <span class="Constant">0x20</span> -<span id="L315" class="LineNr"> 315 </span> <a href='../501draw-text.mu.html#L384'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, n, <span class="Constant">0xf</span>/fg <span class="Constant">0</span>/bg +<span id="L314" class="LineNr"> 314 </span> <a href='../500fake-screen.mu.html#L246'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x2d</span>, <span class="Constant">0x20</span> +<span id="L315" class="LineNr"> 315 </span> <a href='../501draw-text.mu.html#L394'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, n, <span class="Constant">0xf</span>/fg <span class="Constant">0</span>/bg <span id="L316" class="LineNr"> 316 </span> <span class="PreProc">var</span> n/eax: int <span class="Special"><-</span> <a href='hest-life.mu.html#L953'>num-live-neighbors</a> self, <span class="Constant">0x81</span>/curx, <span class="Constant">0x61</span>/cury -<span id="L317" class="LineNr"> 317 </span> <a href='../500fake-screen.mu.html#L190'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x52</span>, <span class="Constant">0x20</span> -<span id="L318" class="LineNr"> 318 </span> <a href='../501draw-text.mu.html#L384'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, n, <span class="Constant">0xf</span>/fg <span class="Constant">0</span>/bg +<span id="L317" class="LineNr"> 317 </span> <a href='../500fake-screen.mu.html#L246'>set-cursor-position</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0x52</span>, <span class="Constant">0x20</span> +<span id="L318" class="LineNr"> 318 </span> <a href='../501draw-text.mu.html#L394'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, n, <span class="Constant">0xf</span>/fg <span class="Constant">0</span>/bg <span id="L319" class="LineNr"> 319 </span> <span class="muComment"># cell 0: conveyors from neighboring inputs to sum node</span> <span id="L320" class="LineNr"> 320 </span> <a href='../509bezier.mu.html#L14'>draw-monotonic-bezier</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0xc0</span>/x0 <span class="Constant">0x40</span>/y0, <span class="Constant">0x100</span>/x1 <span class="Constant">0xd0</span>/ys, <span class="Constant">0x150</span>/xs <span class="Constant">0xd0</span>/ys, <span class="Constant">4</span>/color <span id="L321" class="LineNr"> 321 </span> <a href='../509bezier.mu.html#L14'>draw-monotonic-bezier</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">0xc0</span>/x0 <span class="Constant">0xe8</span>/y0, <span class="Constant">0xc0</span>/x1 <span class="Constant">0xd0</span>/ys, <span class="Constant">0x150</span>/xs <span class="Constant">0xd0</span>/ys, <span class="Constant">4</span>/color diff --git a/html/apps/mandelbrot-fixed.mu.html b/html/apps/mandelbrot-fixed.mu.html index 6264bde1..b6781279 100644 --- a/html/apps/mandelbrot-fixed.mu.html +++ b/html/apps/mandelbrot-fixed.mu.html @@ -191,7 +191,7 @@ if ('onhashchange' in window) { <span id="L127" class="LineNr">127 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='mandelbrot-fixed.mu.html#L127'>mandelbrot</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), scene-cx-f: int, scene-cy-f: int, scene-width-f: int <span class="Delimiter">{</span> <span id="L128" class="LineNr">128 </span> <span class="PreProc">var</span> a/eax: int <span class="Special"><-</span> copy <span class="Constant">0</span> <span id="L129" class="LineNr">129 </span> <span class="PreProc">var</span> b/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L130" class="LineNr">130 </span> a, b <span class="Special"><-</span> <a href='../500fake-screen.mu.html#L86'>screen-size</a> <a href='../500fake-screen.mu.html#L14'>screen</a> +<span id="L130" class="LineNr">130 </span> a, b <span class="Special"><-</span> <a href='../500fake-screen.mu.html#L73'>screen-size</a> <a href='../500fake-screen.mu.html#L14'>screen</a> <span id="L131" class="LineNr">131 </span> <span class="PreProc">var</span> width/<span class="muRegEsi">esi</span>: int <span class="Special"><-</span> copy a <span id="L132" class="LineNr">132 </span> width <span class="Special"><-</span> shift-left <span class="Constant">3</span>/log2-font-width <span id="L133" class="LineNr">133 </span> <span class="PreProc">var</span> height/<span class="muRegEdi">edi</span>: int <span class="Special"><-</span> copy b @@ -214,7 +214,7 @@ if ('onhashchange' in window) { <span id="L150" class="LineNr">150 </span> dummy, color <span class="Special"><-</span> <a href='../314divide.subx.html#L3'>integer-divide</a> iterations, <span class="Constant">0x18</span>/<span class="Constant">24</span>/size-of-cycle-0 <span id="L151" class="LineNr">151 </span> color <span class="Special"><-</span> add <span class="Constant">0x20</span>/cycle-0 <span id="L152" class="LineNr">152 </span> <span class="Delimiter">}</span> -<span id="L153" class="LineNr">153 </span> <a href='../500fake-screen.mu.html#L483'>pixel</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, x, y, color +<span id="L153" class="LineNr">153 </span> <a href='../500fake-screen.mu.html#L557'>pixel</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, x, y, color <span id="L154" class="LineNr">154 </span> x <span class="Special"><-</span> increment <span id="L155" class="LineNr">155 </span> <span class="PreProc">loop</span> <span id="L156" class="LineNr">156 </span> <span class="Delimiter">}</span> diff --git a/html/apps/mandelbrot-silhouette.mu.html b/html/apps/mandelbrot-silhouette.mu.html index 94125193..87cc8150 100644 --- a/html/apps/mandelbrot-silhouette.mu.html +++ b/html/apps/mandelbrot-silhouette.mu.html @@ -79,7 +79,7 @@ if ('onhashchange' in window) { <span id="L17" class="LineNr"> 17 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='mandelbrot-silhouette.mu.html#L17'>mandelbrot</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>) <span class="Delimiter">{</span> <span id="L18" class="LineNr"> 18 </span> <span class="PreProc">var</span> a/eax: int <span class="Special"><-</span> copy <span class="Constant">0</span> <span id="L19" class="LineNr"> 19 </span> <span class="PreProc">var</span> b/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L20" class="LineNr"> 20 </span> a, b <span class="Special"><-</span> <a href='../500fake-screen.mu.html#L86'>screen-size</a> <a href='../500fake-screen.mu.html#L14'>screen</a> +<span id="L20" class="LineNr"> 20 </span> a, b <span class="Special"><-</span> <a href='../500fake-screen.mu.html#L73'>screen-size</a> <a href='../500fake-screen.mu.html#L14'>screen</a> <span id="L21" class="LineNr"> 21 </span> <span class="PreProc">var</span> width/<span class="muRegEsi">esi</span>: int <span class="Special"><-</span> copy a <span id="L22" class="LineNr"> 22 </span> width <span class="Special"><-</span> shift-left <span class="Constant">3</span>/log2-font-width <span id="L23" class="LineNr"> 23 </span> <span class="PreProc">var</span> height/<span class="muRegEdi">edi</span>: int <span class="Special"><-</span> copy b @@ -98,12 +98,12 @@ if ('onhashchange' in window) { <span id="L36" class="LineNr"> 36 </span> compare iterations, <span class="Constant">0x400</span>/max <span id="L37" class="LineNr"> 37 </span> <span class="Delimiter">{</span> <span id="L38" class="LineNr"> 38 </span> <span class="PreProc">break-if->=</span> -<span id="L39" class="LineNr"> 39 </span> <a href='../500fake-screen.mu.html#L483'>pixel</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, x, y, <span class="Constant">0xf</span>/white +<span id="L39" class="LineNr"> 39 </span> <a href='../500fake-screen.mu.html#L557'>pixel</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, x, y, <span class="Constant">0xf</span>/white <span id="L40" class="LineNr"> 40 </span> <span class="Delimiter">}</span> <span id="L41" class="LineNr"> 41 </span> compare iterations, <span class="Constant">0x400</span>/max <span id="L42" class="LineNr"> 42 </span> <span class="Delimiter">{</span> <span id="L43" class="LineNr"> 43 </span> <span class="PreProc">break-if-<</span> -<span id="L44" class="LineNr"> 44 </span> <a href='../500fake-screen.mu.html#L483'>pixel</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, x, y, <span class="Constant">0</span>/black +<span id="L44" class="LineNr"> 44 </span> <a href='../500fake-screen.mu.html#L557'>pixel</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, x, y, <span class="Constant">0</span>/black <span id="L45" class="LineNr"> 45 </span> <span class="Delimiter">}</span> <span id="L46" class="LineNr"> 46 </span> x <span class="Special"><-</span> increment <span id="L47" class="LineNr"> 47 </span> <span class="PreProc">loop</span> diff --git a/html/apps/mandelbrot.mu.html b/html/apps/mandelbrot.mu.html index 6d5d6990..b432dd3e 100644 --- a/html/apps/mandelbrot.mu.html +++ b/html/apps/mandelbrot.mu.html @@ -104,7 +104,7 @@ if ('onhashchange' in window) { <span id="L41" class="LineNr"> 41 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='mandelbrot.mu.html#L41'>mandelbrot</a></span> <a href='../500fake-screen.mu.html#L14'>screen</a>: (addr <a href='../500fake-screen.mu.html#L14'>screen</a>), scene-cx: float, scene-cy: float, scene-width: float <span class="Delimiter">{</span> <span id="L42" class="LineNr"> 42 </span> <span class="PreProc">var</span> a/eax: int <span class="Special"><-</span> copy <span class="Constant">0</span> <span id="L43" class="LineNr"> 43 </span> <span class="PreProc">var</span> b/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L44" class="LineNr"> 44 </span> a, b <span class="Special"><-</span> <a href='../500fake-screen.mu.html#L86'>screen-size</a> <a href='../500fake-screen.mu.html#L14'>screen</a> +<span id="L44" class="LineNr"> 44 </span> a, b <span class="Special"><-</span> <a href='../500fake-screen.mu.html#L73'>screen-size</a> <a href='../500fake-screen.mu.html#L14'>screen</a> <span id="L45" class="LineNr"> 45 </span> <span class="PreProc">var</span> width/<span class="muRegEsi">esi</span>: int <span class="Special"><-</span> copy a <span id="L46" class="LineNr"> 46 </span> width <span class="Special"><-</span> shift-left <span class="Constant">3</span>/log2-font-width <span id="L47" class="LineNr"> 47 </span> <span class="PreProc">var</span> height/<span class="muRegEdi">edi</span>: int <span class="Special"><-</span> copy b @@ -124,7 +124,7 @@ if ('onhashchange' in window) { <span id="L61" class="LineNr"> 61 </span> <span class="PreProc">var</span> color/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> <span id="L62" class="LineNr"> 62 </span> iterations, color <span class="Special"><-</span> <a href='../314divide.subx.html#L3'>integer-divide</a> iterations, <span class="Constant">0x18</span>/<span class="Constant">24</span>/size-of-cycle-0 <span id="L63" class="LineNr"> 63 </span> color <span class="Special"><-</span> add <span class="Constant">0x20</span>/cycle-0 -<span id="L64" class="LineNr"> 64 </span> <a href='../500fake-screen.mu.html#L483'>pixel</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, x, y, color +<span id="L64" class="LineNr"> 64 </span> <a href='../500fake-screen.mu.html#L557'>pixel</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, x, y, color <span id="L65" class="LineNr"> 65 </span> x <span class="Special"><-</span> increment <span id="L66" class="LineNr"> 66 </span> <span class="PreProc">loop</span> <span id="L67" class="LineNr"> 67 </span> <span class="Delimiter">}</span> diff --git a/html/apps/rpn.mu.html b/html/apps/rpn.mu.html index eeec5a89..df5867bb 100644 --- a/html/apps/rpn.mu.html +++ b/html/apps/rpn.mu.html @@ -81,15 +81,15 @@ if ('onhashchange' in window) { <span id="L19" class="LineNr"> 19 </span> <span class="PreProc">var</span> in-storage: (stream byte <span class="Constant">0x80</span>) <span id="L20" class="LineNr"> 20 </span> <span class="PreProc">var</span> in/<span class="muRegEsi">esi</span>: (addr stream byte) <span class="Special"><-</span> address in-storage <span id="L21" class="LineNr"> 21 </span> <span class="PreProc">var</span> y/<span class="muRegEcx">ecx</span>: int <span class="Special"><-</span> copy <span class="Constant">0</span> -<span id="L22" class="LineNr"> 22 </span> <span class="PreProc">var</span> space/<span class="muRegEdx">edx</span>: grapheme <span class="Special"><-</span> copy <span class="Constant">0x20</span> +<span id="L22" class="LineNr"> 22 </span> <span class="PreProc">var</span> space/<span class="muRegEdx">edx</span>: code-point <span class="Special"><-</span> copy <span class="Constant">0x20</span> <span id="L23" class="LineNr"> 23 </span> <span class="muComment"># read-eval-print loop</span> <span id="L24" class="LineNr"> 24 </span> <span class="Delimiter">{</span> <span id="L25" class="LineNr"> 25 </span> <span class="muComment"># print prompt</span> -<span id="L26" class="LineNr"> 26 </span> <span class="PreProc">var</span> x/eax: int <span class="Special"><-</span> <a href='../501draw-text.mu.html#L100'>draw-text-rightward</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"> "</span>, <span class="Constant">0</span>/x, <span class="Constant">0x80</span>/xmax, y, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L26" class="LineNr"> 26 </span> <span class="PreProc">var</span> x/eax: int <span class="Special"><-</span> <a href='../501draw-text.mu.html#L106'>draw-text-rightward</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, <span class="Constant">"> "</span>, <span class="Constant">0</span>/x, <span class="Constant">0x80</span>/xmax, y, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg <span id="L27" class="LineNr"> 27 </span> <span class="muComment"># read line from keyboard</span> <span id="L28" class="LineNr"> 28 </span> <a href='../106stream.subx.html#L20'>clear-stream</a> in <span id="L29" class="LineNr"> 29 </span> <span class="Delimiter">{</span> -<span id="L30" class="LineNr"> 30 </span> <a href='../500fake-screen.mu.html#L237'>draw-cursor</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, space +<span id="L30" class="LineNr"> 30 </span> <a href='../500fake-screen.mu.html#L293'>draw-cursor</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, space <span id="L31" class="LineNr"> 31 </span> <span class="PreProc">var</span> key/eax: byte <span class="Special"><-</span> <a href='../102keyboard.subx.html#L21'>read-key</a> keyboard <span id="L32" class="LineNr"> 32 </span> compare key, <span class="Constant">0xa</span>/newline <span id="L33" class="LineNr"> 33 </span> <span class="PreProc">break-if-=</span> @@ -97,120 +97,119 @@ if ('onhashchange' in window) { <span id="L35" class="LineNr"> 35 </span> <span class="PreProc">loop-if-=</span> <span id="L36" class="LineNr"> 36 </span> <span class="PreProc">var</span> key2/eax: int <span class="Special"><-</span> copy key <span id="L37" class="LineNr"> 37 </span> <a href='../115write-byte.subx.html#L12'>append-byte</a> in, key2 -<span id="L38" class="LineNr"> 38 </span> <span class="PreProc">var</span> g/eax: grapheme <span class="Special"><-</span> copy key2 -<span id="L39" class="LineNr"> 39 </span> <a href='../501draw-text.mu.html#L84'>draw-grapheme-at-cursor</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, g, <span class="Constant">0xf</span>/fg, <span class="Constant">0</span>/bg -<span id="L40" class="LineNr"> 40 </span> <a href='../501draw-text.mu.html#L16'>move-cursor-right</a> <span class="Constant">0</span> -<span id="L41" class="LineNr"> 41 </span> <span class="PreProc">loop</span> -<span id="L42" class="LineNr"> 42 </span> <span class="Delimiter">}</span> -<span id="L43" class="LineNr"> 43 </span> <span class="muComment"># clear cursor</span> -<span id="L44" class="LineNr"> 44 </span> <a href='../501draw-text.mu.html#L84'>draw-grapheme-at-cursor</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, space, <span class="Constant">3</span>/fg/never-used, <span class="Constant">0</span>/bg -<span id="L45" class="LineNr"> 45 </span> <span class="muComment"># parse and eval</span> -<span id="L46" class="LineNr"> 46 </span> <span class="PreProc">var</span> out/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L62'>simplify</a> in -<span id="L47" class="LineNr"> 47 </span> <span class="muComment"># print</span> -<span id="L48" class="LineNr"> 48 </span> y <span class="Special"><-</span> increment -<span id="L49" class="LineNr"> 49 </span> out, y <span class="Special"><-</span> <a href='../501draw-text.mu.html#L337'>draw-int32-decimal-wrapping-right-then-down</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, out, <span class="Constant">0</span>/xmin, y, <span class="Constant">0x80</span>/xmax, <span class="Constant">0x30</span>/ymax, <span class="Constant">0</span>/x, y, <span class="Constant">7</span>/fg, <span class="Constant">0</span>/bg -<span id="L50" class="LineNr"> 50 </span> <span class="muComment"># newline</span> -<span id="L51" class="LineNr"> 51 </span> y <span class="Special"><-</span> increment -<span id="L52" class="LineNr"> 52 </span> <span class="muComment">#</span> -<span id="L53" class="LineNr"> 53 </span> <span class="PreProc">loop</span> -<span id="L54" class="LineNr"> 54 </span> <span class="Delimiter">}</span> -<span id="L55" class="LineNr"> 55 </span><span class="Delimiter">}</span> -<span id="L56" class="LineNr"> 56 </span> -<span id="L57" class="LineNr"> 57 </span><span class="PreProc">type</span> <a href='rpn.mu.html#L57'>int-stack</a> <span class="Delimiter">{</span> -<span id="L58" class="LineNr"> 58 </span> data: (handle array int) -<span id="L59" class="LineNr"> 59 </span> top: int -<span id="L60" class="LineNr"> 60 </span><span class="Delimiter">}</span> -<span id="L61" class="LineNr"> 61 </span> -<span id="L62" class="LineNr"> 62 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='rpn.mu.html#L62'>simplify</a></span> in: (addr stream byte)<span class="PreProc"> -> </span>_/eax: int <span class="Delimiter">{</span> -<span id="L63" class="LineNr"> 63 </span> <span class="PreProc">var</span> word-storage: slice -<span id="L64" class="LineNr"> 64 </span> <span class="PreProc">var</span> word/<span class="muRegEcx">ecx</span>: (addr slice) <span class="Special"><-</span> address word-storage -<span id="L65" class="LineNr"> 65 </span> <span class="PreProc">var</span> stack-storage: <a href='rpn.mu.html#L57'>int-stack</a> -<span id="L66" class="LineNr"> 66 </span> <span class="PreProc">var</span> stack/<span class="muRegEsi">esi</span>: (addr <a href='rpn.mu.html#L57'>int-stack</a>) <span class="Special"><-</span> address stack-storage -<span id="L67" class="LineNr"> 67 </span> <a href='rpn.mu.html#L116'>initialize-int-stack</a> stack, <span class="Constant">0x10</span> -<span id="L68" class="LineNr"> 68 </span> $simplify:word-loop: <span class="Delimiter">{</span> -<span id="L69" class="LineNr"> 69 </span> <a href='../127next-word.subx.html#L11'>next-word</a> in, word -<span id="L70" class="LineNr"> 70 </span> <span class="PreProc">var</span> done?/eax: boolean <span class="Special"><-</span> <a href='../123slice.subx.html#L9'>slice-empty?</a> word -<span id="L71" class="LineNr"> 71 </span> compare done?, <span class="Constant">0</span> -<span id="L72" class="LineNr"> 72 </span> <span class="PreProc">break-if-!=</span> -<span id="L73" class="LineNr"> 73 </span> <span class="muComment"># if word is an operator, perform it</span> -<span id="L74" class="LineNr"> 74 </span> <span class="Delimiter">{</span> -<span id="L75" class="LineNr"> 75 </span> <span class="PreProc">var</span> is-add?/eax: boolean <span class="Special"><-</span> <a href='../123slice.subx.html#L120'>slice-equal?</a> word, <span class="Constant">"+"</span> -<span id="L76" class="LineNr"> 76 </span> compare is-add?, <span class="Constant">0</span> -<span id="L77" class="LineNr"> 77 </span> <span class="PreProc">break-if-=</span> -<span id="L78" class="LineNr"> 78 </span> <span class="PreProc">var</span> _b/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L136'>pop-int-stack</a> stack -<span id="L79" class="LineNr"> 79 </span> <span class="PreProc">var</span> b/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy _b -<span id="L80" class="LineNr"> 80 </span> <span class="PreProc">var</span> a/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L136'>pop-int-stack</a> stack -<span id="L81" class="LineNr"> 81 </span> a <span class="Special"><-</span> add b -<span id="L82" class="LineNr"> 82 </span> <a href='rpn.mu.html#L124'>push-int-stack</a> stack, a -<span id="L83" class="LineNr"> 83 </span> <span class="PreProc">loop</span> $simplify:word-loop -<span id="L84" class="LineNr"> 84 </span> <span class="Delimiter">}</span> -<span id="L85" class="LineNr"> 85 </span> <span class="Delimiter">{</span> -<span id="L86" class="LineNr"> 86 </span> <span class="PreProc">var</span> is-sub?/eax: boolean <span class="Special"><-</span> <a href='../123slice.subx.html#L120'>slice-equal?</a> word, <span class="Constant">"-"</span> -<span id="L87" class="LineNr"> 87 </span> compare is-sub?, <span class="Constant">0</span> -<span id="L88" class="LineNr"> 88 </span> <span class="PreProc">break-if-=</span> -<span id="L89" class="LineNr"> 89 </span> <span class="PreProc">var</span> _b/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L136'>pop-int-stack</a> stack -<span id="L90" class="LineNr"> 90 </span> <span class="PreProc">var</span> b/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy _b -<span id="L91" class="LineNr"> 91 </span> <span class="PreProc">var</span> a/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L136'>pop-int-stack</a> stack -<span id="L92" class="LineNr"> 92 </span> a <span class="Special"><-</span> subtract b -<span id="L93" class="LineNr"> 93 </span> <a href='rpn.mu.html#L124'>push-int-stack</a> stack, a -<span id="L94" class="LineNr"> 94 </span> <span class="PreProc">loop</span> $simplify:word-loop -<span id="L95" class="LineNr"> 95 </span> <span class="Delimiter">}</span> -<span id="L96" class="LineNr"> 96 </span> <span class="Delimiter">{</span> -<span id="L97" class="LineNr"> 97 </span> <span class="PreProc">var</span> is-mul?/eax: boolean <span class="Special"><-</span> <a href='../123slice.subx.html#L120'>slice-equal?</a> word, <span class="Constant">"*"</span> -<span id="L98" class="LineNr"> 98 </span> compare is-mul?, <span class="Constant">0</span> -<span id="L99" class="LineNr"> 99 </span> <span class="PreProc">break-if-=</span> -<span id="L100" class="LineNr">100 </span> <span class="PreProc">var</span> _b/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L136'>pop-int-stack</a> stack -<span id="L101" class="LineNr">101 </span> <span class="PreProc">var</span> b/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy _b -<span id="L102" class="LineNr">102 </span> <span class="PreProc">var</span> a/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L136'>pop-int-stack</a> stack -<span id="L103" class="LineNr">103 </span> a <span class="Special"><-</span> multiply b -<span id="L104" class="LineNr">104 </span> <a href='rpn.mu.html#L124'>push-int-stack</a> stack, a -<span id="L105" class="LineNr">105 </span> <span class="PreProc">loop</span> $simplify:word-loop -<span id="L106" class="LineNr">106 </span> <span class="Delimiter">}</span> -<span id="L107" class="LineNr">107 </span> <span class="muComment"># otherwise it's an int</span> -<span id="L108" class="LineNr">108 </span> <span class="PreProc">var</span> n/eax: int <span class="Special"><-</span> <a href='../311decimal-int.subx.html#L4'>parse-decimal-int-from-slice</a> word -<span id="L109" class="LineNr">109 </span> <a href='rpn.mu.html#L124'>push-int-stack</a> stack, n -<span id="L110" class="LineNr">110 </span> <span class="PreProc">loop</span> -<span id="L111" class="LineNr">111 </span> <span class="Delimiter">}</span> -<span id="L112" class="LineNr">112 </span> <span class="PreProc">var</span> result/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L136'>pop-int-stack</a> stack -<span id="L113" class="LineNr">113 </span> <span class="PreProc">return</span> result -<span id="L114" class="LineNr">114 </span><span class="Delimiter">}</span> -<span id="L115" class="LineNr">115 </span> -<span id="L116" class="LineNr">116 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='rpn.mu.html#L116'>initialize-int-stack</a></span> _self: (addr <a href='rpn.mu.html#L57'>int-stack</a>), n: int <span class="Delimiter">{</span> -<span id="L117" class="LineNr">117 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='rpn.mu.html#L57'>int-stack</a>) <span class="Special"><-</span> copy _self -<span id="L118" class="LineNr">118 </span> <span class="PreProc">var</span> d/<span class="muRegEdi">edi</span>: (addr handle array int) <span class="Special"><-</span> get self, data -<span id="L119" class="LineNr">119 </span> populate d, n -<span id="L120" class="LineNr">120 </span> <span class="PreProc">var</span> top/eax: (addr int) <span class="Special"><-</span> get self, top -<span id="L121" class="LineNr">121 </span> copy-to *top, <span class="Constant">0</span> -<span id="L122" class="LineNr">122 </span><span class="Delimiter">}</span> -<span id="L123" class="LineNr">123 </span> -<span id="L124" class="LineNr">124 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='rpn.mu.html#L124'>push-int-stack</a></span> _self: (addr <a href='rpn.mu.html#L57'>int-stack</a>), _val: int <span class="Delimiter">{</span> -<span id="L125" class="LineNr">125 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='rpn.mu.html#L57'>int-stack</a>) <span class="Special"><-</span> copy _self -<span id="L126" class="LineNr">126 </span> <span class="PreProc">var</span> top-addr/<span class="muRegEcx">ecx</span>: (addr int) <span class="Special"><-</span> get self, top -<span id="L127" class="LineNr">127 </span> <span class="PreProc">var</span> data-ah/<span class="muRegEdx">edx</span>: (addr handle array int) <span class="Special"><-</span> get self, data -<span id="L128" class="LineNr">128 </span> <span class="PreProc">var</span> data/eax: (addr array int) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *data-ah -<span id="L129" class="LineNr">129 </span> <span class="PreProc">var</span> top/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy *top-addr -<span id="L130" class="LineNr">130 </span> <span class="PreProc">var</span> dest-addr/<span class="muRegEdx">edx</span>: (addr int) <span class="Special"><-</span> index data, top -<span id="L131" class="LineNr">131 </span> <span class="PreProc">var</span> val/eax: int <span class="Special"><-</span> copy _val -<span id="L132" class="LineNr">132 </span> copy-to *dest-addr, val -<span id="L133" class="LineNr">133 </span> add-to *top-addr, <span class="Constant">1</span> -<span id="L134" class="LineNr">134 </span><span class="Delimiter">}</span> -<span id="L135" class="LineNr">135 </span> -<span id="L136" class="LineNr">136 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='rpn.mu.html#L136'>pop-int-stack</a></span> _self: (addr <a href='rpn.mu.html#L57'>int-stack</a>)<span class="PreProc"> -> </span>_/eax: int <span class="Delimiter">{</span> -<span id="L137" class="LineNr">137 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='rpn.mu.html#L57'>int-stack</a>) <span class="Special"><-</span> copy _self -<span id="L138" class="LineNr">138 </span> <span class="PreProc">var</span> top-addr/<span class="muRegEcx">ecx</span>: (addr int) <span class="Special"><-</span> get self, top -<span id="L139" class="LineNr">139 </span> <span class="Delimiter">{</span> -<span id="L140" class="LineNr">140 </span> compare *top-addr, <span class="Constant">0</span> -<span id="L141" class="LineNr">141 </span> <span class="PreProc">break-if-></span> -<span id="L142" class="LineNr">142 </span> <span class="PreProc">return</span> <span class="Constant">0</span> -<span id="L143" class="LineNr">143 </span> <span class="Delimiter">}</span> -<span id="L144" class="LineNr">144 </span> subtract-from *top-addr, <span class="Constant">1</span> -<span id="L145" class="LineNr">145 </span> <span class="PreProc">var</span> data-ah/<span class="muRegEdx">edx</span>: (addr handle array int) <span class="Special"><-</span> get self, data -<span id="L146" class="LineNr">146 </span> <span class="PreProc">var</span> data/eax: (addr array int) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *data-ah -<span id="L147" class="LineNr">147 </span> <span class="PreProc">var</span> top/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy *top-addr -<span id="L148" class="LineNr">148 </span> <span class="PreProc">var</span> result-addr/eax: (addr int) <span class="Special"><-</span> index data, top -<span id="L149" class="LineNr">149 </span> <span class="PreProc">var</span> val/eax: int <span class="Special"><-</span> copy *result-addr -<span id="L150" class="LineNr">150 </span> <span class="PreProc">return</span> val -<span id="L151" class="LineNr">151 </span><span class="Delimiter">}</span> +<span id="L38" class="LineNr"> 38 </span> <span class="PreProc">var</span> c/eax: code-point <span class="Special"><-</span> copy key2 +<span id="L39" class="LineNr"> 39 </span> <a href='../501draw-text.mu.html#L84'>draw-code-point-at-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, c, <span class="Constant">0xf</span>/fg, <span class="Constant">0</span>/bg +<span id="L40" class="LineNr"> 40 </span> <span class="PreProc">loop</span> +<span id="L41" class="LineNr"> 41 </span> <span class="Delimiter">}</span> +<span id="L42" class="LineNr"> 42 </span> <span class="muComment"># clear cursor</span> +<span id="L43" class="LineNr"> 43 </span> <a href='../501draw-text.mu.html#L84'>draw-code-point-at-cursor-over-full-screen</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, space, <span class="Constant">3</span>/fg/never-used, <span class="Constant">0</span>/bg +<span id="L44" class="LineNr"> 44 </span> <span class="muComment"># parse and eval</span> +<span id="L45" class="LineNr"> 45 </span> <span class="PreProc">var</span> out/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L61'>simplify</a> in +<span id="L46" class="LineNr"> 46 </span> <span class="muComment"># print</span> +<span id="L47" class="LineNr"> 47 </span> y <span class="Special"><-</span> increment +<span id="L48" class="LineNr"> 48 </span> out, y <span class="Special"><-</span> <a href='../501draw-text.mu.html#L346'>draw-int32-decimal-wrapping-right-then-down</a> <a href='../500fake-screen.mu.html#L14'>screen</a>, out, <span class="Constant">0</span>/xmin, y, <span class="Constant">0x80</span>/xmax, <span class="Constant">0x30</span>/ymax, <span class="Constant">0</span>/x, y, <span class="Constant">7</span>/fg, <span class="Constant">0</span>/bg +<span id="L49" class="LineNr"> 49 </span> <span class="muComment"># newline</span> +<span id="L50" class="LineNr"> 50 </span> y <span class="Special"><-</span> increment +<span id="L51" class="LineNr"> 51 </span> <span class="muComment">#</span> +<span id="L52" class="LineNr"> 52 </span> <span class="PreProc">loop</span> +<span id="L53" class="LineNr"> 53 </span> <span class="Delimiter">}</span> +<span id="L54" class="LineNr"> 54 </span><span class="Delimiter">}</span> +<span id="L55" class="LineNr"> 55 </span> +<span id="L56" class="LineNr"> 56 </span><span class="PreProc">type</span> <a href='rpn.mu.html#L56'>int-stack</a> <span class="Delimiter">{</span> +<span id="L57" class="LineNr"> 57 </span> data: (handle array int) +<span id="L58" class="LineNr"> 58 </span> top: int +<span id="L59" class="LineNr"> 59 </span><span class="Delimiter">}</span> +<span id="L60" class="LineNr"> 60 </span> +<span id="L61" class="LineNr"> 61 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='rpn.mu.html#L61'>simplify</a></span> in: (addr stream byte)<span class="PreProc"> -> </span>_/eax: int <span class="Delimiter">{</span> +<span id="L62" class="LineNr"> 62 </span> <span class="PreProc">var</span> word-storage: slice +<span id="L63" class="LineNr"> 63 </span> <span class="PreProc">var</span> word/<span class="muRegEcx">ecx</span>: (addr slice) <span class="Special"><-</span> address word-storage +<span id="L64" class="LineNr"> 64 </span> <span class="PreProc">var</span> stack-storage: <a href='rpn.mu.html#L56'>int-stack</a> +<span id="L65" class="LineNr"> 65 </span> <span class="PreProc">var</span> stack/<span class="muRegEsi">esi</span>: (addr <a href='rpn.mu.html#L56'>int-stack</a>) <span class="Special"><-</span> address stack-storage +<span id="L66" class="LineNr"> 66 </span> <a href='rpn.mu.html#L115'>initialize-int-stack</a> stack, <span class="Constant">0x10</span> +<span id="L67" class="LineNr"> 67 </span> $simplify:word-loop: <span class="Delimiter">{</span> +<span id="L68" class="LineNr"> 68 </span> <a href='../127next-word.subx.html#L11'>next-word</a> in, word +<span id="L69" class="LineNr"> 69 </span> <span class="PreProc">var</span> done?/eax: boolean <span class="Special"><-</span> <a href='../123slice.subx.html#L9'>slice-empty?</a> word +<span id="L70" class="LineNr"> 70 </span> compare done?, <span class="Constant">0</span> +<span id="L71" class="LineNr"> 71 </span> <span class="PreProc">break-if-!=</span> +<span id="L72" class="LineNr"> 72 </span> <span class="muComment"># if word is an operator, perform it</span> +<span id="L73" class="LineNr"> 73 </span> <span class="Delimiter">{</span> +<span id="L74" class="LineNr"> 74 </span> <span class="PreProc">var</span> is-add?/eax: boolean <span class="Special"><-</span> <a href='../123slice.subx.html#L120'>slice-equal?</a> word, <span class="Constant">"+"</span> +<span id="L75" class="LineNr"> 75 </span> compare is-add?, <span class="Constant">0</span> +<span id="L76" class="LineNr"> 76 </span> <span class="PreProc">break-if-=</span> +<span id="L77" class="LineNr"> 77 </span> <span class="PreProc">var</span> _b/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L135'>pop-int-stack</a> stack +<span id="L78" class="LineNr"> 78 </span> <span class="PreProc">var</span> b/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy _b +<span id="L79" class="LineNr"> 79 </span> <span class="PreProc">var</span> a/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L135'>pop-int-stack</a> stack +<span id="L80" class="LineNr"> 80 </span> a <span class="Special"><-</span> add b +<span id="L81" class="LineNr"> 81 </span> <a href='rpn.mu.html#L123'>push-int-stack</a> stack, a +<span id="L82" class="LineNr"> 82 </span> <span class="PreProc">loop</span> $simplify:word-loop +<span id="L83" class="LineNr"> 83 </span> <span class="Delimiter">}</span> +<span id="L84" class="LineNr"> 84 </span> <span class="Delimiter">{</span> +<span id="L85" class="LineNr"> 85 </span> <span class="PreProc">var</span> is-sub?/eax: boolean <span class="Special"><-</span> <a href='../123slice.subx.html#L120'>slice-equal?</a> word, <span class="Constant">"-"</span> +<span id="L86" class="LineNr"> 86 </span> compare is-sub?, <span class="Constant">0</span> +<span id="L87" class="LineNr"> 87 </span> <span class="PreProc">break-if-=</span> +<span id="L88" class="LineNr"> 88 </span> <span class="PreProc">var</span> _b/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L135'>pop-int-stack</a> stack +<span id="L89" class="LineNr"> 89 </span> <span class="PreProc">var</span> b/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy _b +<span id="L90" class="LineNr"> 90 </span> <span class="PreProc">var</span> a/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L135'>pop-int-stack</a> stack +<span id="L91" class="LineNr"> 91 </span> a <span class="Special"><-</span> subtract b +<span id="L92" class="LineNr"> 92 </span> <a href='rpn.mu.html#L123'>push-int-stack</a> stack, a +<span id="L93" class="LineNr"> 93 </span> <span class="PreProc">loop</span> $simplify:word-loop +<span id="L94" class="LineNr"> 94 </span> <span class="Delimiter">}</span> +<span id="L95" class="LineNr"> 95 </span> <span class="Delimiter">{</span> +<span id="L96" class="LineNr"> 96 </span> <span class="PreProc">var</span> is-mul?/eax: boolean <span class="Special"><-</span> <a href='../123slice.subx.html#L120'>slice-equal?</a> word, <span class="Constant">"*"</span> +<span id="L97" class="LineNr"> 97 </span> compare is-mul?, <span class="Constant">0</span> +<span id="L98" class="LineNr"> 98 </span> <span class="PreProc">break-if-=</span> +<span id="L99" class="LineNr"> 99 </span> <span class="PreProc">var</span> _b/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L135'>pop-int-stack</a> stack +<span id="L100" class="LineNr">100 </span> <span class="PreProc">var</span> b/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy _b +<span id="L101" class="LineNr">101 </span> <span class="PreProc">var</span> a/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L135'>pop-int-stack</a> stack +<span id="L102" class="LineNr">102 </span> a <span class="Special"><-</span> multiply b +<span id="L103" class="LineNr">103 </span> <a href='rpn.mu.html#L123'>push-int-stack</a> stack, a +<span id="L104" class="LineNr">104 </span> <span class="PreProc">loop</span> $simplify:word-loop +<span id="L105" class="LineNr">105 </span> <span class="Delimiter">}</span> +<span id="L106" class="LineNr">106 </span> <span class="muComment"># otherwise it's an int</span> +<span id="L107" class="LineNr">107 </span> <span class="PreProc">var</span> n/eax: int <span class="Special"><-</span> <a href='../311decimal-int.subx.html#L4'>parse-decimal-int-from-slice</a> word +<span id="L108" class="LineNr">108 </span> <a href='rpn.mu.html#L123'>push-int-stack</a> stack, n +<span id="L109" class="LineNr">109 </span> <span class="PreProc">loop</span> +<span id="L110" class="LineNr">110 </span> <span class="Delimiter">}</span> +<span id="L111" class="LineNr">111 </span> <span class="PreProc">var</span> result/eax: int <span class="Special"><-</span> <a href='rpn.mu.html#L135'>pop-int-stack</a> stack +<span id="L112" class="LineNr">112 </span> <span class="PreProc">return</span> result +<span id="L113" class="LineNr">113 </span><span class="Delimiter">}</span> +<span id="L114" class="LineNr">114 </span> +<span id="L115" class="LineNr">115 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='rpn.mu.html#L115'>initialize-int-stack</a></span> _self: (addr <a href='rpn.mu.html#L56'>int-stack</a>), n: int <span class="Delimiter">{</span> +<span id="L116" class="LineNr">116 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='rpn.mu.html#L56'>int-stack</a>) <span class="Special"><-</span> copy _self +<span id="L117" class="LineNr">117 </span> <span class="PreProc">var</span> d/<span class="muRegEdi">edi</span>: (addr handle array int) <span class="Special"><-</span> get self, data +<span id="L118" class="LineNr">118 </span> populate d, n +<span id="L119" class="LineNr">119 </span> <span class="PreProc">var</span> top/eax: (addr int) <span class="Special"><-</span> get self, top +<span id="L120" class="LineNr">120 </span> copy-to *top, <span class="Constant">0</span> +<span id="L121" class="LineNr">121 </span><span class="Delimiter">}</span> +<span id="L122" class="LineNr">122 </span> +<span id="L123" class="LineNr">123 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='rpn.mu.html#L123'>push-int-stack</a></span> _self: (addr <a href='rpn.mu.html#L56'>int-stack</a>), _val: int <span class="Delimiter">{</span> +<span id="L124" class="LineNr">124 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='rpn.mu.html#L56'>int-stack</a>) <span class="Special"><-</span> copy _self +<span id="L125" class="LineNr">125 </span> <span class="PreProc">var</span> top-addr/<span class="muRegEcx">ecx</span>: (addr int) <span class="Special"><-</span> get self, top +<span id="L126" class="LineNr">126 </span> <span class="PreProc">var</span> data-ah/<span class="muRegEdx">edx</span>: (addr handle array int) <span class="Special"><-</span> get self, data +<span id="L127" class="LineNr">127 </span> <span class="PreProc">var</span> data/eax: (addr array int) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *data-ah +<span id="L128" class="LineNr">128 </span> <span class="PreProc">var</span> top/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy *top-addr +<span id="L129" class="LineNr">129 </span> <span class="PreProc">var</span> dest-addr/<span class="muRegEdx">edx</span>: (addr int) <span class="Special"><-</span> index data, top +<span id="L130" class="LineNr">130 </span> <span class="PreProc">var</span> val/eax: int <span class="Special"><-</span> copy _val +<span id="L131" class="LineNr">131 </span> copy-to *dest-addr, val +<span id="L132" class="LineNr">132 </span> add-to *top-addr, <span class="Constant">1</span> +<span id="L133" class="LineNr">133 </span><span class="Delimiter">}</span> +<span id="L134" class="LineNr">134 </span> +<span id="L135" class="LineNr">135 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='rpn.mu.html#L135'>pop-int-stack</a></span> _self: (addr <a href='rpn.mu.html#L56'>int-stack</a>)<span class="PreProc"> -> </span>_/eax: int <span class="Delimiter">{</span> +<span id="L136" class="LineNr">136 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='rpn.mu.html#L56'>int-stack</a>) <span class="Special"><-</span> copy _self +<span id="L137" class="LineNr">137 </span> <span class="PreProc">var</span> top-addr/<span class="muRegEcx">ecx</span>: (addr int) <span class="Special"><-</span> get self, top +<span id="L138" class="LineNr">138 </span> <span class="Delimiter">{</span> +<span id="L139" class="LineNr">139 </span> compare *top-addr, <span class="Constant">0</span> +<span id="L140" class="LineNr">140 </span> <span class="PreProc">break-if-></span> +<span id="L141" class="LineNr">141 </span> <span class="PreProc">return</span> <span class="Constant">0</span> +<span id="L142" class="LineNr">142 </span> <span class="Delimiter">}</span> +<span id="L143" class="LineNr">143 </span> subtract-from *top-addr, <span class="Constant">1</span> +<span id="L144" class="LineNr">144 </span> <span class="PreProc">var</span> data-ah/<span class="muRegEdx">edx</span>: (addr handle array int) <span class="Special"><-</span> get self, data +<span id="L145" class="LineNr">145 </span> <span class="PreProc">var</span> data/eax: (addr array int) <span class="Special"><-</span> <a href='../120allocate.subx.html#L235'>lookup</a> *data-ah +<span id="L146" class="LineNr">146 </span> <span class="PreProc">var</span> top/<span class="muRegEdx">edx</span>: int <span class="Special"><-</span> copy *top-addr +<span id="L147" class="LineNr">147 </span> <span class="PreProc">var</span> result-addr/eax: (addr int) <span class="Special"><-</span> index data, top +<span id="L148" class="LineNr">148 </span> <span class="PreProc">var</span> val/eax: int <span class="Special"><-</span> copy *result-addr +<span id="L149" class="LineNr">149 </span> <span class="PreProc">return</span> val +<span id="L150" class="LineNr">150 </span><span class="Delimiter">}</span> </pre> </body> </html> |