diff options
author | Kartik Agaram <vc@akkartik.com> | 2021-02-13 18:18:05 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2021-02-13 18:41:43 -0800 |
commit | 535fe9ac96dba0950efd1bfe6788801f6197971f (patch) | |
tree | 218270b512ce4175e3c7e3394d7b1a19ad84184b /html/baremetal | |
parent | 9b5ead67eca1b6e1afeeba63e9c68b2790c26436 (diff) | |
download | mu-535fe9ac96dba0950efd1bfe6788801f6197971f.tar.gz |
7737
Diffstat (limited to 'html/baremetal')
36 files changed, 5949 insertions, 2237 deletions
diff --git a/html/baremetal/103grapheme.subx.html b/html/baremetal/103grapheme.subx.html index 1d159d1a..f7157766 100644 --- a/html/baremetal/103grapheme.subx.html +++ b/html/baremetal/103grapheme.subx.html @@ -69,162 +69,165 @@ if ('onhashchange' in window) { <span id="L12" class="LineNr"> 12 </span><span class="subxComment"># The Mu computer's screen is 1024px wide and 768px tall.</span> <span id="L13" class="LineNr"> 13 </span><span class="subxComment"># The Mu computer's font is 8px wide and 16px tall.</span> <span id="L14" class="LineNr"> 14 </span><span class="subxComment"># Therefore 'x' here is in [0, 128), and 'y' is in [0, 48)</span> -<span id="L15" class="LineNr"> 15 </span><span class="subxFunction">draw-grapheme-on-real-screen</span>: <span class="subxComment"># g: grapheme, x: int, y: int, color: int, background-color: int</span> -<span id="L16" class="LineNr"> 16 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L17" class="LineNr"> 17 </span> 55/push-ebp -<span id="L18" class="LineNr"> 18 </span> 89/<- %ebp 4/r32/esp -<span id="L19" class="LineNr"> 19 </span> <span class="subxS1Comment"># . save registers</span> -<span id="L20" class="LineNr"> 20 </span> 50/push-eax -<span id="L21" class="LineNr"> 21 </span> 51/push-ecx -<span id="L22" class="LineNr"> 22 </span> 52/push-edx -<span id="L23" class="LineNr"> 23 </span> 53/push-ebx -<span id="L24" class="LineNr"> 24 </span> 56/push-esi -<span id="L25" class="LineNr"> 25 </span> <span class="subxComment"># var letter-bitmap/esi = font[g]</span> -<span id="L26" class="LineNr"> 26 </span> 8b/-> *(ebp+8) 6/r32/esi -<span id="L27" class="LineNr"> 27 </span> c1 4/subop/shift-left %esi 4/imm8 -<span id="L28" class="LineNr"> 28 </span> 8d/copy-address *(esi+0x8c00) 6/r32/esi <span class="subxComment"># font-start</span> -<span id="L29" class="LineNr"> 29 </span> <span class="subxComment"># if (letter-bitmap >= 0x9400) return # characters beyond ASCII currently not supported</span> -<span id="L30" class="LineNr"> 30 </span> 81 7/subop/compare %esi 0x9400/imm32 -<span id="L31" class="LineNr"> 31 </span> 7d/jump-if->= $draw-grapheme-on-real-screen:end/disp8 -<span id="L32" class="LineNr"> 32 </span> <span class="subxComment"># var ycurr/edx: int = y*16</span> -<span id="L33" class="LineNr"> 33 </span> 8b/-> *(ebp+0x10) 2/r32/edx -<span id="L34" class="LineNr"> 34 </span> c1 4/subop/shift-left %edx 4/imm8 -<span id="L35" class="LineNr"> 35 </span> <span class="subxComment"># var ymax/ebx: int = ycurr + 16</span> -<span id="L36" class="LineNr"> 36 </span> 8b/-> *(ebp+0x10) 3/r32/ebx -<span id="L37" class="LineNr"> 37 </span> c1 4/subop/shift-left %ebx 4/imm8 -<span id="L38" class="LineNr"> 38 </span> 81 0/subop/add %ebx 0x10/imm32 -<span id="L39" class="LineNr"> 39 </span> { -<span id="L40" class="LineNr"> 40 </span> <span class="subxComment"># if (ycurr >= ymax) break</span> -<span id="L41" class="LineNr"> 41 </span> 39/compare %edx 3/r32/ebx -<span id="L42" class="LineNr"> 42 </span> 7d/jump-if->= <span class="Constant">break</span>/disp8 -<span id="L43" class="LineNr"> 43 </span> <span class="subxComment"># var xcurr/eax: int = x*8 + 7</span> -<span id="L44" class="LineNr"> 44 </span> 8b/-> *(ebp+0xc) 0/r32/eax <span class="subxComment"># font-width - 1</span> -<span id="L45" class="LineNr"> 45 </span> c1 4/subop/shift-left %eax 3/imm8 -<span id="L46" class="LineNr"> 46 </span> 81 0/subop/add %eax 7/imm32 -<span id="L47" class="LineNr"> 47 </span> <span class="subxComment"># var xmin/ecx: int = x*8</span> -<span id="L48" class="LineNr"> 48 </span> 8b/-> *(ebp+0xc) 1/r32/ecx -<span id="L49" class="LineNr"> 49 </span> c1 4/subop/shift-left %ecx 3/imm8 -<span id="L50" class="LineNr"> 50 </span> <span class="subxComment"># var row-bitmap/ebx: int = *letter-bitmap</span> -<span id="L51" class="LineNr"> 51 </span> 53/push-ebx -<span id="L52" class="LineNr"> 52 </span> 8b/-> *esi 3/r32/ebx -<span id="L53" class="LineNr"> 53 </span> { -<span id="L54" class="LineNr"> 54 </span> <span class="subxComment"># if (xcurr < xmin) break</span> -<span id="L55" class="LineNr"> 55 </span> 39/compare %eax 1/r32/ecx -<span id="L56" class="LineNr"> 56 </span> 7c/jump-if-< <span class="Constant">break</span>/disp8 -<span id="L57" class="LineNr"> 57 </span> <span class="subxComment"># shift LSB from row-bitmap into carry flag (CF)</span> -<span id="L58" class="LineNr"> 58 </span> c1 5/subop/shift-right-logical %ebx 1/imm8 -<span id="L59" class="LineNr"> 59 </span> <span class="subxComment"># if LSB, draw a pixel in the given color</span> -<span id="L60" class="LineNr"> 60 </span> { -<span id="L61" class="LineNr"> 61 </span> 73/jump-if-not-CF <span class="Constant">break</span>/disp8 -<span id="L62" class="LineNr"> 62 </span> (<a href='101screen.subx.html#L8'>pixel-on-real-screen</a> %eax %edx *(ebp+0x14)) -<span id="L63" class="LineNr"> 63 </span> eb/jump $draw-grapheme-on-real-screen:continue/disp8 -<span id="L64" class="LineNr"> 64 </span> } -<span id="L65" class="LineNr"> 65 </span> <span class="subxComment"># otherwise use the background color</span> -<span id="L66" class="LineNr"> 66 </span> (<a href='101screen.subx.html#L8'>pixel-on-real-screen</a> %eax %edx *(ebp+0x18)) -<span id="L67" class="LineNr"> 67 </span><span class="Constant">$draw-grapheme-on-real-screen:continue</span>: -<span id="L68" class="LineNr"> 68 </span> <span class="subxComment"># --x</span> -<span id="L69" class="LineNr"> 69 </span> 48/decrement-eax -<span id="L70" class="LineNr"> 70 </span> <span class="subxComment">#</span> -<span id="L71" class="LineNr"> 71 </span> eb/jump <span class="Constant">loop</span>/disp8 -<span id="L72" class="LineNr"> 72 </span> } -<span id="L73" class="LineNr"> 73 </span> <span class="subxComment"># reclaim row-bitmap</span> -<span id="L74" class="LineNr"> 74 </span> 5b/pop-to-ebx -<span id="L75" class="LineNr"> 75 </span> <span class="subxComment"># ++y</span> -<span id="L76" class="LineNr"> 76 </span> 42/increment-edx -<span id="L77" class="LineNr"> 77 </span> <span class="subxComment"># next bitmap row</span> -<span id="L78" class="LineNr"> 78 </span> 46/increment-esi -<span id="L79" class="LineNr"> 79 </span> <span class="subxComment">#</span> -<span id="L80" class="LineNr"> 80 </span> eb/jump <span class="Constant">loop</span>/disp8 -<span id="L81" class="LineNr"> 81 </span> } -<span id="L82" class="LineNr"> 82 </span><span class="Constant">$draw-grapheme-on-real-screen:end</span>: -<span id="L83" class="LineNr"> 83 </span> <span class="subxS1Comment"># . restore registers</span> -<span id="L84" class="LineNr"> 84 </span> 5e/pop-to-esi -<span id="L85" class="LineNr"> 85 </span> 5b/pop-to-ebx -<span id="L86" class="LineNr"> 86 </span> 5a/pop-to-edx -<span id="L87" class="LineNr"> 87 </span> 59/pop-to-ecx -<span id="L88" class="LineNr"> 88 </span> 58/pop-to-eax -<span id="L89" class="LineNr"> 89 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L90" class="LineNr"> 90 </span> 89/<- %esp 5/r32/ebp -<span id="L91" class="LineNr"> 91 </span> 5d/pop-to-ebp -<span id="L92" class="LineNr"> 92 </span> c3/return -<span id="L93" class="LineNr"> 93 </span> -<span id="L94" class="LineNr"> 94 </span><span class="subxFunction">cursor-position-on-real-screen</span>: <span class="subxComment"># -> _/eax: int, _/ecx: int</span> -<span id="L95" class="LineNr"> 95 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L96" class="LineNr"> 96 </span> 55/push-ebp -<span id="L97" class="LineNr"> 97 </span> 89/<- %ebp 4/r32/esp -<span id="L98" class="LineNr"> 98 </span> <span class="subxComment"># TODO: support fake screen; we currently assume 'screen' is always 0 (real)</span> -<span id="L99" class="LineNr"> 99 </span> 8b/-> *<span class="SpecialChar"><a href='103grapheme.subx.html#L167'>Real-screen-cursor-x</a></span> 0/r32/eax -<span id="L100" class="LineNr">100 </span> 8b/-> *<span class="SpecialChar"><a href='103grapheme.subx.html#L169'>Real-screen-cursor-y</a></span> 1/r32/ecx -<span id="L101" class="LineNr">101 </span><span class="Constant">$cursor-position-on-real-screen:end</span>: -<span id="L102" class="LineNr">102 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L103" class="LineNr">103 </span> 89/<- %esp 5/r32/ebp -<span id="L104" class="LineNr">104 </span> 5d/pop-to-ebp -<span id="L105" class="LineNr">105 </span> c3/return -<span id="L106" class="LineNr">106 </span> -<span id="L107" class="LineNr">107 </span><span class="subxFunction">set-cursor-position-on-real-screen</span>: <span class="subxComment"># x: int, y: int</span> -<span id="L108" class="LineNr">108 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L109" class="LineNr">109 </span> 55/push-ebp -<span id="L110" class="LineNr">110 </span> 89/<- %ebp 4/r32/esp -<span id="L111" class="LineNr">111 </span> <span class="subxS1Comment"># . save registers</span> -<span id="L112" class="LineNr">112 </span> 50/push-eax -<span id="L113" class="LineNr">113 </span> <span class="subxComment">#</span> -<span id="L114" class="LineNr">114 </span> 8b/-> *(ebp+8) 0/r32/eax -<span id="L115" class="LineNr">115 </span> 89/<- *<span class="SpecialChar"><a href='103grapheme.subx.html#L167'>Real-screen-cursor-x</a></span> 0/r32/eax -<span id="L116" class="LineNr">116 </span> 8b/-> *(ebp+0xc) 0/r32/eax -<span id="L117" class="LineNr">117 </span> 89/<- *<span class="SpecialChar"><a href='103grapheme.subx.html#L169'>Real-screen-cursor-y</a></span> 0/r32/eax -<span id="L118" class="LineNr">118 </span><span class="Constant">$set-cursor-position-on-real-screen:end</span>: -<span id="L119" class="LineNr">119 </span> <span class="subxS1Comment"># . restore registers</span> -<span id="L120" class="LineNr">120 </span> 58/pop-to-eax -<span id="L121" class="LineNr">121 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L122" class="LineNr">122 </span> 89/<- %esp 5/r32/ebp -<span id="L123" class="LineNr">123 </span> 5d/pop-to-ebp -<span id="L124" class="LineNr">124 </span> c3/return -<span id="L125" class="LineNr">125 </span> -<span id="L126" class="LineNr">126 </span><span class="subxComment"># Draw cursor at current location. But this is rickety:</span> -<span id="L127" class="LineNr">127 </span><span class="subxComment"># - does not clear previous location cursor was shown at.</span> -<span id="L128" class="LineNr">128 </span><span class="subxComment"># - does not preserve what was at the cursor. Caller is responsible for</span> -<span id="L129" class="LineNr">129 </span><span class="subxComment"># tracking what was on the screen at this position before and passing it</span> -<span id="L130" class="LineNr">130 </span><span class="subxComment"># in again.</span> -<span id="L131" class="LineNr">131 </span><span class="subxFunction">show-cursor-on-real-screen</span>: <span class="subxComment"># g: grapheme</span> -<span id="L132" class="LineNr">132 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L133" class="LineNr">133 </span> 55/push-ebp -<span id="L134" class="LineNr">134 </span> 89/<- %ebp 4/r32/esp -<span id="L135" class="LineNr">135 </span> <span class="subxS1Comment"># . save registers</span> -<span id="L136" class="LineNr">136 </span> 50/push-eax -<span id="L137" class="LineNr">137 </span> 51/push-ecx -<span id="L138" class="LineNr">138 </span> <span class="subxComment">#</span> -<span id="L139" class="LineNr">139 </span> (<a href='103grapheme.subx.html#L94'>cursor-position-on-real-screen</a>) <span class="subxComment"># => eax, ecx</span> -<span id="L140" class="LineNr">140 </span> (<a href='103grapheme.subx.html#L15'>draw-grapheme-on-real-screen</a> *(ebp+8) %eax %ecx 0 7) -<span id="L141" class="LineNr">141 </span><span class="Constant">$show-cursor-on-real-screen:end</span>: -<span id="L142" class="LineNr">142 </span> <span class="subxS1Comment"># . restore registers</span> -<span id="L143" class="LineNr">143 </span> 59/pop-to-ecx -<span id="L144" class="LineNr">144 </span> 58/pop-to-eax -<span id="L145" class="LineNr">145 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L146" class="LineNr">146 </span> 89/<- %esp 5/r32/ebp -<span id="L147" class="LineNr">147 </span> 5d/pop-to-ebp -<span id="L148" class="LineNr">148 </span> c3/return -<span id="L149" class="LineNr">149 </span> -<span id="L150" class="LineNr">150 </span>== data -<span id="L151" class="LineNr">151 </span> -<span id="L152" class="LineNr">152 </span><span class="subxComment"># The cursor is where certain Mu functions (usually of the form</span> -<span id="L153" class="LineNr">153 </span><span class="subxComment"># 'draw*cursor*') print to by default.</span> -<span id="L154" class="LineNr">154 </span><span class="subxComment">#</span> -<span id="L155" class="LineNr">155 </span><span class="subxComment"># We don't bother displaying the cursor when drawing. It only becomes visible</span> -<span id="L156" class="LineNr">156 </span><span class="subxComment"># on show-cursor, which is quite rickety (see above)</span> +<span id="L15" class="LineNr"> 15 </span><span class="subxComment"># Doesn't update the cursor; where the cursor should go after printing the</span> +<span id="L16" class="LineNr"> 16 </span><span class="subxComment"># current grapheme is a higher-level concern.</span> +<span id="L17" class="LineNr"> 17 </span><span class="subxFunction">draw-grapheme-on-real-screen</span>: <span class="subxComment"># g: grapheme, x: int, y: int, color: int, background-color: int</span> +<span id="L18" class="LineNr"> 18 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L19" class="LineNr"> 19 </span> 55/push-ebp +<span id="L20" class="LineNr"> 20 </span> 89/<- %ebp 4/r32/esp +<span id="L21" class="LineNr"> 21 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L22" class="LineNr"> 22 </span> 50/push-eax +<span id="L23" class="LineNr"> 23 </span> 51/push-ecx +<span id="L24" class="LineNr"> 24 </span> 52/push-edx +<span id="L25" class="LineNr"> 25 </span> 53/push-ebx +<span id="L26" class="LineNr"> 26 </span> 56/push-esi +<span id="L27" class="LineNr"> 27 </span> <span class="subxComment"># var letter-bitmap/esi = font[g]</span> +<span id="L28" class="LineNr"> 28 </span> 8b/-> *(ebp+8) 6/r32/esi +<span id="L29" class="LineNr"> 29 </span> c1 4/subop/shift-left %esi 4/imm8 +<span id="L30" class="LineNr"> 30 </span> 8d/copy-address *(esi+0x8c00) 6/r32/esi <span class="subxComment"># font-start</span> +<span id="L31" class="LineNr"> 31 </span> <span class="subxComment"># if (letter-bitmap >= 0x9400) return # characters beyond ASCII currently not supported</span> +<span id="L32" class="LineNr"> 32 </span> 81 7/subop/compare %esi 0x9400/imm32 +<span id="L33" class="LineNr"> 33 </span> 7d/jump-if->= $draw-grapheme-on-real-screen:end/disp8 +<span id="L34" class="LineNr"> 34 </span> <span class="subxComment"># var ycurr/edx: int = y*16</span> +<span id="L35" class="LineNr"> 35 </span> 8b/-> *(ebp+0x10) 2/r32/edx +<span id="L36" class="LineNr"> 36 </span> c1 4/subop/shift-left %edx 4/imm8 +<span id="L37" class="LineNr"> 37 </span> <span class="subxComment"># var ymax/ebx: int = ycurr + 16</span> +<span id="L38" class="LineNr"> 38 </span> 8b/-> *(ebp+0x10) 3/r32/ebx +<span id="L39" class="LineNr"> 39 </span> c1 4/subop/shift-left %ebx 4/imm8 +<span id="L40" class="LineNr"> 40 </span> 81 0/subop/add %ebx 0x10/imm32 +<span id="L41" class="LineNr"> 41 </span> { +<span id="L42" class="LineNr"> 42 </span> <span class="subxComment"># if (ycurr >= ymax) break</span> +<span id="L43" class="LineNr"> 43 </span> 39/compare %edx 3/r32/ebx +<span id="L44" class="LineNr"> 44 </span> 7d/jump-if->= <span class="Constant">break</span>/disp8 +<span id="L45" class="LineNr"> 45 </span> <span class="subxComment"># var xcurr/eax: int = x*8 + 7</span> +<span id="L46" class="LineNr"> 46 </span> 8b/-> *(ebp+0xc) 0/r32/eax <span class="subxComment"># font-width - 1</span> +<span id="L47" class="LineNr"> 47 </span> c1 4/subop/shift-left %eax 3/imm8 +<span id="L48" class="LineNr"> 48 </span> 81 0/subop/add %eax 7/imm32 +<span id="L49" class="LineNr"> 49 </span> <span class="subxComment"># var xmin/ecx: int = x*8</span> +<span id="L50" class="LineNr"> 50 </span> 8b/-> *(ebp+0xc) 1/r32/ecx +<span id="L51" class="LineNr"> 51 </span> c1 4/subop/shift-left %ecx 3/imm8 +<span id="L52" class="LineNr"> 52 </span> <span class="subxComment"># var row-bitmap/ebx: int = *letter-bitmap</span> +<span id="L53" class="LineNr"> 53 </span> 53/push-ebx +<span id="L54" class="LineNr"> 54 </span> 8b/-> *esi 3/r32/ebx +<span id="L55" class="LineNr"> 55 </span> { +<span id="L56" class="LineNr"> 56 </span> <span class="subxComment"># if (xcurr < xmin) break</span> +<span id="L57" class="LineNr"> 57 </span> 39/compare %eax 1/r32/ecx +<span id="L58" class="LineNr"> 58 </span> 7c/jump-if-< <span class="Constant">break</span>/disp8 +<span id="L59" class="LineNr"> 59 </span> <span class="subxComment"># shift LSB from row-bitmap into carry flag (CF)</span> +<span id="L60" class="LineNr"> 60 </span> c1 5/subop/shift-right-logical %ebx 1/imm8 +<span id="L61" class="LineNr"> 61 </span> <span class="subxComment"># if LSB, draw a pixel in the given color</span> +<span id="L62" class="LineNr"> 62 </span> { +<span id="L63" class="LineNr"> 63 </span> 73/jump-if-not-CF <span class="Constant">break</span>/disp8 +<span id="L64" class="LineNr"> 64 </span> (<a href='101screen.subx.html#L8'>pixel-on-real-screen</a> %eax %edx *(ebp+0x14)) +<span id="L65" class="LineNr"> 65 </span> eb/jump $draw-grapheme-on-real-screen:continue/disp8 +<span id="L66" class="LineNr"> 66 </span> } +<span id="L67" class="LineNr"> 67 </span> <span class="subxComment"># otherwise use the background color</span> +<span id="L68" class="LineNr"> 68 </span> (<a href='101screen.subx.html#L8'>pixel-on-real-screen</a> %eax %edx *(ebp+0x18)) +<span id="L69" class="LineNr"> 69 </span><span class="Constant">$draw-grapheme-on-real-screen:continue</span>: +<span id="L70" class="LineNr"> 70 </span> <span class="subxComment"># --x</span> +<span id="L71" class="LineNr"> 71 </span> 48/decrement-eax +<span id="L72" class="LineNr"> 72 </span> <span class="subxComment">#</span> +<span id="L73" class="LineNr"> 73 </span> eb/jump <span class="Constant">loop</span>/disp8 +<span id="L74" class="LineNr"> 74 </span> } +<span id="L75" class="LineNr"> 75 </span> <span class="subxComment"># reclaim row-bitmap</span> +<span id="L76" class="LineNr"> 76 </span> 5b/pop-to-ebx +<span id="L77" class="LineNr"> 77 </span> <span class="subxComment"># ++y</span> +<span id="L78" class="LineNr"> 78 </span> 42/increment-edx +<span id="L79" class="LineNr"> 79 </span> <span class="subxComment"># next bitmap row</span> +<span id="L80" class="LineNr"> 80 </span> 46/increment-esi +<span id="L81" class="LineNr"> 81 </span> <span class="subxComment">#</span> +<span id="L82" class="LineNr"> 82 </span> eb/jump <span class="Constant">loop</span>/disp8 +<span id="L83" class="LineNr"> 83 </span> } +<span id="L84" class="LineNr"> 84 </span><span class="Constant">$draw-grapheme-on-real-screen:end</span>: +<span id="L85" class="LineNr"> 85 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L86" class="LineNr"> 86 </span> 5e/pop-to-esi +<span id="L87" class="LineNr"> 87 </span> 5b/pop-to-ebx +<span id="L88" class="LineNr"> 88 </span> 5a/pop-to-edx +<span id="L89" class="LineNr"> 89 </span> 59/pop-to-ecx +<span id="L90" class="LineNr"> 90 </span> 58/pop-to-eax +<span id="L91" class="LineNr"> 91 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L92" class="LineNr"> 92 </span> 89/<- %esp 5/r32/ebp +<span id="L93" class="LineNr"> 93 </span> 5d/pop-to-ebp +<span id="L94" class="LineNr"> 94 </span> c3/return +<span id="L95" class="LineNr"> 95 </span> +<span id="L96" class="LineNr"> 96 </span><span class="subxFunction">cursor-position-on-real-screen</span>: <span class="subxComment"># -> _/eax: int, _/ecx: int</span> +<span id="L97" class="LineNr"> 97 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L98" class="LineNr"> 98 </span> 55/push-ebp +<span id="L99" class="LineNr"> 99 </span> 89/<- %ebp 4/r32/esp +<span id="L100" class="LineNr">100 </span> <span class="subxComment"># TODO: support fake screen; we currently assume 'screen' is always 0 (real)</span> +<span id="L101" class="LineNr">101 </span> 8b/-> *<span class="SpecialChar"><a href='103grapheme.subx.html#L170'>Real-screen-cursor-x</a></span> 0/r32/eax +<span id="L102" class="LineNr">102 </span> 8b/-> *<span class="SpecialChar"><a href='103grapheme.subx.html#L172'>Real-screen-cursor-y</a></span> 1/r32/ecx +<span id="L103" class="LineNr">103 </span><span class="Constant">$cursor-position-on-real-screen:end</span>: +<span id="L104" class="LineNr">104 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L105" class="LineNr">105 </span> 89/<- %esp 5/r32/ebp +<span id="L106" class="LineNr">106 </span> 5d/pop-to-ebp +<span id="L107" class="LineNr">107 </span> c3/return +<span id="L108" class="LineNr">108 </span> +<span id="L109" class="LineNr">109 </span><span class="subxFunction">set-cursor-position-on-real-screen</span>: <span class="subxComment"># x: int, y: int</span> +<span id="L110" class="LineNr">110 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L111" class="LineNr">111 </span> 55/push-ebp +<span id="L112" class="LineNr">112 </span> 89/<- %ebp 4/r32/esp +<span id="L113" class="LineNr">113 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L114" class="LineNr">114 </span> 50/push-eax +<span id="L115" class="LineNr">115 </span> <span class="subxComment">#</span> +<span id="L116" class="LineNr">116 </span> 8b/-> *(ebp+8) 0/r32/eax +<span id="L117" class="LineNr">117 </span> 89/<- *<span class="SpecialChar"><a href='103grapheme.subx.html#L170'>Real-screen-cursor-x</a></span> 0/r32/eax +<span id="L118" class="LineNr">118 </span> 8b/-> *(ebp+0xc) 0/r32/eax +<span id="L119" class="LineNr">119 </span> 89/<- *<span class="SpecialChar"><a href='103grapheme.subx.html#L172'>Real-screen-cursor-y</a></span> 0/r32/eax +<span id="L120" class="LineNr">120 </span><span class="Constant">$set-cursor-position-on-real-screen:end</span>: +<span id="L121" class="LineNr">121 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L122" class="LineNr">122 </span> 58/pop-to-eax +<span id="L123" class="LineNr">123 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L124" class="LineNr">124 </span> 89/<- %esp 5/r32/ebp +<span id="L125" class="LineNr">125 </span> 5d/pop-to-ebp +<span id="L126" class="LineNr">126 </span> c3/return +<span id="L127" class="LineNr">127 </span> +<span id="L128" class="LineNr">128 </span><span class="subxComment"># Draw cursor at current location. But this is rickety:</span> +<span id="L129" class="LineNr">129 </span><span class="subxComment"># - does not clear previous location cursor was shown at.</span> +<span id="L130" class="LineNr">130 </span><span class="subxComment"># - does not preserve what was at the cursor. Caller is responsible for</span> +<span id="L131" class="LineNr">131 </span><span class="subxComment"># tracking what was on the screen at this position before and passing it</span> +<span id="L132" class="LineNr">132 </span><span class="subxComment"># in again.</span> +<span id="L133" class="LineNr">133 </span><span class="subxComment"># - does not stop showing the cursor at this location when the cursor moves</span> +<span id="L134" class="LineNr">134 </span><span class="subxFunction">show-cursor-on-real-screen</span>: <span class="subxComment"># g: grapheme</span> +<span id="L135" class="LineNr">135 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L136" class="LineNr">136 </span> 55/push-ebp +<span id="L137" class="LineNr">137 </span> 89/<- %ebp 4/r32/esp +<span id="L138" class="LineNr">138 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L139" class="LineNr">139 </span> 50/push-eax +<span id="L140" class="LineNr">140 </span> 51/push-ecx +<span id="L141" class="LineNr">141 </span> <span class="subxComment">#</span> +<span id="L142" class="LineNr">142 </span> (<a href='103grapheme.subx.html#L96'>cursor-position-on-real-screen</a>) <span class="subxComment"># => eax, ecx</span> +<span id="L143" class="LineNr">143 </span> (<a href='103grapheme.subx.html#L17'>draw-grapheme-on-real-screen</a> *(ebp+8) %eax %ecx 0 7) +<span id="L144" class="LineNr">144 </span><span class="Constant">$show-cursor-on-real-screen:end</span>: +<span id="L145" class="LineNr">145 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L146" class="LineNr">146 </span> 59/pop-to-ecx +<span id="L147" class="LineNr">147 </span> 58/pop-to-eax +<span id="L148" class="LineNr">148 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L149" class="LineNr">149 </span> 89/<- %esp 5/r32/ebp +<span id="L150" class="LineNr">150 </span> 5d/pop-to-ebp +<span id="L151" class="LineNr">151 </span> c3/return +<span id="L152" class="LineNr">152 </span> +<span id="L153" class="LineNr">153 </span>== data +<span id="L154" class="LineNr">154 </span> +<span id="L155" class="LineNr">155 </span><span class="subxComment"># The cursor is where certain Mu functions (usually of the form</span> +<span id="L156" class="LineNr">156 </span><span class="subxComment"># 'draw*cursor*') print to by default.</span> <span id="L157" class="LineNr">157 </span><span class="subxComment">#</span> -<span id="L158" class="LineNr">158 </span><span class="subxComment"># It's up to applications to manage cursor display:</span> -<span id="L159" class="LineNr">159 </span><span class="subxComment"># - clean up where it used to be</span> -<span id="L160" class="LineNr">160 </span><span class="subxComment"># - display the cursor before waiting for a key</span> -<span id="L161" class="LineNr">161 </span><span class="subxComment"># - ensure its location appropriately suggests the effect keystrokes will have</span> -<span id="L162" class="LineNr">162 </span><span class="subxComment"># - ensure its contents (and colors) appropriately reflect the state of the</span> -<span id="L163" class="LineNr">163 </span><span class="subxComment"># screen</span> -<span id="L164" class="LineNr">164 </span><span class="subxComment">#</span> -<span id="L165" class="LineNr">165 </span><span class="subxComment"># There's no blinking, etc. We aren't using any hardware-supported text mode</span> -<span id="L166" class="LineNr">166 </span><span class="subxComment"># here.</span> -<span id="L167" class="LineNr">167 </span><span class="SpecialChar">Real-screen-cursor-x</span>: -<span id="L168" class="LineNr">168 </span> 0/imm32 -<span id="L169" class="LineNr">169 </span><span class="SpecialChar">Real-screen-cursor-y</span>: -<span id="L170" class="LineNr">170 </span> 0/imm32 +<span id="L158" class="LineNr">158 </span><span class="subxComment"># We don't bother displaying the cursor when drawing. It only becomes visible</span> +<span id="L159" class="LineNr">159 </span><span class="subxComment"># on show-cursor, which is quite rickety (see above)</span> +<span id="L160" class="LineNr">160 </span><span class="subxComment">#</span> +<span id="L161" class="LineNr">161 </span><span class="subxComment"># It's up to applications to manage cursor display:</span> +<span id="L162" class="LineNr">162 </span><span class="subxComment"># - clean up where it used to be</span> +<span id="L163" class="LineNr">163 </span><span class="subxComment"># - display the cursor before waiting for a key</span> +<span id="L164" class="LineNr">164 </span><span class="subxComment"># - ensure its location appropriately suggests the effect keystrokes will have</span> +<span id="L165" class="LineNr">165 </span><span class="subxComment"># - ensure its contents (and colors) appropriately reflect the state of the</span> +<span id="L166" class="LineNr">166 </span><span class="subxComment"># screen</span> +<span id="L167" class="LineNr">167 </span><span class="subxComment">#</span> +<span id="L168" class="LineNr">168 </span><span class="subxComment"># There's no blinking, etc. We aren't using any hardware-supported text mode</span> +<span id="L169" class="LineNr">169 </span><span class="subxComment"># here.</span> +<span id="L170" class="LineNr">170 </span><span class="SpecialChar">Real-screen-cursor-x</span>: +<span id="L171" class="LineNr">171 </span> 0/imm32 +<span id="L172" class="LineNr">172 </span><span class="SpecialChar">Real-screen-cursor-y</span>: +<span id="L173" class="LineNr">173 </span> 0/imm32 </pre> </body> </html> diff --git a/html/baremetal/109stream-equal.subx.html b/html/baremetal/109stream-equal.subx.html index 91702ebc..c77c609b 100644 --- a/html/baremetal/109stream-equal.subx.html +++ b/html/baremetal/109stream-equal.subx.html @@ -58,603 +58,600 @@ if ('onhashchange' in window) { <a href='https://github.com/akkartik/mu/blob/main/baremetal/109stream-equal.subx'>https://github.com/akkartik/mu/blob/main/baremetal/109stream-equal.subx</a> <pre id='vimCodeElement'> <span id="L1" class="LineNr"> 1 </span><span class="subxComment"># some primitives for checking stream contents</span> -<span id="L2" class="LineNr"> 2 </span><span class="subxComment">#</span> -<span id="L3" class="LineNr"> 3 </span><span class="subxComment"># We need to do this in machine code because streams need to be opaque types,</span> -<span id="L4" class="LineNr"> 4 </span><span class="subxComment"># and we don't yet support opaque types in Mu.</span> -<span id="L5" class="LineNr"> 5 </span> -<span id="L6" class="LineNr"> 6 </span>== code -<span id="L7" class="LineNr"> 7 </span><span class="subxComment"># instruction effective address register displacement immediate</span> -<span id="L8" class="LineNr"> 8 </span><span class="subxS1Comment"># . op subop mod rm32 base index scale r32</span> -<span id="L9" class="LineNr"> 9 </span><span class="subxS1Comment"># . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes</span> -<span id="L10" class="LineNr"> 10 </span> -<span id="L11" class="LineNr"> 11 </span><span class="subxComment"># compare all the data in a stream (ignoring the read pointer)</span> -<span id="L12" class="LineNr"> 12 </span><span class="subxFunction">stream-data-equal?</span>: <span class="subxComment"># f: (addr stream byte), s: (addr array byte) -> result/eax: boolean</span> -<span id="L13" class="LineNr"> 13 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L14" class="LineNr"> 14 </span> 55/push-ebp -<span id="L15" class="LineNr"> 15 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> -<span id="L16" class="LineNr"> 16 </span> <span class="subxS1Comment"># . save registers</span> -<span id="L17" class="LineNr"> 17 </span> 51/push-ecx -<span id="L18" class="LineNr"> 18 </span> 52/push-edx -<span id="L19" class="LineNr"> 19 </span> 56/push-esi -<span id="L20" class="LineNr"> 20 </span> 57/push-edi -<span id="L21" class="LineNr"> 21 </span> <span class="subxComment"># esi = f</span> -<span id="L22" class="LineNr"> 22 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 6/r32/esi 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+8) to esi</span> -<span id="L23" class="LineNr"> 23 </span> <span class="subxComment"># eax = f->write</span> -<span id="L24" class="LineNr"> 24 </span> 8b/copy 0/mod/indirect 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *esi to eax</span> -<span id="L25" class="LineNr"> 25 </span> <span class="subxComment"># var maxf/edx: (addr byte) = &f->data[f->write]</span> -<span id="L26" class="LineNr"> 26 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 0/index/eax <span class="Normal"> . </span> 2/r32/edx 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy esi+eax+12 to edx</span> -<span id="L27" class="LineNr"> 27 </span> <span class="subxComment"># var currf/esi: (addr byte) = f->data</span> -<span id="L28" class="LineNr"> 28 </span> 81 0/subop/add 3/mod/direct 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esi</span> -<span id="L29" class="LineNr"> 29 </span> <span class="subxComment"># edi = s</span> -<span id="L30" class="LineNr"> 30 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 7/r32/edi 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+12) to edi</span> -<span id="L31" class="LineNr"> 31 </span><span class="Constant">$stream-data-equal?:compare-sizes</span>: -<span id="L32" class="LineNr"> 32 </span> <span class="subxComment"># if (f->write != s->size) return false</span> -<span id="L33" class="LineNr"> 33 </span> 39/compare 0/mod/indirect 7/rm32/edi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare *edi and eax</span> -<span id="L34" class="LineNr"> 34 </span> 75/jump-if-!= $stream-data-equal?:false/disp8 -<span id="L35" class="LineNr"> 35 </span> <span class="subxComment"># var currs/edi: (addr byte) = s->data</span> -<span id="L36" class="LineNr"> 36 </span> 81 0/subop/add 3/mod/direct 7/rm32/edi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to edi</span> -<span id="L37" class="LineNr"> 37 </span> <span class="subxComment"># var eax: byte = 0</span> -<span id="L38" class="LineNr"> 38 </span> 31/xor 3/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear eax</span> -<span id="L39" class="LineNr"> 39 </span> <span class="subxComment"># var ecx: byte = 0</span> -<span id="L40" class="LineNr"> 40 </span> 31/xor 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear ecx</span> -<span id="L41" class="LineNr"> 41 </span><span class="Constant">$stream-data-equal?:loop</span>: -<span id="L42" class="LineNr"> 42 </span> <span class="subxComment"># if (currf >= maxf) return true</span> -<span id="L43" class="LineNr"> 43 </span> 39/compare 3/mod/direct 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare esi with edx</span> -<span id="L44" class="LineNr"> 44 </span> 73/jump-if-addr>= $stream-data-equal?:true/disp8 -<span id="L45" class="LineNr"> 45 </span> <span class="subxComment"># AL = *currs</span> -<span id="L46" class="LineNr"> 46 </span> 8a/copy-byte 0/mod/indirect 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/AL <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy byte at *esi to AL</span> -<span id="L47" class="LineNr"> 47 </span> <span class="subxComment"># CL = *curr</span> -<span id="L48" class="LineNr"> 48 </span> 8a/copy-byte 0/mod/indirect 7/rm32/edi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/CL <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy byte at *edi to CL</span> -<span id="L49" class="LineNr"> 49 </span> <span class="subxComment"># if (eax != ecx) return false</span> -<span id="L50" class="LineNr"> 50 </span> 39/compare 3/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare eax and ecx</span> -<span id="L51" class="LineNr"> 51 </span> 75/jump-if-!= $stream-data-equal?:false/disp8 -<span id="L52" class="LineNr"> 52 </span> <span class="subxComment"># ++f</span> -<span id="L53" class="LineNr"> 53 </span> 46/increment-esi -<span id="L54" class="LineNr"> 54 </span> <span class="subxComment"># ++curr</span> -<span id="L55" class="LineNr"> 55 </span> 47/increment-edi -<span id="L56" class="LineNr"> 56 </span> eb/jump $stream-data-equal?:<span class="Constant">loop</span>/disp8 -<span id="L57" class="LineNr"> 57 </span><span class="Constant">$stream-data-equal?:false</span>: -<span id="L58" class="LineNr"> 58 </span> b8/copy-to-eax 0/imm32 -<span id="L59" class="LineNr"> 59 </span> eb/jump $stream-data-equal?:end/disp8 -<span id="L60" class="LineNr"> 60 </span><span class="Constant">$stream-data-equal?:true</span>: -<span id="L61" class="LineNr"> 61 </span> b8/copy-to-eax 1/imm32 -<span id="L62" class="LineNr"> 62 </span><span class="Constant">$stream-data-equal?:end</span>: -<span id="L63" class="LineNr"> 63 </span> <span class="subxS1Comment"># . restore registers</span> -<span id="L64" class="LineNr"> 64 </span> 5f/pop-to-edi -<span id="L65" class="LineNr"> 65 </span> 5e/pop-to-esi -<span id="L66" class="LineNr"> 66 </span> 5a/pop-to-edx -<span id="L67" class="LineNr"> 67 </span> 59/pop-to-ecx -<span id="L68" class="LineNr"> 68 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L69" class="LineNr"> 69 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> -<span id="L70" class="LineNr"> 70 </span> 5d/pop-to-ebp -<span id="L71" class="LineNr"> 71 </span> c3/return -<span id="L72" class="LineNr"> 72 </span> -<span id="L73" class="LineNr"> 73 </span><span class="subxTest">test-stream-data-equal</span>: -<span id="L74" class="LineNr"> 74 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L75" class="LineNr"> 75 </span> 55/push-ebp -<span id="L76" class="LineNr"> 76 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> -<span id="L77" class="LineNr"> 77 </span> <span class="subxComment"># clear-stream(_test-stream)</span> -<span id="L78" class="LineNr"> 78 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L79" class="LineNr"> 79 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L80" class="LineNr"> 80 </span> <span class="subxS2Comment"># . . call</span> -<span id="L81" class="LineNr"> 81 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 -<span id="L82" class="LineNr"> 82 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L83" class="LineNr"> 83 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> -<span id="L84" class="LineNr"> 84 </span> <span class="subxComment"># write(_test-stream, "Abc")</span> -<span id="L85" class="LineNr"> 85 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L86" class="LineNr"> 86 </span> 68/push <span class="Constant">"Abc"</span>/imm32 -<span id="L87" class="LineNr"> 87 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L88" class="LineNr"> 88 </span> <span class="subxS2Comment"># . . call</span> -<span id="L89" class="LineNr"> 89 </span> e8/call <a href='108write.subx.html#L11'>write</a>/disp32 -<span id="L90" class="LineNr"> 90 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L91" class="LineNr"> 91 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L92" class="LineNr"> 92 </span> <span class="subxComment"># eax = stream-data-equal?(_test-stream, "Abc")</span> -<span id="L93" class="LineNr"> 93 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L94" class="LineNr"> 94 </span> 68/push <span class="Constant">"Abc"</span>/imm32 -<span id="L95" class="LineNr"> 95 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L96" class="LineNr"> 96 </span> <span class="subxS2Comment"># . . call</span> -<span id="L97" class="LineNr"> 97 </span> e8/call <a href='109stream-equal.subx.html#L12'>stream-data-equal?</a>/disp32 -<span id="L98" class="LineNr"> 98 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L99" class="LineNr"> 99 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L100" class="LineNr">100 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> -<span id="L101" class="LineNr">101 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L102" class="LineNr">102 </span> 68/push <span class="Constant">"F - test-stream-data-equal"</span>/imm32 -<span id="L103" class="LineNr">103 </span> 68/push 1/imm32 -<span id="L104" class="LineNr">104 </span> 50/push-eax -<span id="L105" class="LineNr">105 </span> <span class="subxS2Comment"># . . call</span> -<span id="L106" class="LineNr">106 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 -<span id="L107" class="LineNr">107 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L108" class="LineNr">108 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> -<span id="L109" class="LineNr">109 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L110" class="LineNr">110 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> -<span id="L111" class="LineNr">111 </span> 5d/pop-to-ebp -<span id="L112" class="LineNr">112 </span> c3/return -<span id="L113" class="LineNr">113 </span> -<span id="L114" class="LineNr">114 </span><span class="subxTest">test-stream-data-equal-2</span>: -<span id="L115" class="LineNr">115 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L116" class="LineNr">116 </span> 55/push-ebp -<span id="L117" class="LineNr">117 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> -<span id="L118" class="LineNr">118 </span> <span class="subxComment"># clear-stream(_test-stream)</span> -<span id="L119" class="LineNr">119 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L120" class="LineNr">120 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L121" class="LineNr">121 </span> <span class="subxS2Comment"># . . call</span> -<span id="L122" class="LineNr">122 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 -<span id="L123" class="LineNr">123 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L124" class="LineNr">124 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> -<span id="L125" class="LineNr">125 </span> <span class="subxComment"># write(_test-stream, "Abc")</span> -<span id="L126" class="LineNr">126 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L127" class="LineNr">127 </span> 68/push <span class="Constant">"Abc"</span>/imm32 -<span id="L128" class="LineNr">128 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L129" class="LineNr">129 </span> <span class="subxS2Comment"># . . call</span> -<span id="L130" class="LineNr">130 </span> e8/call <a href='108write.subx.html#L11'>write</a>/disp32 -<span id="L131" class="LineNr">131 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L132" class="LineNr">132 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L133" class="LineNr">133 </span> <span class="subxComment"># eax = stream-data-equal?(_test-stream, "Abd")</span> -<span id="L134" class="LineNr">134 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L135" class="LineNr">135 </span> 68/push <span class="Constant">"Abd"</span>/imm32 -<span id="L136" class="LineNr">136 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L137" class="LineNr">137 </span> <span class="subxS2Comment"># . . call</span> -<span id="L138" class="LineNr">138 </span> e8/call <a href='109stream-equal.subx.html#L12'>stream-data-equal?</a>/disp32 -<span id="L139" class="LineNr">139 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L140" class="LineNr">140 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L141" class="LineNr">141 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> -<span id="L142" class="LineNr">142 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L143" class="LineNr">143 </span> 68/push <span class="Constant">"F - test-stream-data-equal-2"</span>/imm32 -<span id="L144" class="LineNr">144 </span> 68/push 0/imm32 -<span id="L145" class="LineNr">145 </span> 50/push-eax -<span id="L146" class="LineNr">146 </span> <span class="subxS2Comment"># . . call</span> -<span id="L147" class="LineNr">147 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 -<span id="L148" class="LineNr">148 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L149" class="LineNr">149 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> -<span id="L150" class="LineNr">150 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L151" class="LineNr">151 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> -<span id="L152" class="LineNr">152 </span> 5d/pop-to-ebp -<span id="L153" class="LineNr">153 </span> c3/return -<span id="L154" class="LineNr">154 </span> -<span id="L155" class="LineNr">155 </span><span class="subxTest">test-stream-data-equal-size-check</span>: -<span id="L156" class="LineNr">156 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L157" class="LineNr">157 </span> 55/push-ebp -<span id="L158" class="LineNr">158 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> -<span id="L159" class="LineNr">159 </span> <span class="subxComment"># clear-stream(_test-stream)</span> -<span id="L160" class="LineNr">160 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L161" class="LineNr">161 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L162" class="LineNr">162 </span> <span class="subxS2Comment"># . . call</span> -<span id="L163" class="LineNr">163 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 -<span id="L164" class="LineNr">164 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L165" class="LineNr">165 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> -<span id="L166" class="LineNr">166 </span> <span class="subxComment"># write(_test-stream, "Abc")</span> -<span id="L167" class="LineNr">167 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L168" class="LineNr">168 </span> 68/push <span class="Constant">"Abc"</span>/imm32 -<span id="L169" class="LineNr">169 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L170" class="LineNr">170 </span> <span class="subxS2Comment"># . . call</span> -<span id="L171" class="LineNr">171 </span> e8/call <a href='108write.subx.html#L11'>write</a>/disp32 -<span id="L172" class="LineNr">172 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L173" class="LineNr">173 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L174" class="LineNr">174 </span> <span class="subxComment"># eax = stream-data-equal?(_test-stream, "Abcd")</span> -<span id="L175" class="LineNr">175 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L176" class="LineNr">176 </span> 68/push <span class="Constant">"Abcd"</span>/imm32 -<span id="L177" class="LineNr">177 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L178" class="LineNr">178 </span> <span class="subxS2Comment"># . . call</span> -<span id="L179" class="LineNr">179 </span> e8/call <a href='109stream-equal.subx.html#L12'>stream-data-equal?</a>/disp32 -<span id="L180" class="LineNr">180 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L181" class="LineNr">181 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L182" class="LineNr">182 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> -<span id="L183" class="LineNr">183 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L184" class="LineNr">184 </span> 68/push <span class="Constant">"F - test-stream-data-equal-size-check"</span>/imm32 -<span id="L185" class="LineNr">185 </span> 68/push 0/imm32 -<span id="L186" class="LineNr">186 </span> 50/push-eax -<span id="L187" class="LineNr">187 </span> <span class="subxS2Comment"># . . call</span> -<span id="L188" class="LineNr">188 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 -<span id="L189" class="LineNr">189 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L190" class="LineNr">190 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> -<span id="L191" class="LineNr">191 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L192" class="LineNr">192 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> -<span id="L193" class="LineNr">193 </span> 5d/pop-to-ebp -<span id="L194" class="LineNr">194 </span> c3/return -<span id="L195" class="LineNr">195 </span> -<span id="L196" class="LineNr">196 </span><span class="subxComment"># helper for later tests</span> -<span id="L197" class="LineNr">197 </span><span class="subxFunction">check-stream-equal</span>: <span class="subxComment"># f: (addr stream byte), s: (addr array byte), msg: (addr array byte)</span> -<span id="L198" class="LineNr">198 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L199" class="LineNr">199 </span> 55/push-ebp -<span id="L200" class="LineNr">200 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> -<span id="L201" class="LineNr">201 </span> <span class="subxS1Comment"># . save registers</span> -<span id="L202" class="LineNr">202 </span> 50/push-eax -<span id="L203" class="LineNr">203 </span> <span class="subxComment"># eax = stream-data-equal?(f, s)</span> -<span id="L204" class="LineNr">204 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L205" class="LineNr">205 </span> ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(ebp+12)</span> -<span id="L206" class="LineNr">206 </span> ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(ebp+8)</span> -<span id="L207" class="LineNr">207 </span> <span class="subxS2Comment"># . . call</span> -<span id="L208" class="LineNr">208 </span> e8/call <a href='109stream-equal.subx.html#L12'>stream-data-equal?</a>/disp32 -<span id="L209" class="LineNr">209 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L210" class="LineNr">210 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L211" class="LineNr">211 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> -<span id="L212" class="LineNr">212 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L213" class="LineNr">213 </span> ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0x10/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(ebp+16)</span> -<span id="L214" class="LineNr">214 </span> 68/push 1/imm32 -<span id="L215" class="LineNr">215 </span> 50/push-eax -<span id="L216" class="LineNr">216 </span> <span class="subxS2Comment"># . . call</span> -<span id="L217" class="LineNr">217 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 -<span id="L218" class="LineNr">218 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L219" class="LineNr">219 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> -<span id="L220" class="LineNr">220 </span><span class="Constant">$check-stream-equal:end</span>: -<span id="L221" class="LineNr">221 </span> <span class="subxS1Comment"># . restore registers</span> -<span id="L222" class="LineNr">222 </span> 58/pop-to-eax -<span id="L223" class="LineNr">223 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L224" class="LineNr">224 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> -<span id="L225" class="LineNr">225 </span> 5d/pop-to-ebp -<span id="L226" class="LineNr">226 </span> c3/return -<span id="L227" class="LineNr">227 </span> -<span id="L228" class="LineNr">228 </span><span class="subxComment"># scan the next line until newline starting from f->read and compare it with</span> -<span id="L229" class="LineNr">229 </span><span class="subxComment"># 's' (ignoring the trailing newline)</span> -<span id="L230" class="LineNr">230 </span><span class="subxComment"># on success, set f->read to after the next newline</span> -<span id="L231" class="LineNr">231 </span><span class="subxComment"># on failure, leave f->read unmodified</span> -<span id="L232" class="LineNr">232 </span><span class="subxComment"># this function is usually used only in tests, so we repeatedly write f->read</span> -<span id="L233" class="LineNr">233 </span><span class="subxFunction">next-stream-line-equal?</span>: <span class="subxComment"># f: (addr stream byte), s: (addr array byte) -> result/eax: boolean</span> -<span id="L234" class="LineNr">234 </span> <span class="subxComment"># pseudocode:</span> -<span id="L235" class="LineNr">235 </span> <span class="subxComment"># currf = f->read # bound: f->write</span> -<span id="L236" class="LineNr">236 </span> <span class="subxComment"># currs = 0 # bound: s->size</span> -<span id="L237" class="LineNr">237 </span> <span class="subxComment"># while true</span> -<span id="L238" class="LineNr">238 </span> <span class="subxComment"># if currf >= f->write</span> +<span id="L2" class="LineNr"> 2 </span> +<span id="L3" class="LineNr"> 3 </span>== code +<span id="L4" class="LineNr"> 4 </span><span class="subxComment"># instruction effective address register displacement immediate</span> +<span id="L5" class="LineNr"> 5 </span><span class="subxS1Comment"># . op subop mod rm32 base index scale r32</span> +<span id="L6" class="LineNr"> 6 </span><span class="subxS1Comment"># . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes</span> +<span id="L7" class="LineNr"> 7 </span> +<span id="L8" class="LineNr"> 8 </span><span class="subxComment"># compare all the data in a stream (ignoring the read pointer)</span> +<span id="L9" class="LineNr"> 9 </span><span class="subxFunction">stream-data-equal?</span>: <span class="subxComment"># f: (addr stream byte), s: (addr array byte) -> result/eax: boolean</span> +<span id="L10" class="LineNr"> 10 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L11" class="LineNr"> 11 </span> 55/push-ebp +<span id="L12" class="LineNr"> 12 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L13" class="LineNr"> 13 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L14" class="LineNr"> 14 </span> 51/push-ecx +<span id="L15" class="LineNr"> 15 </span> 52/push-edx +<span id="L16" class="LineNr"> 16 </span> 56/push-esi +<span id="L17" class="LineNr"> 17 </span> 57/push-edi +<span id="L18" class="LineNr"> 18 </span> <span class="subxComment"># esi = f</span> +<span id="L19" class="LineNr"> 19 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 6/r32/esi 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+8) to esi</span> +<span id="L20" class="LineNr"> 20 </span> <span class="subxComment"># eax = f->write</span> +<span id="L21" class="LineNr"> 21 </span> 8b/copy 0/mod/indirect 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *esi to eax</span> +<span id="L22" class="LineNr"> 22 </span> <span class="subxComment"># var maxf/edx: (addr byte) = &f->data[f->write]</span> +<span id="L23" class="LineNr"> 23 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 0/index/eax <span class="Normal"> . </span> 2/r32/edx 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy esi+eax+12 to edx</span> +<span id="L24" class="LineNr"> 24 </span> <span class="subxComment"># var currf/esi: (addr byte) = f->data</span> +<span id="L25" class="LineNr"> 25 </span> 81 0/subop/add 3/mod/direct 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esi</span> +<span id="L26" class="LineNr"> 26 </span> <span class="subxComment"># edi = s</span> +<span id="L27" class="LineNr"> 27 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 7/r32/edi 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+12) to edi</span> +<span id="L28" class="LineNr"> 28 </span><span class="Constant">$stream-data-equal?:compare-sizes</span>: +<span id="L29" class="LineNr"> 29 </span> <span class="subxComment"># if (f->write != s->size) return false</span> +<span id="L30" class="LineNr"> 30 </span> 39/compare 0/mod/indirect 7/rm32/edi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare *edi and eax</span> +<span id="L31" class="LineNr"> 31 </span> 75/jump-if-!= $stream-data-equal?:false/disp8 +<span id="L32" class="LineNr"> 32 </span> <span class="subxComment"># var currs/edi: (addr byte) = s->data</span> +<span id="L33" class="LineNr"> 33 </span> 81 0/subop/add 3/mod/direct 7/rm32/edi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to edi</span> +<span id="L34" class="LineNr"> 34 </span> <span class="subxComment"># var eax: byte = 0</span> +<span id="L35" class="LineNr"> 35 </span> 31/xor 3/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear eax</span> +<span id="L36" class="LineNr"> 36 </span> <span class="subxComment"># var ecx: byte = 0</span> +<span id="L37" class="LineNr"> 37 </span> 31/xor 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear ecx</span> +<span id="L38" class="LineNr"> 38 </span><span class="Constant">$stream-data-equal?:loop</span>: +<span id="L39" class="LineNr"> 39 </span> <span class="subxComment"># if (currf >= maxf) return true</span> +<span id="L40" class="LineNr"> 40 </span> 39/compare 3/mod/direct 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare esi with edx</span> +<span id="L41" class="LineNr"> 41 </span> 73/jump-if-addr>= $stream-data-equal?:true/disp8 +<span id="L42" class="LineNr"> 42 </span> <span class="subxComment"># AL = *currs</span> +<span id="L43" class="LineNr"> 43 </span> 8a/copy-byte 0/mod/indirect 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/AL <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy byte at *esi to AL</span> +<span id="L44" class="LineNr"> 44 </span> <span class="subxComment"># CL = *curr</span> +<span id="L45" class="LineNr"> 45 </span> 8a/copy-byte 0/mod/indirect 7/rm32/edi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/CL <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy byte at *edi to CL</span> +<span id="L46" class="LineNr"> 46 </span> <span class="subxComment"># if (eax != ecx) return false</span> +<span id="L47" class="LineNr"> 47 </span> 39/compare 3/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare eax and ecx</span> +<span id="L48" class="LineNr"> 48 </span> 75/jump-if-!= $stream-data-equal?:false/disp8 +<span id="L49" class="LineNr"> 49 </span> <span class="subxComment"># ++f</span> +<span id="L50" class="LineNr"> 50 </span> 46/increment-esi +<span id="L51" class="LineNr"> 51 </span> <span class="subxComment"># ++curr</span> +<span id="L52" class="LineNr"> 52 </span> 47/increment-edi +<span id="L53" class="LineNr"> 53 </span> eb/jump $stream-data-equal?:<span class="Constant">loop</span>/disp8 +<span id="L54" class="LineNr"> 54 </span><span class="Constant">$stream-data-equal?:false</span>: +<span id="L55" class="LineNr"> 55 </span> b8/copy-to-eax 0/imm32 +<span id="L56" class="LineNr"> 56 </span> eb/jump $stream-data-equal?:end/disp8 +<span id="L57" class="LineNr"> 57 </span><span class="Constant">$stream-data-equal?:true</span>: +<span id="L58" class="LineNr"> 58 </span> b8/copy-to-eax 1/imm32 +<span id="L59" class="LineNr"> 59 </span><span class="Constant">$stream-data-equal?:end</span>: +<span id="L60" class="LineNr"> 60 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L61" class="LineNr"> 61 </span> 5f/pop-to-edi +<span id="L62" class="LineNr"> 62 </span> 5e/pop-to-esi +<span id="L63" class="LineNr"> 63 </span> 5a/pop-to-edx +<span id="L64" class="LineNr"> 64 </span> 59/pop-to-ecx +<span id="L65" class="LineNr"> 65 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L66" class="LineNr"> 66 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L67" class="LineNr"> 67 </span> 5d/pop-to-ebp +<span id="L68" class="LineNr"> 68 </span> c3/return +<span id="L69" class="LineNr"> 69 </span> +<span id="L70" class="LineNr"> 70 </span><span class="subxTest">test-stream-data-equal</span>: +<span id="L71" class="LineNr"> 71 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L72" class="LineNr"> 72 </span> 55/push-ebp +<span id="L73" class="LineNr"> 73 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L74" class="LineNr"> 74 </span> <span class="subxComment"># clear-stream(_test-stream)</span> +<span id="L75" class="LineNr"> 75 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L76" class="LineNr"> 76 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L77" class="LineNr"> 77 </span> <span class="subxS2Comment"># . . call</span> +<span id="L78" class="LineNr"> 78 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 +<span id="L79" class="LineNr"> 79 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L80" class="LineNr"> 80 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L81" class="LineNr"> 81 </span> <span class="subxComment"># write(_test-stream, "Abc")</span> +<span id="L82" class="LineNr"> 82 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L83" class="LineNr"> 83 </span> 68/push <span class="Constant">"Abc"</span>/imm32 +<span id="L84" class="LineNr"> 84 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L85" class="LineNr"> 85 </span> <span class="subxS2Comment"># . . call</span> +<span id="L86" class="LineNr"> 86 </span> e8/call <a href='108write.subx.html#L11'>write</a>/disp32 +<span id="L87" class="LineNr"> 87 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L88" class="LineNr"> 88 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L89" class="LineNr"> 89 </span> <span class="subxComment"># eax = stream-data-equal?(_test-stream, "Abc")</span> +<span id="L90" class="LineNr"> 90 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L91" class="LineNr"> 91 </span> 68/push <span class="Constant">"Abc"</span>/imm32 +<span id="L92" class="LineNr"> 92 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L93" class="LineNr"> 93 </span> <span class="subxS2Comment"># . . call</span> +<span id="L94" class="LineNr"> 94 </span> e8/call <a href='109stream-equal.subx.html#L9'>stream-data-equal?</a>/disp32 +<span id="L95" class="LineNr"> 95 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L96" class="LineNr"> 96 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L97" class="LineNr"> 97 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> +<span id="L98" class="LineNr"> 98 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L99" class="LineNr"> 99 </span> 68/push <span class="Constant">"F - test-stream-data-equal"</span>/imm32 +<span id="L100" class="LineNr">100 </span> 68/push 1/imm32 +<span id="L101" class="LineNr">101 </span> 50/push-eax +<span id="L102" class="LineNr">102 </span> <span class="subxS2Comment"># . . call</span> +<span id="L103" class="LineNr">103 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L104" class="LineNr">104 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L105" class="LineNr">105 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L106" class="LineNr">106 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L107" class="LineNr">107 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L108" class="LineNr">108 </span> 5d/pop-to-ebp +<span id="L109" class="LineNr">109 </span> c3/return +<span id="L110" class="LineNr">110 </span> +<span id="L111" class="LineNr">111 </span><span class="subxTest">test-stream-data-equal-2</span>: +<span id="L112" class="LineNr">112 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L113" class="LineNr">113 </span> 55/push-ebp +<span id="L114" class="LineNr">114 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L115" class="LineNr">115 </span> <span class="subxComment"># clear-stream(_test-stream)</span> +<span id="L116" class="LineNr">116 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L117" class="LineNr">117 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L118" class="LineNr">118 </span> <span class="subxS2Comment"># . . call</span> +<span id="L119" class="LineNr">119 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 +<span id="L120" class="LineNr">120 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L121" class="LineNr">121 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L122" class="LineNr">122 </span> <span class="subxComment"># write(_test-stream, "Abc")</span> +<span id="L123" class="LineNr">123 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L124" class="LineNr">124 </span> 68/push <span class="Constant">"Abc"</span>/imm32 +<span id="L125" class="LineNr">125 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L126" class="LineNr">126 </span> <span class="subxS2Comment"># . . call</span> +<span id="L127" class="LineNr">127 </span> e8/call <a href='108write.subx.html#L11'>write</a>/disp32 +<span id="L128" class="LineNr">128 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L129" class="LineNr">129 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L130" class="LineNr">130 </span> <span class="subxComment"># eax = stream-data-equal?(_test-stream, "Abd")</span> +<span id="L131" class="LineNr">131 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L132" class="LineNr">132 </span> 68/push <span class="Constant">"Abd"</span>/imm32 +<span id="L133" class="LineNr">133 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L134" class="LineNr">134 </span> <span class="subxS2Comment"># . . call</span> +<span id="L135" class="LineNr">135 </span> e8/call <a href='109stream-equal.subx.html#L9'>stream-data-equal?</a>/disp32 +<span id="L136" class="LineNr">136 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L137" class="LineNr">137 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L138" class="LineNr">138 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> +<span id="L139" class="LineNr">139 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L140" class="LineNr">140 </span> 68/push <span class="Constant">"F - test-stream-data-equal-2"</span>/imm32 +<span id="L141" class="LineNr">141 </span> 68/push 0/imm32 +<span id="L142" class="LineNr">142 </span> 50/push-eax +<span id="L143" class="LineNr">143 </span> <span class="subxS2Comment"># . . call</span> +<span id="L144" class="LineNr">144 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L145" class="LineNr">145 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L146" class="LineNr">146 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L147" class="LineNr">147 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L148" class="LineNr">148 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L149" class="LineNr">149 </span> 5d/pop-to-ebp +<span id="L150" class="LineNr">150 </span> c3/return +<span id="L151" class="LineNr">151 </span> +<span id="L152" class="LineNr">152 </span><span class="subxTest">test-stream-data-equal-size-check</span>: +<span id="L153" class="LineNr">153 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L154" class="LineNr">154 </span> 55/push-ebp +<span id="L155" class="LineNr">155 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L156" class="LineNr">156 </span> <span class="subxComment"># clear-stream(_test-stream)</span> +<span id="L157" class="LineNr">157 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L158" class="LineNr">158 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L159" class="LineNr">159 </span> <span class="subxS2Comment"># . . call</span> +<span id="L160" class="LineNr">160 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 +<span id="L161" class="LineNr">161 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L162" class="LineNr">162 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L163" class="LineNr">163 </span> <span class="subxComment"># write(_test-stream, "Abc")</span> +<span id="L164" class="LineNr">164 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L165" class="LineNr">165 </span> 68/push <span class="Constant">"Abc"</span>/imm32 +<span id="L166" class="LineNr">166 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L167" class="LineNr">167 </span> <span class="subxS2Comment"># . . call</span> +<span id="L168" class="LineNr">168 </span> e8/call <a href='108write.subx.html#L11'>write</a>/disp32 +<span id="L169" class="LineNr">169 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L170" class="LineNr">170 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L171" class="LineNr">171 </span> <span class="subxComment"># eax = stream-data-equal?(_test-stream, "Abcd")</span> +<span id="L172" class="LineNr">172 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L173" class="LineNr">173 </span> 68/push <span class="Constant">"Abcd"</span>/imm32 +<span id="L174" class="LineNr">174 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L175" class="LineNr">175 </span> <span class="subxS2Comment"># . . call</span> +<span id="L176" class="LineNr">176 </span> e8/call <a href='109stream-equal.subx.html#L9'>stream-data-equal?</a>/disp32 +<span id="L177" class="LineNr">177 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L178" class="LineNr">178 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L179" class="LineNr">179 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> +<span id="L180" class="LineNr">180 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L181" class="LineNr">181 </span> 68/push <span class="Constant">"F - test-stream-data-equal-size-check"</span>/imm32 +<span id="L182" class="LineNr">182 </span> 68/push 0/imm32 +<span id="L183" class="LineNr">183 </span> 50/push-eax +<span id="L184" class="LineNr">184 </span> <span class="subxS2Comment"># . . call</span> +<span id="L185" class="LineNr">185 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L186" class="LineNr">186 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L187" class="LineNr">187 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L188" class="LineNr">188 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L189" class="LineNr">189 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L190" class="LineNr">190 </span> 5d/pop-to-ebp +<span id="L191" class="LineNr">191 </span> c3/return +<span id="L192" class="LineNr">192 </span> +<span id="L193" class="LineNr">193 </span><span class="subxComment"># helper for later tests</span> +<span id="L194" class="LineNr">194 </span><span class="subxFunction">check-stream-equal</span>: <span class="subxComment"># f: (addr stream byte), s: (addr array byte), msg: (addr array byte)</span> +<span id="L195" class="LineNr">195 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L196" class="LineNr">196 </span> 55/push-ebp +<span id="L197" class="LineNr">197 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L198" class="LineNr">198 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L199" class="LineNr">199 </span> 50/push-eax +<span id="L200" class="LineNr">200 </span> <span class="subxComment"># eax = stream-data-equal?(f, s)</span> +<span id="L201" class="LineNr">201 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L202" class="LineNr">202 </span> ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(ebp+12)</span> +<span id="L203" class="LineNr">203 </span> ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(ebp+8)</span> +<span id="L204" class="LineNr">204 </span> <span class="subxS2Comment"># . . call</span> +<span id="L205" class="LineNr">205 </span> e8/call <a href='109stream-equal.subx.html#L9'>stream-data-equal?</a>/disp32 +<span id="L206" class="LineNr">206 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L207" class="LineNr">207 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L208" class="LineNr">208 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> +<span id="L209" class="LineNr">209 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L210" class="LineNr">210 </span> ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0x10/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(ebp+16)</span> +<span id="L211" class="LineNr">211 </span> 68/push 1/imm32 +<span id="L212" class="LineNr">212 </span> 50/push-eax +<span id="L213" class="LineNr">213 </span> <span class="subxS2Comment"># . . call</span> +<span id="L214" class="LineNr">214 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L215" class="LineNr">215 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L216" class="LineNr">216 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L217" class="LineNr">217 </span><span class="Constant">$check-stream-equal:end</span>: +<span id="L218" class="LineNr">218 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L219" class="LineNr">219 </span> 58/pop-to-eax +<span id="L220" class="LineNr">220 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L221" class="LineNr">221 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L222" class="LineNr">222 </span> 5d/pop-to-ebp +<span id="L223" class="LineNr">223 </span> c3/return +<span id="L224" class="LineNr">224 </span> +<span id="L225" class="LineNr">225 </span><span class="subxComment"># scan the next line until newline starting from f->read and compare it with</span> +<span id="L226" class="LineNr">226 </span><span class="subxComment"># 's' (ignoring the trailing newline)</span> +<span id="L227" class="LineNr">227 </span><span class="subxComment"># on success, set f->read to after the next newline</span> +<span id="L228" class="LineNr">228 </span><span class="subxComment"># on failure, leave f->read unmodified</span> +<span id="L229" class="LineNr">229 </span><span class="subxComment"># this function is usually used only in tests, so we repeatedly write f->read</span> +<span id="L230" class="LineNr">230 </span><span class="subxFunction">next-stream-line-equal?</span>: <span class="subxComment"># f: (addr stream byte), s: (addr array byte) -> result/eax: boolean</span> +<span id="L231" class="LineNr">231 </span> <span class="subxComment"># pseudocode:</span> +<span id="L232" class="LineNr">232 </span> <span class="subxComment"># currf = f->read # bound: f->write</span> +<span id="L233" class="LineNr">233 </span> <span class="subxComment"># currs = 0 # bound: s->size</span> +<span id="L234" class="LineNr">234 </span> <span class="subxComment"># while true</span> +<span id="L235" class="LineNr">235 </span> <span class="subxComment"># if currf >= f->write</span> +<span id="L236" class="LineNr">236 </span> <span class="subxComment"># return currs >= s->size</span> +<span id="L237" class="LineNr">237 </span> <span class="subxComment"># if f[currf] == '\n'</span> +<span id="L238" class="LineNr">238 </span> <span class="subxComment"># ++currf</span> <span id="L239" class="LineNr">239 </span> <span class="subxComment"># return currs >= s->size</span> -<span id="L240" class="LineNr">240 </span> <span class="subxComment"># if f[currf] == '\n'</span> -<span id="L241" class="LineNr">241 </span> <span class="subxComment"># ++currf</span> -<span id="L242" class="LineNr">242 </span> <span class="subxComment"># return currs >= s->size</span> -<span id="L243" class="LineNr">243 </span> <span class="subxComment"># if (currs >= s->size) return false # the current line of f still has data to match</span> -<span id="L244" class="LineNr">244 </span> <span class="subxComment"># if (f[currf] != s[currs]) return false</span> -<span id="L245" class="LineNr">245 </span> <span class="subxComment"># ++currf</span> -<span id="L246" class="LineNr">246 </span> <span class="subxComment"># ++currs</span> -<span id="L247" class="LineNr">247 </span> <span class="subxComment">#</span> -<span id="L248" class="LineNr">248 </span> <span class="subxComment"># collapsing the two branches that can return true:</span> -<span id="L249" class="LineNr">249 </span> <span class="subxComment"># currf = f->read # bound: f->write</span> -<span id="L250" class="LineNr">250 </span> <span class="subxComment"># currs = 0 # bound: s->size</span> -<span id="L251" class="LineNr">251 </span> <span class="subxComment"># while true</span> -<span id="L252" class="LineNr">252 </span> <span class="subxComment"># if (currf >= f->write) break</span> -<span id="L253" class="LineNr">253 </span> <span class="subxComment"># if (f[currf] == '\n') break</span> -<span id="L254" class="LineNr">254 </span> <span class="subxComment"># if (currs >= s->size) return false # the current line of f still has data to match</span> -<span id="L255" class="LineNr">255 </span> <span class="subxComment"># if (f[currf] != s[currs]) return false</span> -<span id="L256" class="LineNr">256 </span> <span class="subxComment"># ++currf</span> -<span id="L257" class="LineNr">257 </span> <span class="subxComment"># ++currs</span> -<span id="L258" class="LineNr">258 </span> <span class="subxComment"># ++currf # skip '\n'</span> -<span id="L259" class="LineNr">259 </span> <span class="subxComment"># return currs >= s->size</span> -<span id="L260" class="LineNr">260 </span> <span class="subxComment"># Here the final `++currf` is sometimes unnecessary (if we're already at the end of the stream)</span> -<span id="L261" class="LineNr">261 </span> <span class="subxComment">#</span> -<span id="L262" class="LineNr">262 </span> <span class="subxComment"># registers:</span> -<span id="L263" class="LineNr">263 </span> <span class="subxComment"># f: esi</span> -<span id="L264" class="LineNr">264 </span> <span class="subxComment"># s: edi</span> -<span id="L265" class="LineNr">265 </span> <span class="subxComment"># currf: ecx</span> -<span id="L266" class="LineNr">266 </span> <span class="subxComment"># currs: edx</span> -<span id="L267" class="LineNr">267 </span> <span class="subxComment"># f[currf]: eax</span> -<span id="L268" class="LineNr">268 </span> <span class="subxComment"># s[currs]: ebx</span> -<span id="L269" class="LineNr">269 </span> <span class="subxComment">#</span> -<span id="L270" class="LineNr">270 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L271" class="LineNr">271 </span> 55/push-ebp -<span id="L272" class="LineNr">272 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> -<span id="L273" class="LineNr">273 </span> <span class="subxS1Comment"># . save registers</span> -<span id="L274" class="LineNr">274 </span> 51/push-ecx -<span id="L275" class="LineNr">275 </span> 52/push-edx -<span id="L276" class="LineNr">276 </span> 56/push-esi -<span id="L277" class="LineNr">277 </span> 57/push-edi -<span id="L278" class="LineNr">278 </span> <span class="subxComment"># esi = f</span> -<span id="L279" class="LineNr">279 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 6/r32/esi 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+8) to esi</span> -<span id="L280" class="LineNr">280 </span> <span class="subxComment"># var currf/ecx: int = f->read</span> -<span id="L281" class="LineNr">281 </span> 8b/copy 1/mod/*+disp8 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(esi+4) to ecx</span> -<span id="L282" class="LineNr">282 </span> <span class="subxComment"># edi = s</span> -<span id="L283" class="LineNr">283 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 7/r32/edi 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+12) to edi</span> -<span id="L284" class="LineNr">284 </span> <span class="subxComment"># var currs/edx: int = 0</span> -<span id="L285" class="LineNr">285 </span> 31/xor 3/mod/direct 2/rm32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear edx</span> -<span id="L286" class="LineNr">286 </span> <span class="subxComment"># var c1/eax: byte = 0</span> -<span id="L287" class="LineNr">287 </span> 31/xor 3/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear eax</span> -<span id="L288" class="LineNr">288 </span> <span class="subxComment"># var c2/ebx: byte = 0</span> -<span id="L289" class="LineNr">289 </span> 31/xor 3/mod/direct 3/rm32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear ebx</span> -<span id="L290" class="LineNr">290 </span><span class="Constant">$next-stream-line-equal?:loop</span>: -<span id="L291" class="LineNr">291 </span> <span class="subxComment"># if (currf >= f->write) break</span> -<span id="L292" class="LineNr">292 </span> 3b/compare 0/mod/indirect 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare ecx with *esi</span> -<span id="L293" class="LineNr">293 </span> 7d/jump-if->= $next-stream-line-equal?:<span class="Constant">break</span>/disp8 -<span id="L294" class="LineNr">294 </span> <span class="subxComment"># c1 = f->data[f->read]</span> -<span id="L295" class="LineNr">295 </span> 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx <span class="Normal"> . </span> 0/r32/AL 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy byte at *(esi+ecx+12) to AL</span> -<span id="L296" class="LineNr">296 </span> <span class="subxComment"># if (c1 == '\n') break</span> -<span id="L297" class="LineNr">297 </span> 3d/compare-eax-and 0xa/imm32/newline -<span id="L298" class="LineNr">298 </span> 74/jump-if-= $next-stream-line-equal?:<span class="Constant">break</span>/disp8 -<span id="L299" class="LineNr">299 </span> <span class="subxComment"># if (currs >= s->size) return false</span> -<span id="L300" class="LineNr">300 </span> 3b/compare 0/mod/indirect 7/rm32/edi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare edx with *edi</span> -<span id="L301" class="LineNr">301 </span> 7d/jump-if->= $next-stream-line-equal?:false/disp8 -<span id="L302" class="LineNr">302 </span> <span class="subxComment"># c2 = s->data[currs]</span> -<span id="L303" class="LineNr">303 </span> 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 7/base/edi 2/index/edx <span class="Normal"> . </span> 3/r32/BL 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy byte at *(edi+edx+4) to BL</span> -<span id="L304" class="LineNr">304 </span> <span class="subxComment"># if (c1 != c2) return false</span> -<span id="L305" class="LineNr">305 </span> 39/compare 3/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare eax and ebx</span> -<span id="L306" class="LineNr">306 </span> 75/jump-if-!= $next-stream-line-equal?:false/disp8 -<span id="L307" class="LineNr">307 </span> <span class="subxComment"># ++currf</span> -<span id="L308" class="LineNr">308 </span> 41/increment-ecx -<span id="L309" class="LineNr">309 </span> <span class="subxComment"># ++currs</span> -<span id="L310" class="LineNr">310 </span> 42/increment-edx -<span id="L311" class="LineNr">311 </span> eb/jump $next-stream-line-equal?:<span class="Constant">loop</span>/disp8 -<span id="L312" class="LineNr">312 </span><span class="Constant">$next-stream-line-equal?:break</span>: -<span id="L313" class="LineNr">313 </span> <span class="subxComment"># ++currf</span> -<span id="L314" class="LineNr">314 </span> 41/increment-ecx -<span id="L315" class="LineNr">315 </span> <span class="subxComment"># if (currs >= s->size) return true</span> -<span id="L316" class="LineNr">316 </span> 3b/compare 0/mod/indirect 7/rm32/edi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare edx with *edi</span> -<span id="L317" class="LineNr">317 </span> 7c/jump-if-< $next-stream-line-equal?:false/disp8 -<span id="L318" class="LineNr">318 </span><span class="Constant">$next-stream-line-equal?:true</span>: -<span id="L319" class="LineNr">319 </span> b8/copy-to-eax 1/imm32 -<span id="L320" class="LineNr">320 </span> <span class="subxComment"># persist f->read on success</span> -<span id="L321" class="LineNr">321 </span> 89/copy 1/mod/*+disp8 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy ecx to *(esi+4)</span> -<span id="L322" class="LineNr">322 </span> eb/jump $next-stream-line-equal?:end/disp8 -<span id="L323" class="LineNr">323 </span><span class="Constant">$next-stream-line-equal?:false</span>: -<span id="L324" class="LineNr">324 </span> b8/copy-to-eax 0/imm32 -<span id="L325" class="LineNr">325 </span><span class="Constant">$next-stream-line-equal?:end</span>: -<span id="L326" class="LineNr">326 </span> <span class="subxS1Comment"># . restore registers</span> -<span id="L327" class="LineNr">327 </span> 5f/pop-to-edi -<span id="L328" class="LineNr">328 </span> 5e/pop-to-esi -<span id="L329" class="LineNr">329 </span> 5a/pop-to-edx -<span id="L330" class="LineNr">330 </span> 59/pop-to-ecx -<span id="L331" class="LineNr">331 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L332" class="LineNr">332 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> -<span id="L333" class="LineNr">333 </span> 5d/pop-to-ebp -<span id="L334" class="LineNr">334 </span> c3/return -<span id="L335" class="LineNr">335 </span> -<span id="L336" class="LineNr">336 </span><span class="subxTest">test-next-stream-line-equal-stops-at-newline</span>: -<span id="L337" class="LineNr">337 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L338" class="LineNr">338 </span> 55/push-ebp -<span id="L339" class="LineNr">339 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> -<span id="L340" class="LineNr">340 </span> <span class="subxComment"># clear-stream(_test-stream)</span> -<span id="L341" class="LineNr">341 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L342" class="LineNr">342 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L343" class="LineNr">343 </span> <span class="subxS2Comment"># . . call</span> -<span id="L344" class="LineNr">344 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 -<span id="L345" class="LineNr">345 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L346" class="LineNr">346 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> -<span id="L347" class="LineNr">347 </span> <span class="subxComment"># write(_test-stream, "Abc\ndef")</span> -<span id="L348" class="LineNr">348 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L349" class="LineNr">349 </span> 68/push <span class="Constant">"Abc\ndef"</span>/imm32 -<span id="L350" class="LineNr">350 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L351" class="LineNr">351 </span> <span class="subxS2Comment"># . . call</span> -<span id="L352" class="LineNr">352 </span> e8/call <a href='108write.subx.html#L11'>write</a>/disp32 -<span id="L353" class="LineNr">353 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L354" class="LineNr">354 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L355" class="LineNr">355 </span> <span class="subxComment"># eax = next-stream-line-equal?(_test-stream, "Abc")</span> -<span id="L356" class="LineNr">356 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L357" class="LineNr">357 </span> 68/push <span class="Constant">"Abc"</span>/imm32 -<span id="L358" class="LineNr">358 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L359" class="LineNr">359 </span> <span class="subxS2Comment"># . . call</span> -<span id="L360" class="LineNr">360 </span> e8/call <a href='109stream-equal.subx.html#L233'>next-stream-line-equal?</a>/disp32 -<span id="L361" class="LineNr">361 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L362" class="LineNr">362 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L363" class="LineNr">363 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> -<span id="L364" class="LineNr">364 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L365" class="LineNr">365 </span> 68/push <span class="Constant">"F - test-next-stream-line-equal-stops-at-newline"</span>/imm32 -<span id="L366" class="LineNr">366 </span> 68/push 1/imm32 -<span id="L367" class="LineNr">367 </span> 50/push-eax -<span id="L368" class="LineNr">368 </span> <span class="subxS2Comment"># . . call</span> -<span id="L369" class="LineNr">369 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 -<span id="L370" class="LineNr">370 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L371" class="LineNr">371 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> -<span id="L372" class="LineNr">372 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L373" class="LineNr">373 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> -<span id="L374" class="LineNr">374 </span> 5d/pop-to-ebp -<span id="L375" class="LineNr">375 </span> c3/return -<span id="L376" class="LineNr">376 </span> -<span id="L377" class="LineNr">377 </span><span class="subxTest">test-next-stream-line-equal-stops-at-newline-2</span>: -<span id="L378" class="LineNr">378 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L379" class="LineNr">379 </span> 55/push-ebp -<span id="L380" class="LineNr">380 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> -<span id="L381" class="LineNr">381 </span> <span class="subxComment"># clear-stream(_test-stream)</span> -<span id="L382" class="LineNr">382 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L383" class="LineNr">383 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L384" class="LineNr">384 </span> <span class="subxS2Comment"># . . call</span> -<span id="L385" class="LineNr">385 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 -<span id="L386" class="LineNr">386 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L387" class="LineNr">387 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> -<span id="L388" class="LineNr">388 </span> <span class="subxComment"># write(_test-stream, "Abc\ndef")</span> -<span id="L389" class="LineNr">389 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L390" class="LineNr">390 </span> 68/push <span class="Constant">"Abc\ndef"</span>/imm32 -<span id="L391" class="LineNr">391 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L392" class="LineNr">392 </span> <span class="subxS2Comment"># . . call</span> -<span id="L393" class="LineNr">393 </span> e8/call <a href='108write.subx.html#L11'>write</a>/disp32 -<span id="L394" class="LineNr">394 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L395" class="LineNr">395 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L396" class="LineNr">396 </span> <span class="subxComment"># eax = next-stream-line-equal?(_test-stream, "def")</span> -<span id="L397" class="LineNr">397 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L398" class="LineNr">398 </span> 68/push <span class="Constant">"def"</span>/imm32 -<span id="L399" class="LineNr">399 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L400" class="LineNr">400 </span> <span class="subxS2Comment"># . . call</span> -<span id="L401" class="LineNr">401 </span> e8/call <a href='109stream-equal.subx.html#L233'>next-stream-line-equal?</a>/disp32 -<span id="L402" class="LineNr">402 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L403" class="LineNr">403 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L404" class="LineNr">404 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> -<span id="L405" class="LineNr">405 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L406" class="LineNr">406 </span> 68/push <span class="Constant">"F - test-next-stream-line-equal-stops-at-newline-2"</span>/imm32 -<span id="L407" class="LineNr">407 </span> 68/push 0/imm32 -<span id="L408" class="LineNr">408 </span> 50/push-eax -<span id="L409" class="LineNr">409 </span> <span class="subxS2Comment"># . . call</span> -<span id="L410" class="LineNr">410 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 -<span id="L411" class="LineNr">411 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L412" class="LineNr">412 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> -<span id="L413" class="LineNr">413 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L414" class="LineNr">414 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> -<span id="L415" class="LineNr">415 </span> 5d/pop-to-ebp -<span id="L416" class="LineNr">416 </span> c3/return -<span id="L417" class="LineNr">417 </span> -<span id="L418" class="LineNr">418 </span><span class="subxTest">test-next-stream-line-equal-skips-newline</span>: -<span id="L419" class="LineNr">419 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L420" class="LineNr">420 </span> 55/push-ebp -<span id="L421" class="LineNr">421 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> -<span id="L422" class="LineNr">422 </span> <span class="subxComment"># clear-stream(_test-stream)</span> -<span id="L423" class="LineNr">423 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L424" class="LineNr">424 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L425" class="LineNr">425 </span> <span class="subxS2Comment"># . . call</span> -<span id="L426" class="LineNr">426 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 -<span id="L427" class="LineNr">427 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L428" class="LineNr">428 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> -<span id="L429" class="LineNr">429 </span> <span class="subxComment"># write(_test-stream, "Abc\ndef\n")</span> -<span id="L430" class="LineNr">430 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L431" class="LineNr">431 </span> 68/push <span class="Constant">"Abc\ndef\n"</span>/imm32 -<span id="L432" class="LineNr">432 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L433" class="LineNr">433 </span> <span class="subxS2Comment"># . . call</span> -<span id="L434" class="LineNr">434 </span> e8/call <a href='108write.subx.html#L11'>write</a>/disp32 -<span id="L435" class="LineNr">435 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L436" class="LineNr">436 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L437" class="LineNr">437 </span> <span class="subxComment"># next-stream-line-equal?(_test-stream, "Abc")</span> -<span id="L438" class="LineNr">438 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L439" class="LineNr">439 </span> 68/push <span class="Constant">"Abc"</span>/imm32 -<span id="L440" class="LineNr">440 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L441" class="LineNr">441 </span> <span class="subxS2Comment"># . . call</span> -<span id="L442" class="LineNr">442 </span> e8/call <a href='109stream-equal.subx.html#L233'>next-stream-line-equal?</a>/disp32 -<span id="L443" class="LineNr">443 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L444" class="LineNr">444 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L445" class="LineNr">445 </span> <span class="subxComment"># eax = next-stream-line-equal?(_test-stream, "def")</span> -<span id="L446" class="LineNr">446 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L447" class="LineNr">447 </span> 68/push <span class="Constant">"def"</span>/imm32 -<span id="L448" class="LineNr">448 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L449" class="LineNr">449 </span> <span class="subxS2Comment"># . . call</span> -<span id="L450" class="LineNr">450 </span> e8/call <a href='109stream-equal.subx.html#L233'>next-stream-line-equal?</a>/disp32 -<span id="L451" class="LineNr">451 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L452" class="LineNr">452 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L453" class="LineNr">453 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> -<span id="L454" class="LineNr">454 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L455" class="LineNr">455 </span> 68/push <span class="Constant">"F - test-next-stream-line-equal-skips-newline"</span>/imm32 -<span id="L456" class="LineNr">456 </span> 68/push 1/imm32 -<span id="L457" class="LineNr">457 </span> 50/push-eax -<span id="L458" class="LineNr">458 </span> <span class="subxS2Comment"># . . call</span> -<span id="L459" class="LineNr">459 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 -<span id="L460" class="LineNr">460 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L461" class="LineNr">461 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> -<span id="L462" class="LineNr">462 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L463" class="LineNr">463 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> -<span id="L464" class="LineNr">464 </span> 5d/pop-to-ebp -<span id="L465" class="LineNr">465 </span> c3/return -<span id="L466" class="LineNr">466 </span> -<span id="L467" class="LineNr">467 </span><span class="subxTest">test-next-stream-line-equal-handles-final-line</span>: -<span id="L468" class="LineNr">468 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L469" class="LineNr">469 </span> 55/push-ebp -<span id="L470" class="LineNr">470 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> -<span id="L471" class="LineNr">471 </span> <span class="subxComment"># clear-stream(_test-stream)</span> -<span id="L472" class="LineNr">472 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L473" class="LineNr">473 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L474" class="LineNr">474 </span> <span class="subxS2Comment"># . . call</span> -<span id="L475" class="LineNr">475 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 -<span id="L476" class="LineNr">476 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L477" class="LineNr">477 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> -<span id="L478" class="LineNr">478 </span> <span class="subxComment"># write(_test-stream, "Abc\ndef")</span> -<span id="L479" class="LineNr">479 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L480" class="LineNr">480 </span> 68/push <span class="Constant">"Abc\ndef"</span>/imm32 -<span id="L481" class="LineNr">481 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L482" class="LineNr">482 </span> <span class="subxS2Comment"># . . call</span> -<span id="L483" class="LineNr">483 </span> e8/call <a href='108write.subx.html#L11'>write</a>/disp32 -<span id="L484" class="LineNr">484 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L485" class="LineNr">485 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L486" class="LineNr">486 </span> <span class="subxComment"># next-stream-line-equal?(_test-stream, "Abc")</span> -<span id="L487" class="LineNr">487 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L488" class="LineNr">488 </span> 68/push <span class="Constant">"Abc"</span>/imm32 -<span id="L489" class="LineNr">489 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L490" class="LineNr">490 </span> <span class="subxS2Comment"># . . call</span> -<span id="L491" class="LineNr">491 </span> e8/call <a href='109stream-equal.subx.html#L233'>next-stream-line-equal?</a>/disp32 -<span id="L492" class="LineNr">492 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L493" class="LineNr">493 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L494" class="LineNr">494 </span> <span class="subxComment"># eax = next-stream-line-equal?(_test-stream, "def")</span> -<span id="L495" class="LineNr">495 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L496" class="LineNr">496 </span> 68/push <span class="Constant">"def"</span>/imm32 -<span id="L497" class="LineNr">497 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L498" class="LineNr">498 </span> <span class="subxS2Comment"># . . call</span> -<span id="L499" class="LineNr">499 </span> e8/call <a href='109stream-equal.subx.html#L233'>next-stream-line-equal?</a>/disp32 -<span id="L500" class="LineNr">500 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L501" class="LineNr">501 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L502" class="LineNr">502 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> -<span id="L503" class="LineNr">503 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L504" class="LineNr">504 </span> 68/push <span class="Constant">"F - test-next-stream-line-equal-skips-newline"</span>/imm32 -<span id="L505" class="LineNr">505 </span> 68/push 1/imm32 -<span id="L506" class="LineNr">506 </span> 50/push-eax -<span id="L507" class="LineNr">507 </span> <span class="subxS2Comment"># . . call</span> -<span id="L508" class="LineNr">508 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 -<span id="L509" class="LineNr">509 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L510" class="LineNr">510 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> -<span id="L511" class="LineNr">511 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L512" class="LineNr">512 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> -<span id="L513" class="LineNr">513 </span> 5d/pop-to-ebp -<span id="L514" class="LineNr">514 </span> c3/return -<span id="L515" class="LineNr">515 </span> -<span id="L516" class="LineNr">516 </span><span class="subxTest">test-next-stream-line-equal-always-fails-after-Eof</span>: -<span id="L517" class="LineNr">517 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L518" class="LineNr">518 </span> 55/push-ebp -<span id="L519" class="LineNr">519 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> -<span id="L520" class="LineNr">520 </span> <span class="subxComment"># clear-stream(_test-stream)</span> -<span id="L521" class="LineNr">521 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L522" class="LineNr">522 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L523" class="LineNr">523 </span> <span class="subxS2Comment"># . . call</span> -<span id="L524" class="LineNr">524 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 -<span id="L525" class="LineNr">525 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L526" class="LineNr">526 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> -<span id="L527" class="LineNr">527 </span> <span class="subxComment"># write nothing</span> -<span id="L528" class="LineNr">528 </span> <span class="subxComment"># eax = next-stream-line-equal?(_test-stream, "")</span> -<span id="L529" class="LineNr">529 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L530" class="LineNr">530 </span> 68/push <span class="Constant">""</span>/imm32 -<span id="L531" class="LineNr">531 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L532" class="LineNr">532 </span> <span class="subxS2Comment"># . . call</span> -<span id="L533" class="LineNr">533 </span> e8/call <a href='109stream-equal.subx.html#L233'>next-stream-line-equal?</a>/disp32 -<span id="L534" class="LineNr">534 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L535" class="LineNr">535 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L536" class="LineNr">536 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> -<span id="L537" class="LineNr">537 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L538" class="LineNr">538 </span> 68/push <span class="Constant">"F - test-next-stream-line-equal-always-fails-after-Eof"</span>/imm32 -<span id="L539" class="LineNr">539 </span> 68/push 1/imm32 -<span id="L540" class="LineNr">540 </span> 50/push-eax -<span id="L541" class="LineNr">541 </span> <span class="subxS2Comment"># . . call</span> -<span id="L542" class="LineNr">542 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 -<span id="L543" class="LineNr">543 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L544" class="LineNr">544 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> -<span id="L545" class="LineNr">545 </span> <span class="subxComment"># eax = next-stream-line-equal?(_test-stream, "")</span> -<span id="L546" class="LineNr">546 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L547" class="LineNr">547 </span> 68/push <span class="Constant">""</span>/imm32 -<span id="L548" class="LineNr">548 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 -<span id="L549" class="LineNr">549 </span> <span class="subxS2Comment"># . . call</span> -<span id="L550" class="LineNr">550 </span> e8/call <a href='109stream-equal.subx.html#L233'>next-stream-line-equal?</a>/disp32 -<span id="L551" class="LineNr">551 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L552" class="LineNr">552 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L553" class="LineNr">553 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> -<span id="L554" class="LineNr">554 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L555" class="LineNr">555 </span> 68/push <span class="Constant">"F - <a href='109stream-equal.subx.html#L516'>test-next-stream-line-equal-always-fails-after-Eof</a>/2"</span>/imm32 -<span id="L556" class="LineNr">556 </span> 68/push 1/imm32 -<span id="L557" class="LineNr">557 </span> 50/push-eax -<span id="L558" class="LineNr">558 </span> <span class="subxS2Comment"># . . call</span> -<span id="L559" class="LineNr">559 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 -<span id="L560" class="LineNr">560 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L561" class="LineNr">561 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> -<span id="L562" class="LineNr">562 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L563" class="LineNr">563 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> -<span id="L564" class="LineNr">564 </span> 5d/pop-to-ebp -<span id="L565" class="LineNr">565 </span> c3/return -<span id="L566" class="LineNr">566 </span> -<span id="L567" class="LineNr">567 </span><span class="subxComment"># helper for later tests</span> -<span id="L568" class="LineNr">568 </span><span class="subxFunction">check-next-stream-line-equal</span>: <span class="subxComment"># f: (addr stream byte), s: (addr array byte), msg: (addr array byte)</span> -<span id="L569" class="LineNr">569 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L570" class="LineNr">570 </span> 55/push-ebp -<span id="L571" class="LineNr">571 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> -<span id="L572" class="LineNr">572 </span> <span class="subxS1Comment"># . save registers</span> -<span id="L573" class="LineNr">573 </span> 50/push-eax -<span id="L574" class="LineNr">574 </span> <span class="subxComment"># eax = next-stream-line-equal?(f, s)</span> -<span id="L575" class="LineNr">575 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L576" class="LineNr">576 </span> ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(ebp+12)</span> -<span id="L577" class="LineNr">577 </span> ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(ebp+8)</span> -<span id="L578" class="LineNr">578 </span> <span class="subxS2Comment"># . . call</span> -<span id="L579" class="LineNr">579 </span> e8/call <a href='109stream-equal.subx.html#L233'>next-stream-line-equal?</a>/disp32 -<span id="L580" class="LineNr">580 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L581" class="LineNr">581 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L582" class="LineNr">582 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> -<span id="L583" class="LineNr">583 </span> <span class="subxS2Comment"># . . push args</span> -<span id="L584" class="LineNr">584 </span> ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0x10/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(ebp+16)</span> -<span id="L585" class="LineNr">585 </span> 68/push 1/imm32 -<span id="L586" class="LineNr">586 </span> 50/push-eax -<span id="L587" class="LineNr">587 </span> <span class="subxS2Comment"># . . call</span> -<span id="L588" class="LineNr">588 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 -<span id="L589" class="LineNr">589 </span> <span class="subxS2Comment"># . . discard args</span> -<span id="L590" class="LineNr">590 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> -<span id="L591" class="LineNr">591 </span> <span class="subxS1Comment"># . restore registers</span> -<span id="L592" class="LineNr">592 </span> 58/pop-to-eax -<span id="L593" class="LineNr">593 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L594" class="LineNr">594 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> -<span id="L595" class="LineNr">595 </span> 5d/pop-to-ebp -<span id="L596" class="LineNr">596 </span> c3/return -<span id="L597" class="LineNr">597 </span> -<span id="L598" class="LineNr">598 </span><span class="subxS2Comment"># . . vim:nowrap:textwidth=0</span> +<span id="L240" class="LineNr">240 </span> <span class="subxComment"># if (currs >= s->size) return false # the current line of f still has data to match</span> +<span id="L241" class="LineNr">241 </span> <span class="subxComment"># if (f[currf] != s[currs]) return false</span> +<span id="L242" class="LineNr">242 </span> <span class="subxComment"># ++currf</span> +<span id="L243" class="LineNr">243 </span> <span class="subxComment"># ++currs</span> +<span id="L244" class="LineNr">244 </span> <span class="subxComment">#</span> +<span id="L245" class="LineNr">245 </span> <span class="subxComment"># collapsing the two branches that can return true:</span> +<span id="L246" class="LineNr">246 </span> <span class="subxComment"># currf = f->read # bound: f->write</span> +<span id="L247" class="LineNr">247 </span> <span class="subxComment"># currs = 0 # bound: s->size</span> +<span id="L248" class="LineNr">248 </span> <span class="subxComment"># while true</span> +<span id="L249" class="LineNr">249 </span> <span class="subxComment"># if (currf >= f->write) break</span> +<span id="L250" class="LineNr">250 </span> <span class="subxComment"># if (f[currf] == '\n') break</span> +<span id="L251" class="LineNr">251 </span> <span class="subxComment"># if (currs >= s->size) return false # the current line of f still has data to match</span> +<span id="L252" class="LineNr">252 </span> <span class="subxComment"># if (f[currf] != s[currs]) return false</span> +<span id="L253" class="LineNr">253 </span> <span class="subxComment"># ++currf</span> +<span id="L254" class="LineNr">254 </span> <span class="subxComment"># ++currs</span> +<span id="L255" class="LineNr">255 </span> <span class="subxComment"># ++currf # skip '\n'</span> +<span id="L256" class="LineNr">256 </span> <span class="subxComment"># return currs >= s->size</span> +<span id="L257" class="LineNr">257 </span> <span class="subxComment"># Here the final `++currf` is sometimes unnecessary (if we're already at the end of the stream)</span> +<span id="L258" class="LineNr">258 </span> <span class="subxComment">#</span> +<span id="L259" class="LineNr">259 </span> <span class="subxComment"># registers:</span> +<span id="L260" class="LineNr">260 </span> <span class="subxComment"># f: esi</span> +<span id="L261" class="LineNr">261 </span> <span class="subxComment"># s: edi</span> +<span id="L262" class="LineNr">262 </span> <span class="subxComment"># currf: ecx</span> +<span id="L263" class="LineNr">263 </span> <span class="subxComment"># currs: edx</span> +<span id="L264" class="LineNr">264 </span> <span class="subxComment"># f[currf]: eax</span> +<span id="L265" class="LineNr">265 </span> <span class="subxComment"># s[currs]: ebx</span> +<span id="L266" class="LineNr">266 </span> <span class="subxComment">#</span> +<span id="L267" class="LineNr">267 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L268" class="LineNr">268 </span> 55/push-ebp +<span id="L269" class="LineNr">269 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L270" class="LineNr">270 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L271" class="LineNr">271 </span> 51/push-ecx +<span id="L272" class="LineNr">272 </span> 52/push-edx +<span id="L273" class="LineNr">273 </span> 56/push-esi +<span id="L274" class="LineNr">274 </span> 57/push-edi +<span id="L275" class="LineNr">275 </span> <span class="subxComment"># esi = f</span> +<span id="L276" class="LineNr">276 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 6/r32/esi 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+8) to esi</span> +<span id="L277" class="LineNr">277 </span> <span class="subxComment"># var currf/ecx: int = f->read</span> +<span id="L278" class="LineNr">278 </span> 8b/copy 1/mod/*+disp8 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(esi+4) to ecx</span> +<span id="L279" class="LineNr">279 </span> <span class="subxComment"># edi = s</span> +<span id="L280" class="LineNr">280 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 7/r32/edi 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+12) to edi</span> +<span id="L281" class="LineNr">281 </span> <span class="subxComment"># var currs/edx: int = 0</span> +<span id="L282" class="LineNr">282 </span> 31/xor 3/mod/direct 2/rm32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear edx</span> +<span id="L283" class="LineNr">283 </span> <span class="subxComment"># var c1/eax: byte = 0</span> +<span id="L284" class="LineNr">284 </span> 31/xor 3/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear eax</span> +<span id="L285" class="LineNr">285 </span> <span class="subxComment"># var c2/ebx: byte = 0</span> +<span id="L286" class="LineNr">286 </span> 31/xor 3/mod/direct 3/rm32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear ebx</span> +<span id="L287" class="LineNr">287 </span><span class="Constant">$next-stream-line-equal?:loop</span>: +<span id="L288" class="LineNr">288 </span> <span class="subxComment"># if (currf >= f->write) break</span> +<span id="L289" class="LineNr">289 </span> 3b/compare 0/mod/indirect 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare ecx with *esi</span> +<span id="L290" class="LineNr">290 </span> 7d/jump-if->= $next-stream-line-equal?:<span class="Constant">break</span>/disp8 +<span id="L291" class="LineNr">291 </span> <span class="subxComment"># c1 = f->data[f->read]</span> +<span id="L292" class="LineNr">292 </span> 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx <span class="Normal"> . </span> 0/r32/AL 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy byte at *(esi+ecx+12) to AL</span> +<span id="L293" class="LineNr">293 </span> <span class="subxComment"># if (c1 == '\n') break</span> +<span id="L294" class="LineNr">294 </span> 3d/compare-eax-and 0xa/imm32/newline +<span id="L295" class="LineNr">295 </span> 74/jump-if-= $next-stream-line-equal?:<span class="Constant">break</span>/disp8 +<span id="L296" class="LineNr">296 </span> <span class="subxComment"># if (currs >= s->size) return false</span> +<span id="L297" class="LineNr">297 </span> 3b/compare 0/mod/indirect 7/rm32/edi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare edx with *edi</span> +<span id="L298" class="LineNr">298 </span> 7d/jump-if->= $next-stream-line-equal?:false/disp8 +<span id="L299" class="LineNr">299 </span> <span class="subxComment"># c2 = s->data[currs]</span> +<span id="L300" class="LineNr">300 </span> 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 7/base/edi 2/index/edx <span class="Normal"> . </span> 3/r32/BL 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy byte at *(edi+edx+4) to BL</span> +<span id="L301" class="LineNr">301 </span> <span class="subxComment"># if (c1 != c2) return false</span> +<span id="L302" class="LineNr">302 </span> 39/compare 3/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare eax and ebx</span> +<span id="L303" class="LineNr">303 </span> 75/jump-if-!= $next-stream-line-equal?:false/disp8 +<span id="L304" class="LineNr">304 </span> <span class="subxComment"># ++currf</span> +<span id="L305" class="LineNr">305 </span> 41/increment-ecx +<span id="L306" class="LineNr">306 </span> <span class="subxComment"># ++currs</span> +<span id="L307" class="LineNr">307 </span> 42/increment-edx +<span id="L308" class="LineNr">308 </span> eb/jump $next-stream-line-equal?:<span class="Constant">loop</span>/disp8 +<span id="L309" class="LineNr">309 </span><span class="Constant">$next-stream-line-equal?:break</span>: +<span id="L310" class="LineNr">310 </span> <span class="subxComment"># ++currf</span> +<span id="L311" class="LineNr">311 </span> 41/increment-ecx +<span id="L312" class="LineNr">312 </span> <span class="subxComment"># if (currs >= s->size) return true</span> +<span id="L313" class="LineNr">313 </span> 3b/compare 0/mod/indirect 7/rm32/edi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare edx with *edi</span> +<span id="L314" class="LineNr">314 </span> 7c/jump-if-< $next-stream-line-equal?:false/disp8 +<span id="L315" class="LineNr">315 </span><span class="Constant">$next-stream-line-equal?:true</span>: +<span id="L316" class="LineNr">316 </span> b8/copy-to-eax 1/imm32 +<span id="L317" class="LineNr">317 </span> <span class="subxComment"># persist f->read on success</span> +<span id="L318" class="LineNr">318 </span> 89/copy 1/mod/*+disp8 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy ecx to *(esi+4)</span> +<span id="L319" class="LineNr">319 </span> eb/jump $next-stream-line-equal?:end/disp8 +<span id="L320" class="LineNr">320 </span><span class="Constant">$next-stream-line-equal?:false</span>: +<span id="L321" class="LineNr">321 </span> b8/copy-to-eax 0/imm32 +<span id="L322" class="LineNr">322 </span><span class="Constant">$next-stream-line-equal?:end</span>: +<span id="L323" class="LineNr">323 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L324" class="LineNr">324 </span> 5f/pop-to-edi +<span id="L325" class="LineNr">325 </span> 5e/pop-to-esi +<span id="L326" class="LineNr">326 </span> 5a/pop-to-edx +<span id="L327" class="LineNr">327 </span> 59/pop-to-ecx +<span id="L328" class="LineNr">328 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L329" class="LineNr">329 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L330" class="LineNr">330 </span> 5d/pop-to-ebp +<span id="L331" class="LineNr">331 </span> c3/return +<span id="L332" class="LineNr">332 </span> +<span id="L333" class="LineNr">333 </span><span class="subxTest">test-next-stream-line-equal-stops-at-newline</span>: +<span id="L334" class="LineNr">334 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L335" class="LineNr">335 </span> 55/push-ebp +<span id="L336" class="LineNr">336 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L337" class="LineNr">337 </span> <span class="subxComment"># clear-stream(_test-stream)</span> +<span id="L338" class="LineNr">338 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L339" class="LineNr">339 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L340" class="LineNr">340 </span> <span class="subxS2Comment"># . . call</span> +<span id="L341" class="LineNr">341 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 +<span id="L342" class="LineNr">342 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L343" class="LineNr">343 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L344" class="LineNr">344 </span> <span class="subxComment"># write(_test-stream, "Abc\ndef")</span> +<span id="L345" class="LineNr">345 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L346" class="LineNr">346 </span> 68/push <span class="Constant">"Abc\ndef"</span>/imm32 +<span id="L347" class="LineNr">347 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L348" class="LineNr">348 </span> <span class="subxS2Comment"># . . call</span> +<span id="L349" class="LineNr">349 </span> e8/call <a href='108write.subx.html#L11'>write</a>/disp32 +<span id="L350" class="LineNr">350 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L351" class="LineNr">351 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L352" class="LineNr">352 </span> <span class="subxComment"># eax = next-stream-line-equal?(_test-stream, "Abc")</span> +<span id="L353" class="LineNr">353 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L354" class="LineNr">354 </span> 68/push <span class="Constant">"Abc"</span>/imm32 +<span id="L355" class="LineNr">355 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L356" class="LineNr">356 </span> <span class="subxS2Comment"># . . call</span> +<span id="L357" class="LineNr">357 </span> e8/call <a href='109stream-equal.subx.html#L230'>next-stream-line-equal?</a>/disp32 +<span id="L358" class="LineNr">358 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L359" class="LineNr">359 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L360" class="LineNr">360 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> +<span id="L361" class="LineNr">361 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L362" class="LineNr">362 </span> 68/push <span class="Constant">"F - test-next-stream-line-equal-stops-at-newline"</span>/imm32 +<span id="L363" class="LineNr">363 </span> 68/push 1/imm32 +<span id="L364" class="LineNr">364 </span> 50/push-eax +<span id="L365" class="LineNr">365 </span> <span class="subxS2Comment"># . . call</span> +<span id="L366" class="LineNr">366 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L367" class="LineNr">367 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L368" class="LineNr">368 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L369" class="LineNr">369 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L370" class="LineNr">370 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L371" class="LineNr">371 </span> 5d/pop-to-ebp +<span id="L372" class="LineNr">372 </span> c3/return +<span id="L373" class="LineNr">373 </span> +<span id="L374" class="LineNr">374 </span><span class="subxTest">test-next-stream-line-equal-stops-at-newline-2</span>: +<span id="L375" class="LineNr">375 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L376" class="LineNr">376 </span> 55/push-ebp +<span id="L377" class="LineNr">377 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L378" class="LineNr">378 </span> <span class="subxComment"># clear-stream(_test-stream)</span> +<span id="L379" class="LineNr">379 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L380" class="LineNr">380 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L381" class="LineNr">381 </span> <span class="subxS2Comment"># . . call</span> +<span id="L382" class="LineNr">382 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 +<span id="L383" class="LineNr">383 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L384" class="LineNr">384 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L385" class="LineNr">385 </span> <span class="subxComment"># write(_test-stream, "Abc\ndef")</span> +<span id="L386" class="LineNr">386 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L387" class="LineNr">387 </span> 68/push <span class="Constant">"Abc\ndef"</span>/imm32 +<span id="L388" class="LineNr">388 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L389" class="LineNr">389 </span> <span class="subxS2Comment"># . . call</span> +<span id="L390" class="LineNr">390 </span> e8/call <a href='108write.subx.html#L11'>write</a>/disp32 +<span id="L391" class="LineNr">391 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L392" class="LineNr">392 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L393" class="LineNr">393 </span> <span class="subxComment"># eax = next-stream-line-equal?(_test-stream, "def")</span> +<span id="L394" class="LineNr">394 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L395" class="LineNr">395 </span> 68/push <span class="Constant">"def"</span>/imm32 +<span id="L396" class="LineNr">396 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L397" class="LineNr">397 </span> <span class="subxS2Comment"># . . call</span> +<span id="L398" class="LineNr">398 </span> e8/call <a href='109stream-equal.subx.html#L230'>next-stream-line-equal?</a>/disp32 +<span id="L399" class="LineNr">399 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L400" class="LineNr">400 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L401" class="LineNr">401 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> +<span id="L402" class="LineNr">402 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L403" class="LineNr">403 </span> 68/push <span class="Constant">"F - test-next-stream-line-equal-stops-at-newline-2"</span>/imm32 +<span id="L404" class="LineNr">404 </span> 68/push 0/imm32 +<span id="L405" class="LineNr">405 </span> 50/push-eax +<span id="L406" class="LineNr">406 </span> <span class="subxS2Comment"># . . call</span> +<span id="L407" class="LineNr">407 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L408" class="LineNr">408 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L409" class="LineNr">409 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L410" class="LineNr">410 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L411" class="LineNr">411 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L412" class="LineNr">412 </span> 5d/pop-to-ebp +<span id="L413" class="LineNr">413 </span> c3/return +<span id="L414" class="LineNr">414 </span> +<span id="L415" class="LineNr">415 </span><span class="subxTest">test-next-stream-line-equal-skips-newline</span>: +<span id="L416" class="LineNr">416 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L417" class="LineNr">417 </span> 55/push-ebp +<span id="L418" class="LineNr">418 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L419" class="LineNr">419 </span> <span class="subxComment"># clear-stream(_test-stream)</span> +<span id="L420" class="LineNr">420 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L421" class="LineNr">421 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L422" class="LineNr">422 </span> <span class="subxS2Comment"># . . call</span> +<span id="L423" class="LineNr">423 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 +<span id="L424" class="LineNr">424 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L425" class="LineNr">425 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L426" class="LineNr">426 </span> <span class="subxComment"># write(_test-stream, "Abc\ndef\n")</span> +<span id="L427" class="LineNr">427 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L428" class="LineNr">428 </span> 68/push <span class="Constant">"Abc\ndef\n"</span>/imm32 +<span id="L429" class="LineNr">429 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L430" class="LineNr">430 </span> <span class="subxS2Comment"># . . call</span> +<span id="L431" class="LineNr">431 </span> e8/call <a href='108write.subx.html#L11'>write</a>/disp32 +<span id="L432" class="LineNr">432 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L433" class="LineNr">433 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L434" class="LineNr">434 </span> <span class="subxComment"># next-stream-line-equal?(_test-stream, "Abc")</span> +<span id="L435" class="LineNr">435 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L436" class="LineNr">436 </span> 68/push <span class="Constant">"Abc"</span>/imm32 +<span id="L437" class="LineNr">437 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L438" class="LineNr">438 </span> <span class="subxS2Comment"># . . call</span> +<span id="L439" class="LineNr">439 </span> e8/call <a href='109stream-equal.subx.html#L230'>next-stream-line-equal?</a>/disp32 +<span id="L440" class="LineNr">440 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L441" class="LineNr">441 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L442" class="LineNr">442 </span> <span class="subxComment"># eax = next-stream-line-equal?(_test-stream, "def")</span> +<span id="L443" class="LineNr">443 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L444" class="LineNr">444 </span> 68/push <span class="Constant">"def"</span>/imm32 +<span id="L445" class="LineNr">445 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L446" class="LineNr">446 </span> <span class="subxS2Comment"># . . call</span> +<span id="L447" class="LineNr">447 </span> e8/call <a href='109stream-equal.subx.html#L230'>next-stream-line-equal?</a>/disp32 +<span id="L448" class="LineNr">448 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L449" class="LineNr">449 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L450" class="LineNr">450 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> +<span id="L451" class="LineNr">451 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L452" class="LineNr">452 </span> 68/push <span class="Constant">"F - test-next-stream-line-equal-skips-newline"</span>/imm32 +<span id="L453" class="LineNr">453 </span> 68/push 1/imm32 +<span id="L454" class="LineNr">454 </span> 50/push-eax +<span id="L455" class="LineNr">455 </span> <span class="subxS2Comment"># . . call</span> +<span id="L456" class="LineNr">456 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L457" class="LineNr">457 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L458" class="LineNr">458 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L459" class="LineNr">459 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L460" class="LineNr">460 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L461" class="LineNr">461 </span> 5d/pop-to-ebp +<span id="L462" class="LineNr">462 </span> c3/return +<span id="L463" class="LineNr">463 </span> +<span id="L464" class="LineNr">464 </span><span class="subxTest">test-next-stream-line-equal-handles-final-line</span>: +<span id="L465" class="LineNr">465 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L466" class="LineNr">466 </span> 55/push-ebp +<span id="L467" class="LineNr">467 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L468" class="LineNr">468 </span> <span class="subxComment"># clear-stream(_test-stream)</span> +<span id="L469" class="LineNr">469 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L470" class="LineNr">470 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L471" class="LineNr">471 </span> <span class="subxS2Comment"># . . call</span> +<span id="L472" class="LineNr">472 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 +<span id="L473" class="LineNr">473 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L474" class="LineNr">474 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L475" class="LineNr">475 </span> <span class="subxComment"># write(_test-stream, "Abc\ndef")</span> +<span id="L476" class="LineNr">476 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L477" class="LineNr">477 </span> 68/push <span class="Constant">"Abc\ndef"</span>/imm32 +<span id="L478" class="LineNr">478 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L479" class="LineNr">479 </span> <span class="subxS2Comment"># . . call</span> +<span id="L480" class="LineNr">480 </span> e8/call <a href='108write.subx.html#L11'>write</a>/disp32 +<span id="L481" class="LineNr">481 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L482" class="LineNr">482 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L483" class="LineNr">483 </span> <span class="subxComment"># next-stream-line-equal?(_test-stream, "Abc")</span> +<span id="L484" class="LineNr">484 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L485" class="LineNr">485 </span> 68/push <span class="Constant">"Abc"</span>/imm32 +<span id="L486" class="LineNr">486 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L487" class="LineNr">487 </span> <span class="subxS2Comment"># . . call</span> +<span id="L488" class="LineNr">488 </span> e8/call <a href='109stream-equal.subx.html#L230'>next-stream-line-equal?</a>/disp32 +<span id="L489" class="LineNr">489 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L490" class="LineNr">490 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L491" class="LineNr">491 </span> <span class="subxComment"># eax = next-stream-line-equal?(_test-stream, "def")</span> +<span id="L492" class="LineNr">492 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L493" class="LineNr">493 </span> 68/push <span class="Constant">"def"</span>/imm32 +<span id="L494" class="LineNr">494 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L495" class="LineNr">495 </span> <span class="subxS2Comment"># . . call</span> +<span id="L496" class="LineNr">496 </span> e8/call <a href='109stream-equal.subx.html#L230'>next-stream-line-equal?</a>/disp32 +<span id="L497" class="LineNr">497 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L498" class="LineNr">498 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L499" class="LineNr">499 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> +<span id="L500" class="LineNr">500 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L501" class="LineNr">501 </span> 68/push <span class="Constant">"F - test-next-stream-line-equal-skips-newline"</span>/imm32 +<span id="L502" class="LineNr">502 </span> 68/push 1/imm32 +<span id="L503" class="LineNr">503 </span> 50/push-eax +<span id="L504" class="LineNr">504 </span> <span class="subxS2Comment"># . . call</span> +<span id="L505" class="LineNr">505 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L506" class="LineNr">506 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L507" class="LineNr">507 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L508" class="LineNr">508 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L509" class="LineNr">509 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L510" class="LineNr">510 </span> 5d/pop-to-ebp +<span id="L511" class="LineNr">511 </span> c3/return +<span id="L512" class="LineNr">512 </span> +<span id="L513" class="LineNr">513 </span><span class="subxTest">test-next-stream-line-equal-always-fails-after-Eof</span>: +<span id="L514" class="LineNr">514 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L515" class="LineNr">515 </span> 55/push-ebp +<span id="L516" class="LineNr">516 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L517" class="LineNr">517 </span> <span class="subxComment"># clear-stream(_test-stream)</span> +<span id="L518" class="LineNr">518 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L519" class="LineNr">519 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L520" class="LineNr">520 </span> <span class="subxS2Comment"># . . call</span> +<span id="L521" class="LineNr">521 </span> e8/call <a href='106stream.subx.html#L20'>clear-stream</a>/disp32 +<span id="L522" class="LineNr">522 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L523" class="LineNr">523 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L524" class="LineNr">524 </span> <span class="subxComment"># write nothing</span> +<span id="L525" class="LineNr">525 </span> <span class="subxComment"># eax = next-stream-line-equal?(_test-stream, "")</span> +<span id="L526" class="LineNr">526 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L527" class="LineNr">527 </span> 68/push <span class="Constant">""</span>/imm32 +<span id="L528" class="LineNr">528 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L529" class="LineNr">529 </span> <span class="subxS2Comment"># . . call</span> +<span id="L530" class="LineNr">530 </span> e8/call <a href='109stream-equal.subx.html#L230'>next-stream-line-equal?</a>/disp32 +<span id="L531" class="LineNr">531 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L532" class="LineNr">532 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L533" class="LineNr">533 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> +<span id="L534" class="LineNr">534 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L535" class="LineNr">535 </span> 68/push <span class="Constant">"F - test-next-stream-line-equal-always-fails-after-Eof"</span>/imm32 +<span id="L536" class="LineNr">536 </span> 68/push 1/imm32 +<span id="L537" class="LineNr">537 </span> 50/push-eax +<span id="L538" class="LineNr">538 </span> <span class="subxS2Comment"># . . call</span> +<span id="L539" class="LineNr">539 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L540" class="LineNr">540 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L541" class="LineNr">541 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L542" class="LineNr">542 </span> <span class="subxComment"># eax = next-stream-line-equal?(_test-stream, "")</span> +<span id="L543" class="LineNr">543 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L544" class="LineNr">544 </span> 68/push <span class="Constant">""</span>/imm32 +<span id="L545" class="LineNr">545 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 +<span id="L546" class="LineNr">546 </span> <span class="subxS2Comment"># . . call</span> +<span id="L547" class="LineNr">547 </span> e8/call <a href='109stream-equal.subx.html#L230'>next-stream-line-equal?</a>/disp32 +<span id="L548" class="LineNr">548 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L549" class="LineNr">549 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L550" class="LineNr">550 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> +<span id="L551" class="LineNr">551 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L552" class="LineNr">552 </span> 68/push <span class="Constant">"F - <a href='109stream-equal.subx.html#L513'>test-next-stream-line-equal-always-fails-after-Eof</a>/2"</span>/imm32 +<span id="L553" class="LineNr">553 </span> 68/push 1/imm32 +<span id="L554" class="LineNr">554 </span> 50/push-eax +<span id="L555" class="LineNr">555 </span> <span class="subxS2Comment"># . . call</span> +<span id="L556" class="LineNr">556 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L557" class="LineNr">557 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L558" class="LineNr">558 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L559" class="LineNr">559 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L560" class="LineNr">560 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L561" class="LineNr">561 </span> 5d/pop-to-ebp +<span id="L562" class="LineNr">562 </span> c3/return +<span id="L563" class="LineNr">563 </span> +<span id="L564" class="LineNr">564 </span><span class="subxComment"># helper for later tests</span> +<span id="L565" class="LineNr">565 </span><span class="subxFunction">check-next-stream-line-equal</span>: <span class="subxComment"># f: (addr stream byte), s: (addr array byte), msg: (addr array byte)</span> +<span id="L566" class="LineNr">566 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L567" class="LineNr">567 </span> 55/push-ebp +<span id="L568" class="LineNr">568 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L569" class="LineNr">569 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L570" class="LineNr">570 </span> 50/push-eax +<span id="L571" class="LineNr">571 </span> <span class="subxComment"># eax = next-stream-line-equal?(f, s)</span> +<span id="L572" class="LineNr">572 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L573" class="LineNr">573 </span> ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(ebp+12)</span> +<span id="L574" class="LineNr">574 </span> ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(ebp+8)</span> +<span id="L575" class="LineNr">575 </span> <span class="subxS2Comment"># . . call</span> +<span id="L576" class="LineNr">576 </span> e8/call <a href='109stream-equal.subx.html#L230'>next-stream-line-equal?</a>/disp32 +<span id="L577" class="LineNr">577 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L578" class="LineNr">578 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L579" class="LineNr">579 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> +<span id="L580" class="LineNr">580 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L581" class="LineNr">581 </span> ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0x10/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(ebp+16)</span> +<span id="L582" class="LineNr">582 </span> 68/push 1/imm32 +<span id="L583" class="LineNr">583 </span> 50/push-eax +<span id="L584" class="LineNr">584 </span> <span class="subxS2Comment"># . . call</span> +<span id="L585" class="LineNr">585 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L586" class="LineNr">586 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L587" class="LineNr">587 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L588" class="LineNr">588 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L589" class="LineNr">589 </span> 58/pop-to-eax +<span id="L590" class="LineNr">590 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L591" class="LineNr">591 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L592" class="LineNr">592 </span> 5d/pop-to-ebp +<span id="L593" class="LineNr">593 </span> c3/return +<span id="L594" class="LineNr">594 </span> +<span id="L595" class="LineNr">595 </span><span class="subxS2Comment"># . . vim:nowrap:textwidth=0</span> </pre> </body> </html> diff --git a/html/baremetal/112read-byte.subx.html b/html/baremetal/112read-byte.subx.html index 1ae80edd..a853654b 100644 --- a/html/baremetal/112read-byte.subx.html +++ b/html/baremetal/112read-byte.subx.html @@ -16,9 +16,10 @@ a { color:inherit; } * { font-size:12pt; font-size: 1em; } .subxComment { color: #005faf; } .subxS1Comment { color: #0000af; } -.subxS2Comment { color: #8a8a8a; } +.subxMinorFunction { color: #875f5f; } .LineNr { } .Constant { color: #008787; } +.subxS2Comment { color: #8a8a8a; } .subxFunction { color: #af5f00; text-decoration: underline; } .Normal { color: #000000; background-color: #c6c6c6; padding-bottom: 1px; } --> @@ -56,54 +57,129 @@ if ('onhashchange' in window) { <body onload='JumpToLine();'> <a href='https://github.com/akkartik/mu/blob/main/baremetal/112read-byte.subx'>https://github.com/akkartik/mu/blob/main/baremetal/112read-byte.subx</a> <pre id='vimCodeElement'> -<span id="L1" class="LineNr"> 1 </span><span class="subxComment"># Read a single byte from a stream.</span> -<span id="L2" class="LineNr"> 2 </span><span class="subxComment">#</span> -<span id="L3" class="LineNr"> 3 </span><span class="subxComment"># We need to do this in machine code because streams need to be opaque types,</span> -<span id="L4" class="LineNr"> 4 </span><span class="subxComment"># and we don't yet support opaque types in Mu.</span> -<span id="L5" class="LineNr"> 5 </span> -<span id="L6" class="LineNr"> 6 </span>== code -<span id="L7" class="LineNr"> 7 </span><span class="subxComment"># instruction effective address register displacement immediate</span> -<span id="L8" class="LineNr"> 8 </span><span class="subxS1Comment"># . op subop mod rm32 base index scale r32</span> -<span id="L9" class="LineNr"> 9 </span><span class="subxS1Comment"># . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes</span> -<span id="L10" class="LineNr">10 </span> -<span id="L11" class="LineNr">11 </span><span class="subxComment"># Return next byte value in eax, with top 3 bytes cleared.</span> -<span id="L12" class="LineNr">12 </span><span class="subxComment"># Abort on reaching end of stream.</span> -<span id="L13" class="LineNr">13 </span><span class="subxFunction">read-byte</span>: <span class="subxComment"># s: (addr stream byte) -> result/eax: byte</span> -<span id="L14" class="LineNr">14 </span> <span class="subxS1Comment"># . prologue</span> -<span id="L15" class="LineNr">15 </span> 55/push-ebp -<span id="L16" class="LineNr">16 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> -<span id="L17" class="LineNr">17 </span> <span class="subxS1Comment"># . save registers</span> -<span id="L18" class="LineNr">18 </span> 51/push-ecx -<span id="L19" class="LineNr">19 </span> 56/push-esi -<span id="L20" class="LineNr">20 </span> <span class="subxComment"># esi = s</span> -<span id="L21" class="LineNr">21 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 6/r32/esi 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+8) to esi</span> -<span id="L22" class="LineNr">22 </span> <span class="subxComment"># ecx = s->read</span> -<span id="L23" class="LineNr">23 </span> 8b/copy 1/mod/*+disp8 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(esi+4) to ecx</span> -<span id="L24" class="LineNr">24 </span> <span class="subxComment"># if (f->read >= f->write) abort</span> -<span id="L25" class="LineNr">25 </span> 3b/compare 0/mod/indirect 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare ecx with *esi</span> -<span id="L26" class="LineNr">26 </span> 0f 8d/jump-if->= $read-byte:abort/disp32 -<span id="L27" class="LineNr">27 </span> <span class="subxComment"># result = f->data[f->read]</span> -<span id="L28" class="LineNr">28 </span> 31/xor 3/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear eax</span> -<span id="L29" class="LineNr">29 </span> 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx <span class="Normal"> . </span> 0/r32/AL 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy byte at *(esi+ecx+12) to AL</span> -<span id="L30" class="LineNr">30 </span> <span class="subxComment"># ++f->read</span> -<span id="L31" class="LineNr">31 </span> ff 0/subop/increment 1/mod/*+disp8 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># increment *(esi+4)</span> -<span id="L32" class="LineNr">32 </span><span class="Constant">$read-byte:end</span>: -<span id="L33" class="LineNr">33 </span> <span class="subxS1Comment"># . restore registers</span> -<span id="L34" class="LineNr">34 </span> 5e/pop-to-esi -<span id="L35" class="LineNr">35 </span> 59/pop-to-ecx -<span id="L36" class="LineNr">36 </span> <span class="subxS1Comment"># . epilogue</span> -<span id="L37" class="LineNr">37 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> -<span id="L38" class="LineNr">38 </span> 5d/pop-to-ebp -<span id="L39" class="LineNr">39 </span> c3/return -<span id="L40" class="LineNr">40 </span> -<span id="L41" class="LineNr">41 </span><span class="Constant">$read-byte:abort</span>: -<span id="L42" class="LineNr">42 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"read-byte: empty stream"</span> 3) <span class="subxComment"># 3=cyan</span> -<span id="L43" class="LineNr">43 </span> { -<span id="L44" class="LineNr">44 </span> eb/jump <span class="Constant">loop</span>/disp8 -<span id="L45" class="LineNr">45 </span> } -<span id="L46" class="LineNr">46 </span> <span class="subxComment"># never gets here</span> -<span id="L47" class="LineNr">47 </span> -<span id="L48" class="LineNr">48 </span><span class="subxS2Comment"># . . vim:nowrap:textwidth=0</span> +<span id="L1" class="LineNr"> 1 </span><span class="subxComment"># Read a single byte from a stream.</span> +<span id="L2" class="LineNr"> 2 </span><span class="subxComment">#</span> +<span id="L3" class="LineNr"> 3 </span><span class="subxComment"># We need to do this in machine code because streams need to be opaque types,</span> +<span id="L4" class="LineNr"> 4 </span><span class="subxComment"># and we don't yet support opaque types in Mu.</span> +<span id="L5" class="LineNr"> 5 </span> +<span id="L6" class="LineNr"> 6 </span>== code +<span id="L7" class="LineNr"> 7 </span><span class="subxComment"># instruction effective address register displacement immediate</span> +<span id="L8" class="LineNr"> 8 </span><span class="subxS1Comment"># . op subop mod rm32 base index scale r32</span> +<span id="L9" class="LineNr"> 9 </span><span class="subxS1Comment"># . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes</span> +<span id="L10" class="LineNr"> 10 </span> +<span id="L11" class="LineNr"> 11 </span><span class="subxComment"># Return next byte value in eax, with top 3 bytes cleared.</span> +<span id="L12" class="LineNr"> 12 </span><span class="subxComment"># Abort on reaching end of stream.</span> +<span id="L13" class="LineNr"> 13 </span><span class="subxFunction">read-byte</span>: <span class="subxComment"># s: (addr stream byte) -> result/eax: byte</span> +<span id="L14" class="LineNr"> 14 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L15" class="LineNr"> 15 </span> 55/push-ebp +<span id="L16" class="LineNr"> 16 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L17" class="LineNr"> 17 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L18" class="LineNr"> 18 </span> 51/push-ecx +<span id="L19" class="LineNr"> 19 </span> 56/push-esi +<span id="L20" class="LineNr"> 20 </span> <span class="subxComment"># esi = s</span> +<span id="L21" class="LineNr"> 21 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 6/r32/esi 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+8) to esi</span> +<span id="L22" class="LineNr"> 22 </span> <span class="subxComment"># ecx = s->read</span> +<span id="L23" class="LineNr"> 23 </span> 8b/copy 1/mod/*+disp8 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(esi+4) to ecx</span> +<span id="L24" class="LineNr"> 24 </span> <span class="subxComment"># if (f->read >= f->write) abort</span> +<span id="L25" class="LineNr"> 25 </span> 3b/compare 0/mod/indirect 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare ecx with *esi</span> +<span id="L26" class="LineNr"> 26 </span> 0f 8d/jump-if->= $read-byte:<a href='501draw-text.mu.html#L519'>abort</a>/disp32 +<span id="L27" class="LineNr"> 27 </span> <span class="subxComment"># result = f->data[f->read]</span> +<span id="L28" class="LineNr"> 28 </span> 31/xor 3/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear eax</span> +<span id="L29" class="LineNr"> 29 </span> 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/esi 1/index/ecx <span class="Normal"> . </span> 0/r32/AL 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy byte at *(esi+ecx+12) to AL</span> +<span id="L30" class="LineNr"> 30 </span> <span class="subxComment"># ++f->read</span> +<span id="L31" class="LineNr"> 31 </span> ff 0/subop/increment 1/mod/*+disp8 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># increment *(esi+4)</span> +<span id="L32" class="LineNr"> 32 </span><span class="Constant">$read-byte:end</span>: +<span id="L33" class="LineNr"> 33 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L34" class="LineNr"> 34 </span> 5e/pop-to-esi +<span id="L35" class="LineNr"> 35 </span> 59/pop-to-ecx +<span id="L36" class="LineNr"> 36 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L37" class="LineNr"> 37 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L38" class="LineNr"> 38 </span> 5d/pop-to-ebp +<span id="L39" class="LineNr"> 39 </span> c3/return +<span id="L40" class="LineNr"> 40 </span> +<span id="L41" class="LineNr"> 41 </span><span class="Constant">$read-byte:<a href='501draw-text.mu.html#L519'>abort</a></span>: +<span id="L42" class="LineNr"> 42 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"read-byte: empty stream"</span> 3 0) <span class="subxComment"># 3=cyan</span> +<span id="L43" class="LineNr"> 43 </span> { +<span id="L44" class="LineNr"> 44 </span> eb/jump <span class="Constant">loop</span>/disp8 +<span id="L45" class="LineNr"> 45 </span> } +<span id="L46" class="LineNr"> 46 </span> <span class="subxComment"># never gets here</span> +<span id="L47" class="LineNr"> 47 </span> +<span id="L48" class="LineNr"> 48 </span>== data +<span id="L49" class="LineNr"> 49 </span> +<span id="L50" class="LineNr"> 50 </span><span class="subxMinorFunction">_test-input-stream</span>: <span class="subxComment"># (stream byte)</span> +<span id="L51" class="LineNr"> 51 </span> <span class="subxComment"># current write index</span> +<span id="L52" class="LineNr"> 52 </span> 0/imm32 +<span id="L53" class="LineNr"> 53 </span> <span class="subxComment"># current read index</span> +<span id="L54" class="LineNr"> 54 </span> 0/imm32 +<span id="L55" class="LineNr"> 55 </span> <span class="subxComment"># size</span> +<span id="L56" class="LineNr"> 56 </span> 0x400/imm32 <span class="subxComment"># 1024 bytes</span> +<span id="L57" class="LineNr"> 57 </span> <span class="subxComment"># data (64 lines x 16 bytes/line)</span> +<span id="L58" class="LineNr"> 58 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L59" class="LineNr"> 59 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L60" class="LineNr"> 60 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L61" class="LineNr"> 61 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L62" class="LineNr"> 62 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L63" class="LineNr"> 63 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L64" class="LineNr"> 64 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L65" class="LineNr"> 65 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L66" class="LineNr"> 66 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L67" class="LineNr"> 67 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L68" class="LineNr"> 68 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L69" class="LineNr"> 69 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L70" class="LineNr"> 70 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L71" class="LineNr"> 71 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L72" class="LineNr"> 72 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L73" class="LineNr"> 73 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L74" class="LineNr"> 74 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L75" class="LineNr"> 75 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L76" class="LineNr"> 76 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L77" class="LineNr"> 77 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L78" class="LineNr"> 78 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L79" class="LineNr"> 79 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L80" class="LineNr"> 80 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L81" class="LineNr"> 81 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L82" class="LineNr"> 82 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L83" class="LineNr"> 83 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L84" class="LineNr"> 84 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L85" class="LineNr"> 85 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L86" class="LineNr"> 86 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L87" class="LineNr"> 87 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L88" class="LineNr"> 88 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L89" class="LineNr"> 89 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L90" class="LineNr"> 90 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L91" class="LineNr"> 91 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L92" class="LineNr"> 92 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L93" class="LineNr"> 93 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L94" class="LineNr"> 94 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L95" class="LineNr"> 95 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L96" class="LineNr"> 96 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L97" class="LineNr"> 97 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L98" class="LineNr"> 98 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L99" class="LineNr"> 99 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L100" class="LineNr">100 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L101" class="LineNr">101 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L102" class="LineNr">102 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L103" class="LineNr">103 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L104" class="LineNr">104 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L105" class="LineNr">105 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L106" class="LineNr">106 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L107" class="LineNr">107 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L108" class="LineNr">108 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L109" class="LineNr">109 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L110" class="LineNr">110 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L111" class="LineNr">111 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L112" class="LineNr">112 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L113" class="LineNr">113 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L114" class="LineNr">114 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L115" class="LineNr">115 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L116" class="LineNr">116 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L117" class="LineNr">117 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L118" class="LineNr">118 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L119" class="LineNr">119 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L120" class="LineNr">120 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L121" class="LineNr">121 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L122" class="LineNr">122 </span> +<span id="L123" class="LineNr">123 </span><span class="subxS2Comment"># . . vim:nowrap:textwidth=0</span> </pre> </body> </html> diff --git a/html/baremetal/115write-byte.subx.html b/html/baremetal/115write-byte.subx.html index 463ddc4d..002dc0c9 100644 --- a/html/baremetal/115write-byte.subx.html +++ b/html/baremetal/115write-byte.subx.html @@ -82,7 +82,7 @@ if ('onhashchange' in window) { <span id="L22" class="LineNr">22 </span> 8b/copy 0/mod/indirect 7/rm32/edi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *edi to ecx</span> <span id="L23" class="LineNr">23 </span> <span class="subxComment"># if (f->write >= f->size) abort</span> <span id="L24" class="LineNr">24 </span> 3b/compare 1/mod/*+disp8 7/rm32/edi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># compare ecx with *(edi+8)</span> -<span id="L25" class="LineNr">25 </span> 7d/jump-if->= $append-byte:abort/disp8 +<span id="L25" class="LineNr">25 </span> 7d/jump-if->= $append-byte:<a href='501draw-text.mu.html#L519'>abort</a>/disp8 <span id="L26" class="LineNr">26 </span><span class="Constant">$append-byte:to-stream</span>: <span id="L27" class="LineNr">27 </span> <span class="subxComment"># write to stream</span> <span id="L28" class="LineNr">28 </span> <span class="subxComment"># f->data[f->write] = LSB(n)</span> @@ -100,8 +100,8 @@ if ('onhashchange' in window) { <span id="L40" class="LineNr">40 </span> 5d/pop-to-ebp <span id="L41" class="LineNr">41 </span> c3/return <span id="L42" class="LineNr">42 </span> -<span id="L43" class="LineNr">43 </span><span class="Constant">$append-byte:abort</span>: -<span id="L44" class="LineNr">44 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"append-byte: out of space\n"</span> 3) <span class="subxComment"># 3=cyan</span> +<span id="L43" class="LineNr">43 </span><span class="Constant">$append-byte:<a href='501draw-text.mu.html#L519'>abort</a></span>: +<span id="L44" class="LineNr">44 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"append-byte: out of space\n"</span> 3 0) <span class="subxComment"># 3=cyan</span> <span id="L45" class="LineNr">45 </span> { <span id="L46" class="LineNr">46 </span> eb/jump <span class="Constant">loop</span>/disp8 <span id="L47" class="LineNr">47 </span> } @@ -131,7 +131,7 @@ if ('onhashchange' in window) { <span id="L71" class="LineNr">71 </span> 68/push <span class="Constant">"A"</span>/imm32 <span id="L72" class="LineNr">72 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 <span id="L73" class="LineNr">73 </span> <span class="subxS2Comment"># . . call</span> -<span id="L74" class="LineNr">74 </span> e8/call <a href='109stream-equal.subx.html#L197'>check-stream-equal</a>/disp32 +<span id="L74" class="LineNr">74 </span> e8/call <a href='109stream-equal.subx.html#L194'>check-stream-equal</a>/disp32 <span id="L75" class="LineNr">75 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L76" class="LineNr">76 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> <span id="L77" class="LineNr">77 </span> <span class="subxS1Comment"># . end</span> diff --git a/html/baremetal/117write-int-hex.subx.html b/html/baremetal/117write-int-hex.subx.html index 00b68fdd..f0800cbb 100644 --- a/html/baremetal/117write-int-hex.subx.html +++ b/html/baremetal/117write-int-hex.subx.html @@ -143,7 +143,7 @@ if ('onhashchange' in window) { <span id="L83" class="LineNr"> 83 </span> 68/push <span class="Constant">"0a"</span>/imm32 <span id="L84" class="LineNr"> 84 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 <span id="L85" class="LineNr"> 85 </span> <span class="subxS2Comment"># . . call</span> -<span id="L86" class="LineNr"> 86 </span> e8/call <a href='109stream-equal.subx.html#L197'>check-stream-equal</a>/disp32 +<span id="L86" class="LineNr"> 86 </span> e8/call <a href='109stream-equal.subx.html#L194'>check-stream-equal</a>/disp32 <span id="L87" class="LineNr"> 87 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L88" class="LineNr"> 88 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> <span id="L89" class="LineNr"> 89 </span> <span class="subxS1Comment"># . end</span> @@ -253,7 +253,7 @@ if ('onhashchange' in window) { <span id="L193" class="LineNr">193 </span> 68/push <span class="Constant">"0x008899aa"</span>/imm32 <span id="L194" class="LineNr">194 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 <span id="L195" class="LineNr">195 </span> <span class="subxS2Comment"># . . call</span> -<span id="L196" class="LineNr">196 </span> e8/call <a href='109stream-equal.subx.html#L197'>check-stream-equal</a>/disp32 +<span id="L196" class="LineNr">196 </span> e8/call <a href='109stream-equal.subx.html#L194'>check-stream-equal</a>/disp32 <span id="L197" class="LineNr">197 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L198" class="LineNr">198 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> <span id="L199" class="LineNr">199 </span> <span class="subxS1Comment"># . end</span> diff --git a/html/baremetal/118parse-hex-int.subx.html b/html/baremetal/118parse-hex-int.subx.html new file mode 100644 index 00000000..6b441120 --- /dev/null +++ b/html/baremetal/118parse-hex-int.subx.html @@ -0,0 +1,960 @@ +<!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 - baremetal/118parse-hex-int.subx</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,no_foldcolumn,expand_tabs,line_ids,prevent_copy="> +<meta name="colorscheme" content="minimal-light"> +<style type="text/css"> +<!-- +pre { font-family: monospace; color: #000000; background-color: #c6c6c6; } +body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } +a { color:inherit; } +* { font-size:12pt; font-size: 1em; } +.subxComment { color: #005faf; } +.subxS1Comment { color: #0000af; } +.subxS2Comment { color: #8a8a8a; } +.LineNr { } +.Constant { color: #008787; } +.subxTest { color: #5f8700; } +.subxFunction { color: #af5f00; text-decoration: underline; } +.Normal { color: #000000; background-color: #c6c6c6; padding-bottom: 1px; } +--> +</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/baremetal/118parse-hex-int.subx'>https://github.com/akkartik/mu/blob/main/baremetal/118parse-hex-int.subx</a> +<pre id='vimCodeElement'> +<span id="L1" class="LineNr"> 1 </span><span class="subxComment"># some utilities for converting numbers from hex</span> +<span id="L2" class="LineNr"> 2 </span><span class="subxComment"># lowercase letters only for now</span> +<span id="L3" class="LineNr"> 3 </span> +<span id="L4" class="LineNr"> 4 </span>== code +<span id="L5" class="LineNr"> 5 </span><span class="subxComment"># instruction effective address register displacement immediate</span> +<span id="L6" class="LineNr"> 6 </span><span class="subxS1Comment"># . op subop mod rm32 base index scale r32</span> +<span id="L7" class="LineNr"> 7 </span><span class="subxS1Comment"># . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes</span> +<span id="L8" class="LineNr"> 8 </span> +<span id="L9" class="LineNr"> 9 </span><span class="subxFunction">is-hex-int?</span>: <span class="subxComment"># in: (addr slice) -> result/eax: boolean</span> +<span id="L10" class="LineNr"> 10 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L11" class="LineNr"> 11 </span> 55/push-ebp +<span id="L12" class="LineNr"> 12 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L13" class="LineNr"> 13 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L14" class="LineNr"> 14 </span> 51/push-ecx +<span id="L15" class="LineNr"> 15 </span> 52/push-edx +<span id="L16" class="LineNr"> 16 </span> 53/push-ebx +<span id="L17" class="LineNr"> 17 </span> <span class="subxComment"># ecx = s</span> +<span id="L18" class="LineNr"> 18 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+8) to ecx</span> +<span id="L19" class="LineNr"> 19 </span> <span class="subxComment"># edx = s->end</span> +<span id="L20" class="LineNr"> 20 </span> 8b/copy 1/mod/*+disp8 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ecx+4) to edx</span> +<span id="L21" class="LineNr"> 21 </span> <span class="subxComment"># var curr/ecx: (addr byte) = s->start</span> +<span id="L22" class="LineNr"> 22 </span> 8b/copy 0/mod/indirect 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *ecx to ecx</span> +<span id="L23" class="LineNr"> 23 </span> <span class="subxComment"># if s is empty return false</span> +<span id="L24" class="LineNr"> 24 </span> b8/copy-to-eax 0/imm32/false +<span id="L25" class="LineNr"> 25 </span> 39/compare 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare ecx with edx</span> +<span id="L26" class="LineNr"> 26 </span> 73/jump-if-addr>= $is-hex-int?:end/disp8 +<span id="L27" class="LineNr"> 27 </span> <span class="subxComment"># skip past leading '-'</span> +<span id="L28" class="LineNr"> 28 </span> <span class="subxS1Comment"># . if (*curr == '-') ++curr</span> +<span id="L29" class="LineNr"> 29 </span> 31/xor 3/mod/direct 3/rm32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear ebx</span> +<span id="L30" class="LineNr"> 30 </span> 8a/copy-byte 0/mod/indirect 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/BL <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy byte at *ecx to BL</span> +<span id="L31" class="LineNr"> 31 </span> 81 7/subop/compare 3/mod/direct 3/rm32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0x2d/imm32/- <span class="subxComment"># compare ebx</span> +<span id="L32" class="LineNr"> 32 </span> 75/jump-if-!= $is-hex-int?:initial-0/disp8 +<span id="L33" class="LineNr"> 33 </span> <span class="subxS1Comment"># . ++curr</span> +<span id="L34" class="LineNr"> 34 </span> 41/increment-ecx +<span id="L35" class="LineNr"> 35 </span> <span class="subxComment"># skip past leading '0x'</span> +<span id="L36" class="LineNr"> 36 </span><span class="Constant">$is-hex-int?:initial-0</span>: +<span id="L37" class="LineNr"> 37 </span> <span class="subxS1Comment"># . if (*curr != '0') jump to loop</span> +<span id="L38" class="LineNr"> 38 </span> 31/xor 3/mod/direct 3/rm32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear ebx</span> +<span id="L39" class="LineNr"> 39 </span> 8a/copy-byte 0/mod/indirect 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/BL <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy byte at *ecx to BL</span> +<span id="L40" class="LineNr"> 40 </span> 81 7/subop/compare 3/mod/direct 3/rm32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0x30/imm32/0 <span class="subxComment"># compare ebx</span> +<span id="L41" class="LineNr"> 41 </span> 75/jump-if-!= $is-hex-int?:<span class="Constant">loop</span>/disp8 +<span id="L42" class="LineNr"> 42 </span> <span class="subxS1Comment"># . ++curr</span> +<span id="L43" class="LineNr"> 43 </span> 41/increment-ecx +<span id="L44" class="LineNr"> 44 </span><span class="Constant">$is-hex-int?:initial-0x</span>: +<span id="L45" class="LineNr"> 45 </span> <span class="subxS1Comment"># . if (curr >= in->end) return true</span> +<span id="L46" class="LineNr"> 46 </span> 39/compare 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare ecx with edx</span> +<span id="L47" class="LineNr"> 47 </span> 73/jump-if-addr>= $is-hex-int?:true/disp8 +<span id="L48" class="LineNr"> 48 </span> <span class="subxS1Comment"># . if (*curr != 'x') jump to loop # the previous '0' is still valid so doesn't need to be checked again</span> +<span id="L49" class="LineNr"> 49 </span> 31/xor 3/mod/direct 3/rm32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear ebx</span> +<span id="L50" class="LineNr"> 50 </span> 8a/copy-byte 0/mod/indirect 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/BL <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy byte at *ecx to BL</span> +<span id="L51" class="LineNr"> 51 </span> 81 7/subop/compare 3/mod/direct 3/rm32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0x78/imm32/x <span class="subxComment"># compare ebx</span> +<span id="L52" class="LineNr"> 52 </span> 75/jump-if-!= $is-hex-int?:<span class="Constant">loop</span>/disp8 +<span id="L53" class="LineNr"> 53 </span> <span class="subxS1Comment"># . ++curr</span> +<span id="L54" class="LineNr"> 54 </span> 41/increment-ecx +<span id="L55" class="LineNr"> 55 </span><span class="Constant">$is-hex-int?:loop</span>: +<span id="L56" class="LineNr"> 56 </span> <span class="subxComment"># if (curr >= in->end) return true</span> +<span id="L57" class="LineNr"> 57 </span> 39/compare 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare ecx with edx</span> +<span id="L58" class="LineNr"> 58 </span> 73/jump-if-addr>= $is-hex-int?:true/disp8 +<span id="L59" class="LineNr"> 59 </span> <span class="subxComment"># var eax: boolean = is-hex-digit?(*curr)</span> +<span id="L60" class="LineNr"> 60 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L61" class="LineNr"> 61 </span> 8a/copy-byte 0/mod/indirect 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/AL <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy byte at *ecx to AL</span> +<span id="L62" class="LineNr"> 62 </span> 50/push-eax +<span id="L63" class="LineNr"> 63 </span> <span class="subxS2Comment"># . . call</span> +<span id="L64" class="LineNr"> 64 </span> e8/call <a href='118parse-hex-int.subx.html#L701'>is-hex-digit?</a>/disp32 +<span id="L65" class="LineNr"> 65 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L66" class="LineNr"> 66 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L67" class="LineNr"> 67 </span> <span class="subxComment"># if (eax == false) return false</span> +<span id="L68" class="LineNr"> 68 </span> 3d/compare-eax-and 0/imm32/false +<span id="L69" class="LineNr"> 69 </span> 74/jump-if-= $is-hex-int?:end/disp8 +<span id="L70" class="LineNr"> 70 </span> <span class="subxComment"># ++curr</span> +<span id="L71" class="LineNr"> 71 </span> 41/increment-ecx +<span id="L72" class="LineNr"> 72 </span> <span class="subxComment"># loop</span> +<span id="L73" class="LineNr"> 73 </span> eb/jump $is-hex-int?:<span class="Constant">loop</span>/disp8 +<span id="L74" class="LineNr"> 74 </span><span class="Constant">$is-hex-int?:true</span>: +<span id="L75" class="LineNr"> 75 </span> <span class="subxComment"># return true</span> +<span id="L76" class="LineNr"> 76 </span> b8/copy-to-eax 1/imm32/true +<span id="L77" class="LineNr"> 77 </span><span class="Constant">$is-hex-int?:end</span>: +<span id="L78" class="LineNr"> 78 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L79" class="LineNr"> 79 </span> 5b/pop-to-ebx +<span id="L80" class="LineNr"> 80 </span> 5a/pop-to-edx +<span id="L81" class="LineNr"> 81 </span> 59/pop-to-ecx +<span id="L82" class="LineNr"> 82 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L83" class="LineNr"> 83 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L84" class="LineNr"> 84 </span> 5d/pop-to-ebp +<span id="L85" class="LineNr"> 85 </span> c3/return +<span id="L86" class="LineNr"> 86 </span> +<span id="L87" class="LineNr"> 87 </span><span class="subxTest">test-is-hex-int</span>: +<span id="L88" class="LineNr"> 88 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L89" class="LineNr"> 89 </span> 55/push-ebp +<span id="L90" class="LineNr"> 90 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L91" class="LineNr"> 91 </span> <span class="subxComment"># (eax..ecx) = "34"</span> +<span id="L92" class="LineNr"> 92 </span> b8/copy-to-eax <span class="Constant">"34"</span>/imm32 +<span id="L93" class="LineNr"> 93 </span> 8b/copy 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *eax to ecx</span> +<span id="L94" class="LineNr"> 94 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+ecx+4 to ecx</span> +<span id="L95" class="LineNr"> 95 </span> 05/add-to-eax 4/imm32 +<span id="L96" class="LineNr"> 96 </span> <span class="subxComment"># var slice/ecx: slice = {eax, ecx}</span> +<span id="L97" class="LineNr"> 97 </span> 51/push-ecx +<span id="L98" class="LineNr"> 98 </span> 50/push-eax +<span id="L99" class="LineNr"> 99 </span> 89/copy 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ecx</span> +<span id="L100" class="LineNr">100 </span> <span class="subxComment"># eax = is-hex-int?(slice)</span> +<span id="L101" class="LineNr">101 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L102" class="LineNr">102 </span> 51/push-ecx +<span id="L103" class="LineNr">103 </span> <span class="subxS2Comment"># . . call</span> +<span id="L104" class="LineNr">104 </span> e8/call <a href='118parse-hex-int.subx.html#L9'>is-hex-int?</a>/disp32 +<span id="L105" class="LineNr">105 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L106" class="LineNr">106 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L107" class="LineNr">107 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> +<span id="L108" class="LineNr">108 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L109" class="LineNr">109 </span> 68/push <span class="Constant">"F - test-is-hex-int"</span>/imm32 +<span id="L110" class="LineNr">110 </span> 68/push 1/imm32/true +<span id="L111" class="LineNr">111 </span> 50/push-eax +<span id="L112" class="LineNr">112 </span> <span class="subxS2Comment"># . . call</span> +<span id="L113" class="LineNr">113 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L114" class="LineNr">114 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L115" class="LineNr">115 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L116" class="LineNr">116 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L117" class="LineNr">117 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L118" class="LineNr">118 </span> 5d/pop-to-ebp +<span id="L119" class="LineNr">119 </span> c3/return +<span id="L120" class="LineNr">120 </span> +<span id="L121" class="LineNr">121 </span><span class="subxTest">test-is-hex-int-handles-letters</span>: +<span id="L122" class="LineNr">122 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L123" class="LineNr">123 </span> 55/push-ebp +<span id="L124" class="LineNr">124 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L125" class="LineNr">125 </span> <span class="subxComment"># (eax..ecx) = "34a"</span> +<span id="L126" class="LineNr">126 </span> b8/copy-to-eax <span class="Constant">"34a"</span>/imm32 +<span id="L127" class="LineNr">127 </span> 8b/copy 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *eax to ecx</span> +<span id="L128" class="LineNr">128 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+ecx+4 to ecx</span> +<span id="L129" class="LineNr">129 </span> 05/add-to-eax 4/imm32 +<span id="L130" class="LineNr">130 </span> <span class="subxComment"># var slice/ecx: slice = {eax, ecx}</span> +<span id="L131" class="LineNr">131 </span> 51/push-ecx +<span id="L132" class="LineNr">132 </span> 50/push-eax +<span id="L133" class="LineNr">133 </span> 89/copy 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ecx</span> +<span id="L134" class="LineNr">134 </span> <span class="subxComment"># eax = is-hex-int?(slice)</span> +<span id="L135" class="LineNr">135 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L136" class="LineNr">136 </span> 51/push-ecx +<span id="L137" class="LineNr">137 </span> <span class="subxS2Comment"># . . call</span> +<span id="L138" class="LineNr">138 </span> e8/call <a href='118parse-hex-int.subx.html#L9'>is-hex-int?</a>/disp32 +<span id="L139" class="LineNr">139 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L140" class="LineNr">140 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L141" class="LineNr">141 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> +<span id="L142" class="LineNr">142 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L143" class="LineNr">143 </span> 68/push <span class="Constant">"F - test-is-hex-int-handles-letters"</span>/imm32 +<span id="L144" class="LineNr">144 </span> 68/push 1/imm32/true +<span id="L145" class="LineNr">145 </span> 50/push-eax +<span id="L146" class="LineNr">146 </span> <span class="subxS2Comment"># . . call</span> +<span id="L147" class="LineNr">147 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L148" class="LineNr">148 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L149" class="LineNr">149 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L150" class="LineNr">150 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L151" class="LineNr">151 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L152" class="LineNr">152 </span> 5d/pop-to-ebp +<span id="L153" class="LineNr">153 </span> c3/return +<span id="L154" class="LineNr">154 </span> +<span id="L155" class="LineNr">155 </span><span class="subxTest">test-is-hex-int-with-trailing-char</span>: +<span id="L156" class="LineNr">156 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L157" class="LineNr">157 </span> 55/push-ebp +<span id="L158" class="LineNr">158 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L159" class="LineNr">159 </span> <span class="subxComment"># (eax..ecx) = "34q"</span> +<span id="L160" class="LineNr">160 </span> b8/copy-to-eax <span class="Constant">"34q"</span>/imm32 +<span id="L161" class="LineNr">161 </span> 8b/copy 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *eax to ecx</span> +<span id="L162" class="LineNr">162 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+ecx+4 to ecx</span> +<span id="L163" class="LineNr">163 </span> 05/add-to-eax 4/imm32 +<span id="L164" class="LineNr">164 </span> <span class="subxComment"># var slice/ecx: slice = {eax, ecx}</span> +<span id="L165" class="LineNr">165 </span> 51/push-ecx +<span id="L166" class="LineNr">166 </span> 50/push-eax +<span id="L167" class="LineNr">167 </span> 89/copy 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ecx</span> +<span id="L168" class="LineNr">168 </span> <span class="subxComment"># eax = is-hex-int?(slice)</span> +<span id="L169" class="LineNr">169 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L170" class="LineNr">170 </span> 51/push-ecx +<span id="L171" class="LineNr">171 </span> <span class="subxS2Comment"># . . call</span> +<span id="L172" class="LineNr">172 </span> e8/call <a href='118parse-hex-int.subx.html#L9'>is-hex-int?</a>/disp32 +<span id="L173" class="LineNr">173 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L174" class="LineNr">174 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L175" class="LineNr">175 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> +<span id="L176" class="LineNr">176 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L177" class="LineNr">177 </span> 68/push <span class="Constant">"F - test-is-hex-int-with-trailing-char"</span>/imm32 +<span id="L178" class="LineNr">178 </span> 68/push 0/imm32/false +<span id="L179" class="LineNr">179 </span> 50/push-eax +<span id="L180" class="LineNr">180 </span> <span class="subxS2Comment"># . . call</span> +<span id="L181" class="LineNr">181 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L182" class="LineNr">182 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L183" class="LineNr">183 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L184" class="LineNr">184 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L185" class="LineNr">185 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L186" class="LineNr">186 </span> 5d/pop-to-ebp +<span id="L187" class="LineNr">187 </span> c3/return +<span id="L188" class="LineNr">188 </span> +<span id="L189" class="LineNr">189 </span><span class="subxTest">test-is-hex-int-with-leading-char</span>: +<span id="L190" class="LineNr">190 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L191" class="LineNr">191 </span> 55/push-ebp +<span id="L192" class="LineNr">192 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L193" class="LineNr">193 </span> <span class="subxComment"># (eax..ecx) = "q34"</span> +<span id="L194" class="LineNr">194 </span> b8/copy-to-eax <span class="Constant">"q34"</span>/imm32 +<span id="L195" class="LineNr">195 </span> 8b/copy 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *eax to ecx</span> +<span id="L196" class="LineNr">196 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+ecx+4 to ecx</span> +<span id="L197" class="LineNr">197 </span> 05/add-to-eax 4/imm32 +<span id="L198" class="LineNr">198 </span> <span class="subxComment"># var slice/ecx: slice = {eax, ecx}</span> +<span id="L199" class="LineNr">199 </span> 51/push-ecx +<span id="L200" class="LineNr">200 </span> 50/push-eax +<span id="L201" class="LineNr">201 </span> 89/copy 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ecx</span> +<span id="L202" class="LineNr">202 </span> <span class="subxComment"># eax = is-hex-int?(slice)</span> +<span id="L203" class="LineNr">203 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L204" class="LineNr">204 </span> 51/push-ecx +<span id="L205" class="LineNr">205 </span> <span class="subxS2Comment"># . . call</span> +<span id="L206" class="LineNr">206 </span> e8/call <a href='118parse-hex-int.subx.html#L9'>is-hex-int?</a>/disp32 +<span id="L207" class="LineNr">207 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L208" class="LineNr">208 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L209" class="LineNr">209 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> +<span id="L210" class="LineNr">210 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L211" class="LineNr">211 </span> 68/push <span class="Constant">"F - test-is-hex-int-with-leading-char"</span>/imm32 +<span id="L212" class="LineNr">212 </span> 68/push 0/imm32/false +<span id="L213" class="LineNr">213 </span> 50/push-eax +<span id="L214" class="LineNr">214 </span> <span class="subxS2Comment"># . . call</span> +<span id="L215" class="LineNr">215 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L216" class="LineNr">216 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L217" class="LineNr">217 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L218" class="LineNr">218 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L219" class="LineNr">219 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L220" class="LineNr">220 </span> 5d/pop-to-ebp +<span id="L221" class="LineNr">221 </span> c3/return +<span id="L222" class="LineNr">222 </span> +<span id="L223" class="LineNr">223 </span><span class="subxTest">test-is-hex-int-empty</span>: +<span id="L224" class="LineNr">224 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L225" class="LineNr">225 </span> 55/push-ebp +<span id="L226" class="LineNr">226 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L227" class="LineNr">227 </span> <span class="subxComment"># var slice/ecx: slice = ""</span> +<span id="L228" class="LineNr">228 </span> 68/push 0/imm32 +<span id="L229" class="LineNr">229 </span> 68/push 0/imm32 +<span id="L230" class="LineNr">230 </span> 89/copy 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ecx</span> +<span id="L231" class="LineNr">231 </span> <span class="subxComment"># eax = is-hex-int?(slice)</span> +<span id="L232" class="LineNr">232 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L233" class="LineNr">233 </span> 51/push-ecx +<span id="L234" class="LineNr">234 </span> <span class="subxS2Comment"># . . call</span> +<span id="L235" class="LineNr">235 </span> e8/call <a href='118parse-hex-int.subx.html#L9'>is-hex-int?</a>/disp32 +<span id="L236" class="LineNr">236 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L237" class="LineNr">237 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L238" class="LineNr">238 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> +<span id="L239" class="LineNr">239 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L240" class="LineNr">240 </span> 68/push <span class="Constant">"F - test-is-hex-int-empty"</span>/imm32 +<span id="L241" class="LineNr">241 </span> 68/push 0/imm32/false +<span id="L242" class="LineNr">242 </span> 50/push-eax +<span id="L243" class="LineNr">243 </span> <span class="subxS2Comment"># . . call</span> +<span id="L244" class="LineNr">244 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L245" class="LineNr">245 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L246" class="LineNr">246 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L247" class="LineNr">247 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L248" class="LineNr">248 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L249" class="LineNr">249 </span> 5d/pop-to-ebp +<span id="L250" class="LineNr">250 </span> c3/return +<span id="L251" class="LineNr">251 </span> +<span id="L252" class="LineNr">252 </span><span class="subxTest">test-is-hex-int-handles-0x-prefix</span>: +<span id="L253" class="LineNr">253 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L254" class="LineNr">254 </span> 55/push-ebp +<span id="L255" class="LineNr">255 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L256" class="LineNr">256 </span> <span class="subxComment"># (eax..ecx) = "0x3a"</span> +<span id="L257" class="LineNr">257 </span> b8/copy-to-eax <span class="Constant">"0x3a"</span>/imm32 +<span id="L258" class="LineNr">258 </span> 8b/copy 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *eax to ecx</span> +<span id="L259" class="LineNr">259 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+ecx+4 to ecx</span> +<span id="L260" class="LineNr">260 </span> 05/add-to-eax 4/imm32 +<span id="L261" class="LineNr">261 </span> <span class="subxComment"># var slice/ecx: slice = {eax, ecx}</span> +<span id="L262" class="LineNr">262 </span> 51/push-ecx +<span id="L263" class="LineNr">263 </span> 50/push-eax +<span id="L264" class="LineNr">264 </span> 89/copy 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ecx</span> +<span id="L265" class="LineNr">265 </span> <span class="subxComment"># eax = is-hex-int?(slice)</span> +<span id="L266" class="LineNr">266 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L267" class="LineNr">267 </span> 51/push-ecx +<span id="L268" class="LineNr">268 </span> <span class="subxS2Comment"># . . call</span> +<span id="L269" class="LineNr">269 </span> e8/call <a href='118parse-hex-int.subx.html#L9'>is-hex-int?</a>/disp32 +<span id="L270" class="LineNr">270 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L271" class="LineNr">271 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L272" class="LineNr">272 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> +<span id="L273" class="LineNr">273 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L274" class="LineNr">274 </span> 68/push <span class="Constant">"F - test-is-hex-int-handles-0x-prefix"</span>/imm32 +<span id="L275" class="LineNr">275 </span> 68/push 1/imm32/true +<span id="L276" class="LineNr">276 </span> 50/push-eax +<span id="L277" class="LineNr">277 </span> <span class="subxS2Comment"># . . call</span> +<span id="L278" class="LineNr">278 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L279" class="LineNr">279 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L280" class="LineNr">280 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L281" class="LineNr">281 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L282" class="LineNr">282 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L283" class="LineNr">283 </span> 5d/pop-to-ebp +<span id="L284" class="LineNr">284 </span> c3/return +<span id="L285" class="LineNr">285 </span> +<span id="L286" class="LineNr">286 </span><span class="subxTest">test-is-hex-int-handles-negative</span>: +<span id="L287" class="LineNr">287 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L288" class="LineNr">288 </span> 55/push-ebp +<span id="L289" class="LineNr">289 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L290" class="LineNr">290 </span> <span class="subxComment"># (eax..ecx) = "-34a"</span> +<span id="L291" class="LineNr">291 </span> b8/copy-to-eax <span class="Constant">"-34a"</span>/imm32 +<span id="L292" class="LineNr">292 </span> 8b/copy 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *eax to ecx</span> +<span id="L293" class="LineNr">293 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+ecx+4 to ecx</span> +<span id="L294" class="LineNr">294 </span> 05/add-to-eax 4/imm32 +<span id="L295" class="LineNr">295 </span> <span class="subxComment"># var slice/ecx: slice = {eax, ecx}</span> +<span id="L296" class="LineNr">296 </span> 51/push-ecx +<span id="L297" class="LineNr">297 </span> 50/push-eax +<span id="L298" class="LineNr">298 </span> 89/copy 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ecx</span> +<span id="L299" class="LineNr">299 </span> <span class="subxComment"># eax = is-hex-int?(slice)</span> +<span id="L300" class="LineNr">300 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L301" class="LineNr">301 </span> 51/push-ecx +<span id="L302" class="LineNr">302 </span> <span class="subxS2Comment"># . . call</span> +<span id="L303" class="LineNr">303 </span> e8/call <a href='118parse-hex-int.subx.html#L9'>is-hex-int?</a>/disp32 +<span id="L304" class="LineNr">304 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L305" class="LineNr">305 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L306" class="LineNr">306 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> +<span id="L307" class="LineNr">307 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L308" class="LineNr">308 </span> 68/push <span class="Constant">"F - test-is-hex-int-handles-negative"</span>/imm32 +<span id="L309" class="LineNr">309 </span> 68/push 1/imm32/true +<span id="L310" class="LineNr">310 </span> 50/push-eax +<span id="L311" class="LineNr">311 </span> <span class="subxS2Comment"># . . call</span> +<span id="L312" class="LineNr">312 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L313" class="LineNr">313 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L314" class="LineNr">314 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L315" class="LineNr">315 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L316" class="LineNr">316 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L317" class="LineNr">317 </span> 5d/pop-to-ebp +<span id="L318" class="LineNr">318 </span> c3/return +<span id="L319" class="LineNr">319 </span> +<span id="L320" class="LineNr">320 </span><span class="subxTest">test-is-hex-int-handles-negative-0x-prefix</span>: +<span id="L321" class="LineNr">321 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L322" class="LineNr">322 </span> 55/push-ebp +<span id="L323" class="LineNr">323 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L324" class="LineNr">324 </span> <span class="subxComment"># (eax..ecx) = "-0x3a"</span> +<span id="L325" class="LineNr">325 </span> b8/copy-to-eax <span class="Constant">"-0x3a"</span>/imm32 +<span id="L326" class="LineNr">326 </span> 8b/copy 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *eax to ecx</span> +<span id="L327" class="LineNr">327 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+ecx+4 to ecx</span> +<span id="L328" class="LineNr">328 </span> 05/add-to-eax 4/imm32 +<span id="L329" class="LineNr">329 </span> <span class="subxComment"># var slice/ecx: slice = {eax, ecx}</span> +<span id="L330" class="LineNr">330 </span> 51/push-ecx +<span id="L331" class="LineNr">331 </span> 50/push-eax +<span id="L332" class="LineNr">332 </span> 89/copy 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ecx</span> +<span id="L333" class="LineNr">333 </span> <span class="subxComment"># eax = is-hex-int?(slice)</span> +<span id="L334" class="LineNr">334 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L335" class="LineNr">335 </span> 51/push-ecx +<span id="L336" class="LineNr">336 </span> <span class="subxS2Comment"># . . call</span> +<span id="L337" class="LineNr">337 </span> e8/call <a href='118parse-hex-int.subx.html#L9'>is-hex-int?</a>/disp32 +<span id="L338" class="LineNr">338 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L339" class="LineNr">339 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L340" class="LineNr">340 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> +<span id="L341" class="LineNr">341 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L342" class="LineNr">342 </span> 68/push <span class="Constant">"F - test-is-hex-int-handles-negative-0x-prefix"</span>/imm32 +<span id="L343" class="LineNr">343 </span> 68/push 1/imm32/true +<span id="L344" class="LineNr">344 </span> 50/push-eax +<span id="L345" class="LineNr">345 </span> <span class="subxS2Comment"># . . call</span> +<span id="L346" class="LineNr">346 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L347" class="LineNr">347 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L348" class="LineNr">348 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L349" class="LineNr">349 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L350" class="LineNr">350 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L351" class="LineNr">351 </span> 5d/pop-to-ebp +<span id="L352" class="LineNr">352 </span> c3/return +<span id="L353" class="LineNr">353 </span> +<span id="L354" class="LineNr">354 </span><span class="subxFunction">parse-hex-int</span>: <span class="subxComment"># in: (addr array byte) -> result/eax: int</span> +<span id="L355" class="LineNr">355 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L356" class="LineNr">356 </span> 55/push-ebp +<span id="L357" class="LineNr">357 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L358" class="LineNr">358 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L359" class="LineNr">359 </span> 51/push-ecx +<span id="L360" class="LineNr">360 </span> 52/push-edx +<span id="L361" class="LineNr">361 </span> <span class="subxComment"># eax = in</span> +<span id="L362" class="LineNr">362 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+8) to eax</span> +<span id="L363" class="LineNr">363 </span> <span class="subxComment"># var curr/ecx: (addr byte) = &in->data</span> +<span id="L364" class="LineNr">364 </span> 8d/copy-address 1/mod/*+disp8 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+4 to ecx</span> +<span id="L365" class="LineNr">365 </span> <span class="subxComment"># var max/edx: (addr byte) = &in->data[in->size]</span> +<span id="L366" class="LineNr">366 </span> <span class="subxS1Comment"># . edx = in->size</span> +<span id="L367" class="LineNr">367 </span> 8b/copy 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *eax to edx</span> +<span id="L368" class="LineNr">368 </span> <span class="subxS1Comment"># . edx = in->data + in->size</span> +<span id="L369" class="LineNr">369 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 2/index/edx <span class="Normal"> . </span> 2/r32/edx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+edx+4 to edx</span> +<span id="L370" class="LineNr">370 </span> <span class="subxComment"># return parse-hex-int-helper(curr, max)</span> +<span id="L371" class="LineNr">371 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L372" class="LineNr">372 </span> 52/push-edx +<span id="L373" class="LineNr">373 </span> 51/push-ecx +<span id="L374" class="LineNr">374 </span> <span class="subxS2Comment"># . . call</span> +<span id="L375" class="LineNr">375 </span> e8/call <a href='118parse-hex-int.subx.html#L417'>parse-hex-int-helper</a>/disp32 +<span id="L376" class="LineNr">376 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L377" class="LineNr">377 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L378" class="LineNr">378 </span><span class="Constant">$parse-hex-int:end</span>: +<span id="L379" class="LineNr">379 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L380" class="LineNr">380 </span> 5a/pop-to-edx +<span id="L381" class="LineNr">381 </span> 59/pop-to-ecx +<span id="L382" class="LineNr">382 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L383" class="LineNr">383 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L384" class="LineNr">384 </span> 5d/pop-to-ebp +<span id="L385" class="LineNr">385 </span> c3/return +<span id="L386" class="LineNr">386 </span> +<span id="L387" class="LineNr">387 </span><span class="subxFunction">parse-hex-int-from-slice</span>: <span class="subxComment"># in: (addr slice) -> result/eax: int</span> +<span id="L388" class="LineNr">388 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L389" class="LineNr">389 </span> 55/push-ebp +<span id="L390" class="LineNr">390 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L391" class="LineNr">391 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L392" class="LineNr">392 </span> 51/push-ecx +<span id="L393" class="LineNr">393 </span> 52/push-edx +<span id="L394" class="LineNr">394 </span> <span class="subxComment"># ecx = in</span> +<span id="L395" class="LineNr">395 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+8) to ecx</span> +<span id="L396" class="LineNr">396 </span> <span class="subxComment"># var max/edx: (addr byte) = in->end</span> +<span id="L397" class="LineNr">397 </span> 8b/copy 1/mod/*+disp8 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ecx+4) to edx</span> +<span id="L398" class="LineNr">398 </span> <span class="subxComment"># var curr/ecx: (addr byte) = in->start</span> +<span id="L399" class="LineNr">399 </span> 8b/copy 0/mod/indirect 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *ecx to ecx</span> +<span id="L400" class="LineNr">400 </span> <span class="subxComment"># return parse-hex-int-helper(curr, max)</span> +<span id="L401" class="LineNr">401 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L402" class="LineNr">402 </span> 52/push-edx +<span id="L403" class="LineNr">403 </span> 51/push-ecx +<span id="L404" class="LineNr">404 </span> <span class="subxS2Comment"># . . call</span> +<span id="L405" class="LineNr">405 </span> e8/call <a href='118parse-hex-int.subx.html#L417'>parse-hex-int-helper</a>/disp32 +<span id="L406" class="LineNr">406 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L407" class="LineNr">407 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> +<span id="L408" class="LineNr">408 </span><span class="Constant">$parse-hex-int-from-slice:end</span>: +<span id="L409" class="LineNr">409 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L410" class="LineNr">410 </span> 5a/pop-to-edx +<span id="L411" class="LineNr">411 </span> 59/pop-to-ecx +<span id="L412" class="LineNr">412 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L413" class="LineNr">413 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L414" class="LineNr">414 </span> 5d/pop-to-ebp +<span id="L415" class="LineNr">415 </span> c3/return +<span id="L416" class="LineNr">416 </span> +<span id="L417" class="LineNr">417 </span><span class="subxFunction">parse-hex-int-helper</span>: <span class="subxComment"># start: (addr byte), end: (addr byte) -> result/eax: int</span> +<span id="L418" class="LineNr">418 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L419" class="LineNr">419 </span> 55/push-ebp +<span id="L420" class="LineNr">420 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L421" class="LineNr">421 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L422" class="LineNr">422 </span> 51/push-ecx +<span id="L423" class="LineNr">423 </span> 52/push-edx +<span id="L424" class="LineNr">424 </span> 53/push-ebx +<span id="L425" class="LineNr">425 </span> 56/push-esi +<span id="L426" class="LineNr">426 </span> <span class="subxComment"># var curr/ecx: (addr byte) = start</span> +<span id="L427" class="LineNr">427 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+8) to ecx</span> +<span id="L428" class="LineNr">428 </span> <span class="subxComment"># edx = max</span> +<span id="L429" class="LineNr">429 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+12) to edx</span> +<span id="L430" class="LineNr">430 </span> <span class="subxComment"># var result/ebx: int = 0</span> +<span id="L431" class="LineNr">431 </span> 31/xor 3/mod/direct 3/rm32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear ebx</span> +<span id="L432" class="LineNr">432 </span> <span class="subxComment"># var negate?/esi: boolean = false</span> +<span id="L433" class="LineNr">433 </span> 31/xor 3/mod/direct 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 6/r32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear esi</span> +<span id="L434" class="LineNr">434 </span><span class="Constant">$parse-hex-int-helper:negative</span>: +<span id="L435" class="LineNr">435 </span> <span class="subxComment"># if (*curr == '-') ++curr, negate = true</span> +<span id="L436" class="LineNr">436 </span> 31/xor 3/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear eax</span> +<span id="L437" class="LineNr">437 </span> 8a/copy-byte 0/mod/indirect 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/AL <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy byte at *ecx to AL</span> +<span id="L438" class="LineNr">438 </span> 3d/compare-eax-and 0x2d/imm32/- +<span id="L439" class="LineNr">439 </span> 75/jump-if-!= $parse-hex-int-helper:initial-0/disp8 +<span id="L440" class="LineNr">440 </span> <span class="subxS1Comment"># . ++curr</span> +<span id="L441" class="LineNr">441 </span> 41/increment-ecx +<span id="L442" class="LineNr">442 </span> <span class="subxS1Comment"># . negate = true</span> +<span id="L443" class="LineNr">443 </span> be/copy-to-esi 1/imm32/true +<span id="L444" class="LineNr">444 </span><span class="Constant">$parse-hex-int-helper:initial-0</span>: +<span id="L445" class="LineNr">445 </span> <span class="subxComment"># skip past leading '0x'</span> +<span id="L446" class="LineNr">446 </span> <span class="subxS1Comment"># . if (*curr != '0') jump to loop</span> +<span id="L447" class="LineNr">447 </span> 8a/copy-byte 0/mod/indirect 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/AL <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy byte at *ecx to AL</span> +<span id="L448" class="LineNr">448 </span> 3d/compare-eax-and 0x30/imm32/0 +<span id="L449" class="LineNr">449 </span> 75/jump-if-!= $parse-hex-int-helper:<span class="Constant">loop</span>/disp8 +<span id="L450" class="LineNr">450 </span> <span class="subxS1Comment"># . ++curr</span> +<span id="L451" class="LineNr">451 </span> 41/increment-ecx +<span id="L452" class="LineNr">452 </span><span class="Constant">$parse-hex-int-helper:initial-0x</span>: +<span id="L453" class="LineNr">453 </span> <span class="subxS1Comment"># . if (curr >= in->end) return result</span> +<span id="L454" class="LineNr">454 </span> 39/compare 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare ecx with edx</span> +<span id="L455" class="LineNr">455 </span> 73/jump-if-addr>= $parse-hex-int-helper:end/disp8 +<span id="L456" class="LineNr">456 </span> <span class="subxS1Comment"># . if (*curr != 'x') jump to loop # the previous '0' is still valid so doesn't need to be checked again</span> +<span id="L457" class="LineNr">457 </span> 31/xor 3/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear eax</span> +<span id="L458" class="LineNr">458 </span> 8a/copy-byte 0/mod/indirect 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/AL <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy byte at *ecx to AL</span> +<span id="L459" class="LineNr">459 </span> 3d/compare-eax-and 0x78/imm32/x +<span id="L460" class="LineNr">460 </span> 75/jump-if-!= $parse-hex-int-helper:<span class="Constant">loop</span>/disp8 +<span id="L461" class="LineNr">461 </span> <span class="subxS1Comment"># . ++curr</span> +<span id="L462" class="LineNr">462 </span> 41/increment-ecx +<span id="L463" class="LineNr">463 </span><span class="Constant">$parse-hex-int-helper:loop</span>: +<span id="L464" class="LineNr">464 </span> <span class="subxComment"># if (curr >= in->end) break</span> +<span id="L465" class="LineNr">465 </span> 39/compare 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare ecx with edx</span> +<span id="L466" class="LineNr">466 </span> 73/jump-if-addr>= $parse-hex-int-helper:negate/disp8 +<span id="L467" class="LineNr">467 </span> <span class="subxComment"># var eax: int = from-hex-char(*curr)</span> +<span id="L468" class="LineNr">468 </span> <span class="subxS2Comment"># . . copy arg to eax</span> +<span id="L469" class="LineNr">469 </span> 8a/copy-byte 0/mod/indirect 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/AL <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy byte at *ecx to AL</span> +<span id="L470" class="LineNr">470 </span> <span class="subxS2Comment"># . . call</span> +<span id="L471" class="LineNr">471 </span> e8/call <a href='118parse-hex-int.subx.html#L864'>from-hex-char</a>/disp32 +<span id="L472" class="LineNr">472 </span> <span class="subxComment"># result = result * 16 + eax</span> +<span id="L473" class="LineNr">473 </span> c1/shift 4/subop/left 3/mod/direct 3/rm32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm8 <span class="subxComment"># shift ebx left by 4 bits</span> +<span id="L474" class="LineNr">474 </span> 01/add 3/mod/direct 3/rm32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># add eax to ebx</span> +<span id="L475" class="LineNr">475 </span> <span class="subxComment"># ++curr</span> +<span id="L476" class="LineNr">476 </span> 41/increment-ecx +<span id="L477" class="LineNr">477 </span> <span class="subxComment"># loop</span> +<span id="L478" class="LineNr">478 </span> eb/jump $parse-hex-int-helper:<span class="Constant">loop</span>/disp8 +<span id="L479" class="LineNr">479 </span><span class="Constant">$parse-hex-int-helper:negate</span>: +<span id="L480" class="LineNr">480 </span> <span class="subxComment"># if (negate?) result = -result</span> +<span id="L481" class="LineNr">481 </span> 81 7/subop/compare 3/mod/direct 6/rm32/esi <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/imm32/false <span class="subxComment"># compare esi</span> +<span id="L482" class="LineNr">482 </span> 74/jump-if-= $parse-hex-int-helper:end/disp8 +<span id="L483" class="LineNr">483 </span> f7 3/subop/negate 3/mod/direct 3/rm32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># negate ebx</span> +<span id="L484" class="LineNr">484 </span><span class="Constant">$parse-hex-int-helper:end</span>: +<span id="L485" class="LineNr">485 </span> <span class="subxComment"># return result</span> +<span id="L486" class="LineNr">486 </span> 89/copy 3/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebx to eax</span> +<span id="L487" class="LineNr">487 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L488" class="LineNr">488 </span> 5e/pop-to-esi +<span id="L489" class="LineNr">489 </span> 5b/pop-to-ebx +<span id="L490" class="LineNr">490 </span> 5a/pop-to-edx +<span id="L491" class="LineNr">491 </span> 59/pop-to-ecx +<span id="L492" class="LineNr">492 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L493" class="LineNr">493 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L494" class="LineNr">494 </span> 5d/pop-to-ebp +<span id="L495" class="LineNr">495 </span> c3/return +<span id="L496" class="LineNr">496 </span> +<span id="L497" class="LineNr">497 </span><span class="subxTest">test-parse-hex-int-from-slice-single-digit</span>: +<span id="L498" class="LineNr">498 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L499" class="LineNr">499 </span> 55/push-ebp +<span id="L500" class="LineNr">500 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L501" class="LineNr">501 </span> <span class="subxComment"># (eax..ecx) = "a"</span> +<span id="L502" class="LineNr">502 </span> b8/copy-to-eax <span class="Constant">"a"</span>/imm32 +<span id="L503" class="LineNr">503 </span> 8b/copy 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *eax to ecx</span> +<span id="L504" class="LineNr">504 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+ecx+4 to ecx</span> +<span id="L505" class="LineNr">505 </span> 05/add-to-eax 4/imm32 +<span id="L506" class="LineNr">506 </span> <span class="subxComment"># var slice/ecx: slice = {eax, ecx}</span> +<span id="L507" class="LineNr">507 </span> 51/push-ecx +<span id="L508" class="LineNr">508 </span> 50/push-eax +<span id="L509" class="LineNr">509 </span> 89/copy 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ecx</span> +<span id="L510" class="LineNr">510 </span> <span class="subxComment"># eax = parse-hex-int-from-slice(slice)</span> +<span id="L511" class="LineNr">511 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L512" class="LineNr">512 </span> 51/push-ecx +<span id="L513" class="LineNr">513 </span> <span class="subxS2Comment"># . . call</span> +<span id="L514" class="LineNr">514 </span> e8/call <a href='118parse-hex-int.subx.html#L387'>parse-hex-int-from-slice</a>/disp32 +<span id="L515" class="LineNr">515 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L516" class="LineNr">516 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L517" class="LineNr">517 </span> <span class="subxComment"># check-ints-equal(eax, 0xa, msg)</span> +<span id="L518" class="LineNr">518 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L519" class="LineNr">519 </span> 68/push <span class="Constant">"F - test-parse-hex-int-from-slice-single-digit"</span>/imm32 +<span id="L520" class="LineNr">520 </span> 68/push 0xa/imm32 +<span id="L521" class="LineNr">521 </span> 50/push-eax +<span id="L522" class="LineNr">522 </span> <span class="subxS2Comment"># . . call</span> +<span id="L523" class="LineNr">523 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L524" class="LineNr">524 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L525" class="LineNr">525 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L526" class="LineNr">526 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L527" class="LineNr">527 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L528" class="LineNr">528 </span> 5d/pop-to-ebp +<span id="L529" class="LineNr">529 </span> c3/return +<span id="L530" class="LineNr">530 </span> +<span id="L531" class="LineNr">531 </span><span class="subxTest">test-parse-hex-int-from-slice-multi-digit</span>: +<span id="L532" class="LineNr">532 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L533" class="LineNr">533 </span> 55/push-ebp +<span id="L534" class="LineNr">534 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L535" class="LineNr">535 </span> <span class="subxComment"># (eax..ecx) = "34a"</span> +<span id="L536" class="LineNr">536 </span> b8/copy-to-eax <span class="Constant">"34a"</span>/imm32 +<span id="L537" class="LineNr">537 </span> 8b/copy 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *eax to ecx</span> +<span id="L538" class="LineNr">538 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+ecx+4 to ecx</span> +<span id="L539" class="LineNr">539 </span> 05/add-to-eax 4/imm32 +<span id="L540" class="LineNr">540 </span> <span class="subxComment"># var slice/ecx: slice = {eax, ecx}</span> +<span id="L541" class="LineNr">541 </span> 51/push-ecx +<span id="L542" class="LineNr">542 </span> 50/push-eax +<span id="L543" class="LineNr">543 </span> 89/copy 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ecx</span> +<span id="L544" class="LineNr">544 </span> <span class="subxComment"># eax = parse-hex-int-from-slice(slice)</span> +<span id="L545" class="LineNr">545 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L546" class="LineNr">546 </span> 51/push-ecx +<span id="L547" class="LineNr">547 </span> <span class="subxS2Comment"># . . call</span> +<span id="L548" class="LineNr">548 </span> e8/call <a href='118parse-hex-int.subx.html#L387'>parse-hex-int-from-slice</a>/disp32 +<span id="L549" class="LineNr">549 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L550" class="LineNr">550 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L551" class="LineNr">551 </span> <span class="subxComment"># check-ints-equal(eax, 0x34a, msg)</span> +<span id="L552" class="LineNr">552 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L553" class="LineNr">553 </span> 68/push <span class="Constant">"F - test-parse-hex-int-from-slice-multi-digit"</span>/imm32 +<span id="L554" class="LineNr">554 </span> 68/push 0x34a/imm32 +<span id="L555" class="LineNr">555 </span> 50/push-eax +<span id="L556" class="LineNr">556 </span> <span class="subxS2Comment"># . . call</span> +<span id="L557" class="LineNr">557 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L558" class="LineNr">558 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L559" class="LineNr">559 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L560" class="LineNr">560 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L561" class="LineNr">561 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L562" class="LineNr">562 </span> 5d/pop-to-ebp +<span id="L563" class="LineNr">563 </span> c3/return +<span id="L564" class="LineNr">564 </span> +<span id="L565" class="LineNr">565 </span><span class="subxTest">test-parse-hex-int-from-slice-0x-prefix</span>: +<span id="L566" class="LineNr">566 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L567" class="LineNr">567 </span> 55/push-ebp +<span id="L568" class="LineNr">568 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L569" class="LineNr">569 </span> <span class="subxComment"># (eax..ecx) = "0x34"</span> +<span id="L570" class="LineNr">570 </span> b8/copy-to-eax <span class="Constant">"0x34"</span>/imm32 +<span id="L571" class="LineNr">571 </span> 8b/copy 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *eax to ecx</span> +<span id="L572" class="LineNr">572 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+ecx+4 to ecx</span> +<span id="L573" class="LineNr">573 </span> 05/add-to-eax 4/imm32 +<span id="L574" class="LineNr">574 </span> <span class="subxComment"># var slice/ecx: slice = {eax, ecx}</span> +<span id="L575" class="LineNr">575 </span> 51/push-ecx +<span id="L576" class="LineNr">576 </span> 50/push-eax +<span id="L577" class="LineNr">577 </span> 89/copy 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ecx</span> +<span id="L578" class="LineNr">578 </span> <span class="subxComment"># eax = parse-hex-int-from-slice(slice)</span> +<span id="L579" class="LineNr">579 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L580" class="LineNr">580 </span> 51/push-ecx +<span id="L581" class="LineNr">581 </span> <span class="subxS2Comment"># . . call</span> +<span id="L582" class="LineNr">582 </span> e8/call <a href='118parse-hex-int.subx.html#L387'>parse-hex-int-from-slice</a>/disp32 +<span id="L583" class="LineNr">583 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L584" class="LineNr">584 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L585" class="LineNr">585 </span> <span class="subxComment"># check-ints-equal(eax, 0x34, msg)</span> +<span id="L586" class="LineNr">586 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L587" class="LineNr">587 </span> 68/push <span class="Constant">"F - test-parse-hex-int-from-slice-0x-prefix"</span>/imm32 +<span id="L588" class="LineNr">588 </span> 68/push 0x34/imm32 +<span id="L589" class="LineNr">589 </span> 50/push-eax +<span id="L590" class="LineNr">590 </span> <span class="subxS2Comment"># . . call</span> +<span id="L591" class="LineNr">591 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L592" class="LineNr">592 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L593" class="LineNr">593 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L594" class="LineNr">594 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L595" class="LineNr">595 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L596" class="LineNr">596 </span> 5d/pop-to-ebp +<span id="L597" class="LineNr">597 </span> c3/return +<span id="L598" class="LineNr">598 </span> +<span id="L599" class="LineNr">599 </span><span class="subxTest">test-parse-hex-int-from-slice-zero</span>: +<span id="L600" class="LineNr">600 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L601" class="LineNr">601 </span> 55/push-ebp +<span id="L602" class="LineNr">602 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L603" class="LineNr">603 </span> <span class="subxComment"># (eax..ecx) = "0"</span> +<span id="L604" class="LineNr">604 </span> b8/copy-to-eax <span class="Constant">"0"</span>/imm32 +<span id="L605" class="LineNr">605 </span> 8b/copy 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *eax to ecx</span> +<span id="L606" class="LineNr">606 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+ecx+4 to ecx</span> +<span id="L607" class="LineNr">607 </span> 05/add-to-eax 4/imm32 +<span id="L608" class="LineNr">608 </span> <span class="subxComment"># var slice/ecx: slice = {eax, ecx}</span> +<span id="L609" class="LineNr">609 </span> 51/push-ecx +<span id="L610" class="LineNr">610 </span> 50/push-eax +<span id="L611" class="LineNr">611 </span> 89/copy 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ecx</span> +<span id="L612" class="LineNr">612 </span> <span class="subxComment"># eax = parse-hex-int-from-slice(slice)</span> +<span id="L613" class="LineNr">613 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L614" class="LineNr">614 </span> 51/push-ecx +<span id="L615" class="LineNr">615 </span> <span class="subxS2Comment"># . . call</span> +<span id="L616" class="LineNr">616 </span> e8/call <a href='118parse-hex-int.subx.html#L387'>parse-hex-int-from-slice</a>/disp32 +<span id="L617" class="LineNr">617 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L618" class="LineNr">618 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L619" class="LineNr">619 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> +<span id="L620" class="LineNr">620 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L621" class="LineNr">621 </span> 68/push <span class="Constant">"F - test-parse-hex-int-from-slice-zero"</span>/imm32 +<span id="L622" class="LineNr">622 </span> 68/push 0/imm32 +<span id="L623" class="LineNr">623 </span> 50/push-eax +<span id="L624" class="LineNr">624 </span> <span class="subxS2Comment"># . . call</span> +<span id="L625" class="LineNr">625 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L626" class="LineNr">626 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L627" class="LineNr">627 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L628" class="LineNr">628 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L629" class="LineNr">629 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L630" class="LineNr">630 </span> 5d/pop-to-ebp +<span id="L631" class="LineNr">631 </span> c3/return +<span id="L632" class="LineNr">632 </span> +<span id="L633" class="LineNr">633 </span><span class="subxTest">test-parse-hex-int-from-slice-0-prefix</span>: +<span id="L634" class="LineNr">634 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L635" class="LineNr">635 </span> 55/push-ebp +<span id="L636" class="LineNr">636 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L637" class="LineNr">637 </span> <span class="subxComment"># (eax..ecx) = "03"</span> +<span id="L638" class="LineNr">638 </span> b8/copy-to-eax <span class="Constant">"03"</span>/imm32 +<span id="L639" class="LineNr">639 </span> 8b/copy 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *eax to ecx</span> +<span id="L640" class="LineNr">640 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+ecx+4 to ecx</span> +<span id="L641" class="LineNr">641 </span> 05/add-to-eax 4/imm32 +<span id="L642" class="LineNr">642 </span> <span class="subxComment"># var slice/ecx: slice = {eax, ecx}</span> +<span id="L643" class="LineNr">643 </span> 51/push-ecx +<span id="L644" class="LineNr">644 </span> 50/push-eax +<span id="L645" class="LineNr">645 </span> 89/copy 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ecx</span> +<span id="L646" class="LineNr">646 </span> <span class="subxComment"># eax = parse-hex-int-from-slice(slice)</span> +<span id="L647" class="LineNr">647 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L648" class="LineNr">648 </span> 51/push-ecx +<span id="L649" class="LineNr">649 </span> <span class="subxS2Comment"># . . call</span> +<span id="L650" class="LineNr">650 </span> e8/call <a href='118parse-hex-int.subx.html#L387'>parse-hex-int-from-slice</a>/disp32 +<span id="L651" class="LineNr">651 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L652" class="LineNr">652 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L653" class="LineNr">653 </span> <span class="subxComment"># check-ints-equal(eax, 0x3, msg)</span> +<span id="L654" class="LineNr">654 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L655" class="LineNr">655 </span> 68/push <span class="Constant">"F - test-parse-hex-int-from-slice-0-prefix"</span>/imm32 +<span id="L656" class="LineNr">656 </span> 68/push 0x3/imm32 +<span id="L657" class="LineNr">657 </span> 50/push-eax +<span id="L658" class="LineNr">658 </span> <span class="subxS2Comment"># . . call</span> +<span id="L659" class="LineNr">659 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L660" class="LineNr">660 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L661" class="LineNr">661 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L662" class="LineNr">662 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L663" class="LineNr">663 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L664" class="LineNr">664 </span> 5d/pop-to-ebp +<span id="L665" class="LineNr">665 </span> c3/return +<span id="L666" class="LineNr">666 </span> +<span id="L667" class="LineNr">667 </span><span class="subxTest">test-parse-hex-int-from-slice-negative</span>: +<span id="L668" class="LineNr">668 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L669" class="LineNr">669 </span> 55/push-ebp +<span id="L670" class="LineNr">670 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L671" class="LineNr">671 </span> <span class="subxComment"># (eax..ecx) = "-03"</span> +<span id="L672" class="LineNr">672 </span> b8/copy-to-eax <span class="Constant">"-03"</span>/imm32 +<span id="L673" class="LineNr">673 </span> 8b/copy 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *eax to ecx</span> +<span id="L674" class="LineNr">674 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx <span class="Normal"> . </span> 1/r32/ecx 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+ecx+4 to ecx</span> +<span id="L675" class="LineNr">675 </span> 05/add-to-eax 4/imm32 +<span id="L676" class="LineNr">676 </span> <span class="subxComment"># var slice/ecx: slice = {eax, ecx}</span> +<span id="L677" class="LineNr">677 </span> 51/push-ecx +<span id="L678" class="LineNr">678 </span> 50/push-eax +<span id="L679" class="LineNr">679 </span> 89/copy 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ecx</span> +<span id="L680" class="LineNr">680 </span> <span class="subxComment"># eax = parse-hex-int-from-slice(slice)</span> +<span id="L681" class="LineNr">681 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L682" class="LineNr">682 </span> 51/push-ecx +<span id="L683" class="LineNr">683 </span> <span class="subxS2Comment"># . . call</span> +<span id="L684" class="LineNr">684 </span> e8/call <a href='118parse-hex-int.subx.html#L387'>parse-hex-int-from-slice</a>/disp32 +<span id="L685" class="LineNr">685 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L686" class="LineNr">686 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L687" class="LineNr">687 </span> <span class="subxComment"># check-ints-equal(eax, -3, msg)</span> +<span id="L688" class="LineNr">688 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L689" class="LineNr">689 </span> 68/push <span class="Constant">"F - test-parse-hex-int-from-slice-negative"</span>/imm32 +<span id="L690" class="LineNr">690 </span> 68/push -3/imm32 +<span id="L691" class="LineNr">691 </span> 50/push-eax +<span id="L692" class="LineNr">692 </span> <span class="subxS2Comment"># . . call</span> +<span id="L693" class="LineNr">693 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L694" class="LineNr">694 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L695" class="LineNr">695 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L696" class="LineNr">696 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L697" class="LineNr">697 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L698" class="LineNr">698 </span> 5d/pop-to-ebp +<span id="L699" class="LineNr">699 </span> c3/return +<span id="L700" class="LineNr">700 </span> +<span id="L701" class="LineNr">701 </span><span class="subxFunction">is-hex-digit?</span>: <span class="subxComment"># c: byte -> result/eax: boolean</span> +<span id="L702" class="LineNr">702 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L703" class="LineNr">703 </span> 55/push-ebp +<span id="L704" class="LineNr">704 </span> 89/copy 3/mod/direct 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy esp to ebp</span> +<span id="L705" class="LineNr">705 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L706" class="LineNr">706 </span> 51/push-ecx +<span id="L707" class="LineNr">707 </span> <span class="subxComment"># ecx = c</span> +<span id="L708" class="LineNr">708 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+8) to ecx</span> +<span id="L709" class="LineNr">709 </span> <span class="subxComment"># return false if c < '0'</span> +<span id="L710" class="LineNr">710 </span> 81 7/subop/compare 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0x30/imm32 <span class="subxComment"># compare ecx</span> +<span id="L711" class="LineNr">711 </span> 7c/jump-if-< $is-hex-digit?:false/disp8 +<span id="L712" class="LineNr">712 </span> <span class="subxComment"># return true if c <= '9'</span> +<span id="L713" class="LineNr">713 </span> 81 7/subop/compare 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0x39/imm32 <span class="subxComment"># compare ecx</span> +<span id="L714" class="LineNr">714 </span> 7e/jump-if-<= $is-hex-digit?:true/disp8 +<span id="L715" class="LineNr">715 </span> <span class="subxComment"># drop case</span> +<span id="L716" class="LineNr">716 </span> 25/and-eax-with 0x5f/imm32 +<span id="L717" class="LineNr">717 </span> <span class="subxComment"># return false if c > 'f'</span> +<span id="L718" class="LineNr">718 </span> 81 7/subop/compare 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0x66/imm32 <span class="subxComment"># compare ecx</span> +<span id="L719" class="LineNr">719 </span> 7f/jump-if-> $is-hex-digit?:false/disp8 +<span id="L720" class="LineNr">720 </span> <span class="subxComment"># return true if c >= 'a'</span> +<span id="L721" class="LineNr">721 </span> 81 7/subop/compare 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0x61/imm32 <span class="subxComment"># compare ecx</span> +<span id="L722" class="LineNr">722 </span> 7d/jump-if->= $is-hex-digit?:true/disp8 +<span id="L723" class="LineNr">723 </span> <span class="subxComment"># otherwise return false</span> +<span id="L724" class="LineNr">724 </span><span class="Constant">$is-hex-digit?:false</span>: +<span id="L725" class="LineNr">725 </span> b8/copy-to-eax 0/imm32/false +<span id="L726" class="LineNr">726 </span> eb/jump $is-hex-digit?:end/disp8 +<span id="L727" class="LineNr">727 </span><span class="Constant">$is-hex-digit?:true</span>: +<span id="L728" class="LineNr">728 </span> b8/copy-to-eax 1/imm32/true +<span id="L729" class="LineNr">729 </span><span class="Constant">$is-hex-digit?:end</span>: +<span id="L730" class="LineNr">730 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L731" class="LineNr">731 </span> 59/pop-to-ecx +<span id="L732" class="LineNr">732 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L733" class="LineNr">733 </span> 89/copy 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ebp to esp</span> +<span id="L734" class="LineNr">734 </span> 5d/pop-to-ebp +<span id="L735" class="LineNr">735 </span> c3/return +<span id="L736" class="LineNr">736 </span> +<span id="L737" class="LineNr">737 </span><span class="subxTest">test-hex-below-0</span>: +<span id="L738" class="LineNr">738 </span> <span class="subxComment"># eax = is-hex-digit?(0x2f)</span> +<span id="L739" class="LineNr">739 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L740" class="LineNr">740 </span> 68/push 0x2f/imm32 +<span id="L741" class="LineNr">741 </span> <span class="subxS2Comment"># . . call</span> +<span id="L742" class="LineNr">742 </span> e8/call <a href='118parse-hex-int.subx.html#L701'>is-hex-digit?</a>/disp32 +<span id="L743" class="LineNr">743 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L744" class="LineNr">744 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L745" class="LineNr">745 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> +<span id="L746" class="LineNr">746 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L747" class="LineNr">747 </span> 68/push <span class="Constant">"F - test-hex-below-0"</span>/imm32 +<span id="L748" class="LineNr">748 </span> 68/push 0/imm32/false +<span id="L749" class="LineNr">749 </span> 50/push-eax +<span id="L750" class="LineNr">750 </span> <span class="subxS2Comment"># . . call</span> +<span id="L751" class="LineNr">751 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L752" class="LineNr">752 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L753" class="LineNr">753 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L754" class="LineNr">754 </span> c3/return +<span id="L755" class="LineNr">755 </span> +<span id="L756" class="LineNr">756 </span><span class="subxTest">test-hex-0-to-9</span>: +<span id="L757" class="LineNr">757 </span> <span class="subxComment"># eax = is-hex-digit?(0x30)</span> +<span id="L758" class="LineNr">758 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L759" class="LineNr">759 </span> 68/push 0x30/imm32 +<span id="L760" class="LineNr">760 </span> <span class="subxS2Comment"># . . call</span> +<span id="L761" class="LineNr">761 </span> e8/call <a href='118parse-hex-int.subx.html#L701'>is-hex-digit?</a>/disp32 +<span id="L762" class="LineNr">762 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L763" class="LineNr">763 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L764" class="LineNr">764 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> +<span id="L765" class="LineNr">765 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L766" class="LineNr">766 </span> 68/push <span class="Constant">"F - test-hex-at-0"</span>/imm32 +<span id="L767" class="LineNr">767 </span> 68/push 1/imm32/true +<span id="L768" class="LineNr">768 </span> 50/push-eax +<span id="L769" class="LineNr">769 </span> <span class="subxS2Comment"># . . call</span> +<span id="L770" class="LineNr">770 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L771" class="LineNr">771 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L772" class="LineNr">772 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L773" class="LineNr">773 </span> <span class="subxComment"># eax = is-hex-digit?(0x39)</span> +<span id="L774" class="LineNr">774 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L775" class="LineNr">775 </span> 68/push 0x39/imm32 +<span id="L776" class="LineNr">776 </span> <span class="subxS2Comment"># . . call</span> +<span id="L777" class="LineNr">777 </span> e8/call <a href='118parse-hex-int.subx.html#L701'>is-hex-digit?</a>/disp32 +<span id="L778" class="LineNr">778 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L779" class="LineNr">779 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L780" class="LineNr">780 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> +<span id="L781" class="LineNr">781 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L782" class="LineNr">782 </span> 68/push <span class="Constant">"F - test-hex-at-9"</span>/imm32 +<span id="L783" class="LineNr">783 </span> 68/push 1/imm32/true +<span id="L784" class="LineNr">784 </span> 50/push-eax +<span id="L785" class="LineNr">785 </span> <span class="subxS2Comment"># . . call</span> +<span id="L786" class="LineNr">786 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L787" class="LineNr">787 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L788" class="LineNr">788 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L789" class="LineNr">789 </span> c3/return +<span id="L790" class="LineNr">790 </span> +<span id="L791" class="LineNr">791 </span><span class="subxTest">test-hex-above-9-to-a</span>: +<span id="L792" class="LineNr">792 </span> <span class="subxComment"># eax = is-hex-digit?(0x3a)</span> +<span id="L793" class="LineNr">793 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L794" class="LineNr">794 </span> 68/push 0x3a/imm32 +<span id="L795" class="LineNr">795 </span> <span class="subxS2Comment"># . . call</span> +<span id="L796" class="LineNr">796 </span> e8/call <a href='118parse-hex-int.subx.html#L701'>is-hex-digit?</a>/disp32 +<span id="L797" class="LineNr">797 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L798" class="LineNr">798 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L799" class="LineNr">799 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> +<span id="L800" class="LineNr">800 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L801" class="LineNr">801 </span> 68/push <span class="Constant">"F - test-hex-above-9-to-a"</span>/imm32 +<span id="L802" class="LineNr">802 </span> 68/push 0/imm32/false +<span id="L803" class="LineNr">803 </span> 50/push-eax +<span id="L804" class="LineNr">804 </span> <span class="subxS2Comment"># . . call</span> +<span id="L805" class="LineNr">805 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L806" class="LineNr">806 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L807" class="LineNr">807 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L808" class="LineNr">808 </span> c3/return +<span id="L809" class="LineNr">809 </span> +<span id="L810" class="LineNr">810 </span><span class="subxTest">test-hex-a-to-f</span>: +<span id="L811" class="LineNr">811 </span> <span class="subxComment"># eax = is-hex-digit?(0x61)</span> +<span id="L812" class="LineNr">812 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L813" class="LineNr">813 </span> 68/push 0x61/imm32 +<span id="L814" class="LineNr">814 </span> <span class="subxS2Comment"># . . call</span> +<span id="L815" class="LineNr">815 </span> e8/call <a href='118parse-hex-int.subx.html#L701'>is-hex-digit?</a>/disp32 +<span id="L816" class="LineNr">816 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L817" class="LineNr">817 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L818" class="LineNr">818 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> +<span id="L819" class="LineNr">819 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L820" class="LineNr">820 </span> 68/push <span class="Constant">"F - test-hex-at-a"</span>/imm32 +<span id="L821" class="LineNr">821 </span> 68/push 1/imm32/true +<span id="L822" class="LineNr">822 </span> 50/push-eax +<span id="L823" class="LineNr">823 </span> <span class="subxS2Comment"># . . call</span> +<span id="L824" class="LineNr">824 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L825" class="LineNr">825 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L826" class="LineNr">826 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L827" class="LineNr">827 </span> <span class="subxComment"># eax = is-hex-digit?(0x66)</span> +<span id="L828" class="LineNr">828 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L829" class="LineNr">829 </span> 68/push 0x66/imm32 +<span id="L830" class="LineNr">830 </span> <span class="subxS2Comment"># . . call</span> +<span id="L831" class="LineNr">831 </span> e8/call <a href='118parse-hex-int.subx.html#L701'>is-hex-digit?</a>/disp32 +<span id="L832" class="LineNr">832 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L833" class="LineNr">833 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L834" class="LineNr">834 </span> <span class="subxComment"># check-ints-equal(eax, 1, msg)</span> +<span id="L835" class="LineNr">835 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L836" class="LineNr">836 </span> 68/push <span class="Constant">"F - test-hex-at-f"</span>/imm32 +<span id="L837" class="LineNr">837 </span> 68/push 1/imm32/true +<span id="L838" class="LineNr">838 </span> 50/push-eax +<span id="L839" class="LineNr">839 </span> <span class="subxS2Comment"># . . call</span> +<span id="L840" class="LineNr">840 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L841" class="LineNr">841 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L842" class="LineNr">842 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L843" class="LineNr">843 </span> c3/return +<span id="L844" class="LineNr">844 </span> +<span id="L845" class="LineNr">845 </span><span class="subxTest">test-hex-above-f</span>: +<span id="L846" class="LineNr">846 </span> <span class="subxComment"># eax = is-hex-digit?(0x67)</span> +<span id="L847" class="LineNr">847 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L848" class="LineNr">848 </span> 68/push 0x67/imm32 +<span id="L849" class="LineNr">849 </span> <span class="subxS2Comment"># . . call</span> +<span id="L850" class="LineNr">850 </span> e8/call <a href='118parse-hex-int.subx.html#L701'>is-hex-digit?</a>/disp32 +<span id="L851" class="LineNr">851 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L852" class="LineNr">852 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to esp</span> +<span id="L853" class="LineNr">853 </span> <span class="subxComment"># check-ints-equal(eax, 0, msg)</span> +<span id="L854" class="LineNr">854 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L855" class="LineNr">855 </span> 68/push <span class="Constant">"F - test-hex-above-f"</span>/imm32 +<span id="L856" class="LineNr">856 </span> 68/push 0/imm32/false +<span id="L857" class="LineNr">857 </span> 50/push-eax +<span id="L858" class="LineNr">858 </span> <span class="subxS2Comment"># . . call</span> +<span id="L859" class="LineNr">859 </span> e8/call <a href='502test.mu.html#L2'>check-ints-equal</a>/disp32 +<span id="L860" class="LineNr">860 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L861" class="LineNr">861 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> +<span id="L862" class="LineNr">862 </span> c3/return +<span id="L863" class="LineNr">863 </span> +<span id="L864" class="LineNr">864 </span><span class="subxFunction">from-hex-char</span>: <span class="subxComment"># in/eax: byte -> out/eax: nibble</span> +<span id="L865" class="LineNr">865 </span><span class="Constant">$from-hex-char:check0</span>: +<span id="L866" class="LineNr">866 </span> <span class="subxComment"># if (eax < '0') goto abort</span> +<span id="L867" class="LineNr">867 </span> 3d/compare-eax-with 0x30/imm32/0 +<span id="L868" class="LineNr">868 </span> 7c/jump-if-< $from-hex-char:<a href='501draw-text.mu.html#L519'>abort</a>/disp8 +<span id="L869" class="LineNr">869 </span><span class="Constant">$from-hex-char:check1</span>: +<span id="L870" class="LineNr">870 </span> <span class="subxComment"># if (eax > 'f') goto abort</span> +<span id="L871" class="LineNr">871 </span> 3d/compare-eax-with 0x66/imm32/f +<span id="L872" class="LineNr">872 </span> 7f/jump-if-> $from-hex-char:<a href='501draw-text.mu.html#L519'>abort</a>/disp8 +<span id="L873" class="LineNr">873 </span><span class="Constant">$from-hex-char:check2</span>: +<span id="L874" class="LineNr">874 </span> <span class="subxComment"># if (eax > '9') goto next check</span> +<span id="L875" class="LineNr">875 </span> 3d/compare-eax-with 0x39/imm32/9 +<span id="L876" class="LineNr">876 </span> 7f/jump-if-> $from-hex-char:check3/disp8 +<span id="L877" class="LineNr">877 </span><span class="Constant">$from-hex-char:digit</span>: +<span id="L878" class="LineNr">878 </span> <span class="subxComment"># return eax - '0'</span> +<span id="L879" class="LineNr">879 </span> 2d/subtract-from-eax 0x30/imm32/0 +<span id="L880" class="LineNr">880 </span> c3/return +<span id="L881" class="LineNr">881 </span><span class="Constant">$from-hex-char:check3</span>: +<span id="L882" class="LineNr">882 </span> <span class="subxComment"># if (eax < 'a') goto abort</span> +<span id="L883" class="LineNr">883 </span> 3d/compare-eax-with 0x61/imm32/a +<span id="L884" class="LineNr">884 </span> 7c/jump-if-< $from-hex-char:<a href='501draw-text.mu.html#L519'>abort</a>/disp8 +<span id="L885" class="LineNr">885 </span><span class="Constant">$from-hex-char:letter</span>: +<span id="L886" class="LineNr">886 </span> <span class="subxComment"># return eax - ('a'-10)</span> +<span id="L887" class="LineNr">887 </span> 2d/subtract-from-eax 0x57/imm32/a-10 +<span id="L888" class="LineNr">888 </span> c3/return +<span id="L889" class="LineNr">889 </span> +<span id="L890" class="LineNr">890 </span><span class="Constant">$from-hex-char:<a href='501draw-text.mu.html#L519'>abort</a></span>: +<span id="L891" class="LineNr">891 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"invalid hex char"</span> 3 0) <span class="subxComment"># 3=cyan</span> +<span id="L892" class="LineNr">892 </span> { +<span id="L893" class="LineNr">893 </span> eb/jump <span class="Constant">loop</span>/disp8 +<span id="L894" class="LineNr">894 </span> } +<span id="L895" class="LineNr">895 </span> <span class="subxComment"># never gets here</span> +<span id="L896" class="LineNr">896 </span> +<span id="L897" class="LineNr">897 </span><span class="subxS2Comment"># . . vim:nowrap:textwidth=0</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/baremetal/120allocate.subx.html b/html/baremetal/120allocate.subx.html index f19e0902..b55f5483 100644 --- a/html/baremetal/120allocate.subx.html +++ b/html/baremetal/120allocate.subx.html @@ -173,7 +173,7 @@ if ('onhashchange' in window) { <span id="L112" class="LineNr">112 </span> <span class="subxComment"># TODO: move this check up before any state updates when we support error recovery</span> <span id="L113" class="LineNr">113 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 3/index/ebx <span class="Normal"> . </span> 0/r32/eax 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy eax+ebx+4 to eax</span> <span id="L114" class="LineNr">114 </span> 3b/compare 1/mod/*+disp8 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># compare eax with *(ecx+4)</span> -<span id="L115" class="LineNr">115 </span> 73/jump-if->=-signed $allocate-raw:abort/disp8 +<span id="L115" class="LineNr">115 </span> 73/jump-if->=-signed $allocate-raw:<a href='501draw-text.mu.html#L519'>abort</a>/disp8 <span id="L116" class="LineNr">116 </span><span class="Constant">$allocate-raw:commit</span>: <span id="L117" class="LineNr">117 </span> <span class="subxComment"># ad->curr += n+4</span> <span id="L118" class="LineNr">118 </span> 89/copy 0/mod/indirect 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy eax to *ecx</span> @@ -190,8 +190,8 @@ if ('onhashchange' in window) { <span id="L129" class="LineNr">129 </span> 5d/pop-to-ebp <span id="L130" class="LineNr">130 </span> c3/return <span id="L131" class="LineNr">131 </span> -<span id="L132" class="LineNr">132 </span><span class="Constant">$allocate-raw:abort</span>: -<span id="L133" class="LineNr">133 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"allocate: failed"</span> 3) <span class="subxComment"># 3=cyan</span> +<span id="L132" class="LineNr">132 </span><span class="Constant">$allocate-raw:<a href='501draw-text.mu.html#L519'>abort</a></span>: +<span id="L133" class="LineNr">133 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"allocate: failed"</span> 3 0) <span class="subxComment"># 3=cyan</span> <span id="L134" class="LineNr">134 </span> { <span id="L135" class="LineNr">135 </span> eb/jump <span class="Constant">loop</span>/disp8 <span id="L136" class="LineNr">136 </span> } @@ -301,7 +301,7 @@ if ('onhashchange' in window) { <span id="L240" class="LineNr">240 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+12) to eax</span> <span id="L241" class="LineNr">241 </span> <span class="subxComment"># if (ecx != *eax) abort</span> <span id="L242" class="LineNr">242 </span> 39/compare 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare *eax and ecx</span> -<span id="L243" class="LineNr">243 </span> 75/jump-if-!= $lookup:abort/disp8 +<span id="L243" class="LineNr">243 </span> 75/jump-if-!= $lookup:<a href='501draw-text.mu.html#L519'>abort</a>/disp8 <span id="L244" class="LineNr">244 </span> <span class="subxComment"># add 4 to eax</span> <span id="L245" class="LineNr">245 </span> 05/add-to-eax 4/imm32 <span id="L246" class="LineNr">246 </span><span class="Constant">$lookup:end</span>: @@ -312,8 +312,8 @@ if ('onhashchange' in window) { <span id="L251" class="LineNr">251 </span> 5d/pop-to-ebp <span id="L252" class="LineNr">252 </span> c3/return <span id="L253" class="LineNr">253 </span> -<span id="L254" class="LineNr">254 </span><span class="Constant">$lookup:abort</span>: -<span id="L255" class="LineNr">255 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"lookup: failed"</span> 3) <span class="subxComment"># 3=cyan</span> +<span id="L254" class="LineNr">254 </span><span class="Constant">$lookup:<a href='501draw-text.mu.html#L519'>abort</a></span>: +<span id="L255" class="LineNr">255 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"lookup: failed"</span> 3 0) <span class="subxComment"># 3=cyan</span> <span id="L256" class="LineNr">256 </span> { <span id="L257" class="LineNr">257 </span> eb/jump <span class="Constant">loop</span>/disp8 <span id="L258" class="LineNr">258 </span> } @@ -560,7 +560,7 @@ if ('onhashchange' in window) { <span id="L499" class="LineNr">499 </span> 05/add-to-eax 4/imm32 <span id="L500" class="LineNr">500 </span> <span class="subxComment"># if (eax == 0) abort</span> <span id="L501" class="LineNr">501 </span> 3d/compare-eax-and 0/imm32 -<span id="L502" class="LineNr">502 </span> 74/jump-if-= $allocate-region:abort/disp8 +<span id="L502" class="LineNr">502 </span> 74/jump-if-= $allocate-region:<a href='501draw-text.mu.html#L519'>abort</a>/disp8 <span id="L503" class="LineNr">503 </span> <span class="subxComment"># earmark 8 bytes at the start for a new allocation descriptor</span> <span id="L504" class="LineNr">504 </span> <span class="subxS1Comment"># . *eax = eax + 8</span> <span id="L505" class="LineNr">505 </span> 89/copy 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy eax to ecx</span> @@ -584,8 +584,8 @@ if ('onhashchange' in window) { <span id="L523" class="LineNr">523 </span><span class="subxComment"># conditional jump, even if it's unused the vast majority of the time. This way</span> <span id="L524" class="LineNr">524 </span><span class="subxComment"># we bloat a potentially cold segment in RAM so we can abort with a single</span> <span id="L525" class="LineNr">525 </span><span class="subxComment"># instruction.</span> -<span id="L526" class="LineNr">526 </span><span class="Constant">$allocate-region:abort</span>: -<span id="L527" class="LineNr">527 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"allocate-region: failed to allocate"</span> 3) <span class="subxComment"># 3=cyan</span> +<span id="L526" class="LineNr">526 </span><span class="Constant">$allocate-region:<a href='501draw-text.mu.html#L519'>abort</a></span>: +<span id="L527" class="LineNr">527 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"allocate-region: failed to allocate"</span> 3 0) <span class="subxComment"># 3=cyan</span> <span id="L528" class="LineNr">528 </span> { <span id="L529" class="LineNr">529 </span> eb/jump <span class="Constant">loop</span>/disp8 <span id="L530" class="LineNr">530 </span> } diff --git a/html/baremetal/123slice.subx.html b/html/baremetal/123slice.subx.html index 312af093..1c6925f7 100644 --- a/html/baremetal/123slice.subx.html +++ b/html/baremetal/123slice.subx.html @@ -880,7 +880,7 @@ if ('onhashchange' in window) { <span id="L819" class="LineNr"> 819 </span> 73/jump-if-addr>= $write-slice:loop-end/disp8 <span id="L820" class="LineNr"> 820 </span> <span class="subxComment"># if (out->write >= out->size) abort</span> <span id="L821" class="LineNr"> 821 </span> 39/compare 3/mod/direct 3/rm32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare ebx with edx</span> -<span id="L822" class="LineNr"> 822 </span> 7d/jump-if->= $write-slice:abort/disp8 +<span id="L822" class="LineNr"> 822 </span> 7d/jump-if->= $write-slice:<a href='501draw-text.mu.html#L519'>abort</a>/disp8 <span id="L823" class="LineNr"> 823 </span> <span class="subxComment"># out->data[out->write] = *in</span> <span id="L824" class="LineNr"> 824 </span> <span class="subxS1Comment"># . AL = *in</span> <span id="L825" class="LineNr"> 825 </span> 31/xor 3/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear eax</span> @@ -908,8 +908,8 @@ if ('onhashchange' in window) { <span id="L847" class="LineNr"> 847 </span> 5d/pop-to-ebp <span id="L848" class="LineNr"> 848 </span> c3/return <span id="L849" class="LineNr"> 849 </span> -<span id="L850" class="LineNr"> 850 </span><span class="Constant">$write-slice:abort</span>: -<span id="L851" class="LineNr"> 851 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"write-slice: out of space"</span> 3) <span class="subxComment"># 3=cyan</span> +<span id="L850" class="LineNr"> 850 </span><span class="Constant">$write-slice:<a href='501draw-text.mu.html#L519'>abort</a></span>: +<span id="L851" class="LineNr"> 851 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"write-slice: out of space"</span> 3 0) <span class="subxComment"># 3=cyan</span> <span id="L852" class="LineNr"> 852 </span> { <span id="L853" class="LineNr"> 853 </span> eb/jump <span class="Constant">loop</span>/disp8 <span id="L854" class="LineNr"> 854 </span> } @@ -950,7 +950,7 @@ if ('onhashchange' in window) { <span id="L889" class="LineNr"> 889 </span> 68/push <span class="Constant">"Abc"</span>/imm32 <span id="L890" class="LineNr"> 890 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 <span id="L891" class="LineNr"> 891 </span> <span class="subxS2Comment"># . . call</span> -<span id="L892" class="LineNr"> 892 </span> e8/call <a href='109stream-equal.subx.html#L197'>check-stream-equal</a>/disp32 +<span id="L892" class="LineNr"> 892 </span> e8/call <a href='109stream-equal.subx.html#L194'>check-stream-equal</a>/disp32 <span id="L893" class="LineNr"> 893 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L894" class="LineNr"> 894 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> <span id="L895" class="LineNr"> 895 </span> <span class="subxS1Comment"># . epilogue</span> @@ -995,7 +995,7 @@ if ('onhashchange' in window) { <span id="L934" class="LineNr"> 934 </span> 05/add-to-eax 4/imm32 <span id="L935" class="LineNr"> 935 </span> <span class="subxComment"># if (eax == 0) abort</span> <span id="L936" class="LineNr"> 936 </span> 3d/compare-eax-and 0/imm32 -<span id="L937" class="LineNr"> 937 </span> 74/jump-if-= $slice-to-string:abort/disp8 +<span id="L937" class="LineNr"> 937 </span> 74/jump-if-= $slice-to-string:<a href='501draw-text.mu.html#L519'>abort</a>/disp8 <span id="L938" class="LineNr"> 938 </span> <span class="subxComment"># out->size = size-4</span> <span id="L939" class="LineNr"> 939 </span> 89/copy 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ecx to *eax</span> <span id="L940" class="LineNr"> 940 </span> 81 5/subop/subtract 0/mod/indirect 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># subtract 4 from *eax</span> @@ -1030,8 +1030,8 @@ if ('onhashchange' in window) { <span id="L969" class="LineNr"> 969 </span> 5d/pop-to-ebp <span id="L970" class="LineNr"> 970 </span> c3/return <span id="L971" class="LineNr"> 971 </span> -<span id="L972" class="LineNr"> 972 </span><span class="Constant">$slice-to-string:abort</span>: -<span id="L973" class="LineNr"> 973 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"slice-to-string: out of space\n"</span> 3) <span class="subxComment"># 3=cyan</span> +<span id="L972" class="LineNr"> 972 </span><span class="Constant">$slice-to-string:<a href='501draw-text.mu.html#L519'>abort</a></span>: +<span id="L973" class="LineNr"> 973 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"slice-to-string: out of space\n"</span> 3 0) <span class="subxComment"># 3=cyan</span> <span id="L974" class="LineNr"> 974 </span> { <span id="L975" class="LineNr"> 975 </span> eb/jump <span class="Constant">loop</span>/disp8 <span id="L976" class="LineNr"> 976 </span> } @@ -1077,7 +1077,7 @@ if ('onhashchange' in window) { <span id="L1016" class="LineNr">1016 </span> 8b/copy 1/mod/*+disp8 3/rm32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebx+4) to eax</span> <span id="L1017" class="LineNr">1017 </span> <span class="subxComment"># skip payload->allocid</span> <span id="L1018" class="LineNr">1018 </span> 05/add-to-eax 4/imm32 -<span id="L1019" class="Folded">1019 </span><span class="Folded">+-- 26 lines: #? # dump eax ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</span> +<span id="L1019" class="Folded">1019 </span><span class="Folded">+-- 26 lines: #? # dump eax ---------------------------------------------------------------------------------------------------------------------------------------------------------</span> <span id="L1045" class="LineNr">1045 </span> <span class="subxComment"># eax = string-equal?(eax, "Abc")</span> <span id="L1046" class="LineNr">1046 </span> <span class="subxS2Comment"># . . push args</span> <span id="L1047" class="LineNr">1047 </span> 68/push <span class="Constant">"Abc"</span>/imm32 diff --git a/html/baremetal/126write-int-decimal.subx.html b/html/baremetal/126write-int-decimal.subx.html index e1c786ea..c85343f0 100644 --- a/html/baremetal/126write-int-decimal.subx.html +++ b/html/baremetal/126write-int-decimal.subx.html @@ -150,7 +150,7 @@ if ('onhashchange' in window) { <span id="L89" class="LineNr"> 89 </span> 74/jump-if-= $write-int32-decimal:write-break/disp8 <span id="L90" class="LineNr"> 90 </span> <span class="subxComment"># if (curr >= max) abort</span> <span id="L91" class="LineNr"> 91 </span> 39/compare 3/mod/direct 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare ecx with ebx</span> -<span id="L92" class="LineNr"> 92 </span> 73/jump-if-addr>= $write-int32-decimal:abort/disp8 +<span id="L92" class="LineNr"> 92 </span> 73/jump-if-addr>= $write-int32-decimal:<a href='501draw-text.mu.html#L519'>abort</a>/disp8 <span id="L93" class="LineNr"> 93 </span><span class="Constant">$write-int32-decimal:write-char</span>: <span id="L94" class="LineNr"> 94 </span> <span class="subxComment"># *curr = AL</span> <span id="L95" class="LineNr"> 95 </span> 88/copy-byte 0/mod/indirect 1/rm32/ecx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/AL <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy AL to byte at *ecx</span> @@ -174,8 +174,8 @@ if ('onhashchange' in window) { <span id="L113" class="LineNr">113 </span> 5d/pop-to-ebp <span id="L114" class="LineNr">114 </span> c3/return <span id="L115" class="LineNr">115 </span> -<span id="L116" class="LineNr">116 </span><span class="Constant">$write-int32-decimal:abort</span>: -<span id="L117" class="LineNr">117 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"write-int32-decimal: stream out of space"</span> 3) <span class="subxComment"># 3=cyan</span> +<span id="L116" class="LineNr">116 </span><span class="Constant">$write-int32-decimal:<a href='501draw-text.mu.html#L519'>abort</a></span>: +<span id="L117" class="LineNr">117 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"write-int32-decimal: stream out of space"</span> 3 0) <span class="subxComment"># 3=cyan</span> <span id="L118" class="LineNr">118 </span> { <span id="L119" class="LineNr">119 </span> eb/jump <span class="Constant">loop</span>/disp8 <span id="L120" class="LineNr">120 </span> } @@ -205,7 +205,7 @@ if ('onhashchange' in window) { <span id="L144" class="LineNr">144 </span> 68/push <span class="Constant">"9"</span>/imm32 <span id="L145" class="LineNr">145 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 <span id="L146" class="LineNr">146 </span> <span class="subxS2Comment"># . . call</span> -<span id="L147" class="LineNr">147 </span> e8/call <a href='109stream-equal.subx.html#L197'>check-stream-equal</a>/disp32 +<span id="L147" class="LineNr">147 </span> e8/call <a href='109stream-equal.subx.html#L194'>check-stream-equal</a>/disp32 <span id="L148" class="LineNr">148 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L149" class="LineNr">149 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> <span id="L150" class="LineNr">150 </span> <span class="subxS1Comment"># . end</span> @@ -235,7 +235,7 @@ if ('onhashchange' in window) { <span id="L174" class="LineNr">174 </span> 68/push <span class="Constant">"0"</span>/imm32 <span id="L175" class="LineNr">175 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 <span id="L176" class="LineNr">176 </span> <span class="subxS2Comment"># . . call</span> -<span id="L177" class="LineNr">177 </span> e8/call <a href='109stream-equal.subx.html#L197'>check-stream-equal</a>/disp32 +<span id="L177" class="LineNr">177 </span> e8/call <a href='109stream-equal.subx.html#L194'>check-stream-equal</a>/disp32 <span id="L178" class="LineNr">178 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L179" class="LineNr">179 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> <span id="L180" class="LineNr">180 </span> <span class="subxS1Comment"># . end</span> @@ -265,7 +265,7 @@ if ('onhashchange' in window) { <span id="L204" class="LineNr">204 </span> 68/push <span class="Constant">"10"</span>/imm32 <span id="L205" class="LineNr">205 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 <span id="L206" class="LineNr">206 </span> <span class="subxS2Comment"># . . call</span> -<span id="L207" class="LineNr">207 </span> e8/call <a href='109stream-equal.subx.html#L197'>check-stream-equal</a>/disp32 +<span id="L207" class="LineNr">207 </span> e8/call <a href='109stream-equal.subx.html#L194'>check-stream-equal</a>/disp32 <span id="L208" class="LineNr">208 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L209" class="LineNr">209 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> <span id="L210" class="LineNr">210 </span> <span class="subxS1Comment"># . end</span> @@ -289,14 +289,14 @@ if ('onhashchange' in window) { <span id="L228" class="LineNr">228 </span> e8/call <a href='126write-int-decimal.subx.html#L8'>write-int32-decimal</a>/disp32 <span id="L229" class="LineNr">229 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L230" class="LineNr">230 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> -<span id="L231" class="Folded">231 </span><span class="Folded">+-- 26 lines: #? # dump _test-stream ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------</span> +<span id="L231" class="Folded">231 </span><span class="Folded">+-- 26 lines: #? # dump _test-stream ------------------------------------------------------------------------------------------------------------------------------------------------</span> <span id="L257" class="LineNr">257 </span> <span class="subxComment"># check-stream-equal(_test-stream, "-9", msg)</span> <span id="L258" class="LineNr">258 </span> <span class="subxS2Comment"># . . push args</span> <span id="L259" class="LineNr">259 </span> 68/push <span class="Constant">"F - test-write-int32-decimal-negative"</span>/imm32 <span id="L260" class="LineNr">260 </span> 68/push <span class="Constant">"-9"</span>/imm32 <span id="L261" class="LineNr">261 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 <span id="L262" class="LineNr">262 </span> <span class="subxS2Comment"># . . call</span> -<span id="L263" class="LineNr">263 </span> e8/call <a href='109stream-equal.subx.html#L197'>check-stream-equal</a>/disp32 +<span id="L263" class="LineNr">263 </span> e8/call <a href='109stream-equal.subx.html#L194'>check-stream-equal</a>/disp32 <span id="L264" class="LineNr">264 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L265" class="LineNr">265 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> <span id="L266" class="LineNr">266 </span> <span class="subxS1Comment"># . end</span> @@ -326,7 +326,7 @@ if ('onhashchange' in window) { <span id="L290" class="LineNr">290 </span> 68/push <span class="Constant">"-10"</span>/imm32 <span id="L291" class="LineNr">291 </span> 68/push <a href='108write.subx.html#L125'>_test-stream</a>/imm32 <span id="L292" class="LineNr">292 </span> <span class="subxS2Comment"># . . call</span> -<span id="L293" class="LineNr">293 </span> e8/call <a href='109stream-equal.subx.html#L197'>check-stream-equal</a>/disp32 +<span id="L293" class="LineNr">293 </span> e8/call <a href='109stream-equal.subx.html#L194'>check-stream-equal</a>/disp32 <span id="L294" class="LineNr">294 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L295" class="LineNr">295 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> <span id="L296" class="LineNr">296 </span> <span class="subxS1Comment"># . end</span> @@ -440,11 +440,11 @@ if ('onhashchange' in window) { <span id="L404" class="LineNr">404 </span><span class="Constant">$to-decimal-digit:check0</span>: <span id="L405" class="LineNr">405 </span> <span class="subxComment"># if (eax < '0') goto abort</span> <span id="L406" class="LineNr">406 </span> 3d/compare-eax-with 0x30/imm32/0 -<span id="L407" class="LineNr">407 </span> 7c/jump-if-< $to-decimal-digit:abort/disp8 +<span id="L407" class="LineNr">407 </span> 7c/jump-if-< $to-decimal-digit:<a href='501draw-text.mu.html#L519'>abort</a>/disp8 <span id="L408" class="LineNr">408 </span><span class="Constant">$to-decimal-digit:check1</span>: <span id="L409" class="LineNr">409 </span> <span class="subxComment"># if (eax > '9') goto abort</span> <span id="L410" class="LineNr">410 </span> 3d/compare-eax-with 0x39/imm32/f -<span id="L411" class="LineNr">411 </span> 7f/jump-if-> $to-decimal-digit:abort/disp8 +<span id="L411" class="LineNr">411 </span> 7f/jump-if-> $to-decimal-digit:<a href='501draw-text.mu.html#L519'>abort</a>/disp8 <span id="L412" class="LineNr">412 </span><span class="Constant">$to-decimal-digit:digit</span>: <span id="L413" class="LineNr">413 </span> <span class="subxComment"># return eax - '0'</span> <span id="L414" class="LineNr">414 </span> 2d/subtract-from-eax 0x30/imm32/0 @@ -454,8 +454,8 @@ if ('onhashchange' in window) { <span id="L418" class="LineNr">418 </span> 5d/pop-to-ebp <span id="L419" class="LineNr">419 </span> c3/return <span id="L420" class="LineNr">420 </span> -<span id="L421" class="LineNr">421 </span><span class="Constant">$to-decimal-digit:abort</span>: -<span id="L422" class="LineNr">422 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"to-decimal-digit: not a digit character"</span> 3) <span class="subxComment"># 3=cyan</span> +<span id="L421" class="LineNr">421 </span><span class="Constant">$to-decimal-digit:<a href='501draw-text.mu.html#L519'>abort</a></span>: +<span id="L422" class="LineNr">422 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"to-decimal-digit: not a digit character"</span> 3 0) <span class="subxComment"># 3=cyan</span> <span id="L423" class="LineNr">423 </span> { <span id="L424" class="LineNr">424 </span> eb/jump <span class="Constant">loop</span>/disp8 <span id="L425" class="LineNr">425 </span> } diff --git a/html/baremetal/301array-equal.subx.html b/html/baremetal/301array-equal.subx.html new file mode 100644 index 00000000..b3a727ff --- /dev/null +++ b/html/baremetal/301array-equal.subx.html @@ -0,0 +1,496 @@ +<!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 - baremetal/301array-equal.subx</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: #c6c6c6; } +body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } +a { color:inherit; } +* { font-size:12pt; font-size: 1em; } +.SpecialChar { color: #d70000; } +.subxComment { color: #005faf; } +.subxS1Comment { color: #0000af; } +.LineNr { } +.subxH1Comment { color: #005faf; text-decoration: underline; } +.subxMinorFunction { color: #875f5f; } +.subxTest { color: #5f8700; } +.subxFunction { color: #af5f00; text-decoration: underline; } +.Constant { color: #008787; } +--> +</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/baremetal/301array-equal.subx'>https://github.com/akkartik/mu/blob/main/baremetal/301array-equal.subx</a> +<pre id='vimCodeElement'> +<span id="L1" class="LineNr"> 1 </span><span class="subxComment"># Comparing arrays of numbers.</span> +<span id="L2" class="LineNr"> 2 </span> +<span id="L3" class="LineNr"> 3 </span>== code +<span id="L4" class="LineNr"> 4 </span> +<span id="L5" class="LineNr"> 5 </span><span class="subxFunction">array-equal?</span>: <span class="subxComment"># a: (addr array int), b: (addr array int) -> result/eax: boolean</span> +<span id="L6" class="LineNr"> 6 </span> <span class="subxComment"># pseudocode:</span> +<span id="L7" class="LineNr"> 7 </span> <span class="subxComment"># asize = a->size</span> +<span id="L8" class="LineNr"> 8 </span> <span class="subxComment"># if (asize != b->size) return false</span> +<span id="L9" class="LineNr"> 9 </span> <span class="subxComment"># i = 0</span> +<span id="L10" class="LineNr"> 10 </span> <span class="subxComment"># curra = a->data</span> +<span id="L11" class="LineNr"> 11 </span> <span class="subxComment"># currb = b->data</span> +<span id="L12" class="LineNr"> 12 </span> <span class="subxComment"># while i < asize</span> +<span id="L13" class="LineNr"> 13 </span> <span class="subxComment"># i1 = *curra</span> +<span id="L14" class="LineNr"> 14 </span> <span class="subxComment"># i2 = *currb</span> +<span id="L15" class="LineNr"> 15 </span> <span class="subxComment"># if (c1 != c2) return false</span> +<span id="L16" class="LineNr"> 16 </span> <span class="subxComment"># i+=4, curra+=4, currb+=4</span> +<span id="L17" class="LineNr"> 17 </span> <span class="subxComment"># return true</span> +<span id="L18" class="LineNr"> 18 </span> <span class="subxComment">#</span> +<span id="L19" class="LineNr"> 19 </span> <span class="subxComment"># registers:</span> +<span id="L20" class="LineNr"> 20 </span> <span class="subxComment"># i: ecx</span> +<span id="L21" class="LineNr"> 21 </span> <span class="subxComment"># asize: edx</span> +<span id="L22" class="LineNr"> 22 </span> <span class="subxComment"># curra: esi</span> +<span id="L23" class="LineNr"> 23 </span> <span class="subxComment"># currb: edi</span> +<span id="L24" class="LineNr"> 24 </span> <span class="subxComment"># i1: eax</span> +<span id="L25" class="LineNr"> 25 </span> <span class="subxComment"># i2: ebx</span> +<span id="L26" class="LineNr"> 26 </span> <span class="subxComment">#</span> +<span id="L27" class="LineNr"> 27 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L28" class="LineNr"> 28 </span> 55/push-ebp +<span id="L29" class="LineNr"> 29 </span> 89/<- %ebp 4/r32/esp +<span id="L30" class="LineNr"> 30 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L31" class="LineNr"> 31 </span> 51/push-ecx +<span id="L32" class="LineNr"> 32 </span> 52/push-edx +<span id="L33" class="LineNr"> 33 </span> 53/push-ebx +<span id="L34" class="LineNr"> 34 </span> 56/push-esi +<span id="L35" class="LineNr"> 35 </span> 57/push-edi +<span id="L36" class="LineNr"> 36 </span> <span class="subxComment"># esi = a</span> +<span id="L37" class="LineNr"> 37 </span> 8b/-> *(ebp+8) 6/r32/esi +<span id="L38" class="LineNr"> 38 </span> <span class="subxComment"># edi = b</span> +<span id="L39" class="LineNr"> 39 </span> 8b/-> *(ebp+0xc) 7/r32/edi +<span id="L40" class="LineNr"> 40 </span> <span class="subxComment"># var asize/edx: int = a->size</span> +<span id="L41" class="LineNr"> 41 </span> 8b/-> *esi 2/r32/edx +<span id="L42" class="LineNr"> 42 </span><span class="Constant">$array-equal?:sizes</span>: +<span id="L43" class="LineNr"> 43 </span> <span class="subxComment"># if (asize != b->size) return false</span> +<span id="L44" class="LineNr"> 44 </span> 39/compare *edi 2/r32/edx +<span id="L45" class="LineNr"> 45 </span> 75/jump-if-!= $array-equal?:false/disp8 +<span id="L46" class="LineNr"> 46 </span> <span class="subxComment"># var curra/esi: (addr byte) = a->data</span> +<span id="L47" class="LineNr"> 47 </span> 81 0/subop/add %esi 4/imm32 +<span id="L48" class="LineNr"> 48 </span> <span class="subxComment"># var currb/edi: (addr byte) = b->data</span> +<span id="L49" class="LineNr"> 49 </span> 81 0/subop/add %edi 4/imm32 +<span id="L50" class="LineNr"> 50 </span> <span class="subxComment"># var i/ecx: int = 0</span> +<span id="L51" class="LineNr"> 51 </span> 31/xor-with %ecx 1/r32/ecx +<span id="L52" class="LineNr"> 52 </span> <span class="subxComment"># var vala/eax: int</span> +<span id="L53" class="LineNr"> 53 </span> <span class="subxComment"># var valb/ebx: int</span> +<span id="L54" class="LineNr"> 54 </span><span class="Constant">$array-equal?:loop</span>: +<span id="L55" class="LineNr"> 55 </span> <span class="subxComment"># if (i >= asize) return true</span> +<span id="L56" class="LineNr"> 56 </span> 39/compare %ecx 2/r32/edx +<span id="L57" class="LineNr"> 57 </span> 7d/jump-if->= $array-equal?:true/disp8 +<span id="L58" class="LineNr"> 58 </span> <span class="subxComment"># var vala/eax: int = *curra</span> +<span id="L59" class="LineNr"> 59 </span> 8b/-> *esi 0/r32/eax +<span id="L60" class="LineNr"> 60 </span> <span class="subxComment"># var valb/ebx: int = *currb</span> +<span id="L61" class="LineNr"> 61 </span> 8b/-> *edi 3/r32/ebx +<span id="L62" class="LineNr"> 62 </span> <span class="subxComment"># if (vala != valb) return false</span> +<span id="L63" class="LineNr"> 63 </span> 39/compare %eax 3/r32/ebx +<span id="L64" class="LineNr"> 64 </span> 75/jump-if-!= $array-equal?:false/disp8 +<span id="L65" class="LineNr"> 65 </span> <span class="subxComment"># i += 4</span> +<span id="L66" class="LineNr"> 66 </span> 81 0/subop/add %ecx 4/imm32 +<span id="L67" class="LineNr"> 67 </span> <span class="subxComment"># currs += 4</span> +<span id="L68" class="LineNr"> 68 </span> 81 0/subop/add %esi 4/imm32 +<span id="L69" class="LineNr"> 69 </span> <span class="subxComment"># currb += 4</span> +<span id="L70" class="LineNr"> 70 </span> 81 0/subop/add %edi 4/imm32 +<span id="L71" class="LineNr"> 71 </span> eb/jump $array-equal?:<span class="Constant">loop</span>/disp8 +<span id="L72" class="LineNr"> 72 </span><span class="Constant">$array-equal?:true</span>: +<span id="L73" class="LineNr"> 73 </span> b8/copy-to-eax 1/imm32 +<span id="L74" class="LineNr"> 74 </span> eb/jump $array-equal?:end/disp8 +<span id="L75" class="LineNr"> 75 </span><span class="Constant">$array-equal?:false</span>: +<span id="L76" class="LineNr"> 76 </span> b8/copy-to-eax 0/imm32 +<span id="L77" class="LineNr"> 77 </span><span class="Constant">$array-equal?:end</span>: +<span id="L78" class="LineNr"> 78 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L79" class="LineNr"> 79 </span> 5f/pop-to-edi +<span id="L80" class="LineNr"> 80 </span> 5e/pop-to-esi +<span id="L81" class="LineNr"> 81 </span> 5b/pop-to-ebx +<span id="L82" class="LineNr"> 82 </span> 5a/pop-to-edx +<span id="L83" class="LineNr"> 83 </span> 59/pop-to-ecx +<span id="L84" class="LineNr"> 84 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L85" class="LineNr"> 85 </span> 89/<- %esp 5/r32/ebp +<span id="L86" class="LineNr"> 86 </span> 5d/pop-to-ebp +<span id="L87" class="LineNr"> 87 </span> c3/return +<span id="L88" class="LineNr"> 88 </span> +<span id="L89" class="LineNr"> 89 </span><span class="subxTest">test-compare-empty-with-empty-array</span>: +<span id="L90" class="LineNr"> 90 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L91" class="LineNr"> 91 </span> 55/push-ebp +<span id="L92" class="LineNr"> 92 </span> 89/<- %ebp 4/r32/esp +<span id="L93" class="LineNr"> 93 </span> <span class="subxComment"># var ecx: (array _) = []</span> +<span id="L94" class="LineNr"> 94 </span> 68/push 0/imm32/size +<span id="L95" class="LineNr"> 95 </span> 89/<- %ecx 4/r32/esp +<span id="L96" class="LineNr"> 96 </span> <span class="subxComment"># var edx: (array _) = []</span> +<span id="L97" class="LineNr"> 97 </span> 68/push 0/imm32/size +<span id="L98" class="LineNr"> 98 </span> 89/<- %edx 4/r32/esp +<span id="L99" class="LineNr"> 99 </span> <span class="subxComment">#</span> +<span id="L100" class="LineNr">100 </span> (<a href='301array-equal.subx.html#L5'>array-equal?</a> %ecx %edx) <span class="subxComment"># => eax</span> +<span id="L101" class="LineNr">101 </span> (<a href='502test.mu.html#L2'>check-ints-equal</a> %eax 1 <span class="Constant">"F - test-compare-empty-with-empty-array"</span>) +<span id="L102" class="LineNr">102 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L103" class="LineNr">103 </span> 89/<- %esp 5/r32/ebp +<span id="L104" class="LineNr">104 </span> 5d/pop-to-ebp +<span id="L105" class="LineNr">105 </span> c3/return +<span id="L106" class="LineNr">106 </span> +<span id="L107" class="LineNr">107 </span><span class="subxTest">test-compare-empty-with-non-empty-array</span>: <span class="subxComment"># also checks size-mismatch code path</span> +<span id="L108" class="LineNr">108 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L109" class="LineNr">109 </span> 55/push-ebp +<span id="L110" class="LineNr">110 </span> 89/<- %ebp 4/r32/esp +<span id="L111" class="LineNr">111 </span> <span class="subxComment"># var ecx: (array int) = [1]</span> +<span id="L112" class="LineNr">112 </span> 68/push 1/imm32 +<span id="L113" class="LineNr">113 </span> 68/push 4/imm32/size +<span id="L114" class="LineNr">114 </span> 89/<- %ecx 4/r32/esp +<span id="L115" class="LineNr">115 </span> <span class="subxComment"># var edx: (array int) = []</span> +<span id="L116" class="LineNr">116 </span> 68/push 0/imm32/size +<span id="L117" class="LineNr">117 </span> 89/<- %edx 4/r32/esp +<span id="L118" class="LineNr">118 </span> <span class="subxComment">#</span> +<span id="L119" class="LineNr">119 </span> (<a href='301array-equal.subx.html#L5'>array-equal?</a> %ecx %edx) <span class="subxComment"># => eax</span> +<span id="L120" class="LineNr">120 </span> (<a href='502test.mu.html#L2'>check-ints-equal</a> %eax 0 <span class="Constant">"F - test-compare-empty-with-non-empty-array"</span>) +<span id="L121" class="LineNr">121 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L122" class="LineNr">122 </span> 89/<- %esp 5/r32/ebp +<span id="L123" class="LineNr">123 </span> 5d/pop-to-ebp +<span id="L124" class="LineNr">124 </span> c3/return +<span id="L125" class="LineNr">125 </span> +<span id="L126" class="LineNr">126 </span><span class="subxTest">test-compare-equal-arrays</span>: +<span id="L127" class="LineNr">127 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L128" class="LineNr">128 </span> 55/push-ebp +<span id="L129" class="LineNr">129 </span> 89/<- %ebp 4/r32/esp +<span id="L130" class="LineNr">130 </span> <span class="subxComment"># var ecx: (array int) = [1, 2, 3]</span> +<span id="L131" class="LineNr">131 </span> 68/push 3/imm32 +<span id="L132" class="LineNr">132 </span> 68/push 2/imm32 +<span id="L133" class="LineNr">133 </span> 68/push 1/imm32 +<span id="L134" class="LineNr">134 </span> 68/push 0xc/imm32/size +<span id="L135" class="LineNr">135 </span> 89/<- %ecx 4/r32/esp +<span id="L136" class="LineNr">136 </span> <span class="subxComment"># var edx: (array int) = [1, 2, 3]</span> +<span id="L137" class="LineNr">137 </span> 68/push 3/imm32 +<span id="L138" class="LineNr">138 </span> 68/push 2/imm32 +<span id="L139" class="LineNr">139 </span> 68/push 1/imm32 +<span id="L140" class="LineNr">140 </span> 68/push 0xc/imm32/size +<span id="L141" class="LineNr">141 </span> 89/<- %edx 4/r32/esp +<span id="L142" class="LineNr">142 </span> <span class="subxComment">#</span> +<span id="L143" class="LineNr">143 </span> (<a href='301array-equal.subx.html#L5'>array-equal?</a> %ecx %edx) <span class="subxComment"># => eax</span> +<span id="L144" class="LineNr">144 </span> (<a href='502test.mu.html#L2'>check-ints-equal</a> %eax 1 <span class="Constant">"F - test-compare-equal-arrays"</span>) +<span id="L145" class="LineNr">145 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L146" class="LineNr">146 </span> 89/<- %esp 5/r32/ebp +<span id="L147" class="LineNr">147 </span> 5d/pop-to-ebp +<span id="L148" class="LineNr">148 </span> c3/return +<span id="L149" class="LineNr">149 </span> +<span id="L150" class="LineNr">150 </span><span class="subxTest">test-compare-inequal-arrays-equal-sizes</span>: +<span id="L151" class="LineNr">151 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L152" class="LineNr">152 </span> 55/push-ebp +<span id="L153" class="LineNr">153 </span> 89/<- %ebp 4/r32/esp +<span id="L154" class="LineNr">154 </span> <span class="subxComment"># var ecx: (array int) = [1, 4, 3]</span> +<span id="L155" class="LineNr">155 </span> 68/push 3/imm32 +<span id="L156" class="LineNr">156 </span> 68/push 4/imm32 +<span id="L157" class="LineNr">157 </span> 68/push 1/imm32 +<span id="L158" class="LineNr">158 </span> 68/push 0xc/imm32/size +<span id="L159" class="LineNr">159 </span> 89/<- %ecx 4/r32/esp +<span id="L160" class="LineNr">160 </span> <span class="subxComment"># var edx: (array int) = [1, 2, 3]</span> +<span id="L161" class="LineNr">161 </span> 68/push 3/imm32 +<span id="L162" class="LineNr">162 </span> 68/push 2/imm32 +<span id="L163" class="LineNr">163 </span> 68/push 1/imm32 +<span id="L164" class="LineNr">164 </span> 68/push 0xc/imm32/size +<span id="L165" class="LineNr">165 </span> 89/<- %edx 4/r32/esp +<span id="L166" class="LineNr">166 </span> <span class="subxComment">#</span> +<span id="L167" class="LineNr">167 </span> (<a href='301array-equal.subx.html#L5'>array-equal?</a> %ecx %edx) <span class="subxComment"># => eax</span> +<span id="L168" class="LineNr">168 </span> (<a href='502test.mu.html#L2'>check-ints-equal</a> %eax 0 <span class="Constant">"F - test-compare-inequal-arrays-equal-sizes"</span>) +<span id="L169" class="LineNr">169 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L170" class="LineNr">170 </span> 89/<- %esp 5/r32/ebp +<span id="L171" class="LineNr">171 </span> 5d/pop-to-ebp +<span id="L172" class="LineNr">172 </span> c3/return +<span id="L173" class="LineNr">173 </span> +<span id="L174" class="LineNr">174 </span><span class="subxMinorFunction">_parse-array-of-ints</span>: <span class="subxComment"># ad: (addr allocation-descriptor), s: (addr array byte), out: (addr handle array int)</span> +<span id="L175" class="LineNr">175 </span> <span class="subxComment"># pseudocode</span> +<span id="L176" class="LineNr">176 </span> <span class="subxComment"># end = &s->data[s->size]</span> +<span id="L177" class="LineNr">177 </span> <span class="subxComment"># curr = s->data</span> +<span id="L178" class="LineNr">178 </span> <span class="subxComment"># size = 0</span> +<span id="L179" class="LineNr">179 </span> <span class="subxComment"># while true</span> +<span id="L180" class="LineNr">180 </span> <span class="subxComment"># if (curr >= end) break</span> +<span id="L181" class="LineNr">181 </span> <span class="subxComment"># curr = skip-chars-matching-in-slice(curr, end, ' ')</span> +<span id="L182" class="LineNr">182 </span> <span class="subxComment"># if (curr >= end) break</span> +<span id="L183" class="LineNr">183 </span> <span class="subxComment"># curr = skip-chars-not-matching-in-slice(curr, end, ' ')</span> +<span id="L184" class="LineNr">184 </span> <span class="subxComment"># ++size</span> +<span id="L185" class="LineNr">185 </span> <span class="subxComment"># allocate-array(ad, size*4, out)</span> +<span id="L186" class="LineNr">186 </span> <span class="subxComment"># var slice: slice = {s->data, 0}</span> +<span id="L187" class="LineNr">187 </span> <span class="subxComment"># curr = lookup(out)->data</span> +<span id="L188" class="LineNr">188 </span> <span class="subxComment"># while true</span> +<span id="L189" class="LineNr">189 </span> <span class="subxComment"># if (slice->start >= end) break</span> +<span id="L190" class="LineNr">190 </span> <span class="subxComment"># slice->start = skip-chars-matching-in-slice(slice->start, end, ' ')</span> +<span id="L191" class="LineNr">191 </span> <span class="subxComment"># if (slice->start >= end) break</span> +<span id="L192" class="LineNr">192 </span> <span class="subxComment"># slice->end = skip-chars-not-matching-in-slice(slice->start, end, ' ')</span> +<span id="L193" class="LineNr">193 </span> <span class="subxComment"># *curr = parse-hex-int-from-slice(slice)</span> +<span id="L194" class="LineNr">194 </span> <span class="subxComment"># curr += 4</span> +<span id="L195" class="LineNr">195 </span> <span class="subxComment"># slice->start = slice->end</span> +<span id="L196" class="LineNr">196 </span> <span class="subxComment"># return result</span> +<span id="L197" class="LineNr">197 </span> <span class="subxComment">#</span> +<span id="L198" class="LineNr">198 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L199" class="LineNr">199 </span> 55/push-ebp +<span id="L200" class="LineNr">200 </span> 89/<- %ebp 4/r32/esp +<span id="L201" class="LineNr">201 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L202" class="LineNr">202 </span> 50/push-eax +<span id="L203" class="LineNr">203 </span> 51/push-ecx +<span id="L204" class="LineNr">204 </span> 52/push-edx +<span id="L205" class="LineNr">205 </span> 53/push-ebx +<span id="L206" class="LineNr">206 </span> 56/push-esi +<span id="L207" class="LineNr">207 </span> 57/push-edi +<span id="L208" class="LineNr">208 </span> <span class="subxComment"># esi = s</span> +<span id="L209" class="LineNr">209 </span> 8b/-> *(ebp+0xc) 6/r32/esi +<span id="L210" class="LineNr">210 </span> <span class="subxComment"># var curr/ecx: (addr byte) = s->data</span> +<span id="L211" class="LineNr">211 </span> 8d/copy-address *(esi+4) 1/r32/ecx +<span id="L212" class="LineNr">212 </span> <span class="subxComment"># var end/edx: (addr byte) = &s->data[s->size]</span> +<span id="L213" class="LineNr">213 </span> <span class="subxS1Comment"># . edx = s->size</span> +<span id="L214" class="LineNr">214 </span> 8b/-> *esi 2/r32/edx +<span id="L215" class="LineNr">215 </span> <span class="subxS1Comment"># . edx += curr</span> +<span id="L216" class="LineNr">216 </span> 01/add-to %edx 1/r32/ecx +<span id="L217" class="LineNr">217 </span> <span class="subxComment"># var size/ebx: int = 0</span> +<span id="L218" class="LineNr">218 </span> 31/xor-with %ebx 3/r32/ebx +<span id="L219" class="LineNr">219 </span><span class="Constant">$_parse-array-of-ints:loop1</span>: +<span id="L220" class="LineNr">220 </span> <span class="subxComment"># if (curr >= end) break</span> +<span id="L221" class="LineNr">221 </span> 39/compare %ecx 2/r32/edx +<span id="L222" class="LineNr">222 </span> 73/jump-if-addr>= $_parse-array-of-ints:break1/disp8 +<span id="L223" class="LineNr">223 </span> <span class="subxComment"># curr = skip-chars-matching-in-slice(curr, end, ' ')</span> +<span id="L224" class="LineNr">224 </span> (<a href='124next-token.subx.html#L804'>skip-chars-matching-in-slice</a> %ecx %edx 0x20) <span class="subxComment"># => eax</span> +<span id="L225" class="LineNr">225 </span> 89/<- %ecx 0/r32/eax +<span id="L226" class="LineNr">226 </span> <span class="subxComment"># if (curr >= end) break</span> +<span id="L227" class="LineNr">227 </span> 39/compare %ecx 2/r32/edx +<span id="L228" class="LineNr">228 </span> 73/jump-if-addr>= $_parse-array-of-ints:break1/disp8 +<span id="L229" class="LineNr">229 </span> <span class="subxComment"># curr = skip-chars-not-matching-in-slice(curr, end, ' ')</span> +<span id="L230" class="LineNr">230 </span> (<a href='124next-token.subx.html#L973'>skip-chars-not-matching-in-slice</a> %ecx %edx 0x20) <span class="subxComment"># => eax</span> +<span id="L231" class="LineNr">231 </span> 89/<- %ecx 0/r32/eax +<span id="L232" class="LineNr">232 </span> <span class="subxComment"># size += 4</span> +<span id="L233" class="LineNr">233 </span> 81 0/subop/add %ebx 4/imm32 +<span id="L234" class="LineNr">234 </span> eb/jump $_parse-array-of-ints:loop1/disp8 +<span id="L235" class="LineNr">235 </span><span class="Constant">$_parse-array-of-ints:break1</span>: +<span id="L236" class="LineNr">236 </span> (<a href='120allocate.subx.html#L535'>allocate-array</a> *(ebp+8) %ebx *(ebp+0x10)) +<span id="L237" class="LineNr">237 </span><span class="Constant">$_parse-array-of-ints:pass2</span>: +<span id="L238" class="LineNr">238 </span> <span class="subxComment"># var slice/edi: slice = {s->data, 0}</span> +<span id="L239" class="LineNr">239 </span> 68/push 0/imm32/end +<span id="L240" class="LineNr">240 </span> 8d/copy-address *(esi+4) 7/r32/edi +<span id="L241" class="LineNr">241 </span> 57/push-edi +<span id="L242" class="LineNr">242 </span> 89/<- %edi 4/r32/esp +<span id="L243" class="LineNr">243 </span> <span class="subxComment"># curr = lookup(out)->data</span> +<span id="L244" class="LineNr">244 </span> 8b/-> *(ebp+0x10) 0/r32/eax +<span id="L245" class="LineNr">245 </span> (<a href='120allocate.subx.html#L226'>lookup</a> *eax *(eax+4)) <span class="subxComment"># => eax</span> +<span id="L246" class="LineNr">246 </span> 8d/copy-address *(eax+4) 1/r32/ecx +<span id="L247" class="LineNr">247 </span><span class="Constant">$_parse-array-of-ints:loop2</span>: +<span id="L248" class="LineNr">248 </span> <span class="subxComment"># if (slice->start >= end) break</span> +<span id="L249" class="LineNr">249 </span> 39/compare *edi 2/r32/edx +<span id="L250" class="LineNr">250 </span> 73/jump-if-addr>= $_parse-array-of-ints:end/disp8 +<span id="L251" class="LineNr">251 </span> <span class="subxComment"># slice->start = skip-chars-matching-in-slice(slice->start, end, ' ')</span> +<span id="L252" class="LineNr">252 </span> (<a href='124next-token.subx.html#L804'>skip-chars-matching-in-slice</a> *edi %edx 0x20) <span class="subxComment"># => eax</span> +<span id="L253" class="LineNr">253 </span> 89/<- *edi 0/r32/eax +<span id="L254" class="LineNr">254 </span> <span class="subxComment"># if (slice->start >= end) break</span> +<span id="L255" class="LineNr">255 </span> 39/compare *edi 2/r32/edx +<span id="L256" class="LineNr">256 </span> 73/jump-if-addr>= $_parse-array-of-ints:end/disp8 +<span id="L257" class="LineNr">257 </span> <span class="subxComment"># slice->end = skip-chars-not-matching-in-slice(slice->start, end, ' ')</span> +<span id="L258" class="LineNr">258 </span> (<a href='124next-token.subx.html#L973'>skip-chars-not-matching-in-slice</a> *edi %edx 0x20) <span class="subxComment"># => eax</span> +<span id="L259" class="LineNr">259 </span> 89/<- *(edi+4) 0/r32/eax +<span id="L260" class="LineNr">260 </span> <span class="subxComment"># *curr = parse-hex-int-from-slice(slice)</span> +<span id="L261" class="LineNr">261 </span> (<a href='118parse-hex-int.subx.html#L387'>parse-hex-int-from-slice</a> %edi) +<span id="L262" class="LineNr">262 </span> 89/<- *ecx 0/r32/eax +<span id="L263" class="LineNr">263 </span> <span class="subxComment"># curr += 4</span> +<span id="L264" class="LineNr">264 </span> 81 0/subop/add %ecx 4/imm32 +<span id="L265" class="LineNr">265 </span> <span class="subxComment"># slice->start = slice->end</span> +<span id="L266" class="LineNr">266 </span> 8b/-> *(edi+4) 0/r32/eax +<span id="L267" class="LineNr">267 </span> 89/<- *edi 0/r32/eax +<span id="L268" class="LineNr">268 </span> eb/jump $_parse-array-of-ints:loop2/disp8 +<span id="L269" class="LineNr">269 </span><span class="Constant">$_parse-array-of-ints:end</span>: +<span id="L270" class="LineNr">270 </span> <span class="subxS1Comment"># . reclaim locals</span> +<span id="L271" class="LineNr">271 </span> 81 0/subop/add %esp 8/imm32 +<span id="L272" class="LineNr">272 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L273" class="LineNr">273 </span> 5f/pop-to-edi +<span id="L274" class="LineNr">274 </span> 5e/pop-to-esi +<span id="L275" class="LineNr">275 </span> 5b/pop-to-ebx +<span id="L276" class="LineNr">276 </span> 5a/pop-to-edx +<span id="L277" class="LineNr">277 </span> 59/pop-to-ecx +<span id="L278" class="LineNr">278 </span> 58/pop-to-eax +<span id="L279" class="LineNr">279 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L280" class="LineNr">280 </span> 89/<- %esp 5/r32/ebp +<span id="L281" class="LineNr">281 </span> 5d/pop-to-ebp +<span id="L282" class="LineNr">282 </span> c3/return +<span id="L283" class="LineNr">283 </span> +<span id="L284" class="LineNr">284 </span><span class="subxTest">test-parse-array-of-ints</span>: +<span id="L285" class="LineNr">285 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L286" class="LineNr">286 </span> 55/push-ebp +<span id="L287" class="LineNr">287 </span> 89/<- %ebp 4/r32/esp +<span id="L288" class="LineNr">288 </span> <span class="subxComment"># var h/esi: (handle array int)</span> +<span id="L289" class="LineNr">289 </span> 68/push 0/imm32 +<span id="L290" class="LineNr">290 </span> 68/push 0/imm32 +<span id="L291" class="LineNr">291 </span> 89/<- %esi 4/r32/esp +<span id="L292" class="LineNr">292 </span> <span class="subxComment"># var ecx: (array int) = [1, 2, 3]</span> +<span id="L293" class="LineNr">293 </span> 68/push 3/imm32 +<span id="L294" class="LineNr">294 </span> 68/push 2/imm32 +<span id="L295" class="LineNr">295 </span> 68/push 1/imm32 +<span id="L296" class="LineNr">296 </span> 68/push 0xc/imm32/size +<span id="L297" class="LineNr">297 </span> 89/<- %ecx 4/r32/esp +<span id="L298" class="LineNr">298 </span> <span class="subxComment">#</span> +<span id="L299" class="LineNr">299 </span> (<a href='301array-equal.subx.html#L174'>_parse-array-of-ints</a> <span class="SpecialChar"><a href='120allocate.subx.html#L27'>Heap</a></span> <span class="Constant">"1 2 3"</span> %esi) +<span id="L300" class="LineNr">300 </span> (<a href='120allocate.subx.html#L226'>lookup</a> *esi *(esi+4)) <span class="subxComment"># => eax</span> +<span id="L301" class="LineNr">301 </span> (<a href='301array-equal.subx.html#L5'>array-equal?</a> %ecx %eax) <span class="subxComment"># => eax</span> +<span id="L302" class="LineNr">302 </span> (<a href='502test.mu.html#L2'>check-ints-equal</a> %eax 1 <span class="Constant">"F - test-parse-array-of-ints"</span>) +<span id="L303" class="LineNr">303 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L304" class="LineNr">304 </span> 89/<- %esp 5/r32/ebp +<span id="L305" class="LineNr">305 </span> 5d/pop-to-ebp +<span id="L306" class="LineNr">306 </span> c3/return +<span id="L307" class="LineNr">307 </span> +<span id="L308" class="LineNr">308 </span><span class="subxTest">test-parse-array-of-ints-empty</span>: +<span id="L309" class="LineNr">309 </span> <span class="subxH1Comment"># - empty string = empty array</span> +<span id="L310" class="LineNr">310 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L311" class="LineNr">311 </span> 55/push-ebp +<span id="L312" class="LineNr">312 </span> 89/<- %ebp 4/r32/esp +<span id="L313" class="LineNr">313 </span> <span class="subxComment"># var h/esi: handle</span> +<span id="L314" class="LineNr">314 </span> 68/push 0/imm32 +<span id="L315" class="LineNr">315 </span> 68/push 0/imm32 +<span id="L316" class="LineNr">316 </span> 89/<- %esi 4/r32/esp +<span id="L317" class="LineNr">317 </span> <span class="subxComment">#</span> +<span id="L318" class="LineNr">318 </span> (<a href='301array-equal.subx.html#L174'>_parse-array-of-ints</a> <span class="SpecialChar"><a href='120allocate.subx.html#L27'>Heap</a></span> <span class="Constant">""</span> %esi) +<span id="L319" class="LineNr">319 </span> (<a href='120allocate.subx.html#L226'>lookup</a> *esi *(esi+4)) <span class="subxComment"># => eax</span> +<span id="L320" class="LineNr">320 </span> (<a href='502test.mu.html#L2'>check-ints-equal</a> *eax 0 <span class="Constant">"F - test-parse-array-of-ints-empty"</span>) +<span id="L321" class="LineNr">321 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L322" class="LineNr">322 </span> 89/<- %esp 5/r32/ebp +<span id="L323" class="LineNr">323 </span> 5d/pop-to-ebp +<span id="L324" class="LineNr">324 </span> c3/return +<span id="L325" class="LineNr">325 </span> +<span id="L326" class="LineNr">326 </span><span class="subxTest">test-parse-array-of-ints-just-whitespace</span>: +<span id="L327" class="LineNr">327 </span> <span class="subxH1Comment"># - just whitespace = empty array</span> +<span id="L328" class="LineNr">328 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L329" class="LineNr">329 </span> 55/push-ebp +<span id="L330" class="LineNr">330 </span> 89/<- %ebp 4/r32/esp +<span id="L331" class="LineNr">331 </span> <span class="subxComment"># var h/esi: handle</span> +<span id="L332" class="LineNr">332 </span> 68/push 0/imm32 +<span id="L333" class="LineNr">333 </span> 68/push 0/imm32 +<span id="L334" class="LineNr">334 </span> 89/<- %esi 4/r32/esp +<span id="L335" class="LineNr">335 </span> <span class="subxComment">#</span> +<span id="L336" class="LineNr">336 </span> (<a href='301array-equal.subx.html#L174'>_parse-array-of-ints</a> <span class="SpecialChar"><a href='120allocate.subx.html#L27'>Heap</a></span> <span class="SpecialChar"><a href='301array-equal.subx.html#L428'>Space</a></span> %esi) +<span id="L337" class="LineNr">337 </span> (<a href='120allocate.subx.html#L226'>lookup</a> *esi *(esi+4)) <span class="subxComment"># => eax</span> +<span id="L338" class="LineNr">338 </span> (<a href='502test.mu.html#L2'>check-ints-equal</a> *eax 0 <span class="Constant">"F - test-parse-array-of-ints-just-whitespace"</span>) +<span id="L339" class="LineNr">339 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L340" class="LineNr">340 </span> 89/<- %esp 5/r32/ebp +<span id="L341" class="LineNr">341 </span> 5d/pop-to-ebp +<span id="L342" class="LineNr">342 </span> c3/return +<span id="L343" class="LineNr">343 </span> +<span id="L344" class="LineNr">344 </span><span class="subxTest">test-parse-array-of-ints-extra-whitespace</span>: +<span id="L345" class="LineNr">345 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L346" class="LineNr">346 </span> 55/push-ebp +<span id="L347" class="LineNr">347 </span> 89/<- %ebp 4/r32/esp +<span id="L348" class="LineNr">348 </span> <span class="subxComment"># var h/esi: handle</span> +<span id="L349" class="LineNr">349 </span> 68/push 0/imm32 +<span id="L350" class="LineNr">350 </span> 68/push 0/imm32 +<span id="L351" class="LineNr">351 </span> 89/<- %esi 4/r32/esp +<span id="L352" class="LineNr">352 </span> <span class="subxComment"># var ecx: (array int) = [1, 2, 3]</span> +<span id="L353" class="LineNr">353 </span> 68/push 3/imm32 +<span id="L354" class="LineNr">354 </span> 68/push 2/imm32 +<span id="L355" class="LineNr">355 </span> 68/push 1/imm32 +<span id="L356" class="LineNr">356 </span> 68/push 0xc/imm32/size +<span id="L357" class="LineNr">357 </span> 89/<- %ecx 4/r32/esp +<span id="L358" class="LineNr">358 </span> <span class="subxComment">#</span> +<span id="L359" class="LineNr">359 </span> (<a href='301array-equal.subx.html#L174'>_parse-array-of-ints</a> <span class="SpecialChar"><a href='120allocate.subx.html#L27'>Heap</a></span> <span class="Constant">" 1 2 3 "</span> %esi) +<span id="L360" class="LineNr">360 </span> (<a href='120allocate.subx.html#L226'>lookup</a> *esi *(esi+4)) <span class="subxComment"># => eax</span> +<span id="L361" class="LineNr">361 </span> (<a href='301array-equal.subx.html#L5'>array-equal?</a> %ecx %eax) <span class="subxComment"># => eax</span> +<span id="L362" class="LineNr">362 </span> (<a href='502test.mu.html#L2'>check-ints-equal</a> %eax 1 <span class="Constant">"F - test-parse-array-of-ints-extra-whitespace"</span>) +<span id="L363" class="LineNr">363 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L364" class="LineNr">364 </span> 89/<- %esp 5/r32/ebp +<span id="L365" class="LineNr">365 </span> 5d/pop-to-ebp +<span id="L366" class="LineNr">366 </span> c3/return +<span id="L367" class="LineNr">367 </span> +<span id="L368" class="LineNr">368 </span><span class="subxFunction">parse-array-of-ints</span>: <span class="subxComment"># s: (addr array byte), out: (addr handle array int)</span> +<span id="L369" class="LineNr">369 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L370" class="LineNr">370 </span> 55/push-ebp +<span id="L371" class="LineNr">371 </span> 89/<- %ebp 4/r32/esp +<span id="L372" class="LineNr">372 </span> <span class="subxComment">#</span> +<span id="L373" class="LineNr">373 </span> (<a href='301array-equal.subx.html#L174'>_parse-array-of-ints</a> <span class="SpecialChar"><a href='120allocate.subx.html#L27'>Heap</a></span> *(ebp+8) *(ebp+0xc)) +<span id="L374" class="LineNr">374 </span><span class="Constant">$parse-array-of-ints:end</span>: +<span id="L375" class="LineNr">375 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L376" class="LineNr">376 </span> 89/<- %esp 5/r32/ebp +<span id="L377" class="LineNr">377 </span> 5d/pop-to-ebp +<span id="L378" class="LineNr">378 </span> c3/return +<span id="L379" class="LineNr">379 </span> +<span id="L380" class="LineNr">380 </span><span class="subxComment"># helper for later tests</span> +<span id="L381" class="LineNr">381 </span><span class="subxComment"># compare an array with a string representation of an array literal</span> +<span id="L382" class="LineNr">382 </span><span class="subxFunction">check-array-equal</span>: <span class="subxComment"># a: (addr array int), expected: (addr string), msg: (addr string)</span> +<span id="L383" class="LineNr">383 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L384" class="LineNr">384 </span> 55/push-ebp +<span id="L385" class="LineNr">385 </span> 89/<- %ebp 4/r32/esp +<span id="L386" class="LineNr">386 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L387" class="LineNr">387 </span> 50/push-eax +<span id="L388" class="LineNr">388 </span> 56/push-esi +<span id="L389" class="LineNr">389 </span> <span class="subxComment"># var h/esi: handle</span> +<span id="L390" class="LineNr">390 </span> 68/push 0/imm32 +<span id="L391" class="LineNr">391 </span> 68/push 0/imm32 +<span id="L392" class="LineNr">392 </span> 89/<- %esi 4/r32/esp +<span id="L393" class="LineNr">393 </span> <span class="subxComment"># var b/eax: (addr array int) = parse-array-of-ints(Heap, expected)</span> +<span id="L394" class="LineNr">394 </span> (<a href='301array-equal.subx.html#L368'>parse-array-of-ints</a> *(ebp+0xc) %esi) +<span id="L395" class="LineNr">395 </span> (<a href='120allocate.subx.html#L226'>lookup</a> *esi *(esi+4)) <span class="subxComment"># => eax</span> +<span id="L396" class="LineNr">396 </span> <span class="subxComment">#</span> +<span id="L397" class="LineNr">397 </span> (<a href='301array-equal.subx.html#L5'>array-equal?</a> *(ebp+8) %eax) +<span id="L398" class="LineNr">398 </span> (<a href='502test.mu.html#L2'>check-ints-equal</a> %eax 1 *(ebp+0x10)) +<span id="L399" class="LineNr">399 </span><span class="Constant">$check-array-equal:end</span>: +<span id="L400" class="LineNr">400 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L401" class="LineNr">401 </span> 5e/pop-to-esi +<span id="L402" class="LineNr">402 </span> 58/pop-to-eax +<span id="L403" class="LineNr">403 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L404" class="LineNr">404 </span> 89/<- %esp 5/r32/ebp +<span id="L405" class="LineNr">405 </span> 5d/pop-to-ebp +<span id="L406" class="LineNr">406 </span> c3/return +<span id="L407" class="LineNr">407 </span> +<span id="L408" class="LineNr">408 </span><span class="subxTest">test-check-array-equal</span>: +<span id="L409" class="LineNr">409 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L410" class="LineNr">410 </span> 55/push-ebp +<span id="L411" class="LineNr">411 </span> 89/<- %ebp 4/r32/esp +<span id="L412" class="LineNr">412 </span> <span class="subxComment"># var ecx: (array int) = [1, 2, 3]</span> +<span id="L413" class="LineNr">413 </span> 68/push 3/imm32 +<span id="L414" class="LineNr">414 </span> 68/push 2/imm32 +<span id="L415" class="LineNr">415 </span> 68/push 1/imm32 +<span id="L416" class="LineNr">416 </span> 68/push 0xc/imm32/size +<span id="L417" class="LineNr">417 </span> 89/<- %ecx 4/r32/esp +<span id="L418" class="LineNr">418 </span> <span class="subxComment">#</span> +<span id="L419" class="LineNr">419 </span> (<a href='301array-equal.subx.html#L382'>check-array-equal</a> %ecx <span class="Constant">"1 2 3"</span> <span class="Constant">"F - test-check-array-equal"</span>) +<span id="L420" class="LineNr">420 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L421" class="LineNr">421 </span> 89/<- %esp 5/r32/ebp +<span id="L422" class="LineNr">422 </span> 5d/pop-to-ebp +<span id="L423" class="LineNr">423 </span> c3/return +<span id="L424" class="LineNr">424 </span> +<span id="L425" class="LineNr">425 </span>== data +<span id="L426" class="LineNr">426 </span> +<span id="L427" class="LineNr">427 </span><span class="subxComment"># length-prefixed string containing just a single space</span> +<span id="L428" class="LineNr">428 </span><span class="SpecialChar">Space</span>: <span class="subxComment"># (array byte)</span> +<span id="L429" class="LineNr">429 </span> <span class="subxComment"># size: int</span> +<span id="L430" class="LineNr">430 </span> 1/imm32 +<span id="L431" class="LineNr">431 </span> <span class="subxComment"># data</span> +<span id="L432" class="LineNr">432 </span> 20/space +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/baremetal/309stream.subx.html b/html/baremetal/309stream.subx.html index a82b6792..65ecbe81 100644 --- a/html/baremetal/309stream.subx.html +++ b/html/baremetal/309stream.subx.html @@ -125,7 +125,7 @@ if ('onhashchange' in window) { <span id="L69" class="LineNr"> 69 </span> 8b/-> *(ebp+0x10) 1/r32/ecx <span id="L70" class="LineNr"> 70 </span> 01/add-to %ecx 2/r32/edx <span id="L71" class="LineNr"> 71 </span> 3b/compare 1/r32/ecx *(edi+8) -<span id="L72" class="LineNr"> 72 </span> 0f 8f/jump-if-> $write-to-stream:abort/disp32 +<span id="L72" class="LineNr"> 72 </span> 0f 8f/jump-if-> $write-to-stream:<a href='501draw-text.mu.html#L519'>abort</a>/disp32 <span id="L73" class="LineNr"> 73 </span> <span class="subxComment"># var out/edx: (addr byte) = s->data + s->write</span> <span id="L74" class="LineNr"> 74 </span> 8d/copy-address *(edi+edx+0xc) 2/r32/edx <span id="L75" class="LineNr"> 75 </span> <span class="subxComment"># var outend/ebx: (addr byte) = out + n</span> @@ -153,8 +153,8 @@ if ('onhashchange' in window) { <span id="L97" class="LineNr"> 97 </span> 5d/pop-to-ebp <span id="L98" class="LineNr"> 98 </span> c3/return <span id="L99" class="LineNr"> 99 </span> -<span id="L100" class="LineNr">100 </span><span class="Constant">$write-to-stream:abort</span>: -<span id="L101" class="LineNr">101 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"write-to-stream: stream full"</span> 3) <span class="subxComment"># 3=cyan</span> +<span id="L100" class="LineNr">100 </span><span class="Constant">$write-to-stream:<a href='501draw-text.mu.html#L519'>abort</a></span>: +<span id="L101" class="LineNr">101 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"write-to-stream: stream full"</span> 3 0) <span class="subxComment"># 3=cyan</span> <span id="L102" class="LineNr">102 </span> { <span id="L103" class="LineNr">103 </span> eb/jump <span class="Constant">loop</span>/disp8 <span id="L104" class="LineNr">104 </span> } @@ -178,7 +178,7 @@ if ('onhashchange' in window) { <span id="L122" class="LineNr">122 </span> 8b/-> *(ebp+0x10) 1/r32/ecx <span id="L123" class="LineNr">123 </span> 01/add-to %ecx 2/r32/edx <span id="L124" class="LineNr">124 </span> 3b/compare 1/r32/ecx *esi -<span id="L125" class="LineNr">125 </span> 0f 8f/jump-if-> $read-from-stream:abort/disp32 +<span id="L125" class="LineNr">125 </span> 0f 8f/jump-if-> $read-from-stream:<a href='501draw-text.mu.html#L519'>abort</a>/disp32 <span id="L126" class="LineNr">126 </span> <span class="subxComment"># var in/edx: (addr byte) = s->data + s->read</span> <span id="L127" class="LineNr">127 </span> 8d/copy-address *(esi+edx+0xc) 2/r32/edx <span id="L128" class="LineNr">128 </span> <span class="subxComment"># var inend/ebx: (addr byte) = in + n</span> @@ -206,8 +206,8 @@ if ('onhashchange' in window) { <span id="L150" class="LineNr">150 </span> 5d/pop-to-ebp <span id="L151" class="LineNr">151 </span> c3/return <span id="L152" class="LineNr">152 </span> -<span id="L153" class="LineNr">153 </span><span class="Constant">$read-from-stream:abort</span>: -<span id="L154" class="LineNr">154 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"read-from-stream: stream empty"</span> 3) <span class="subxComment"># 3=cyan</span> +<span id="L153" class="LineNr">153 </span><span class="Constant">$read-from-stream:<a href='501draw-text.mu.html#L519'>abort</a></span>: +<span id="L154" class="LineNr">154 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"read-from-stream: stream empty"</span> 3 0) <span class="subxComment"># 3=cyan</span> <span id="L155" class="LineNr">155 </span> { <span id="L156" class="LineNr">156 </span> eb/jump <span class="Constant">loop</span>/disp8 <span id="L157" class="LineNr">157 </span> } diff --git a/html/baremetal/310copy-bytes.subx.html b/html/baremetal/310copy-bytes.subx.html new file mode 100644 index 00000000..65b80e17 --- /dev/null +++ b/html/baremetal/310copy-bytes.subx.html @@ -0,0 +1,219 @@ +<!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 - baremetal/310copy-bytes.subx</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: #c6c6c6; } +body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } +a { color:inherit; } +* { font-size:12pt; font-size: 1em; } +.SpecialChar { color: #d70000; } +.subxComment { color: #005faf; } +.subxS1Comment { color: #0000af; } +.LineNr { } +.subxTest { color: #5f8700; } +.subxFunction { color: #af5f00; text-decoration: underline; } +.Constant { color: #008787; } +--> +</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/baremetal/310copy-bytes.subx'>https://github.com/akkartik/mu/blob/main/baremetal/310copy-bytes.subx</a> +<pre id='vimCodeElement'> +<span id="L1" class="LineNr"> 1 </span><span class="subxComment"># Some helpers for copying non-overlapping regions of memory.</span> +<span id="L2" class="LineNr"> 2 </span><span class="subxComment"># Really only intended to be called from code generated by mu.subx.</span> +<span id="L3" class="LineNr"> 3 </span> +<span id="L4" class="LineNr"> 4 </span>== code +<span id="L5" class="LineNr"> 5 </span> +<span id="L6" class="LineNr"> 6 </span><span class="subxFunction">copy-bytes</span>: <span class="subxComment"># src: (addr byte), dest: (addr byte), size: int</span> +<span id="L7" class="LineNr"> 7 </span> <span class="subxComment"># pseudocode:</span> +<span id="L8" class="LineNr"> 8 </span> <span class="subxComment"># curr-src/esi = src</span> +<span id="L9" class="LineNr"> 9 </span> <span class="subxComment"># curr-dest/edi = dest</span> +<span id="L10" class="LineNr"> 10 </span> <span class="subxComment"># i/ecx = 0</span> +<span id="L11" class="LineNr"> 11 </span> <span class="subxComment"># while true</span> +<span id="L12" class="LineNr"> 12 </span> <span class="subxComment"># if (i >= size) break</span> +<span id="L13" class="LineNr"> 13 </span> <span class="subxComment"># *curr-dest = *curr-src</span> +<span id="L14" class="LineNr"> 14 </span> <span class="subxComment"># ++curr-src</span> +<span id="L15" class="LineNr"> 15 </span> <span class="subxComment"># ++curr-dest</span> +<span id="L16" class="LineNr"> 16 </span> <span class="subxComment"># ++i</span> +<span id="L17" class="LineNr"> 17 </span> <span class="subxComment">#</span> +<span id="L18" class="LineNr"> 18 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L19" class="LineNr"> 19 </span> 55/push-ebp +<span id="L20" class="LineNr"> 20 </span> 89/<- %ebp 4/r32/esp +<span id="L21" class="LineNr"> 21 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L22" class="LineNr"> 22 </span> 50/push-eax +<span id="L23" class="LineNr"> 23 </span> 51/push-ecx +<span id="L24" class="LineNr"> 24 </span> 52/push-edx +<span id="L25" class="LineNr"> 25 </span> 56/push-esi +<span id="L26" class="LineNr"> 26 </span> 57/push-edi +<span id="L27" class="LineNr"> 27 </span> <span class="subxComment"># curr-src/esi = src</span> +<span id="L28" class="LineNr"> 28 </span> 8b/-> *(ebp+8) 6/r32/esi +<span id="L29" class="LineNr"> 29 </span> <span class="subxComment"># curr-dest/edi = dest</span> +<span id="L30" class="LineNr"> 30 </span> 8b/-> *(ebp+0xc) 7/r32/edi +<span id="L31" class="LineNr"> 31 </span> <span class="subxComment"># var i/ecx: int = 0</span> +<span id="L32" class="LineNr"> 32 </span> b9/copy-to-ecx 0/imm32 +<span id="L33" class="LineNr"> 33 </span> <span class="subxComment"># edx = size</span> +<span id="L34" class="LineNr"> 34 </span> 8b/-> *(ebp+0x10) 2/r32/edx +<span id="L35" class="LineNr"> 35 </span> { +<span id="L36" class="LineNr"> 36 </span> <span class="subxComment"># if (i >= size) break</span> +<span id="L37" class="LineNr"> 37 </span> 39/compare %ecx 2/r32/edx +<span id="L38" class="LineNr"> 38 </span> 7d/jump-if->= <span class="Constant">break</span>/disp8 +<span id="L39" class="LineNr"> 39 </span> <span class="subxComment"># *curr-dest = *curr-src</span> +<span id="L40" class="LineNr"> 40 </span> 8a/byte-> *esi 0/r32/AL +<span id="L41" class="LineNr"> 41 </span> 88/byte<- *edi 0/r32/AL +<span id="L42" class="LineNr"> 42 </span> <span class="subxComment"># update</span> +<span id="L43" class="LineNr"> 43 </span> 46/increment-esi +<span id="L44" class="LineNr"> 44 </span> 47/increment-edi +<span id="L45" class="LineNr"> 45 </span> 41/increment-ecx +<span id="L46" class="LineNr"> 46 </span> eb/jump <span class="Constant">loop</span>/disp8 +<span id="L47" class="LineNr"> 47 </span> } +<span id="L48" class="LineNr"> 48 </span><span class="Constant">$copy-bytes:end</span>: +<span id="L49" class="LineNr"> 49 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L50" class="LineNr"> 50 </span> 5f/pop-to-edi +<span id="L51" class="LineNr"> 51 </span> 5e/pop-to-esi +<span id="L52" class="LineNr"> 52 </span> 5a/pop-to-edx +<span id="L53" class="LineNr"> 53 </span> 59/pop-to-ecx +<span id="L54" class="LineNr"> 54 </span> 58/pop-to-eax +<span id="L55" class="LineNr"> 55 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L56" class="LineNr"> 56 </span> 89/<- %esp 5/r32/ebp +<span id="L57" class="LineNr"> 57 </span> 5d/pop-to-ebp +<span id="L58" class="LineNr"> 58 </span> c3/return +<span id="L59" class="LineNr"> 59 </span> +<span id="L60" class="LineNr"> 60 </span><span class="subxFunction">stream-to-array</span>: <span class="subxComment"># in: (addr stream _), out: (addr handle array _)</span> +<span id="L61" class="LineNr"> 61 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L62" class="LineNr"> 62 </span> 55/push-ebp +<span id="L63" class="LineNr"> 63 </span> 89/<- %ebp 4/r32/esp +<span id="L64" class="LineNr"> 64 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L65" class="LineNr"> 65 </span> 50/push-eax +<span id="L66" class="LineNr"> 66 </span> 51/push-ecx +<span id="L67" class="LineNr"> 67 </span> 52/push-edx +<span id="L68" class="LineNr"> 68 </span> 56/push-esi +<span id="L69" class="LineNr"> 69 </span> <span class="subxComment"># esi = s</span> +<span id="L70" class="LineNr"> 70 </span> 8b/-> *(ebp+8) 6/r32/esi +<span id="L71" class="LineNr"> 71 </span> <span class="subxComment"># var len/ecx: int = s->write - s->read</span> +<span id="L72" class="LineNr"> 72 </span> 8b/-> *esi 1/r32/ecx +<span id="L73" class="LineNr"> 73 </span> 2b/subtract *(esi+4) 1/r32/ecx +<span id="L74" class="LineNr"> 74 </span> <span class="subxComment"># allocate</span> +<span id="L75" class="LineNr"> 75 </span> (<a href='120allocate.subx.html#L535'>allocate-array</a> <span class="SpecialChar"><a href='120allocate.subx.html#L27'>Heap</a></span> %ecx *(ebp+0xc)) +<span id="L76" class="LineNr"> 76 </span> <span class="subxComment"># var in/edx: (addr byte) = s->data + s->read</span> +<span id="L77" class="LineNr"> 77 </span> 8b/-> *(esi+4) 2/r32/edx +<span id="L78" class="LineNr"> 78 </span> 8d/copy-address *(esi+edx+0xc) 2/r32/edx +<span id="L79" class="LineNr"> 79 </span> <span class="subxComment"># var dest/eax: (addr byte) = data for out</span> +<span id="L80" class="LineNr"> 80 </span> 8b/-> *(ebp+0xc) 0/r32/eax +<span id="L81" class="LineNr"> 81 </span> (<a href='120allocate.subx.html#L226'>lookup</a> *eax *(eax+4)) <span class="subxComment"># => eax</span> +<span id="L82" class="LineNr"> 82 </span> 8d/copy-address *(eax+4) 0/r32/eax +<span id="L83" class="LineNr"> 83 </span> <span class="subxComment">#</span> +<span id="L84" class="LineNr"> 84 </span> (<a href='310copy-bytes.subx.html#L6'>copy-bytes</a> %edx %eax %ecx) +<span id="L85" class="LineNr"> 85 </span><span class="Constant">$stream-to-array:end</span>: +<span id="L86" class="LineNr"> 86 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L87" class="LineNr"> 87 </span> 5e/pop-to-esi +<span id="L88" class="LineNr"> 88 </span> 5a/pop-to-edx +<span id="L89" class="LineNr"> 89 </span> 59/pop-to-ecx +<span id="L90" class="LineNr"> 90 </span> 58/pop-to-eax +<span id="L91" class="LineNr"> 91 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L92" class="LineNr"> 92 </span> 89/<- %esp 5/r32/ebp +<span id="L93" class="LineNr"> 93 </span> 5d/pop-to-ebp +<span id="L94" class="LineNr"> 94 </span> c3/return +<span id="L95" class="LineNr"> 95 </span> +<span id="L96" class="LineNr"> 96 </span><span class="subxTest">test-stream-to-array</span>: +<span id="L97" class="LineNr"> 97 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L98" class="LineNr"> 98 </span> 55/push-ebp +<span id="L99" class="LineNr"> 99 </span> 89/<- %ebp 4/r32/esp +<span id="L100" class="LineNr">100 </span> <span class="subxComment"># setup</span> +<span id="L101" class="LineNr">101 </span> (<a href='106stream.subx.html#L20'>clear-stream</a> <a href='112read-byte.subx.html#L50'>_test-input-stream</a>) +<span id="L102" class="LineNr">102 </span> (<a href='108write.subx.html#L11'>write</a> <a href='112read-byte.subx.html#L50'>_test-input-stream</a> <span class="Constant">"abc"</span>) +<span id="L103" class="LineNr">103 </span> <span class="subxComment"># skip something</span> +<span id="L104" class="LineNr">104 </span> (<a href='112read-byte.subx.html#L13'>read-byte</a> <a href='112read-byte.subx.html#L50'>_test-input-stream</a>) <span class="subxComment"># => eax</span> +<span id="L105" class="LineNr">105 </span> <span class="subxComment"># var out/ecx: (handle array byte)</span> +<span id="L106" class="LineNr">106 </span> 68/push 0/imm32 +<span id="L107" class="LineNr">107 </span> 68/push 0/imm32 +<span id="L108" class="LineNr">108 </span> 89/<- %ecx 4/r32/esp +<span id="L109" class="LineNr">109 </span> <span class="subxComment">#</span> +<span id="L110" class="LineNr">110 </span> (<a href='310copy-bytes.subx.html#L60'>stream-to-array</a> <a href='112read-byte.subx.html#L50'>_test-input-stream</a> %ecx) +<span id="L111" class="LineNr">111 </span> (<a href='120allocate.subx.html#L226'>lookup</a> *ecx *(ecx+4)) <span class="subxComment"># => eax</span> +<span id="L112" class="LineNr">112 </span> (<a href='105string-equal.subx.html#L213'>check-strings-equal</a> %eax <span class="Constant">"bc"</span>) +<span id="L113" class="LineNr">113 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L114" class="LineNr">114 </span> 89/<- %esp 5/r32/ebp +<span id="L115" class="LineNr">115 </span> 5d/pop-to-ebp +<span id="L116" class="LineNr">116 </span> c3/return +<span id="L117" class="LineNr">117 </span> +<span id="L118" class="LineNr">118 </span><span class="subxComment"># like stream-to-array but ignore surrounding quotes</span> +<span id="L119" class="LineNr">119 </span><span class="subxComment"># we might do other stuff here later</span> +<span id="L120" class="LineNr">120 </span><span class="subxFunction">unquote-stream-to-array</span>: <span class="subxComment"># in: (addr stream _), out: (addr handle array _)</span> +<span id="L121" class="LineNr">121 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L122" class="LineNr">122 </span> 55/push-ebp +<span id="L123" class="LineNr">123 </span> 89/<- %ebp 4/r32/esp +<span id="L124" class="LineNr">124 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L125" class="LineNr">125 </span> 50/push-eax +<span id="L126" class="LineNr">126 </span> 51/push-ecx +<span id="L127" class="LineNr">127 </span> 52/push-edx +<span id="L128" class="LineNr">128 </span> 56/push-esi +<span id="L129" class="LineNr">129 </span> <span class="subxComment"># esi = s</span> +<span id="L130" class="LineNr">130 </span> 8b/-> *(ebp+8) 6/r32/esi +<span id="L131" class="LineNr">131 </span> <span class="subxComment"># var len/ecx: int = s->write - s->read - 2</span> +<span id="L132" class="LineNr">132 </span> 8b/-> *esi 1/r32/ecx +<span id="L133" class="LineNr">133 </span> 2b/subtract *(esi+4) 1/r32/ecx +<span id="L134" class="LineNr">134 </span> 81 7/subop/compare %ecx 2/imm32 +<span id="L135" class="LineNr">135 </span> 7c/jump-if-< $unquote-stream-to-array:end/disp8 +<span id="L136" class="LineNr">136 </span> 81 5/subop/subtract %ecx 2/imm32 +<span id="L137" class="LineNr">137 </span> <span class="subxComment"># allocate</span> +<span id="L138" class="LineNr">138 </span> (<a href='120allocate.subx.html#L535'>allocate-array</a> <span class="SpecialChar"><a href='120allocate.subx.html#L27'>Heap</a></span> %ecx *(ebp+0xc)) +<span id="L139" class="LineNr">139 </span> <span class="subxComment"># var in/edx: (addr byte) = s->data + s->read + 1</span> +<span id="L140" class="LineNr">140 </span> 8b/-> *(esi+4) 2/r32/edx +<span id="L141" class="LineNr">141 </span> 8d/copy-address *(esi+edx+0xd) 2/r32/edx <span class="subxComment"># Stream-data + 1</span> +<span id="L142" class="LineNr">142 </span> <span class="subxComment"># var dest/eax: (addr byte) = data for out</span> +<span id="L143" class="LineNr">143 </span> 8b/-> *(ebp+0xc) 0/r32/eax +<span id="L144" class="LineNr">144 </span> (<a href='120allocate.subx.html#L226'>lookup</a> *eax *(eax+4)) <span class="subxComment"># => eax</span> +<span id="L145" class="LineNr">145 </span> 8d/copy-address *(eax+4) 0/r32/eax +<span id="L146" class="LineNr">146 </span> <span class="subxComment">#</span> +<span id="L147" class="LineNr">147 </span> (<a href='310copy-bytes.subx.html#L6'>copy-bytes</a> %edx %eax %ecx) +<span id="L148" class="LineNr">148 </span><span class="Constant">$unquote-stream-to-array:end</span>: +<span id="L149" class="LineNr">149 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L150" class="LineNr">150 </span> 5e/pop-to-esi +<span id="L151" class="LineNr">151 </span> 5a/pop-to-edx +<span id="L152" class="LineNr">152 </span> 59/pop-to-ecx +<span id="L153" class="LineNr">153 </span> 58/pop-to-eax +<span id="L154" class="LineNr">154 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L155" class="LineNr">155 </span> 89/<- %esp 5/r32/ebp +<span id="L156" class="LineNr">156 </span> 5d/pop-to-ebp +<span id="L157" class="LineNr">157 </span> c3/return +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/baremetal/311decimal-int.subx.html b/html/baremetal/311decimal-int.subx.html index 86304b6b..9c57479e 100644 --- a/html/baremetal/311decimal-int.subx.html +++ b/html/baremetal/311decimal-int.subx.html @@ -14,9 +14,12 @@ pre { white-space: pre-wrap; font-family: monospace; color: #000000; background- body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } +.SpecialChar { color: #d70000; } .subxComment { color: #005faf; } .subxS1Comment { color: #0000af; } .LineNr { } +.subxH1Comment { color: #005faf; text-decoration: underline; } +.subxMinorFunction { color: #875f5f; } .subxTest { color: #5f8700; } .subxFunction { color: #af5f00; text-decoration: underline; } .Constant { color: #008787; } @@ -482,6 +485,212 @@ if ('onhashchange' in window) { <span id="L425" class="LineNr">425 </span> 89/<- %esp 5/r32/ebp <span id="L426" class="LineNr">426 </span> 5d/pop-to-ebp <span id="L427" class="LineNr">427 </span> c3/return +<span id="L428" class="LineNr">428 </span> +<span id="L429" class="LineNr">429 </span><span class="subxMinorFunction">_parse-array-of-decimal-ints</span>: <span class="subxComment"># ad: (addr allocation-descriptor), s: (addr array byte), out: (addr handle array int)</span> +<span id="L430" class="LineNr">430 </span> <span class="subxComment"># pseudocode</span> +<span id="L431" class="LineNr">431 </span> <span class="subxComment"># end = &s->data[s->size]</span> +<span id="L432" class="LineNr">432 </span> <span class="subxComment"># curr = s->data</span> +<span id="L433" class="LineNr">433 </span> <span class="subxComment"># size = 0</span> +<span id="L434" class="LineNr">434 </span> <span class="subxComment"># while true</span> +<span id="L435" class="LineNr">435 </span> <span class="subxComment"># if (curr >= end) break</span> +<span id="L436" class="LineNr">436 </span> <span class="subxComment"># curr = skip-chars-matching-in-slice(curr, end, ' ')</span> +<span id="L437" class="LineNr">437 </span> <span class="subxComment"># if (curr >= end) break</span> +<span id="L438" class="LineNr">438 </span> <span class="subxComment"># curr = skip-chars-not-matching-in-slice(curr, end, ' ')</span> +<span id="L439" class="LineNr">439 </span> <span class="subxComment"># ++size</span> +<span id="L440" class="LineNr">440 </span> <span class="subxComment"># allocate-array(ad, size*4, out)</span> +<span id="L441" class="LineNr">441 </span> <span class="subxComment"># var slice: slice = {s->data, 0}</span> +<span id="L442" class="LineNr">442 </span> <span class="subxComment"># curr = lookup(out)->data</span> +<span id="L443" class="LineNr">443 </span> <span class="subxComment"># while true</span> +<span id="L444" class="LineNr">444 </span> <span class="subxComment"># if (slice->start >= end) break</span> +<span id="L445" class="LineNr">445 </span> <span class="subxComment"># slice->start = skip-chars-matching-in-slice(slice->start, end, ' ')</span> +<span id="L446" class="LineNr">446 </span> <span class="subxComment"># if (slice->start >= end) break</span> +<span id="L447" class="LineNr">447 </span> <span class="subxComment"># slice->end = skip-chars-not-matching-in-slice(slice->start, end, ' ')</span> +<span id="L448" class="LineNr">448 </span> <span class="subxComment"># *curr = parse-hex-int-from-slice(slice)</span> +<span id="L449" class="LineNr">449 </span> <span class="subxComment"># curr += 4</span> +<span id="L450" class="LineNr">450 </span> <span class="subxComment"># slice->start = slice->end</span> +<span id="L451" class="LineNr">451 </span> <span class="subxComment"># return result</span> +<span id="L452" class="LineNr">452 </span> <span class="subxComment">#</span> +<span id="L453" class="LineNr">453 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L454" class="LineNr">454 </span> 55/push-ebp +<span id="L455" class="LineNr">455 </span> 89/<- %ebp 4/r32/esp +<span id="L456" class="LineNr">456 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L457" class="LineNr">457 </span> 50/push-eax +<span id="L458" class="LineNr">458 </span> 51/push-ecx +<span id="L459" class="LineNr">459 </span> 52/push-edx +<span id="L460" class="LineNr">460 </span> 53/push-ebx +<span id="L461" class="LineNr">461 </span> 56/push-esi +<span id="L462" class="LineNr">462 </span> 57/push-edi +<span id="L463" class="LineNr">463 </span> <span class="subxComment"># esi = s</span> +<span id="L464" class="LineNr">464 </span> 8b/-> *(ebp+0xc) 6/r32/esi +<span id="L465" class="LineNr">465 </span> <span class="subxComment"># var curr/ecx: (addr byte) = s->data</span> +<span id="L466" class="LineNr">466 </span> 8d/copy-address *(esi+4) 1/r32/ecx +<span id="L467" class="LineNr">467 </span> <span class="subxComment"># var end/edx: (addr byte) = &s->data[s->size]</span> +<span id="L468" class="LineNr">468 </span> <span class="subxS1Comment"># . edx = s->size</span> +<span id="L469" class="LineNr">469 </span> 8b/-> *esi 2/r32/edx +<span id="L470" class="LineNr">470 </span> <span class="subxS1Comment"># . edx += curr</span> +<span id="L471" class="LineNr">471 </span> 01/add-to %edx 1/r32/ecx +<span id="L472" class="LineNr">472 </span> <span class="subxComment"># var size/ebx: int = 0</span> +<span id="L473" class="LineNr">473 </span> 31/xor-with %ebx 3/r32/ebx +<span id="L474" class="LineNr">474 </span><span class="Constant">$_parse-array-of-decimal-ints:loop1</span>: +<span id="L475" class="LineNr">475 </span> <span class="subxComment"># if (curr >= end) break</span> +<span id="L476" class="LineNr">476 </span> 39/compare %ecx 2/r32/edx +<span id="L477" class="LineNr">477 </span> 73/jump-if-addr>= $_parse-array-of-decimal-ints:break1/disp8 +<span id="L478" class="LineNr">478 </span> <span class="subxComment"># curr = skip-chars-matching-in-slice(curr, end, ' ')</span> +<span id="L479" class="LineNr">479 </span> (<a href='124next-token.subx.html#L804'>skip-chars-matching-in-slice</a> %ecx %edx 0x20) <span class="subxComment"># => eax</span> +<span id="L480" class="LineNr">480 </span> 89/<- %ecx 0/r32/eax +<span id="L481" class="LineNr">481 </span> <span class="subxComment"># if (curr >= end) break</span> +<span id="L482" class="LineNr">482 </span> 39/compare %ecx 2/r32/edx +<span id="L483" class="LineNr">483 </span> 73/jump-if-addr>= $_parse-array-of-decimal-ints:break1/disp8 +<span id="L484" class="LineNr">484 </span> <span class="subxComment"># curr = skip-chars-not-matching-in-slice(curr, end, ' ')</span> +<span id="L485" class="LineNr">485 </span> (<a href='124next-token.subx.html#L973'>skip-chars-not-matching-in-slice</a> %ecx %edx 0x20) <span class="subxComment"># => eax</span> +<span id="L486" class="LineNr">486 </span> 89/<- %ecx 0/r32/eax +<span id="L487" class="LineNr">487 </span> <span class="subxComment"># size += 4</span> +<span id="L488" class="LineNr">488 </span> 81 0/subop/add %ebx 4/imm32 +<span id="L489" class="LineNr">489 </span> eb/jump $_parse-array-of-decimal-ints:loop1/disp8 +<span id="L490" class="LineNr">490 </span><span class="Constant">$_parse-array-of-decimal-ints:break1</span>: +<span id="L491" class="LineNr">491 </span> (<a href='120allocate.subx.html#L535'>allocate-array</a> *(ebp+8) %ebx *(ebp+0x10)) +<span id="L492" class="LineNr">492 </span><span class="Constant">$_parse-array-of-decimal-ints:pass2</span>: +<span id="L493" class="LineNr">493 </span> <span class="subxComment"># var slice/edi: slice = {s->data, 0}</span> +<span id="L494" class="LineNr">494 </span> 68/push 0/imm32/end +<span id="L495" class="LineNr">495 </span> 8d/copy-address *(esi+4) 7/r32/edi +<span id="L496" class="LineNr">496 </span> 57/push-edi +<span id="L497" class="LineNr">497 </span> 89/<- %edi 4/r32/esp +<span id="L498" class="LineNr">498 </span> <span class="subxComment"># curr = lookup(out)->data</span> +<span id="L499" class="LineNr">499 </span> 8b/-> *(ebp+0x10) 0/r32/eax +<span id="L500" class="LineNr">500 </span> (<a href='120allocate.subx.html#L226'>lookup</a> *eax *(eax+4)) <span class="subxComment"># => eax</span> +<span id="L501" class="LineNr">501 </span> 8d/copy-address *(eax+4) 1/r32/ecx +<span id="L502" class="LineNr">502 </span><span class="Constant">$_parse-array-of-decimal-ints:loop2</span>: +<span id="L503" class="LineNr">503 </span> <span class="subxComment"># if (slice->start >= end) break</span> +<span id="L504" class="LineNr">504 </span> 39/compare *edi 2/r32/edx +<span id="L505" class="LineNr">505 </span> 73/jump-if-addr>= $_parse-array-of-decimal-ints:end/disp8 +<span id="L506" class="LineNr">506 </span> <span class="subxComment"># slice->start = skip-chars-matching-in-slice(slice->start, end, ' ')</span> +<span id="L507" class="LineNr">507 </span> (<a href='124next-token.subx.html#L804'>skip-chars-matching-in-slice</a> *edi %edx 0x20) <span class="subxComment"># => eax</span> +<span id="L508" class="LineNr">508 </span> 89/<- *edi 0/r32/eax +<span id="L509" class="LineNr">509 </span> <span class="subxComment"># if (slice->start >= end) break</span> +<span id="L510" class="LineNr">510 </span> 39/compare *edi 2/r32/edx +<span id="L511" class="LineNr">511 </span> 73/jump-if-addr>= $_parse-array-of-decimal-ints:end/disp8 +<span id="L512" class="LineNr">512 </span> <span class="subxComment"># slice->end = skip-chars-not-matching-in-slice(slice->start, end, ' ')</span> +<span id="L513" class="LineNr">513 </span> (<a href='124next-token.subx.html#L973'>skip-chars-not-matching-in-slice</a> *edi %edx 0x20) <span class="subxComment"># => eax</span> +<span id="L514" class="LineNr">514 </span> 89/<- *(edi+4) 0/r32/eax +<span id="L515" class="LineNr">515 </span> <span class="subxComment"># *curr = parse-hex-int-from-slice(slice)</span> +<span id="L516" class="LineNr">516 </span> (<a href='311decimal-int.subx.html#L4'>parse-decimal-int-from-slice</a> %edi) +<span id="L517" class="LineNr">517 </span> 89/<- *ecx 0/r32/eax +<span id="L518" class="LineNr">518 </span> <span class="subxComment"># curr += 4</span> +<span id="L519" class="LineNr">519 </span> 81 0/subop/add %ecx 4/imm32 +<span id="L520" class="LineNr">520 </span> <span class="subxComment"># slice->start = slice->end</span> +<span id="L521" class="LineNr">521 </span> 8b/-> *(edi+4) 0/r32/eax +<span id="L522" class="LineNr">522 </span> 89/<- *edi 0/r32/eax +<span id="L523" class="LineNr">523 </span> eb/jump $_parse-array-of-decimal-ints:loop2/disp8 +<span id="L524" class="LineNr">524 </span><span class="Constant">$_parse-array-of-decimal-ints:end</span>: +<span id="L525" class="LineNr">525 </span> <span class="subxS1Comment"># . reclaim locals</span> +<span id="L526" class="LineNr">526 </span> 81 0/subop/add %esp 8/imm32 +<span id="L527" class="LineNr">527 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L528" class="LineNr">528 </span> 5f/pop-to-edi +<span id="L529" class="LineNr">529 </span> 5e/pop-to-esi +<span id="L530" class="LineNr">530 </span> 5b/pop-to-ebx +<span id="L531" class="LineNr">531 </span> 5a/pop-to-edx +<span id="L532" class="LineNr">532 </span> 59/pop-to-ecx +<span id="L533" class="LineNr">533 </span> 58/pop-to-eax +<span id="L534" class="LineNr">534 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L535" class="LineNr">535 </span> 89/<- %esp 5/r32/ebp +<span id="L536" class="LineNr">536 </span> 5d/pop-to-ebp +<span id="L537" class="LineNr">537 </span> c3/return +<span id="L538" class="LineNr">538 </span> +<span id="L539" class="LineNr">539 </span><span class="subxTest">test-parse-array-of-decimal-ints</span>: +<span id="L540" class="LineNr">540 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L541" class="LineNr">541 </span> 55/push-ebp +<span id="L542" class="LineNr">542 </span> 89/<- %ebp 4/r32/esp +<span id="L543" class="LineNr">543 </span> <span class="subxComment"># var h/esi: (handle array int)</span> +<span id="L544" class="LineNr">544 </span> 68/push 0/imm32 +<span id="L545" class="LineNr">545 </span> 68/push 0/imm32 +<span id="L546" class="LineNr">546 </span> 89/<- %esi 4/r32/esp +<span id="L547" class="LineNr">547 </span> <span class="subxComment"># var ecx: (array int) = [1, 2, 3]</span> +<span id="L548" class="LineNr">548 </span> 68/push 3/imm32 +<span id="L549" class="LineNr">549 </span> 68/push 2/imm32 +<span id="L550" class="LineNr">550 </span> 68/push 1/imm32 +<span id="L551" class="LineNr">551 </span> 68/push 0xc/imm32/size +<span id="L552" class="LineNr">552 </span> 89/<- %ecx 4/r32/esp +<span id="L553" class="LineNr">553 </span> <span class="subxComment">#</span> +<span id="L554" class="LineNr">554 </span> (<a href='311decimal-int.subx.html#L429'>_parse-array-of-decimal-ints</a> <span class="SpecialChar"><a href='120allocate.subx.html#L27'>Heap</a></span> <span class="Constant">"1 2 3"</span> %esi) +<span id="L555" class="LineNr">555 </span> (<a href='120allocate.subx.html#L226'>lookup</a> *esi *(esi+4)) <span class="subxComment"># => eax</span> +<span id="L556" class="LineNr">556 </span> (<a href='301array-equal.subx.html#L5'>array-equal?</a> %ecx %eax) <span class="subxComment"># => eax</span> +<span id="L557" class="LineNr">557 </span> (<a href='502test.mu.html#L2'>check-ints-equal</a> %eax 1 <span class="Constant">"F - test-parse-array-of-decimal-ints"</span>) +<span id="L558" class="LineNr">558 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L559" class="LineNr">559 </span> 89/<- %esp 5/r32/ebp +<span id="L560" class="LineNr">560 </span> 5d/pop-to-ebp +<span id="L561" class="LineNr">561 </span> c3/return +<span id="L562" class="LineNr">562 </span> +<span id="L563" class="LineNr">563 </span><span class="subxTest">test-parse-array-of-decimal-ints-empty</span>: +<span id="L564" class="LineNr">564 </span> <span class="subxH1Comment"># - empty string = empty array</span> +<span id="L565" class="LineNr">565 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L566" class="LineNr">566 </span> 55/push-ebp +<span id="L567" class="LineNr">567 </span> 89/<- %ebp 4/r32/esp +<span id="L568" class="LineNr">568 </span> <span class="subxComment"># var h/esi: handle</span> +<span id="L569" class="LineNr">569 </span> 68/push 0/imm32 +<span id="L570" class="LineNr">570 </span> 68/push 0/imm32 +<span id="L571" class="LineNr">571 </span> 89/<- %esi 4/r32/esp +<span id="L572" class="LineNr">572 </span> <span class="subxComment">#</span> +<span id="L573" class="LineNr">573 </span> (<a href='311decimal-int.subx.html#L429'>_parse-array-of-decimal-ints</a> <span class="SpecialChar"><a href='120allocate.subx.html#L27'>Heap</a></span> <span class="Constant">""</span> %esi) +<span id="L574" class="LineNr">574 </span> (<a href='120allocate.subx.html#L226'>lookup</a> *esi *(esi+4)) <span class="subxComment"># => eax</span> +<span id="L575" class="LineNr">575 </span> (<a href='502test.mu.html#L2'>check-ints-equal</a> *eax 0 <span class="Constant">"F - test-parse-array-of-decimal-ints-empty"</span>) +<span id="L576" class="LineNr">576 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L577" class="LineNr">577 </span> 89/<- %esp 5/r32/ebp +<span id="L578" class="LineNr">578 </span> 5d/pop-to-ebp +<span id="L579" class="LineNr">579 </span> c3/return +<span id="L580" class="LineNr">580 </span> +<span id="L581" class="LineNr">581 </span><span class="subxTest">test-parse-array-of-decimal-ints-just-whitespace</span>: +<span id="L582" class="LineNr">582 </span> <span class="subxH1Comment"># - just whitespace = empty array</span> +<span id="L583" class="LineNr">583 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L584" class="LineNr">584 </span> 55/push-ebp +<span id="L585" class="LineNr">585 </span> 89/<- %ebp 4/r32/esp +<span id="L586" class="LineNr">586 </span> <span class="subxComment"># var h/esi: handle</span> +<span id="L587" class="LineNr">587 </span> 68/push 0/imm32 +<span id="L588" class="LineNr">588 </span> 68/push 0/imm32 +<span id="L589" class="LineNr">589 </span> 89/<- %esi 4/r32/esp +<span id="L590" class="LineNr">590 </span> <span class="subxComment">#</span> +<span id="L591" class="LineNr">591 </span> (<a href='311decimal-int.subx.html#L429'>_parse-array-of-decimal-ints</a> <span class="SpecialChar"><a href='120allocate.subx.html#L27'>Heap</a></span> <span class="SpecialChar"><a href='301array-equal.subx.html#L428'>Space</a></span> %esi) +<span id="L592" class="LineNr">592 </span> (<a href='120allocate.subx.html#L226'>lookup</a> *esi *(esi+4)) <span class="subxComment"># => eax</span> +<span id="L593" class="LineNr">593 </span> (<a href='502test.mu.html#L2'>check-ints-equal</a> *eax 0 <span class="Constant">"F - test-parse-array-of-decimal-ints-just-whitespace"</span>) +<span id="L594" class="LineNr">594 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L595" class="LineNr">595 </span> 89/<- %esp 5/r32/ebp +<span id="L596" class="LineNr">596 </span> 5d/pop-to-ebp +<span id="L597" class="LineNr">597 </span> c3/return +<span id="L598" class="LineNr">598 </span> +<span id="L599" class="LineNr">599 </span><span class="subxTest">test-parse-array-of-decimal-ints-extra-whitespace</span>: +<span id="L600" class="LineNr">600 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L601" class="LineNr">601 </span> 55/push-ebp +<span id="L602" class="LineNr">602 </span> 89/<- %ebp 4/r32/esp +<span id="L603" class="LineNr">603 </span> <span class="subxComment"># var h/esi: handle</span> +<span id="L604" class="LineNr">604 </span> 68/push 0/imm32 +<span id="L605" class="LineNr">605 </span> 68/push 0/imm32 +<span id="L606" class="LineNr">606 </span> 89/<- %esi 4/r32/esp +<span id="L607" class="LineNr">607 </span> <span class="subxComment"># var ecx: (array int) = [1, 2, 3]</span> +<span id="L608" class="LineNr">608 </span> 68/push 3/imm32 +<span id="L609" class="LineNr">609 </span> 68/push 2/imm32 +<span id="L610" class="LineNr">610 </span> 68/push 1/imm32 +<span id="L611" class="LineNr">611 </span> 68/push 0xc/imm32/size +<span id="L612" class="LineNr">612 </span> 89/<- %ecx 4/r32/esp +<span id="L613" class="LineNr">613 </span> <span class="subxComment">#</span> +<span id="L614" class="LineNr">614 </span> (<a href='311decimal-int.subx.html#L429'>_parse-array-of-decimal-ints</a> <span class="SpecialChar"><a href='120allocate.subx.html#L27'>Heap</a></span> <span class="Constant">" 1 2 3 "</span> %esi) +<span id="L615" class="LineNr">615 </span> (<a href='120allocate.subx.html#L226'>lookup</a> *esi *(esi+4)) <span class="subxComment"># => eax</span> +<span id="L616" class="LineNr">616 </span> (<a href='301array-equal.subx.html#L5'>array-equal?</a> %ecx %eax) <span class="subxComment"># => eax</span> +<span id="L617" class="LineNr">617 </span> (<a href='502test.mu.html#L2'>check-ints-equal</a> %eax 1 <span class="Constant">"F - test-parse-array-of-decimal-ints-extra-whitespace"</span>) +<span id="L618" class="LineNr">618 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L619" class="LineNr">619 </span> 89/<- %esp 5/r32/ebp +<span id="L620" class="LineNr">620 </span> 5d/pop-to-ebp +<span id="L621" class="LineNr">621 </span> c3/return +<span id="L622" class="LineNr">622 </span> +<span id="L623" class="LineNr">623 </span><span class="subxFunction">parse-array-of-decimal-ints</span>: <span class="subxComment"># s: (addr array byte), out: (addr handle array int)</span> +<span id="L624" class="LineNr">624 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L625" class="LineNr">625 </span> 55/push-ebp +<span id="L626" class="LineNr">626 </span> 89/<- %ebp 4/r32/esp +<span id="L627" class="LineNr">627 </span> <span class="subxComment">#</span> +<span id="L628" class="LineNr">628 </span> (<a href='311decimal-int.subx.html#L429'>_parse-array-of-decimal-ints</a> <span class="SpecialChar"><a href='120allocate.subx.html#L27'>Heap</a></span> *(ebp+8) *(ebp+0xc)) +<span id="L629" class="LineNr">629 </span><span class="Constant">$parse-array-of-decimal-ints:end</span>: +<span id="L630" class="LineNr">630 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L631" class="LineNr">631 </span> 89/<- %esp 5/r32/ebp +<span id="L632" class="LineNr">632 </span> 5d/pop-to-ebp +<span id="L633" class="LineNr">633 </span> c3/return </pre> </body> </html> diff --git a/html/baremetal/312copy.subx.html b/html/baremetal/312copy.subx.html new file mode 100644 index 00000000..5b2754dc --- /dev/null +++ b/html/baremetal/312copy.subx.html @@ -0,0 +1,74 @@ +<!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 - baremetal/312copy.subx</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: #c6c6c6; } +body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } +a { color:inherit; } +* { font-size:12pt; font-size: 1em; } +.SpecialChar { color: #d70000; } +.subxComment { color: #005faf; } +.subxS1Comment { color: #0000af; } +.LineNr { } +.subxFunction { color: #af5f00; text-decoration: underline; } +.Constant { color: #008787; } +--> +</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/baremetal/312copy.subx'>https://github.com/akkartik/mu/blob/main/baremetal/312copy.subx</a> +<pre id='vimCodeElement'> +<span id="L1" class="LineNr"> 1 </span>== code +<span id="L2" class="LineNr"> 2 </span> +<span id="L3" class="LineNr"> 3 </span><span class="subxFunction">copy-array-object</span>: <span class="subxComment"># src: (addr array T), dest-ah: (addr handle array T)</span> +<span id="L4" class="LineNr"> 4 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L5" class="LineNr"> 5 </span> 55/push-ebp +<span id="L6" class="LineNr"> 6 </span> 89/<- %ebp 4/r32/esp +<span id="L7" class="LineNr"> 7 </span> <span class="subxComment">#</span> +<span id="L8" class="LineNr"> 8 </span> (<a href='120allocate.subx.html#L669'>copy-array</a> <span class="SpecialChar"><a href='120allocate.subx.html#L27'>Heap</a></span> *(ebp+8) *(ebp+0xc)) +<span id="L9" class="LineNr"> 9 </span><span class="Constant">$copy-array-object:end</span>: +<span id="L10" class="LineNr">10 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L11" class="LineNr">11 </span> 89/<- %esp 5/r32/ebp +<span id="L12" class="LineNr">12 </span> 5d/pop-to-ebp +<span id="L13" class="LineNr">13 </span> c3/return +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/baremetal/313index-bounds-check.subx.html b/html/baremetal/313index-bounds-check.subx.html index 48ea8b01..8f2509c7 100644 --- a/html/baremetal/313index-bounds-check.subx.html +++ b/html/baremetal/313index-bounds-check.subx.html @@ -82,13 +82,13 @@ if ('onhashchange' in window) { <span id="L26" class="LineNr">26 </span> 39/compare %eax 1/r32/ecx <span id="L27" class="LineNr">27 </span> 0f 82/jump-if-unsigned< $__check-mu-array-bounds:end/disp32 <span class="subxComment"># negative index should always abort</span> <span id="L28" class="LineNr">28 </span> <span class="subxComment"># abort if necessary</span> -<span id="L29" class="LineNr">29 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"fn "</span> 3) <span class="subxComment"># 3=cyan</span> -<span id="L30" class="LineNr">30 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 *(ebp+0x14) 3) <span class="subxComment"># 3=cyan</span> -<span id="L31" class="LineNr">31 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">": offset "</span> 3) <span class="subxComment"># 3=cyan</span> -<span id="L32" class="LineNr">32 </span> (<a href='501draw-text.mu.html#L285'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 %eax 3) <span class="subxComment"># 3=cyan</span> -<span id="L33" class="LineNr">33 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">" is too large for array '"</span> 3) <span class="subxComment"># 3=cyan</span> -<span id="L34" class="LineNr">34 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 *(ebp+0x18) 3) <span class="subxComment"># 3=cyan</span> -<span id="L35" class="LineNr">35 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"'"</span> 3) <span class="subxComment"># 3=cyan</span> +<span id="L29" class="LineNr">29 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"fn "</span> 3 0) <span class="subxComment"># 3=cyan</span> +<span id="L30" class="LineNr">30 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 *(ebp+0x14) 3 0) <span class="subxComment"># 3=cyan</span> +<span id="L31" class="LineNr">31 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">": offset "</span> 3 0) <span class="subxComment"># 3=cyan</span> +<span id="L32" class="LineNr">32 </span> (<a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 %eax 3 0) <span class="subxComment"># 3=cyan</span> +<span id="L33" class="LineNr">33 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">" is too large for array '"</span> 3 0) <span class="subxComment"># 3=cyan</span> +<span id="L34" class="LineNr">34 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 *(ebp+0x18) 3 0) <span class="subxComment"># 3=cyan</span> +<span id="L35" class="LineNr">35 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"'"</span> 3 0) <span class="subxComment"># 3=cyan</span> <span id="L36" class="LineNr">36 </span> { <span id="L37" class="LineNr">37 </span> eb/jump <span class="Constant">loop</span>/disp8 <span id="L38" class="LineNr">38 </span> } @@ -104,12 +104,12 @@ if ('onhashchange' in window) { <span id="L48" class="LineNr">48 </span> c3/return <span id="L49" class="LineNr">49 </span> <span id="L50" class="LineNr">50 </span><span class="subxMinorFunction">__check-mu-array-bounds:overflow</span>: -<span id="L51" class="LineNr">51 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"fn "</span> 3) <span class="subxComment"># 3=cyan</span> -<span id="L52" class="LineNr">52 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 *(ebp+0x14) 3) <span class="subxComment"># 3=cyan</span> -<span id="L53" class="LineNr">53 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">": offset to array '"</span> 3) <span class="subxComment"># 3=cyan</span> -<span id="L54" class="LineNr">54 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"offset to array overflowed 32 bits"</span> 3) <span class="subxComment"># 3=cyan</span> -<span id="L55" class="LineNr">55 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 *(ebp+0x18) 3) <span class="subxComment"># 3=cyan</span> -<span id="L56" class="LineNr">56 </span> (<a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"' overflowed 32 bits"</span> 3) <span class="subxComment"># 3=cyan</span> +<span id="L51" class="LineNr">51 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"fn "</span> 3 0) <span class="subxComment"># 3=cyan</span> +<span id="L52" class="LineNr">52 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 *(ebp+0x14) 3 0) <span class="subxComment"># 3=cyan</span> +<span id="L53" class="LineNr">53 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">": offset to array '"</span> 3 0) <span class="subxComment"># 3=cyan</span> +<span id="L54" class="LineNr">54 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"offset to array overflowed 32 bits"</span> 3 0) <span class="subxComment"># 3=cyan</span> +<span id="L55" class="LineNr">55 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 *(ebp+0x18) 3 0) <span class="subxComment"># 3=cyan</span> +<span id="L56" class="LineNr">56 </span> (<a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> 0 <span class="Constant">"' overflowed 32 bits"</span> 3 0) <span class="subxComment"># 3=cyan</span> <span id="L57" class="LineNr">57 </span> { <span id="L58" class="LineNr">58 </span> eb/jump <span class="Constant">loop</span>/disp8 <span id="L59" class="LineNr">59 </span> } diff --git a/html/baremetal/314divide.subx.html b/html/baremetal/314divide.subx.html new file mode 100644 index 00000000..9345a7e5 --- /dev/null +++ b/html/baremetal/314divide.subx.html @@ -0,0 +1,77 @@ +<!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 - baremetal/314divide.subx</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: #c6c6c6; } +body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } +a { color:inherit; } +* { font-size:12pt; font-size: 1em; } +.subxComment { color: #005faf; } +.subxS1Comment { color: #0000af; } +.LineNr { } +.subxFunction { color: #af5f00; text-decoration: underline; } +.Constant { color: #008787; } +--> +</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/baremetal/314divide.subx'>https://github.com/akkartik/mu/blob/main/baremetal/314divide.subx</a> +<pre id='vimCodeElement'> +<span id="L1" class="LineNr"> 1 </span>== code +<span id="L2" class="LineNr"> 2 </span> +<span id="L3" class="LineNr"> 3 </span><span class="subxFunction">integer-divide</span>: <span class="subxComment"># a: int, b: int -> quotient/eax: int, remainder/edx: int</span> +<span id="L4" class="LineNr"> 4 </span> <span class="subxS1Comment"># . prologue</span> +<span id="L5" class="LineNr"> 5 </span> 55/push-ebp +<span id="L6" class="LineNr"> 6 </span> 89/<- %ebp 4/r32/esp +<span id="L7" class="LineNr"> 7 </span> <span class="subxComment"># eax = a</span> +<span id="L8" class="LineNr"> 8 </span> 8b/-> *(ebp+8) 0/r32/eax +<span id="L9" class="LineNr"> 9 </span> <span class="subxComment"># edx = all 0s or all 1s</span> +<span id="L10" class="LineNr">10 </span> 99/sign-extend-eax-into-edx +<span id="L11" class="LineNr">11 </span> <span class="subxComment"># quotient, remainder = divide eax by b</span> +<span id="L12" class="LineNr">12 </span> f7 7/subop/divide-eax-edx-by *(ebp+0xc) +<span id="L13" class="LineNr">13 </span><span class="Constant">$integer-divide:end</span>: +<span id="L14" class="LineNr">14 </span> <span class="subxS1Comment"># . epilogue</span> +<span id="L15" class="LineNr">15 </span> 89/<- %esp 5/r32/ebp +<span id="L16" class="LineNr">16 </span> 5d/pop-to-ebp +<span id="L17" class="LineNr">17 </span> c3/return +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/baremetal/400.mu.html b/html/baremetal/400.mu.html index 7d2d49c5..c5302dfc 100644 --- a/html/baremetal/400.mu.html +++ b/html/baremetal/400.mu.html @@ -55,10 +55,10 @@ if ('onhashchange' in window) { <pre id='vimCodeElement'> <span id="L1" class="LineNr"> 1 </span><span class="muComment"># screen</span> <span id="L2" class="LineNr"> 2 </span><span class="PreProc">sig</span> <a href='101screen.subx.html#L8'>pixel-on-real-screen</a> x: int, y: int, color: int -<span id="L3" class="LineNr"> 3 </span><span class="PreProc">sig</span> <a href='103grapheme.subx.html#L15'>draw-grapheme-on-real-screen</a> g: grapheme, x: int, y: int, color: int, background-color: int -<span id="L4" class="LineNr"> 4 </span><span class="PreProc">sig</span> <a href='103grapheme.subx.html#L94'>cursor-position-on-real-screen</a><span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int -<span id="L5" class="LineNr"> 5 </span><span class="PreProc">sig</span> <a href='103grapheme.subx.html#L107'>set-cursor-position-on-real-screen</a> x: int, y: int -<span id="L6" class="LineNr"> 6 </span><span class="PreProc">sig</span> <a href='103grapheme.subx.html#L131'>show-cursor-on-real-screen</a> g: grapheme +<span id="L3" class="LineNr"> 3 </span><span class="PreProc">sig</span> <a href='103grapheme.subx.html#L17'>draw-grapheme-on-real-screen</a> g: grapheme, x: int, y: int, color: int, background-color: int +<span id="L4" class="LineNr"> 4 </span><span class="PreProc">sig</span> <a href='103grapheme.subx.html#L96'>cursor-position-on-real-screen</a><span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int +<span id="L5" class="LineNr"> 5 </span><span class="PreProc">sig</span> <a href='103grapheme.subx.html#L109'>set-cursor-position-on-real-screen</a> x: int, y: int +<span id="L6" class="LineNr"> 6 </span><span class="PreProc">sig</span> <a href='103grapheme.subx.html#L134'>show-cursor-on-real-screen</a> g: grapheme <span id="L7" class="LineNr"> 7 </span> <span id="L8" class="LineNr"> 8 </span><span class="muComment"># keyboard</span> <span id="L9" class="LineNr"> 9 </span><span class="PreProc">sig</span> <a href='102keyboard.subx.html#L9'>read-key</a> kbd: (addr keyboard)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: byte @@ -67,51 +67,71 @@ if ('onhashchange' in window) { <span id="L12" class="LineNr">12 </span><span class="PreProc">sig</span> <a href='104test.subx.html#L5'>count-test-failure</a> <span id="L13" class="LineNr">13 </span><span class="PreProc">sig</span> <a href='104test.subx.html#L17'>num-test-failures</a><span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span id="L14" class="LineNr">14 </span> -<span id="L15" class="LineNr">15 </span><span class="muComment"># streams</span> -<span id="L16" class="LineNr">16 </span><span class="PreProc">sig</span> <a href='106stream.subx.html#L20'>clear-stream</a> f: (addr stream _) -<span id="L17" class="LineNr">17 </span><span class="PreProc">sig</span> <a href='106stream.subx.html#L59'>rewind-stream</a> f: (addr stream _) -<span id="L18" class="LineNr">18 </span><span class="PreProc">sig</span> <a href='108write.subx.html#L11'>write</a> f: (addr stream byte), s: (addr array byte) -<span id="L19" class="LineNr">19 </span><span class="PreProc">sig</span> <a href='112read-byte.subx.html#L13'>read-byte</a> s: (addr stream byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: byte -<span id="L20" class="LineNr">20 </span><span class="PreProc">sig</span> <a href='115write-byte.subx.html#L12'>append-byte</a> f: (addr stream byte), n: int -<span id="L21" class="LineNr">21 </span><span class="muComment">#sig to-hex-char in/eax: int -> out/eax: int</span> -<span id="L22" class="LineNr">22 </span><span class="PreProc">sig</span> <a href='117write-int-hex.subx.html#L21'>append-byte-hex</a> f: (addr stream byte), n: int -<span id="L23" class="LineNr">23 </span><span class="PreProc">sig</span> <a href='117write-int-hex.subx.html#L92'>write-int32-hex</a> f: (addr stream byte), n: int -<span id="L24" class="LineNr">24 </span><span class="PreProc">sig</span> <a href='117write-int-hex.subx.html#L123'>write-int32-hex-bits</a> f: (addr stream byte), n: int, bits: int -<span id="L25" class="LineNr">25 </span><span class="PreProc">sig</span> is-hex-int? in: (addr slice)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean -<span id="L26" class="LineNr">26 </span><span class="PreProc">sig</span> parse-hex-int in: (addr array byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int -<span id="L27" class="LineNr">27 </span><span class="PreProc">sig</span> parse-hex-int-from-slice in: (addr slice)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int -<span id="L28" class="LineNr">28 </span><span class="muComment">#sig parse-hex-int-helper start: (addr byte), end: (addr byte) -> _/eax: int</span> -<span id="L29" class="LineNr">29 </span><span class="PreProc">sig</span> is-hex-digit? c: byte<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean -<span id="L30" class="LineNr">30 </span><span class="muComment">#sig from-hex-char in/eax: byte -> out/eax: nibble</span> -<span id="L31" class="LineNr">31 </span><span class="PreProc">sig</span> <a href='311decimal-int.subx.html#L23'>parse-decimal-int</a> in: (addr array byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int -<span id="L32" class="LineNr">32 </span><span class="PreProc">sig</span> <a href='311decimal-int.subx.html#L4'>parse-decimal-int-from-slice</a> in: (addr slice)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int -<span id="L33" class="LineNr">33 </span><span class="PreProc">sig</span> <a href='311decimal-int.subx.html#L48'>parse-decimal-int-from-stream</a> in: (addr stream byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int -<span id="L34" class="LineNr">34 </span><span class="muComment">#sig parse-decimal-int-helper start: (addr byte), end: (addr byte) -> _/eax: int</span> -<span id="L35" class="LineNr">35 </span><span class="PreProc">sig</span> <a href='311decimal-int.subx.html#L312'>decimal-size</a> n: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int -<span id="L36" class="LineNr">36 </span><span class="muComment">#sig allocate ad: (addr allocation-descriptor), n: int, out: (addr handle _)</span> -<span id="L37" class="LineNr">37 </span><span class="muComment">#sig allocate-raw ad: (addr allocation-descriptor), n: int, out: (addr handle _)</span> -<span id="L38" class="LineNr">38 </span><span class="PreProc">sig</span> <a href='120allocate.subx.html#L226'>lookup</a> h: (handle _T)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: (addr _T) -<span id="L39" class="LineNr">39 </span><span class="PreProc">sig</span> <a href='120allocate.subx.html#L424'>handle-equal?</a> a: (handle _T), b: (handle _T)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean -<span id="L40" class="LineNr">40 </span><span class="PreProc">sig</span> <a href='120allocate.subx.html#L455'>copy-handle</a> src: (handle _T), dest: (addr handle _T) -<span id="L41" class="LineNr">41 </span><span class="muComment">#sig allocate-region ad: (addr allocation-descriptor), n: int, out: (addr handle allocation-descriptor)</span> -<span id="L42" class="LineNr">42 </span><span class="muComment">#sig allocate-array ad: (addr allocation-descriptor), n: int, out: (addr handle _)</span> -<span id="L43" class="LineNr">43 </span><span class="PreProc">sig</span> <a href='120allocate.subx.html#L669'>copy-array</a> ad: (addr allocation-descriptor), src: (addr array _T), out: (addr handle array _T) -<span id="L44" class="LineNr">44 </span><span class="muComment">#sig zero-out start: (addr byte), size: int</span> -<span id="L45" class="LineNr">45 </span><span class="PreProc">sig</span> <a href='123slice.subx.html#L9'>slice-empty?</a> s: (addr slice)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean -<span id="L46" class="LineNr">46 </span><span class="PreProc">sig</span> <a href='123slice.subx.html#L120'>slice-equal?</a> s: (addr slice), p: (addr array byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean -<span id="L47" class="LineNr">47 </span><span class="PreProc">sig</span> <a href='123slice.subx.html#L487'>slice-starts-with?</a> s: (addr slice), head: (addr array byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean -<span id="L48" class="LineNr">48 </span><span class="PreProc">sig</span> <a href='123slice.subx.html#L793'>write-slice</a> out: (addr stream byte), s: (addr slice) -<span id="L49" class="LineNr">49 </span><span class="muComment"># bad name alert</span> -<span id="L50" class="LineNr">50 </span><span class="PreProc">sig</span> <a href='123slice.subx.html#L901'>slice-to-string</a> ad: (addr allocation-descriptor), in: (addr slice), out: (addr handle array byte) -<span id="L51" class="LineNr">51 </span><span class="PreProc">sig</span> <a href='126write-int-decimal.subx.html#L8'>write-int32-decimal</a> out: (addr stream byte), n: int -<span id="L52" class="LineNr">52 </span><span class="PreProc">sig</span> <a href='126write-int-decimal.subx.html#L299'>is-decimal-digit?</a> c: grapheme<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean -<span id="L53" class="LineNr">53 </span><span class="PreProc">sig</span> <a href='126write-int-decimal.subx.html#L398'>to-decimal-digit</a> in: grapheme<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int -<span id="L54" class="LineNr">54 </span><span class="muComment"># bad name alert</span> -<span id="L55" class="LineNr">55 </span><span class="muComment"># next-word really tokenizes</span> -<span id="L56" class="LineNr">56 </span><span class="muComment"># next-raw-word really reads whitespace-separated words</span> -<span id="L57" class="LineNr">57 </span><span class="PreProc">sig</span> <a href='127next-word.subx.html#L11'>next-word</a> line: (addr stream byte), out: (addr slice) <span class="muComment"># skips '#' comments</span> -<span id="L58" class="LineNr">58 </span><span class="PreProc">sig</span> <a href='127next-word.subx.html#L306'>next-raw-word</a> line: (addr stream byte), out: (addr slice) <span class="muComment"># does not skip '#' comments</span> -<span id="L59" class="LineNr">59 </span><span class="PreProc">sig</span> <a href='309stream.subx.html#L6'>stream-empty?</a> s: (addr stream _)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean +<span id="L15" class="LineNr">15 </span><span class="PreProc">sig</span> <a href='105string-equal.subx.html#L213'>check-strings-equal</a> s: (addr array byte), expected: (addr array byte), msg: (addr array byte) +<span id="L16" class="LineNr">16 </span> +<span id="L17" class="LineNr">17 </span><span class="muComment"># streams</span> +<span id="L18" class="LineNr">18 </span><span class="PreProc">sig</span> <a href='106stream.subx.html#L20'>clear-stream</a> f: (addr stream _) +<span id="L19" class="LineNr">19 </span><span class="PreProc">sig</span> <a href='106stream.subx.html#L59'>rewind-stream</a> f: (addr stream _) +<span id="L20" class="LineNr">20 </span><span class="PreProc">sig</span> <a href='109stream-equal.subx.html#L9'>stream-data-equal?</a> f: (addr stream byte), s: (addr array byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean +<span id="L21" class="LineNr">21 </span><span class="PreProc">sig</span> <a href='109stream-equal.subx.html#L194'>check-stream-equal</a> f: (addr stream byte), s: (addr array byte), msg: (addr array byte) +<span id="L22" class="LineNr">22 </span><span class="PreProc">sig</span> <a href='109stream-equal.subx.html#L230'>next-stream-line-equal?</a> f: (addr stream byte), s: (addr array byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean +<span id="L23" class="LineNr">23 </span><span class="PreProc">sig</span> <a href='109stream-equal.subx.html#L565'>check-next-stream-line-equal</a> f: (addr stream byte), s: (addr array byte), msg: (addr array byte) +<span id="L24" class="LineNr">24 </span><span class="PreProc">sig</span> <a href='108write.subx.html#L11'>write</a> f: (addr stream byte), s: (addr array byte) +<span id="L25" class="LineNr">25 </span><span class="PreProc">sig</span> <a href='112read-byte.subx.html#L13'>read-byte</a> s: (addr stream byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: byte +<span id="L26" class="LineNr">26 </span><span class="PreProc">sig</span> <a href='115write-byte.subx.html#L12'>append-byte</a> f: (addr stream byte), n: int +<span id="L27" class="LineNr">27 </span><span class="muComment">#sig to-hex-char in/eax: int -> out/eax: int</span> +<span id="L28" class="LineNr">28 </span><span class="PreProc">sig</span> <a href='117write-int-hex.subx.html#L21'>append-byte-hex</a> f: (addr stream byte), n: int +<span id="L29" class="LineNr">29 </span><span class="PreProc">sig</span> <a href='117write-int-hex.subx.html#L92'>write-int32-hex</a> f: (addr stream byte), n: int +<span id="L30" class="LineNr">30 </span><span class="PreProc">sig</span> <a href='117write-int-hex.subx.html#L123'>write-int32-hex-bits</a> f: (addr stream byte), n: int, bits: int +<span id="L31" class="LineNr">31 </span><span class="PreProc">sig</span> <a href='118parse-hex-int.subx.html#L9'>is-hex-int?</a> in: (addr slice)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean +<span id="L32" class="LineNr">32 </span><span class="PreProc">sig</span> <a href='118parse-hex-int.subx.html#L354'>parse-hex-int</a> in: (addr array byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int +<span id="L33" class="LineNr">33 </span><span class="PreProc">sig</span> <a href='118parse-hex-int.subx.html#L387'>parse-hex-int-from-slice</a> in: (addr slice)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int +<span id="L34" class="LineNr">34 </span><span class="muComment">#sig parse-hex-int-helper start: (addr byte), end: (addr byte) -> _/eax: int</span> +<span id="L35" class="LineNr">35 </span><span class="PreProc">sig</span> <a href='118parse-hex-int.subx.html#L701'>is-hex-digit?</a> c: byte<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean +<span id="L36" class="LineNr">36 </span><span class="muComment">#sig from-hex-char in/eax: byte -> out/eax: nibble</span> +<span id="L37" class="LineNr">37 </span><span class="PreProc">sig</span> <a href='311decimal-int.subx.html#L23'>parse-decimal-int</a> in: (addr array byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int +<span id="L38" class="LineNr">38 </span><span class="PreProc">sig</span> <a href='311decimal-int.subx.html#L4'>parse-decimal-int-from-slice</a> in: (addr slice)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int +<span id="L39" class="LineNr">39 </span><span class="PreProc">sig</span> <a href='311decimal-int.subx.html#L48'>parse-decimal-int-from-stream</a> in: (addr stream byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int +<span id="L40" class="LineNr">40 </span><span class="muComment">#sig parse-decimal-int-helper start: (addr byte), end: (addr byte) -> _/eax: int</span> +<span id="L41" class="LineNr">41 </span><span class="PreProc">sig</span> <a href='311decimal-int.subx.html#L312'>decimal-size</a> n: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int +<span id="L42" class="LineNr">42 </span><span class="muComment">#sig allocate ad: (addr allocation-descriptor), n: int, out: (addr handle _)</span> +<span id="L43" class="LineNr">43 </span><span class="muComment">#sig allocate-raw ad: (addr allocation-descriptor), n: int, out: (addr handle _)</span> +<span id="L44" class="LineNr">44 </span><span class="PreProc">sig</span> <a href='120allocate.subx.html#L226'>lookup</a> h: (handle _T)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: (addr _T) +<span id="L45" class="LineNr">45 </span><span class="PreProc">sig</span> <a href='120allocate.subx.html#L424'>handle-equal?</a> a: (handle _T), b: (handle _T)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean +<span id="L46" class="LineNr">46 </span><span class="PreProc">sig</span> <a href='120allocate.subx.html#L455'>copy-handle</a> src: (handle _T), dest: (addr handle _T) +<span id="L47" class="LineNr">47 </span><span class="muComment">#sig allocate-region ad: (addr allocation-descriptor), n: int, out: (addr handle allocation-descriptor)</span> +<span id="L48" class="LineNr">48 </span><span class="muComment">#sig allocate-array ad: (addr allocation-descriptor), n: int, out: (addr handle _)</span> +<span id="L49" class="LineNr">49 </span><span class="PreProc">sig</span> <a href='120allocate.subx.html#L669'>copy-array</a> ad: (addr allocation-descriptor), src: (addr array _T), out: (addr handle array _T) +<span id="L50" class="LineNr">50 </span><span class="muComment">#sig zero-out start: (addr byte), size: int</span> +<span id="L51" class="LineNr">51 </span><span class="PreProc">sig</span> <a href='123slice.subx.html#L9'>slice-empty?</a> s: (addr slice)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean +<span id="L52" class="LineNr">52 </span><span class="PreProc">sig</span> <a href='123slice.subx.html#L120'>slice-equal?</a> s: (addr slice), p: (addr array byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean +<span id="L53" class="LineNr">53 </span><span class="PreProc">sig</span> <a href='123slice.subx.html#L487'>slice-starts-with?</a> s: (addr slice), head: (addr array byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean +<span id="L54" class="LineNr">54 </span><span class="PreProc">sig</span> <a href='123slice.subx.html#L793'>write-slice</a> out: (addr stream byte), s: (addr slice) +<span id="L55" class="LineNr">55 </span><span class="muComment"># bad name alert</span> +<span id="L56" class="LineNr">56 </span><span class="PreProc">sig</span> <a href='123slice.subx.html#L901'>slice-to-string</a> ad: (addr allocation-descriptor), in: (addr slice), out: (addr handle array byte) +<span id="L57" class="LineNr">57 </span><span class="PreProc">sig</span> <a href='126write-int-decimal.subx.html#L8'>write-int32-decimal</a> out: (addr stream byte), n: int +<span id="L58" class="LineNr">58 </span><span class="PreProc">sig</span> <a href='126write-int-decimal.subx.html#L299'>is-decimal-digit?</a> c: grapheme<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean +<span id="L59" class="LineNr">59 </span><span class="PreProc">sig</span> <a href='126write-int-decimal.subx.html#L398'>to-decimal-digit</a> in: grapheme<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int +<span id="L60" class="LineNr">60 </span><span class="muComment"># bad name alert</span> +<span id="L61" class="LineNr">61 </span><span class="muComment"># next-word really tokenizes</span> +<span id="L62" class="LineNr">62 </span><span class="muComment"># next-raw-word really reads whitespace-separated words</span> +<span id="L63" class="LineNr">63 </span><span class="PreProc">sig</span> <a href='127next-word.subx.html#L11'>next-word</a> line: (addr stream byte), out: (addr slice) <span class="muComment"># skips '#' comments</span> +<span id="L64" class="LineNr">64 </span><span class="PreProc">sig</span> <a href='127next-word.subx.html#L306'>next-raw-word</a> line: (addr stream byte), out: (addr slice) <span class="muComment"># does not skip '#' comments</span> +<span id="L65" class="LineNr">65 </span><span class="PreProc">sig</span> <a href='309stream.subx.html#L6'>stream-empty?</a> s: (addr stream _)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean +<span id="L66" class="LineNr">66 </span><span class="PreProc">sig</span> <a href='309stream.subx.html#L30'>stream-full?</a> s: (addr stream _)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean +<span id="L67" class="LineNr">67 </span><span class="PreProc">sig</span> <a href='310copy-bytes.subx.html#L60'>stream-to-array</a> in: (addr stream _), out: (addr handle array _) +<span id="L68" class="LineNr">68 </span><span class="PreProc">sig</span> <a href='310copy-bytes.subx.html#L120'>unquote-stream-to-array</a> in: (addr stream _), out: (addr handle array _) +<span id="L69" class="LineNr">69 </span><span class="PreProc">sig</span> <a href='309stream.subx.html#L160'>stream-first</a> s: (addr stream byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: byte +<span id="L70" class="LineNr">70 </span><span class="PreProc">sig</span> <a href='309stream.subx.html#L187'>stream-final</a> s: (addr stream byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: byte +<span id="L71" class="LineNr">71 </span> +<span id="L72" class="LineNr">72 </span><span class="muComment">#sig copy-bytes src: (addr byte), dest: (addr byte), n: int</span> +<span id="L73" class="LineNr">73 </span><span class="PreProc">sig</span> <a href='312copy.subx.html#L3'>copy-array-object</a> src: (addr array _), dest-ah: (addr handle array _) +<span id="L74" class="LineNr">74 </span><span class="PreProc">sig</span> <a href='301array-equal.subx.html#L5'>array-equal?</a> a: (addr array int), b: (addr array int)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean +<span id="L75" class="LineNr">75 </span><span class="PreProc">sig</span> <a href='301array-equal.subx.html#L368'>parse-array-of-ints</a> s: (addr array byte), out: (addr handle array int) +<span id="L76" class="LineNr">76 </span><span class="PreProc">sig</span> <a href='311decimal-int.subx.html#L623'>parse-array-of-decimal-ints</a> s: (addr array byte), out: (addr handle array int) +<span id="L77" class="LineNr">77 </span><span class="PreProc">sig</span> <a href='301array-equal.subx.html#L382'>check-array-equal</a> a: (addr array int), expected: (addr string), msg: (addr string) +<span id="L78" class="LineNr">78 </span> +<span id="L79" class="LineNr">79 </span><span class="PreProc">sig</span> <a href='314divide.subx.html#L3'>integer-divide</a> a: int, b: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">edx</span>: int </pre> </body> </html> diff --git a/html/baremetal/403unicode.mu.html b/html/baremetal/403unicode.mu.html index 81caf261..30c58205 100644 --- a/html/baremetal/403unicode.mu.html +++ b/html/baremetal/403unicode.mu.html @@ -151,7 +151,7 @@ if ('onhashchange' in window) { <span id="L93" class="LineNr"> 93 </span> <span class="muComment"># if at eof, return EOF</span> <span id="L94" class="LineNr"> 94 </span> <span class="Delimiter">{</span> <span id="L95" class="LineNr"> 95 </span> <span class="PreProc">var</span> eof?/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='309stream.subx.html#L6'>stream-empty?</a> in -<span id="L96" class="LineNr"> 96 </span> compare eof?, <span class="Constant">0</span> <span class="muComment"># false</span> +<span id="L96" class="LineNr"> 96 </span> compare eof?, <span class="Constant">0</span>/false <span id="L97" class="LineNr"> 97 </span> <span class="PreProc">break-if-=</span> <span id="L98" class="LineNr"> 98 </span> <span class="PreProc">return</span> <span class="Constant">0xffffffff</span> <span id="L99" class="LineNr"> 99 </span> <span class="Delimiter">}</span> diff --git a/html/baremetal/408float.mu.html b/html/baremetal/408float.mu.html new file mode 100644 index 00000000..bd17e264 --- /dev/null +++ b/html/baremetal/408float.mu.html @@ -0,0 +1,85 @@ +<!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 - baremetal/408float.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: #c6c6c6; } +body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } +a { color:inherit; } +* { font-size:12pt; font-size: 1em; } +.PreProc { color: #c000c0; } +.LineNr { } +.Constant { color: #008787; } +.SpecialChar { color: #d70000; } +.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/baremetal/408float.mu'>https://github.com/akkartik/mu/blob/main/baremetal/408float.mu</a> +<pre id='vimCodeElement'> +<span id="L1" class="LineNr"> 1 </span><span class="muComment"># Some quick-n-dirty ways to create floats.</span> +<span id="L2" class="LineNr"> 2 </span> +<span id="L3" class="LineNr"> 3 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='408float.mu.html#L3'>fill-in-rational</a></span> _out: (addr float), nr: int, dr: int <span class="Delimiter">{</span> +<span id="L4" class="LineNr"> 4 </span> <span class="PreProc">var</span> out/<span class="Constant">edi</span>: (addr float) <span class="SpecialChar"><-</span> copy _out +<span id="L5" class="LineNr"> 5 </span> <span class="PreProc">var</span> result/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> convert nr +<span id="L6" class="LineNr"> 6 </span> <span class="PreProc">var</span> divisor/<span class="Constant">xmm1</span>: float <span class="SpecialChar"><-</span> convert dr +<span id="L7" class="LineNr"> 7 </span> result <span class="SpecialChar"><-</span> divide divisor +<span id="L8" class="LineNr"> 8 </span> copy-to *out, result +<span id="L9" class="LineNr"> 9 </span><span class="Delimiter">}</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='408float.mu.html#L11'>fill-in-sqrt</a></span> _out: (addr float), n: int <span class="Delimiter">{</span> +<span id="L12" class="LineNr">12 </span> <span class="PreProc">var</span> out/<span class="Constant">edi</span>: (addr float) <span class="SpecialChar"><-</span> copy _out +<span id="L13" class="LineNr">13 </span> <span class="PreProc">var</span> result/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> convert n +<span id="L14" class="LineNr">14 </span> result <span class="SpecialChar"><-</span> square-root result +<span id="L15" class="LineNr">15 </span> copy-to *out, result +<span id="L16" class="LineNr">16 </span><span class="Delimiter">}</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='408float.mu.html#L18'>rational</a></span> nr: int, dr: int<span class="PreProc"> -> </span>_/<span class="Constant">xmm0</span>: float <span class="Delimiter">{</span> +<span id="L19" class="LineNr">19 </span> <span class="PreProc">var</span> result/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> convert nr +<span id="L20" class="LineNr">20 </span> <span class="PreProc">var</span> divisor/<span class="Constant">xmm1</span>: float <span class="SpecialChar"><-</span> convert dr +<span id="L21" class="LineNr">21 </span> result <span class="SpecialChar"><-</span> divide divisor +<span id="L22" class="LineNr">22 </span> <span class="PreProc">return</span> result +<span id="L23" class="LineNr">23 </span><span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/baremetal/411string.mu.html b/html/baremetal/411string.mu.html new file mode 100644 index 00000000..46b70129 --- /dev/null +++ b/html/baremetal/411string.mu.html @@ -0,0 +1,189 @@ +<!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 - baremetal/411string.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: #c6c6c6; } +body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } +a { color:inherit; } +* { font-size:12pt; font-size: 1em; } +.PreProc { color: #c000c0; } +.LineNr { } +.CommentedCode { color: #8a8a8a; } +.Constant { color: #008787; } +.SpecialChar { color: #d70000; } +.Delimiter { color: #c000c0; } +.muFunction { color: #af5f00; text-decoration: underline; } +.muTest { color: #5f8700; } +.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/baremetal/411string.mu'>https://github.com/akkartik/mu/blob/main/baremetal/411string.mu</a> +<pre id='vimCodeElement'> +<span id="L1" class="LineNr"> 1 </span><span class="muComment"># read up to 'len' graphemes after skipping the first 'start' ones</span> +<span id="L2" class="LineNr"> 2 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='411string.mu.html#L2'>substring</a></span> in: (addr array byte), start: int, len: int, out-ah: (addr handle array byte) <span class="Delimiter">{</span> +<span id="L3" class="LineNr"> 3 </span> <span class="PreProc">var</span> in-stream: (stream byte <span class="Constant">0x100</span>) +<span id="L4" class="LineNr"> 4 </span> <span class="PreProc">var</span> in-stream-addr/<span class="Constant">esi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address in-stream +<span id="L5" class="LineNr"> 5 </span> <a href='108write.subx.html#L11'>write</a> in-stream-addr, in +<span id="L6" class="LineNr"> 6 </span> <span class="PreProc">var</span> out-stream: (stream byte <span class="Constant">0x100</span>) +<span id="L7" class="LineNr"> 7 </span> <span class="PreProc">var</span> out-stream-addr/<span class="Constant">edi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address out-stream +<span id="L8" class="LineNr"> 8 </span> $substring:core: <span class="Delimiter">{</span> +<span id="L9" class="LineNr"> 9 </span> <span class="muComment"># skip 'start' graphemes</span> +<span id="L10" class="LineNr"> 10 </span> <span class="PreProc">var</span> i/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L11" class="LineNr"> 11 </span> <span class="Delimiter">{</span> +<span id="L12" class="LineNr"> 12 </span> compare i, start +<span id="L13" class="LineNr"> 13 </span> <span class="PreProc">break-if->=</span> +<span id="L14" class="LineNr"> 14 </span> <span class="Delimiter">{</span> +<span id="L15" class="LineNr"> 15 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> in-stream-addr +<span id="L16" class="LineNr"> 16 </span> compare dummy, <span class="Constant">0xffffffff</span>/end-of-file +<span id="L17" class="LineNr"> 17 </span> <span class="PreProc">break-if-=</span> $substring:core +<span id="L18" class="LineNr"> 18 </span> <span class="Delimiter">}</span> +<span id="L19" class="LineNr"> 19 </span> i <span class="SpecialChar"><-</span> increment +<span id="L20" class="LineNr"> 20 </span> <span class="PreProc">loop</span> +<span id="L21" class="LineNr"> 21 </span> <span class="Delimiter">}</span> +<span id="L22" class="LineNr"> 22 </span> <span class="muComment"># copy 'len' graphemes</span> +<span id="L23" class="LineNr"> 23 </span> i <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L24" class="LineNr"> 24 </span> <span class="Delimiter">{</span> +<span id="L25" class="LineNr"> 25 </span> compare i, len +<span id="L26" class="LineNr"> 26 </span> <span class="PreProc">break-if->=</span> +<span id="L27" class="LineNr"> 27 </span> <span class="Delimiter">{</span> +<span id="L28" class="LineNr"> 28 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> in-stream-addr +<span id="L29" class="LineNr"> 29 </span> compare g, <span class="Constant">0xffffffff</span>/end-of-file +<span id="L30" class="LineNr"> 30 </span> <span class="PreProc">break-if-=</span> $substring:core +<span id="L31" class="LineNr"> 31 </span> <a href='403unicode.mu.html#L176'>write-grapheme</a> out-stream-addr, g +<span id="L32" class="LineNr"> 32 </span> <span class="Delimiter">}</span> +<span id="L33" class="LineNr"> 33 </span> i <span class="SpecialChar"><-</span> increment +<span id="L34" class="LineNr"> 34 </span> <span class="PreProc">loop</span> +<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> <a href='310copy-bytes.subx.html#L60'>stream-to-array</a> out-stream-addr, out-ah +<span id="L38" class="LineNr"> 38 </span><span class="Delimiter">}</span> +<span id="L39" class="LineNr"> 39 </span> +<span id="L40" class="LineNr"> 40 </span><span class="PreProc">fn</span> <span class="muTest"><a href='411string.mu.html#L40'>test-substring</a></span> <span class="Delimiter">{</span> +<span id="L41" class="LineNr"> 41 </span> <span class="PreProc">var</span> out-h: (handle array byte) +<span id="L42" class="LineNr"> 42 </span> <span class="PreProc">var</span> out-ah/<span class="Constant">edi</span>: (addr handle array byte) <span class="SpecialChar"><-</span> address out-h +<span id="L43" class="LineNr"> 43 </span> <span class="muComment"># prefix substrings</span> +<span id="L44" class="LineNr"> 44 </span> <a href='411string.mu.html#L2'>substring</a> <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>, out-ah +<span id="L45" class="LineNr"> 45 </span> <span class="PreProc">var</span> out/<span class="Constant">eax</span>: (addr array byte) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *out-ah +<span id="L46" class="LineNr"> 46 </span> <a href='105string-equal.subx.html#L213'>check-strings-equal</a> out, <span class="Constant">""</span>, <span class="Constant">"F - <a href='411string.mu.html#L40'>test-substring</a>/null"</span> +<span id="L47" class="LineNr"> 47 </span> <a href='411string.mu.html#L2'>substring</a> <span class="Constant">""</span>, <span class="Constant">0</span>, <span class="Constant">3</span>, out-ah +<span id="L48" class="LineNr"> 48 </span> <span class="PreProc">var</span> out/<span class="Constant">eax</span>: (addr array byte) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *out-ah +<span id="L49" class="LineNr"> 49 </span><span class="CommentedCode">#? print-string-to-real-screen out</span> +<span id="L50" class="LineNr"> 50 </span><span class="CommentedCode">#? print-string-to-real-screen "\n"</span> +<span id="L51" class="LineNr"> 51 </span> <a href='105string-equal.subx.html#L213'>check-strings-equal</a> out, <span class="Constant">""</span>, <span class="Constant">"F - <a href='411string.mu.html#L40'>test-substring</a>/empty"</span> +<span id="L52" class="LineNr"> 52 </span> <span class="muComment">#</span> +<span id="L53" class="LineNr"> 53 </span> <a href='411string.mu.html#L2'>substring</a> <span class="Constant">"abcde"</span>, <span class="Constant">0</span>, <span class="Constant">3</span>, out-ah +<span id="L54" class="LineNr"> 54 </span> <span class="PreProc">var</span> out/<span class="Constant">eax</span>: (addr array byte) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *out-ah +<span id="L55" class="LineNr"> 55 </span><span class="CommentedCode">#? print-string-to-real-screen out</span> +<span id="L56" class="LineNr"> 56 </span><span class="CommentedCode">#? print-string-to-real-screen "\n"</span> +<span id="L57" class="LineNr"> 57 </span> <a href='105string-equal.subx.html#L213'>check-strings-equal</a> out, <span class="Constant">"abc"</span>, <span class="Constant">"F - <a href='411string.mu.html#L40'>test-substring</a>/truncate"</span> +<span id="L58" class="LineNr"> 58 </span> <span class="muComment">#</span> +<span id="L59" class="LineNr"> 59 </span> <a href='411string.mu.html#L2'>substring</a> <span class="Constant">"abcde"</span>, <span class="Constant">0</span>, <span class="Constant">5</span>, out-ah +<span id="L60" class="LineNr"> 60 </span> <span class="PreProc">var</span> out/<span class="Constant">eax</span>: (addr array byte) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *out-ah +<span id="L61" class="LineNr"> 61 </span> <a href='105string-equal.subx.html#L213'>check-strings-equal</a> out, <span class="Constant">"abcde"</span>, <span class="Constant">"F - <a href='411string.mu.html#L40'>test-substring</a>/all"</span> +<span id="L62" class="LineNr"> 62 </span> <span class="muComment">#</span> +<span id="L63" class="LineNr"> 63 </span> <a href='411string.mu.html#L2'>substring</a> <span class="Constant">"abcde"</span>, <span class="Constant">0</span>, <span class="Constant">7</span>, out-ah +<span id="L64" class="LineNr"> 64 </span> <span class="PreProc">var</span> out/<span class="Constant">eax</span>: (addr array byte) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *out-ah +<span id="L65" class="LineNr"> 65 </span> <a href='105string-equal.subx.html#L213'>check-strings-equal</a> out, <span class="Constant">"abcde"</span>, <span class="Constant">"F - <a href='411string.mu.html#L40'>test-substring</a>/too-small"</span> +<span id="L66" class="LineNr"> 66 </span> <span class="muComment"># substrings outside string</span> +<span id="L67" class="LineNr"> 67 </span> <a href='411string.mu.html#L2'>substring</a> <span class="Constant">"abcde"</span>, <span class="Constant">6</span>, <span class="Constant">1</span>, out-ah +<span id="L68" class="LineNr"> 68 </span> <span class="PreProc">var</span> out/<span class="Constant">eax</span>: (addr array byte) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *out-ah +<span id="L69" class="LineNr"> 69 </span> <a href='105string-equal.subx.html#L213'>check-strings-equal</a> out, <span class="Constant">""</span>, <span class="Constant">"F - <a href='411string.mu.html#L40'>test-substring</a>/start-too-large"</span> +<span id="L70" class="LineNr"> 70 </span> <span class="muComment"># trim prefix</span> +<span id="L71" class="LineNr"> 71 </span> <a href='411string.mu.html#L2'>substring</a> <span class="Constant">""</span>, <span class="Constant">2</span>, <span class="Constant">3</span>, out-ah +<span id="L72" class="LineNr"> 72 </span> <span class="PreProc">var</span> out/<span class="Constant">eax</span>: (addr array byte) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *out-ah +<span id="L73" class="LineNr"> 73 </span> <a href='105string-equal.subx.html#L213'>check-strings-equal</a> out, <span class="Constant">""</span>, <span class="Constant">"F - <a href='411string.mu.html#L40'>test-substring</a>/middle-empty"</span> +<span id="L74" class="LineNr"> 74 </span> <span class="muComment">#</span> +<span id="L75" class="LineNr"> 75 </span> <a href='411string.mu.html#L2'>substring</a> <span class="Constant">"abcde"</span>, <span class="Constant">1</span>, <span class="Constant">2</span>, out-ah +<span id="L76" class="LineNr"> 76 </span> <span class="PreProc">var</span> out/<span class="Constant">eax</span>: (addr array byte) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *out-ah +<span id="L77" class="LineNr"> 77 </span> <a href='105string-equal.subx.html#L213'>check-strings-equal</a> out, <span class="Constant">"bc"</span>, <span class="Constant">"F - <a href='411string.mu.html#L40'>test-substring</a>/middle-truncate"</span> +<span id="L78" class="LineNr"> 78 </span> <span class="muComment">#</span> +<span id="L79" class="LineNr"> 79 </span> <a href='411string.mu.html#L2'>substring</a> <span class="Constant">"abcde"</span>, <span class="Constant">1</span>, <span class="Constant">4</span>, out-ah +<span id="L80" class="LineNr"> 80 </span> <span class="PreProc">var</span> out/<span class="Constant">eax</span>: (addr array byte) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *out-ah +<span id="L81" class="LineNr"> 81 </span> <a href='105string-equal.subx.html#L213'>check-strings-equal</a> out, <span class="Constant">"bcde"</span>, <span class="Constant">"F - <a href='411string.mu.html#L40'>test-substring</a>/middle-all"</span> +<span id="L82" class="LineNr"> 82 </span> <span class="muComment">#</span> +<span id="L83" class="LineNr"> 83 </span> <a href='411string.mu.html#L2'>substring</a> <span class="Constant">"abcde"</span>, <span class="Constant">1</span>, <span class="Constant">5</span>, out-ah +<span id="L84" class="LineNr"> 84 </span> <span class="PreProc">var</span> out/<span class="Constant">eax</span>: (addr array byte) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *out-ah +<span id="L85" class="LineNr"> 85 </span> <a href='105string-equal.subx.html#L213'>check-strings-equal</a> out, <span class="Constant">"bcde"</span>, <span class="Constant">"F - <a href='411string.mu.html#L40'>test-substring</a>/middle-too-small"</span> +<span id="L86" class="LineNr"> 86 </span><span class="Delimiter">}</span> +<span id="L87" class="LineNr"> 87 </span> +<span id="L88" class="LineNr"> 88 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='411string.mu.html#L88'>split-string</a></span> in: (addr array byte), delim: grapheme, out: (addr handle array (handle array byte)) <span class="Delimiter">{</span> +<span id="L89" class="LineNr"> 89 </span> <span class="PreProc">var</span> in-stream: (stream byte <span class="Constant">0x100</span>) +<span id="L90" class="LineNr"> 90 </span> <span class="PreProc">var</span> in-stream-addr/<span class="Constant">esi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address in-stream +<span id="L91" class="LineNr"> 91 </span> <a href='108write.subx.html#L11'>write</a> in-stream-addr, in +<span id="L92" class="LineNr"> 92 </span> <span class="PreProc">var</span> tokens-stream: (stream (handle array byte) <span class="Constant">0x100</span>) +<span id="L93" class="LineNr"> 93 </span> <span class="PreProc">var</span> tokens-stream-addr/<span class="Constant">edi</span>: (addr stream (handle array byte)) <span class="SpecialChar"><-</span> address tokens-stream +<span id="L94" class="LineNr"> 94 </span> <span class="PreProc">var</span> curr-stream: (stream byte <span class="Constant">0x100</span>) +<span id="L95" class="LineNr"> 95 </span> <span class="PreProc">var</span> curr-stream-addr/<span class="Constant">ecx</span>: (addr stream byte) <span class="SpecialChar"><-</span> address curr-stream +<span id="L96" class="LineNr"> 96 </span> $split-string:core: <span class="Delimiter">{</span> +<span id="L97" class="LineNr"> 97 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> in-stream-addr +<span id="L98" class="LineNr"> 98 </span> compare g, <span class="Constant">0xffffffff</span> +<span id="L99" class="LineNr"> 99 </span> <span class="PreProc">break-if-=</span> +<span id="L100" class="LineNr">100 </span><span class="CommentedCode">#? print-grapheme-to-real-screen g</span> +<span id="L101" class="LineNr">101 </span><span class="CommentedCode">#? print-string-to-real-screen "\n"</span> +<span id="L102" class="LineNr">102 </span> compare g, delim +<span id="L103" class="LineNr">103 </span> <span class="Delimiter">{</span> +<span id="L104" class="LineNr">104 </span> <span class="PreProc">break-if-!=</span> +<span id="L105" class="LineNr">105 </span> <span class="muComment"># token complete; flush</span> +<span id="L106" class="LineNr">106 </span> <span class="PreProc">var</span> token: (handle array byte) +<span id="L107" class="LineNr">107 </span> <span class="PreProc">var</span> token-ah/<span class="Constant">eax</span>: (addr handle array byte) <span class="SpecialChar"><-</span> address token +<span id="L108" class="LineNr">108 </span> <a href='310copy-bytes.subx.html#L60'>stream-to-array</a> curr-stream-addr, token-ah +<span id="L109" class="LineNr">109 </span> <a href='309stream.subx.html#L54'>write-to-stream</a> tokens-stream-addr, token-ah +<span id="L110" class="LineNr">110 </span> <a href='106stream.subx.html#L20'>clear-stream</a> curr-stream-addr +<span id="L111" class="LineNr">111 </span> <span class="PreProc">loop</span> $split-string:core +<span id="L112" class="LineNr">112 </span> <span class="Delimiter">}</span> +<span id="L113" class="LineNr">113 </span> <a href='403unicode.mu.html#L176'>write-grapheme</a> curr-stream-addr, g +<span id="L114" class="LineNr">114 </span> <span class="PreProc">loop</span> +<span id="L115" class="LineNr">115 </span> <span class="Delimiter">}</span> +<span id="L116" class="LineNr">116 </span> <a href='310copy-bytes.subx.html#L60'>stream-to-array</a> tokens-stream-addr, out +<span id="L117" class="LineNr">117 </span><span class="Delimiter">}</span> +<span id="L118" class="LineNr">118 </span> +<span id="L119" class="LineNr">119 </span><span class="PreProc">fn</span> <span class="muTest"><a href='411string.mu.html#L119'>test-split-string</a></span> <span class="Delimiter">{</span> +<span id="L120" class="LineNr">120 </span> <span class="PreProc">var</span> out-h: (handle array (handle array byte)) +<span id="L121" class="LineNr">121 </span> <span class="PreProc">var</span> out-ah/<span class="Constant">edi</span>: (addr handle array (handle array byte)) <span class="SpecialChar"><-</span> address out-h +<span id="L122" class="LineNr">122 </span> <span class="muComment"># prefix substrings</span> +<span id="L123" class="LineNr">123 </span> <a href='411string.mu.html#L88'>split-string</a> <span class="Constant">"bab"</span>, <span class="Constant">0x61</span>, out-ah +<span id="L124" class="LineNr">124 </span> <span class="muComment"># no crash</span> +<span id="L125" class="LineNr">125 </span><span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/baremetal/412render-float-decimal.mu.html b/html/baremetal/412render-float-decimal.mu.html new file mode 100644 index 00000000..4bcbefd7 --- /dev/null +++ b/html/baremetal/412render-float-decimal.mu.html @@ -0,0 +1,667 @@ +<!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 - baremetal/412render-float-decimal.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: #c6c6c6; } +body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } +a { color:inherit; } +* { font-size:12pt; font-size: 1em; } +.PreProc { color: #c000c0; } +.LineNr { } +.Constant { color: #008787; } +.SpecialChar { color: #d70000; } +.Delimiter { color: #c000c0; } +.muFunction { color: #af5f00; text-decoration: underline; } +.muTest { color: #5f8700; } +.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/baremetal/412render-float-decimal.mu'>https://github.com/akkartik/mu/blob/main/baremetal/412render-float-decimal.mu</a> +<pre id='vimCodeElement'> +<span id="L1" class="LineNr"> 1 </span><span class="muComment"># print out floats in decimal</span> +<span id="L2" class="LineNr"> 2 </span><span class="muComment"># <a href="https://research.swtch.com/ftoa">https://research.swtch.com/ftoa</a></span> +<span id="L3" class="LineNr"> 3 </span><span class="muComment">#</span> +<span id="L4" class="LineNr"> 4 </span><span class="muComment"># Basic idea:</span> +<span id="L5" class="LineNr"> 5 </span><span class="muComment"># Ignoring sign, floating point numbers are represented as 1.mantissa * 2^exponent</span> +<span id="L6" class="LineNr"> 6 </span><span class="muComment"># Therefore, to print a float in decimal, we need to:</span> +<span id="L7" class="LineNr"> 7 </span><span class="muComment"># - compute its value without decimal point</span> +<span id="L8" class="LineNr"> 8 </span><span class="muComment"># - convert to an array of decimal digits</span> +<span id="L9" class="LineNr"> 9 </span><span class="muComment"># - print out the array while inserting the decimal point appropriately</span> +<span id="L10" class="LineNr"> 10 </span><span class="muComment">#</span> +<span id="L11" class="LineNr"> 11 </span><span class="muComment"># Basic complication: the computation generates numbers larger than an int can</span> +<span id="L12" class="LineNr"> 12 </span><span class="muComment"># hold. We need a way to represent big ints.</span> +<span id="L13" class="LineNr"> 13 </span><span class="muComment">#</span> +<span id="L14" class="LineNr"> 14 </span><span class="muComment"># Key insight: use a representation for big ints that's close to what we need</span> +<span id="L15" class="LineNr"> 15 </span><span class="muComment"># anyway, an array of decimal digits.</span> +<span id="L16" class="LineNr"> 16 </span><span class="muComment">#</span> +<span id="L17" class="LineNr"> 17 </span><span class="muComment"># Style note: we aren't creating a big int library here. The only operations</span> +<span id="L18" class="LineNr"> 18 </span><span class="muComment"># we need are halving and doubling. Following the link above, it seems more</span> +<span id="L19" class="LineNr"> 19 </span><span class="muComment"># comprehensible to keep these operations inlined so that we can track the</span> +<span id="L20" class="LineNr"> 20 </span><span class="muComment"># position of the decimal point with dispatch.</span> +<span id="L21" class="LineNr"> 21 </span><span class="muComment">#</span> +<span id="L22" class="LineNr"> 22 </span><span class="muComment"># This approach turns out to be fast enough for most purposes.</span> +<span id="L23" class="LineNr"> 23 </span><span class="muComment"># Optimizations, however, get wildly more complex.</span> +<span id="L24" class="LineNr"> 24 </span> +<span id="L25" class="LineNr"> 25 </span><span class="PreProc">fn</span> <span class="muTest"><a href='412render-float-decimal.mu.html#L25'>test-render-float-decimal-normal</a></span> <span class="Delimiter">{</span> +<span id="L26" class="LineNr"> 26 </span> <span class="PreProc">var</span> screen-on-stack: <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L27" class="LineNr"> 27 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> address screen-on-stack +<span id="L28" class="LineNr"> 28 </span> <a href='500text-screen.mu.html#L23'>initialize-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x20</span>, <span class="Constant">5</span> <span class="muComment"># 32 columns should be more than enough</span> +<span id="L29" class="LineNr"> 29 </span> <span class="muComment"># 0.5</span> +<span id="L30" class="LineNr"> 30 </span> <span class="PreProc">var</span> half/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> <a href='408float.mu.html#L18'>rational</a> <span class="Constant">1</span>, <span class="Constant">2</span> +<span id="L31" class="LineNr"> 31 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, half, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L32" class="LineNr"> 32 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"0.5 "</span>, <span class="Constant">"F - <a href='412render-float-decimal.mu.html#L25'>test-render-float-decimal-normal</a> 0.5"</span> +<span id="L33" class="LineNr"> 33 </span> <span class="muComment"># 0.25</span> +<span id="L34" class="LineNr"> 34 </span> <a href='500text-screen.mu.html#L194'>clear-screen</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L35" class="LineNr"> 35 </span> <span class="PreProc">var</span> quarter/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> <a href='408float.mu.html#L18'>rational</a> <span class="Constant">1</span>, <span class="Constant">4</span> +<span id="L36" class="LineNr"> 36 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, quarter, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L37" class="LineNr"> 37 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"0.25 "</span>, <span class="Constant">"F - <a href='412render-float-decimal.mu.html#L25'>test-render-float-decimal-normal</a> 0.25"</span> +<span id="L38" class="LineNr"> 38 </span> <span class="muComment"># 0.75</span> +<span id="L39" class="LineNr"> 39 </span> <a href='500text-screen.mu.html#L194'>clear-screen</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L40" class="LineNr"> 40 </span> <span class="PreProc">var</span> three-quarters/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> <a href='408float.mu.html#L18'>rational</a> <span class="Constant">3</span>, <span class="Constant">4</span> +<span id="L41" class="LineNr"> 41 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, three-quarters, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L42" class="LineNr"> 42 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"0.75 "</span>, <span class="Constant">"F - <a href='412render-float-decimal.mu.html#L25'>test-render-float-decimal-normal</a> 0.75"</span> +<span id="L43" class="LineNr"> 43 </span> <span class="muComment"># 0.125</span> +<span id="L44" class="LineNr"> 44 </span> <a href='500text-screen.mu.html#L194'>clear-screen</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L45" class="LineNr"> 45 </span> <span class="PreProc">var</span> eighth/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> <a href='408float.mu.html#L18'>rational</a> <span class="Constant">1</span>, <span class="Constant">8</span> +<span id="L46" class="LineNr"> 46 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, eighth, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L47" class="LineNr"> 47 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"0.125 "</span>, <span class="Constant">"F - <a href='412render-float-decimal.mu.html#L25'>test-render-float-decimal-normal</a> 0.125"</span> +<span id="L48" class="LineNr"> 48 </span> <span class="muComment"># 0.0625; start using scientific notation</span> +<span id="L49" class="LineNr"> 49 </span> <a href='500text-screen.mu.html#L194'>clear-screen</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L50" class="LineNr"> 50 </span> <span class="PreProc">var</span> sixteenth/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> <a href='408float.mu.html#L18'>rational</a> <span class="Constant">1</span>, <span class="Constant">0x10</span> +<span id="L51" class="LineNr"> 51 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, sixteenth, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L52" class="LineNr"> 52 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"6.25e-2 "</span>, <span class="Constant">"F - <a href='412render-float-decimal.mu.html#L25'>test-render-float-decimal-normal</a> 0.0625"</span> +<span id="L53" class="LineNr"> 53 </span> <span class="muComment"># sqrt(2); truncate floats with lots of digits after the decimal but not too many before</span> +<span id="L54" class="LineNr"> 54 </span> <a href='500text-screen.mu.html#L194'>clear-screen</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L55" class="LineNr"> 55 </span> <span class="PreProc">var</span> two-f/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> <a href='408float.mu.html#L18'>rational</a> <span class="Constant">2</span>, <span class="Constant">1</span> +<span id="L56" class="LineNr"> 56 </span> <span class="PreProc">var</span> sqrt-2/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> square-root two-f +<span id="L57" class="LineNr"> 57 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, sqrt-2, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L58" class="LineNr"> 58 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"1.414 "</span>, <span class="Constant">"F - <a href='412render-float-decimal.mu.html#L25'>test-render-float-decimal-normal</a> √2"</span> +<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="muComment"># print whole integers without decimals</span> +<span id="L62" class="LineNr"> 62 </span><span class="PreProc">fn</span> <span class="muTest"><a href='412render-float-decimal.mu.html#L62'>test-render-float-decimal-integer</a></span> <span class="Delimiter">{</span> +<span id="L63" class="LineNr"> 63 </span> <span class="PreProc">var</span> screen-on-stack: <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L64" class="LineNr"> 64 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> address screen-on-stack +<span id="L65" class="LineNr"> 65 </span> <a href='500text-screen.mu.html#L23'>initialize-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x20</span>, <span class="Constant">5</span> <span class="muComment"># 32 columns should be more than enough</span> +<span id="L66" class="LineNr"> 66 </span> <span class="muComment"># 1</span> +<span id="L67" class="LineNr"> 67 </span> <span class="PreProc">var</span> one-f/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> <a href='408float.mu.html#L18'>rational</a> <span class="Constant">1</span>, <span class="Constant">1</span> +<span id="L68" class="LineNr"> 68 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, one-f, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L69" class="LineNr"> 69 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"1 "</span>, <span class="Constant">"F - <a href='412render-float-decimal.mu.html#L62'>test-render-float-decimal-integer</a> 1"</span> +<span id="L70" class="LineNr"> 70 </span> <span class="muComment"># 2</span> +<span id="L71" class="LineNr"> 71 </span> <a href='500text-screen.mu.html#L194'>clear-screen</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L72" class="LineNr"> 72 </span> <span class="PreProc">var</span> two-f/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> <a href='408float.mu.html#L18'>rational</a> <span class="Constant">2</span>, <span class="Constant">1</span> +<span id="L73" class="LineNr"> 73 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, two-f, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L74" class="LineNr"> 74 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"2 "</span>, <span class="Constant">"F - <a href='412render-float-decimal.mu.html#L62'>test-render-float-decimal-integer</a> 2"</span> +<span id="L75" class="LineNr"> 75 </span> <span class="muComment"># 10</span> +<span id="L76" class="LineNr"> 76 </span> <a href='500text-screen.mu.html#L194'>clear-screen</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L77" class="LineNr"> 77 </span> <span class="PreProc">var</span> ten-f/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> <a href='408float.mu.html#L18'>rational</a> <span class="Constant">0xa</span>, <span class="Constant">1</span> +<span id="L78" class="LineNr"> 78 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, ten-f, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L79" class="LineNr"> 79 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"10 "</span>, <span class="Constant">"F - <a href='412render-float-decimal.mu.html#L62'>test-render-float-decimal-integer</a> 10"</span> +<span id="L80" class="LineNr"> 80 </span> <span class="muComment"># -10</span> +<span id="L81" class="LineNr"> 81 </span> <a href='500text-screen.mu.html#L194'>clear-screen</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L82" class="LineNr"> 82 </span> <span class="PreProc">var</span> minus-ten-f/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> <a href='408float.mu.html#L18'>rational</a> <span class="Constant">-0xa</span>, <span class="Constant">1</span> +<span id="L83" class="LineNr"> 83 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, minus-ten-f, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L84" class="LineNr"> 84 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"-10 "</span>, <span class="Constant">"F - <a href='412render-float-decimal.mu.html#L62'>test-render-float-decimal-integer</a> -10"</span> +<span id="L85" class="LineNr"> 85 </span> <span class="muComment"># 999</span> +<span id="L86" class="LineNr"> 86 </span> <a href='500text-screen.mu.html#L194'>clear-screen</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L87" class="LineNr"> 87 </span> <span class="PreProc">var</span> minus-ten-f/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> <a href='408float.mu.html#L18'>rational</a> <span class="Constant">0x3e7</span>, <span class="Constant">1</span> +<span id="L88" class="LineNr"> 88 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, minus-ten-f, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L89" class="LineNr"> 89 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"999 "</span>, <span class="Constant">"F - <a href='412render-float-decimal.mu.html#L62'>test-render-float-decimal-integer</a> 1000"</span> +<span id="L90" class="LineNr"> 90 </span> <span class="muComment"># 1000 - start using scientific notation</span> +<span id="L91" class="LineNr"> 91 </span> <a href='500text-screen.mu.html#L194'>clear-screen</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L92" class="LineNr"> 92 </span> <span class="PreProc">var</span> minus-ten-f/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> <a href='408float.mu.html#L18'>rational</a> <span class="Constant">0x3e8</span>, <span class="Constant">1</span> +<span id="L93" class="LineNr"> 93 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, minus-ten-f, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L94" class="LineNr"> 94 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"1.00e3 "</span>, <span class="Constant">"F - <a href='412render-float-decimal.mu.html#L62'>test-render-float-decimal-integer</a> 1000"</span> +<span id="L95" class="LineNr"> 95 </span> <span class="muComment"># 100,000</span> +<span id="L96" class="LineNr"> 96 </span> <a href='500text-screen.mu.html#L194'>clear-screen</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L97" class="LineNr"> 97 </span> <span class="PreProc">var</span> hundred-thousand/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0x186a0</span> +<span id="L98" class="LineNr"> 98 </span> <span class="PreProc">var</span> hundred-thousand-f/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> convert hundred-thousand +<span id="L99" class="LineNr"> 99 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, hundred-thousand-f, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L100" class="LineNr">100 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"1.00e5 "</span>, <span class="Constant">"F - <a href='412render-float-decimal.mu.html#L62'>test-render-float-decimal-integer</a> 100,000"</span> +<span id="L101" class="LineNr">101 </span><span class="Delimiter">}</span> +<span id="L102" class="LineNr">102 </span> +<span id="L103" class="LineNr">103 </span><span class="PreProc">fn</span> <span class="muTest"><a href='412render-float-decimal.mu.html#L103'>test-render-float-decimal-zero</a></span> <span class="Delimiter">{</span> +<span id="L104" class="LineNr">104 </span> <span class="PreProc">var</span> screen-on-stack: <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L105" class="LineNr">105 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> address screen-on-stack +<span id="L106" class="LineNr">106 </span> <a href='500text-screen.mu.html#L23'>initialize-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x20</span>, <span class="Constant">5</span> <span class="muComment"># 32 columns should be more than enough</span> +<span id="L107" class="LineNr">107 </span> <span class="PreProc">var</span> zero: float +<span id="L108" class="LineNr">108 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, zero, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L109" class="LineNr">109 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"0 "</span>, <span class="Constant">"F - test-render-float-decimal-zero"</span> +<span id="L110" class="LineNr">110 </span><span class="Delimiter">}</span> +<span id="L111" class="LineNr">111 </span> +<span id="L112" class="LineNr">112 </span><span class="PreProc">fn</span> <span class="muTest"><a href='412render-float-decimal.mu.html#L112'>test-render-float-decimal-negative-zero</a></span> <span class="Delimiter">{</span> +<span id="L113" class="LineNr">113 </span> <span class="PreProc">var</span> screen-on-stack: <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L114" class="LineNr">114 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> address screen-on-stack +<span id="L115" class="LineNr">115 </span> <a href='500text-screen.mu.html#L23'>initialize-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x20</span>, <span class="Constant">5</span> <span class="muComment"># 32 columns should be more than enough</span> +<span id="L116" class="LineNr">116 </span> <span class="PreProc">var</span> n: int +<span id="L117" class="LineNr">117 </span> copy-to n, <span class="Constant">0x80000000</span> +<span id="L118" class="LineNr">118 </span> <span class="PreProc">var</span> negative-zero/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> reinterpret n +<span id="L119" class="LineNr">119 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, negative-zero, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L120" class="LineNr">120 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"-0 "</span>, <span class="Constant">"F - test-render-float-decimal-negative-zero"</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="muTest"><a href='412render-float-decimal.mu.html#L123'>test-render-float-decimal-infinity</a></span> <span class="Delimiter">{</span> +<span id="L124" class="LineNr">124 </span> <span class="PreProc">var</span> screen-on-stack: <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L125" class="LineNr">125 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> address screen-on-stack +<span id="L126" class="LineNr">126 </span> <a href='500text-screen.mu.html#L23'>initialize-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x20</span>, <span class="Constant">5</span> <span class="muComment"># 32 columns should be more than enough</span> +<span id="L127" class="LineNr">127 </span> <span class="PreProc">var</span> n: int +<span id="L128" class="LineNr">128 </span> <span class="muComment"># 0|11111111|00000000000000000000000</span> +<span id="L129" class="LineNr">129 </span> <span class="muComment"># 0111|1111|1000|0000|0000|0000|0000|0000</span> +<span id="L130" class="LineNr">130 </span> copy-to n, <span class="Constant">0x7f800000</span> +<span id="L131" class="LineNr">131 </span> <span class="PreProc">var</span> infinity/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> reinterpret n +<span id="L132" class="LineNr">132 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, infinity, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L133" class="LineNr">133 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"Inf "</span>, <span class="Constant">"F - test-render-float-decimal-infinity"</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="muTest"><a href='412render-float-decimal.mu.html#L136'>test-render-float-decimal-negative-infinity</a></span> <span class="Delimiter">{</span> +<span id="L137" class="LineNr">137 </span> <span class="PreProc">var</span> screen-on-stack: <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L138" class="LineNr">138 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> address screen-on-stack +<span id="L139" class="LineNr">139 </span> <a href='500text-screen.mu.html#L23'>initialize-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x20</span>, <span class="Constant">5</span> <span class="muComment"># 32 columns should be more than enough</span> +<span id="L140" class="LineNr">140 </span> <span class="PreProc">var</span> n: int +<span id="L141" class="LineNr">141 </span> copy-to n, <span class="Constant">0xff800000</span> +<span id="L142" class="LineNr">142 </span> <span class="PreProc">var</span> negative-infinity/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> reinterpret n +<span id="L143" class="LineNr">143 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, negative-infinity, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L144" class="LineNr">144 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"-Inf "</span>, <span class="Constant">"F - test-render-float-decimal-negative-infinity"</span> +<span id="L145" class="LineNr">145 </span><span class="Delimiter">}</span> +<span id="L146" class="LineNr">146 </span> +<span id="L147" class="LineNr">147 </span><span class="PreProc">fn</span> <span class="muTest"><a href='412render-float-decimal.mu.html#L147'>test-render-float-decimal-not-a-number</a></span> <span class="Delimiter">{</span> +<span id="L148" class="LineNr">148 </span> <span class="PreProc">var</span> screen-on-stack: <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L149" class="LineNr">149 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> address screen-on-stack +<span id="L150" class="LineNr">150 </span> <a href='500text-screen.mu.html#L23'>initialize-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x20</span>, <span class="Constant">5</span> <span class="muComment"># 32 columns should be more than enough</span> +<span id="L151" class="LineNr">151 </span> <span class="PreProc">var</span> n: int +<span id="L152" class="LineNr">152 </span> copy-to n, <span class="Constant">0xffffffff</span> <span class="muComment"># exponent must be all 1's, and mantissa must be non-zero</span> +<span id="L153" class="LineNr">153 </span> <span class="PreProc">var</span> nan/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> reinterpret n +<span id="L154" class="LineNr">154 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a> <a href='500text-screen.mu.html#L9'>screen</a>, nan, <span class="Constant">3</span>/precision, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">3</span>/fg, <span class="Constant">0</span>/bg +<span id="L155" class="LineNr">155 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"NaN "</span>, <span class="Constant">"F - test-render-float-decimal-not-a-number"</span> +<span id="L156" class="LineNr">156 </span><span class="Delimiter">}</span> +<span id="L157" class="LineNr">157 </span> +<span id="L158" class="LineNr">158 </span><span class="muComment"># 'precision' controls the maximum width past which we resort to scientific notation</span> +<span id="L159" class="LineNr">159 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='412render-float-decimal.mu.html#L159'>render-float-decimal</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), in: float, precision: int, x: int, y: int, color: int, background-color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L160" class="LineNr">160 </span> <span class="muComment"># - special names</span> +<span id="L161" class="LineNr">161 </span> <span class="PreProc">var</span> bits/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> reinterpret in +<span id="L162" class="LineNr">162 </span> compare bits, <span class="Constant">0</span> +<span id="L163" class="LineNr">163 </span> <span class="Delimiter">{</span> +<span id="L164" class="LineNr">164 </span> <span class="PreProc">break-if-!=</span> +<span id="L165" class="LineNr">165 </span> <span class="PreProc">var</span> new-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L116'>draw-text-rightward-over-full-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">"0"</span>, x, y, color, background-color +<span id="L166" class="LineNr">166 </span> <span class="PreProc">return</span> new-x +<span id="L167" class="LineNr">167 </span> <span class="Delimiter">}</span> +<span id="L168" class="LineNr">168 </span> compare bits, <span class="Constant">0x80000000</span> +<span id="L169" class="LineNr">169 </span> <span class="Delimiter">{</span> +<span id="L170" class="LineNr">170 </span> <span class="PreProc">break-if-!=</span> +<span id="L171" class="LineNr">171 </span> <span class="PreProc">var</span> new-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L116'>draw-text-rightward-over-full-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">"-0"</span>, x, y, color, background-color +<span id="L172" class="LineNr">172 </span> <span class="PreProc">return</span> new-x +<span id="L173" class="LineNr">173 </span> <span class="Delimiter">}</span> +<span id="L174" class="LineNr">174 </span> compare bits, <span class="Constant">0x7f800000</span> +<span id="L175" class="LineNr">175 </span> <span class="Delimiter">{</span> +<span id="L176" class="LineNr">176 </span> <span class="PreProc">break-if-!=</span> +<span id="L177" class="LineNr">177 </span> <span class="PreProc">var</span> new-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L116'>draw-text-rightward-over-full-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">"Inf"</span>, x, y, color, background-color +<span id="L178" class="LineNr">178 </span> <span class="PreProc">return</span> new-x +<span id="L179" class="LineNr">179 </span> <span class="Delimiter">}</span> +<span id="L180" class="LineNr">180 </span> compare bits, <span class="Constant">0xff800000</span> +<span id="L181" class="LineNr">181 </span> <span class="Delimiter">{</span> +<span id="L182" class="LineNr">182 </span> <span class="PreProc">break-if-!=</span> +<span id="L183" class="LineNr">183 </span> <span class="PreProc">var</span> new-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L116'>draw-text-rightward-over-full-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">"-Inf"</span>, x, y, color, background-color +<span id="L184" class="LineNr">184 </span> <span class="PreProc">return</span> new-x +<span id="L185" class="LineNr">185 </span> <span class="Delimiter">}</span> +<span id="L186" class="LineNr">186 </span> <span class="PreProc">var</span> exponent/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy bits +<span id="L187" class="LineNr">187 </span> exponent <span class="SpecialChar"><-</span> shift-right <span class="Constant">0x17</span> <span class="muComment"># 23 bits of mantissa</span> +<span id="L188" class="LineNr">188 </span> exponent <span class="SpecialChar"><-</span> and <span class="Constant">0xff</span> +<span id="L189" class="LineNr">189 </span> exponent <span class="SpecialChar"><-</span> subtract <span class="Constant">0x7f</span> +<span id="L190" class="LineNr">190 </span> compare exponent, <span class="Constant">0x80</span> +<span id="L191" class="LineNr">191 </span> <span class="Delimiter">{</span> +<span id="L192" class="LineNr">192 </span> <span class="PreProc">break-if-!=</span> +<span id="L193" class="LineNr">193 </span> <span class="PreProc">var</span> new-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L116'>draw-text-rightward-over-full-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">"NaN"</span>, x, y, color, background-color +<span id="L194" class="LineNr">194 </span> <span class="PreProc">return</span> new-x +<span id="L195" class="LineNr">195 </span> <span class="Delimiter">}</span> +<span id="L196" class="LineNr">196 </span> <span class="muComment"># - regular numbers</span> +<span id="L197" class="LineNr">197 </span> <span class="PreProc">var</span> sign/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy bits +<span id="L198" class="LineNr">198 </span> sign <span class="SpecialChar"><-</span> shift-right <span class="Constant">0x1f</span> +<span id="L199" class="LineNr">199 </span> <span class="Delimiter">{</span> +<span id="L200" class="LineNr">200 </span> compare sign, <span class="Constant">1</span> +<span id="L201" class="LineNr">201 </span> <span class="PreProc">break-if-!=</span> +<span id="L202" class="LineNr">202 </span> <a href='500text-screen.mu.html#L94'>draw-code-point</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x2d</span>/minus, x, y, color, background-color +<span id="L203" class="LineNr">203 </span> increment x +<span id="L204" class="LineNr">204 </span> <span class="Delimiter">}</span> +<span id="L205" class="LineNr">205 </span> +<span id="L206" class="LineNr">206 </span> <span class="muComment"># v = 1.mantissa (in base 2) << 0x17</span> +<span id="L207" class="LineNr">207 </span> <span class="PreProc">var</span> v/<span class="Constant">ebx</span>: int <span class="SpecialChar"><-</span> copy bits +<span id="L208" class="LineNr">208 </span> v <span class="SpecialChar"><-</span> and <span class="Constant">0x7fffff</span> +<span id="L209" class="LineNr">209 </span> v <span class="SpecialChar"><-</span> or <span class="Constant">0x00800000</span> <span class="muComment"># insert implicit 1</span> +<span id="L210" class="LineNr">210 </span> <span class="muComment"># e = exponent - 0x17</span> +<span id="L211" class="LineNr">211 </span> <span class="PreProc">var</span> e/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy exponent +<span id="L212" class="LineNr">212 </span> e <span class="SpecialChar"><-</span> subtract <span class="Constant">0x17</span> <span class="muComment"># move decimal place from before mantissa to after</span> +<span id="L213" class="LineNr">213 </span> +<span id="L214" class="LineNr">214 </span> <span class="muComment"># initialize buffer with decimal representation of v</span> +<span id="L215" class="LineNr">215 </span> <span class="muComment"># unlike <a href="https://research.swtch.com/ftoa">https://research.swtch.com/ftoa</a>, no ascii here</span> +<span id="L216" class="LineNr">216 </span> <span class="PreProc">var</span> buf-storage: (array byte <span class="Constant">0x7f</span>) +<span id="L217" class="LineNr">217 </span> <span class="PreProc">var</span> buf/<span class="Constant">edi</span>: (addr array byte) <span class="SpecialChar"><-</span> address buf-storage +<span id="L218" class="LineNr">218 </span> <span class="PreProc">var</span> n/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L249'>decimal-digits</a> v, buf +<span id="L219" class="LineNr">219 </span> <span class="muComment"># I suspect we can do without reversing, but we'll follow <a href="https://research.swtch.com/ftoa">https://research.swtch.com/ftoa</a></span> +<span id="L220" class="LineNr">220 </span> <span class="muComment"># closely for now.</span> +<span id="L221" class="LineNr">221 </span> <a href='412render-float-decimal.mu.html#L266'>reverse-digits</a> buf, n +<span id="L222" class="LineNr">222 </span> +<span id="L223" class="LineNr">223 </span> <span class="muComment"># loop if e > 0</span> +<span id="L224" class="LineNr">224 </span> <span class="Delimiter">{</span> +<span id="L225" class="LineNr">225 </span> compare e, <span class="Constant">0</span> +<span id="L226" class="LineNr">226 </span> <span class="PreProc">break-if-<=</span> +<span id="L227" class="LineNr">227 </span> n <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L288'>double-array-of-decimal-digits</a> buf, n +<span id="L228" class="LineNr">228 </span> e <span class="SpecialChar"><-</span> decrement +<span id="L229" class="LineNr">229 </span> <span class="PreProc">loop</span> +<span id="L230" class="LineNr">230 </span> <span class="Delimiter">}</span> +<span id="L231" class="LineNr">231 </span> +<span id="L232" class="LineNr">232 </span> <span class="PreProc">var</span> dp/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy n +<span id="L233" class="LineNr">233 </span> +<span id="L234" class="LineNr">234 </span> <span class="muComment"># loop if e < 0</span> +<span id="L235" class="LineNr">235 </span> <span class="Delimiter">{</span> +<span id="L236" class="LineNr">236 </span> compare e, <span class="Constant">0</span> +<span id="L237" class="LineNr">237 </span> <span class="PreProc">break-if->=</span> +<span id="L238" class="LineNr">238 </span> n, dp <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L339'>halve-array-of-decimal-digits</a> buf, n, dp +<span id="L239" class="LineNr">239 </span> e <span class="SpecialChar"><-</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 id="L243" class="LineNr">243 </span> <span class="PreProc">var</span> new-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L413'>render-float-buffer</a> <a href='500text-screen.mu.html#L9'>screen</a>, buf, n, dp, precision, x, y, color, background-color +<span id="L244" class="LineNr">244 </span> <span class="PreProc">return</span> new-x +<span id="L245" class="LineNr">245 </span><span class="Delimiter">}</span> +<span id="L246" class="LineNr">246 </span> +<span id="L247" class="LineNr">247 </span><span class="muComment"># store the decimal digits of 'n' into 'buf', units first</span> +<span id="L248" class="LineNr">248 </span><span class="muComment"># n must be positive</span> +<span id="L249" class="LineNr">249 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='412render-float-decimal.mu.html#L249'>decimal-digits</a></span> n: int, _buf: (addr array byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L250" class="LineNr">250 </span> <span class="PreProc">var</span> buf/<span class="Constant">edi</span>: (addr array byte) <span class="SpecialChar"><-</span> copy _buf +<span id="L251" class="LineNr">251 </span> <span class="PreProc">var</span> i/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L252" class="LineNr">252 </span> <span class="PreProc">var</span> curr/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy n +<span id="L253" class="LineNr">253 </span> <span class="PreProc">var</span> curr-byte/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L254" class="LineNr">254 </span> <span class="Delimiter">{</span> +<span id="L255" class="LineNr">255 </span> compare curr, <span class="Constant">0</span> +<span id="L256" class="LineNr">256 </span> <span class="PreProc">break-if-=</span> +<span id="L257" class="LineNr">257 </span> curr, curr-byte <span class="SpecialChar"><-</span> <a href='314divide.subx.html#L3'>integer-divide</a> curr, <span class="Constant">0xa</span> +<span id="L258" class="LineNr">258 </span> <span class="PreProc">var</span> dest/<span class="Constant">ebx</span>: (addr byte) <span class="SpecialChar"><-</span> index buf, i +<span id="L259" class="LineNr">259 </span> copy-byte-to *dest, curr-byte +<span id="L260" class="LineNr">260 </span> i <span class="SpecialChar"><-</span> increment +<span id="L261" class="LineNr">261 </span> <span class="PreProc">loop</span> +<span id="L262" class="LineNr">262 </span> <span class="Delimiter">}</span> +<span id="L263" class="LineNr">263 </span> <span class="PreProc">return</span> i +<span id="L264" class="LineNr">264 </span><span class="Delimiter">}</span> +<span id="L265" class="LineNr">265 </span> +<span id="L266" class="LineNr">266 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='412render-float-decimal.mu.html#L266'>reverse-digits</a></span> _buf: (addr array byte), n: int <span class="Delimiter">{</span> +<span id="L267" class="LineNr">267 </span> <span class="PreProc">var</span> buf/<span class="Constant">esi</span>: (addr array byte) <span class="SpecialChar"><-</span> copy _buf +<span id="L268" class="LineNr">268 </span> <span class="PreProc">var</span> left/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L269" class="LineNr">269 </span> <span class="PreProc">var</span> right/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy n +<span id="L270" class="LineNr">270 </span> right <span class="SpecialChar"><-</span> decrement +<span id="L271" class="LineNr">271 </span> <span class="Delimiter">{</span> +<span id="L272" class="LineNr">272 </span> compare left, right +<span id="L273" class="LineNr">273 </span> <span class="PreProc">break-if->=</span> +<span id="L274" class="LineNr">274 </span> <span class="Delimiter">{</span> +<span id="L275" class="LineNr">275 </span> <span class="PreProc">var</span> l-a/<span class="Constant">ecx</span>: (addr byte) <span class="SpecialChar"><-</span> index buf, left +<span id="L276" class="LineNr">276 </span> <span class="PreProc">var</span> r-a/<span class="Constant">edx</span>: (addr byte) <span class="SpecialChar"><-</span> index buf, right +<span id="L277" class="LineNr">277 </span> <span class="PreProc">var</span> l/<span class="Constant">ebx</span>: byte <span class="SpecialChar"><-</span> copy-byte *l-a +<span id="L278" class="LineNr">278 </span> <span class="PreProc">var</span> r/<span class="Constant">eax</span>: byte <span class="SpecialChar"><-</span> copy-byte *r-a +<span id="L279" class="LineNr">279 </span> copy-byte-to *l-a, r +<span id="L280" class="LineNr">280 </span> copy-byte-to *r-a, l +<span id="L281" class="LineNr">281 </span> <span class="Delimiter">}</span> +<span id="L282" class="LineNr">282 </span> left <span class="SpecialChar"><-</span> increment +<span id="L283" class="LineNr">283 </span> right <span class="SpecialChar"><-</span> decrement +<span id="L284" class="LineNr">284 </span> <span class="PreProc">loop</span> +<span id="L285" class="LineNr">285 </span> <span class="Delimiter">}</span> +<span id="L286" class="LineNr">286 </span><span class="Delimiter">}</span> +<span id="L287" class="LineNr">287 </span> +<span id="L288" class="LineNr">288 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='412render-float-decimal.mu.html#L288'>double-array-of-decimal-digits</a></span> _buf: (addr array byte), _n: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L289" class="LineNr">289 </span> <span class="PreProc">var</span> buf/<span class="Constant">edi</span>: (addr array byte) <span class="SpecialChar"><-</span> copy _buf +<span id="L290" class="LineNr">290 </span> <span class="muComment"># initialize delta</span> +<span id="L291" class="LineNr">291 </span> <span class="PreProc">var</span> delta/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L292" class="LineNr">292 </span> <span class="Delimiter">{</span> +<span id="L293" class="LineNr">293 </span> <span class="PreProc">var</span> curr/<span class="Constant">ebx</span>: (addr byte) <span class="SpecialChar"><-</span> index buf, <span class="Constant">0</span> +<span id="L294" class="LineNr">294 </span> <span class="PreProc">var</span> tmp/<span class="Constant">eax</span>: byte <span class="SpecialChar"><-</span> copy-byte *curr +<span id="L295" class="LineNr">295 </span> compare tmp, <span class="Constant">5</span> +<span id="L296" class="LineNr">296 </span> <span class="PreProc">break-if-<</span> +<span id="L297" class="LineNr">297 </span> delta <span class="SpecialChar"><-</span> copy <span class="Constant">1</span> +<span id="L298" class="LineNr">298 </span> <span class="Delimiter">}</span> +<span id="L299" class="LineNr">299 </span> <span class="muComment"># loop</span> +<span id="L300" class="LineNr">300 </span> <span class="PreProc">var</span> x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L301" class="LineNr">301 </span> <span class="PreProc">var</span> i/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy _n +<span id="L302" class="LineNr">302 </span> i <span class="SpecialChar"><-</span> decrement +<span id="L303" class="LineNr">303 </span> <span class="Delimiter">{</span> +<span id="L304" class="LineNr">304 </span> compare i, <span class="Constant">0</span> +<span id="L305" class="LineNr">305 </span> <span class="PreProc">break-if-<=</span> +<span id="L306" class="LineNr">306 </span> <span class="muComment"># x += 2*buf[i]</span> +<span id="L307" class="LineNr">307 </span> <span class="Delimiter">{</span> +<span id="L308" class="LineNr">308 </span> <span class="PreProc">var</span> tmp/<span class="Constant">ecx</span>: (addr byte) <span class="SpecialChar"><-</span> index buf, i +<span id="L309" class="LineNr">309 </span> <span class="PreProc">var</span> tmp2/<span class="Constant">ecx</span>: byte <span class="SpecialChar"><-</span> copy-byte *tmp +<span id="L310" class="LineNr">310 </span> x <span class="SpecialChar"><-</span> add tmp2 +<span id="L311" class="LineNr">311 </span> x <span class="SpecialChar"><-</span> add tmp2 +<span id="L312" class="LineNr">312 </span> <span class="Delimiter">}</span> +<span id="L313" class="LineNr">313 </span> <span class="muComment"># x, buf[i+delta] = x/10, x%10</span> +<span id="L314" class="LineNr">314 </span> <span class="Delimiter">{</span> +<span id="L315" class="LineNr">315 </span> <span class="PreProc">var</span> dest-index/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy i +<span id="L316" class="LineNr">316 </span> dest-index <span class="SpecialChar"><-</span> add delta +<span id="L317" class="LineNr">317 </span> <span class="PreProc">var</span> dest/<span class="Constant">edi</span>: (addr byte) <span class="SpecialChar"><-</span> index buf, dest-index +<span id="L318" class="LineNr">318 </span> <span class="PreProc">var</span> next-digit/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L319" class="LineNr">319 </span> x, next-digit <span class="SpecialChar"><-</span> <a href='314divide.subx.html#L3'>integer-divide</a> x, <span class="Constant">0xa</span> +<span id="L320" class="LineNr">320 </span> copy-byte-to *dest, next-digit +<span id="L321" class="LineNr">321 </span> <span class="Delimiter">}</span> +<span id="L322" class="LineNr">322 </span> <span class="muComment">#</span> +<span id="L323" class="LineNr">323 </span> i <span class="SpecialChar"><-</span> decrement +<span id="L324" class="LineNr">324 </span> <span class="PreProc">loop</span> +<span id="L325" class="LineNr">325 </span> <span class="Delimiter">}</span> +<span id="L326" class="LineNr">326 </span> <span class="muComment"># final patch-up</span> +<span id="L327" class="LineNr">327 </span> <span class="PreProc">var</span> n/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy _n +<span id="L328" class="LineNr">328 </span> compare delta, <span class="Constant">1</span> +<span id="L329" class="LineNr">329 </span> <span class="Delimiter">{</span> +<span id="L330" class="LineNr">330 </span> <span class="PreProc">break-if-!=</span> +<span id="L331" class="LineNr">331 </span> <span class="PreProc">var</span> curr/<span class="Constant">ebx</span>: (addr byte) <span class="SpecialChar"><-</span> index buf, <span class="Constant">0</span> +<span id="L332" class="LineNr">332 </span> <span class="PreProc">var</span> one/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">1</span> +<span id="L333" class="LineNr">333 </span> copy-byte-to *curr, one +<span id="L334" class="LineNr">334 </span> n <span class="SpecialChar"><-</span> increment +<span id="L335" class="LineNr">335 </span> <span class="Delimiter">}</span> +<span id="L336" class="LineNr">336 </span> <span class="PreProc">return</span> n +<span id="L337" class="LineNr">337 </span><span class="Delimiter">}</span> +<span id="L338" class="LineNr">338 </span> +<span id="L339" class="LineNr">339 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='412render-float-decimal.mu.html#L339'>halve-array-of-decimal-digits</a></span> _buf: (addr array byte), _n: int, _dp: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">edx</span>: int <span class="Delimiter">{</span> +<span id="L340" class="LineNr">340 </span> <span class="PreProc">var</span> buf/<span class="Constant">edi</span>: (addr array byte) <span class="SpecialChar"><-</span> copy _buf +<span id="L341" class="LineNr">341 </span> <span class="PreProc">var</span> n/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy _n +<span id="L342" class="LineNr">342 </span> <span class="PreProc">var</span> dp/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy _dp +<span id="L343" class="LineNr">343 </span> <span class="muComment"># initialize one side</span> +<span id="L344" class="LineNr">344 </span> <span class="Delimiter">{</span> +<span id="L345" class="LineNr">345 </span> <span class="muComment"># if buf[n-1]%2 == 0, break</span> +<span id="L346" class="LineNr">346 </span> <span class="PreProc">var</span> right-index/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy n +<span id="L347" class="LineNr">347 </span> right-index <span class="SpecialChar"><-</span> decrement +<span id="L348" class="LineNr">348 </span> <span class="PreProc">var</span> right-a/<span class="Constant">ecx</span>: (addr byte) <span class="SpecialChar"><-</span> index buf, right-index +<span id="L349" class="LineNr">349 </span> <span class="PreProc">var</span> right/<span class="Constant">ecx</span>: byte <span class="SpecialChar"><-</span> copy-byte *right-a +<span id="L350" class="LineNr">350 </span> <span class="PreProc">var</span> right-int/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy right +<span id="L351" class="LineNr">351 </span> <span class="PreProc">var</span> remainder/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L352" class="LineNr">352 </span> <span class="Delimiter">{</span> +<span id="L353" class="LineNr">353 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L354" class="LineNr">354 </span> dummy, remainder <span class="SpecialChar"><-</span> <a href='314divide.subx.html#L3'>integer-divide</a> right-int, <span class="Constant">2</span> +<span id="L355" class="LineNr">355 </span> <span class="Delimiter">}</span> +<span id="L356" class="LineNr">356 </span> compare remainder, <span class="Constant">0</span> +<span id="L357" class="LineNr">357 </span> <span class="PreProc">break-if-=</span> +<span id="L358" class="LineNr">358 </span> <span class="muComment"># buf[n] = 0</span> +<span id="L359" class="LineNr">359 </span> <span class="PreProc">var</span> next-a/<span class="Constant">ecx</span>: (addr byte) <span class="SpecialChar"><-</span> index buf, n +<span id="L360" class="LineNr">360 </span> <span class="PreProc">var</span> zero/<span class="Constant">edx</span>: byte <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L361" class="LineNr">361 </span> copy-byte-to *next-a, zero +<span id="L362" class="LineNr">362 </span> <span class="muComment"># n++</span> +<span id="L363" class="LineNr">363 </span> n <span class="SpecialChar"><-</span> increment +<span id="L364" class="LineNr">364 </span> <span class="Delimiter">}</span> +<span id="L365" class="LineNr">365 </span> <span class="muComment"># initialize the other</span> +<span id="L366" class="LineNr">366 </span> <span class="PreProc">var</span> delta/<span class="Constant">ebx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L367" class="LineNr">367 </span> <span class="PreProc">var</span> x/<span class="Constant">esi</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L368" class="LineNr">368 </span> <span class="Delimiter">{</span> +<span id="L369" class="LineNr">369 </span> <span class="muComment"># if buf[0] >= 2, break</span> +<span id="L370" class="LineNr">370 </span> <span class="PreProc">var</span> left/<span class="Constant">ecx</span>: (addr byte) <span class="SpecialChar"><-</span> index buf, <span class="Constant">0</span> +<span id="L371" class="LineNr">371 </span> <span class="PreProc">var</span> src/<span class="Constant">ecx</span>: byte <span class="SpecialChar"><-</span> copy-byte *left +<span id="L372" class="LineNr">372 </span> compare src, <span class="Constant">2</span> +<span id="L373" class="LineNr">373 </span> <span class="PreProc">break-if->=</span> +<span id="L374" class="LineNr">374 </span> <span class="muComment"># delta, x = 1, buf[0]</span> +<span id="L375" class="LineNr">375 </span> delta <span class="SpecialChar"><-</span> copy <span class="Constant">1</span> +<span id="L376" class="LineNr">376 </span> x <span class="SpecialChar"><-</span> copy src +<span id="L377" class="LineNr">377 </span> <span class="muComment"># n--</span> +<span id="L378" class="LineNr">378 </span> n <span class="SpecialChar"><-</span> decrement +<span id="L379" class="LineNr">379 </span> <span class="muComment"># dp--</span> +<span id="L380" class="LineNr">380 </span> dp <span class="SpecialChar"><-</span> decrement +<span id="L381" class="LineNr">381 </span> <span class="Delimiter">}</span> +<span id="L382" class="LineNr">382 </span> <span class="muComment"># loop</span> +<span id="L383" class="LineNr">383 </span> <span class="PreProc">var</span> i/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L384" class="LineNr">384 </span> <span class="Delimiter">{</span> +<span id="L385" class="LineNr">385 </span> compare i, n +<span id="L386" class="LineNr">386 </span> <span class="PreProc">break-if->=</span> +<span id="L387" class="LineNr">387 </span> <span class="muComment"># x = x*10 + buf[i+delta]</span> +<span id="L388" class="LineNr">388 </span> <span class="Delimiter">{</span> +<span id="L389" class="LineNr">389 </span> <span class="PreProc">var</span> ten/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0xa</span> +<span id="L390" class="LineNr">390 </span> x <span class="SpecialChar"><-</span> multiply ten +<span id="L391" class="LineNr">391 </span> <span class="PreProc">var</span> src-index/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy i +<span id="L392" class="LineNr">392 </span> src-index <span class="SpecialChar"><-</span> add delta +<span id="L393" class="LineNr">393 </span> <span class="PreProc">var</span> src-a/<span class="Constant">edx</span>: (addr byte) <span class="SpecialChar"><-</span> index buf, src-index +<span id="L394" class="LineNr">394 </span> <span class="PreProc">var</span> src/<span class="Constant">edx</span>: byte <span class="SpecialChar"><-</span> copy-byte *src-a +<span id="L395" class="LineNr">395 </span> x <span class="SpecialChar"><-</span> add src +<span id="L396" class="LineNr">396 </span> <span class="Delimiter">}</span> +<span id="L397" class="LineNr">397 </span> <span class="muComment"># buf[i], x = x/2, x%2</span> +<span id="L398" class="LineNr">398 </span> <span class="Delimiter">{</span> +<span id="L399" class="LineNr">399 </span> <span class="PreProc">var</span> quotient/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L400" class="LineNr">400 </span> <span class="PreProc">var</span> remainder/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L401" class="LineNr">401 </span> quotient, remainder <span class="SpecialChar"><-</span> <a href='314divide.subx.html#L3'>integer-divide</a> x, <span class="Constant">2</span> +<span id="L402" class="LineNr">402 </span> x <span class="SpecialChar"><-</span> copy remainder +<span id="L403" class="LineNr">403 </span> <span class="PreProc">var</span> dest/<span class="Constant">edx</span>: (addr byte) <span class="SpecialChar"><-</span> index buf, i +<span id="L404" class="LineNr">404 </span> copy-byte-to *dest, quotient +<span id="L405" class="LineNr">405 </span> <span class="Delimiter">}</span> +<span id="L406" class="LineNr">406 </span> <span class="muComment">#</span> +<span id="L407" class="LineNr">407 </span> i <span class="SpecialChar"><-</span> increment +<span id="L408" class="LineNr">408 </span> <span class="PreProc">loop</span> +<span id="L409" class="LineNr">409 </span> <span class="Delimiter">}</span> +<span id="L410" class="LineNr">410 </span> <span class="PreProc">return</span> n, dp +<span id="L411" class="LineNr">411 </span><span class="Delimiter">}</span> +<span id="L412" class="LineNr">412 </span> +<span id="L413" class="LineNr">413 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='412render-float-decimal.mu.html#L413'>render-float-buffer</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), _buf: (addr array byte), n: int, dp: int, precision: int, x: int, y: int, color: int, background-color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L414" class="LineNr">414 </span> <span class="PreProc">var</span> buf/<span class="Constant">edi</span>: (addr array byte) <span class="SpecialChar"><-</span> copy _buf +<span id="L415" class="LineNr">415 </span> <span class="Delimiter">{</span> +<span id="L416" class="LineNr">416 </span> compare dp, <span class="Constant">0</span> +<span id="L417" class="LineNr">417 </span> <span class="PreProc">break-if->=</span> +<span id="L418" class="LineNr">418 </span> <span class="PreProc">var</span> new-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L465'>render-float-buffer-in-scientific-notation</a> <a href='500text-screen.mu.html#L9'>screen</a>, buf, n, dp, precision, x, y, color, background-color +<span id="L419" class="LineNr">419 </span> <span class="PreProc">return</span> new-x +<span id="L420" class="LineNr">420 </span> <span class="Delimiter">}</span> +<span id="L421" class="LineNr">421 </span> <span class="Delimiter">{</span> +<span id="L422" class="LineNr">422 </span> <span class="PreProc">var</span> dp2/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy dp +<span id="L423" class="LineNr">423 </span> compare dp2, precision +<span id="L424" class="LineNr">424 </span> <span class="PreProc">break-if-<=</span> +<span id="L425" class="LineNr">425 </span> <span class="PreProc">var</span> new-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L465'>render-float-buffer-in-scientific-notation</a> <a href='500text-screen.mu.html#L9'>screen</a>, buf, n, dp, precision, x, y, color, background-color +<span id="L426" class="LineNr">426 </span> <span class="PreProc">return</span> new-x +<span id="L427" class="LineNr">427 </span> <span class="Delimiter">}</span> +<span id="L428" class="LineNr">428 </span> <span class="Delimiter">{</span> +<span id="L429" class="LineNr">429 </span> compare dp, <span class="Constant">0</span> +<span id="L430" class="LineNr">430 </span> <span class="PreProc">break-if-!=</span> +<span id="L431" class="LineNr">431 </span> <a href='500text-screen.mu.html#L94'>draw-code-point</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x30</span>/<span class="Constant">0</span>, x, y, color, background-color +<span id="L432" class="LineNr">432 </span> increment x +<span id="L433" class="LineNr">433 </span> <span class="Delimiter">}</span> +<span id="L434" class="LineNr">434 </span> <span class="PreProc">var</span> i/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L435" class="LineNr">435 </span> <span class="muComment"># bounds = min(n, dp+3)</span> +<span id="L436" class="LineNr">436 </span> <span class="PreProc">var</span> limit/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy dp +<span id="L437" class="LineNr">437 </span> limit <span class="SpecialChar"><-</span> add <span class="Constant">3</span> +<span id="L438" class="LineNr">438 </span> <span class="Delimiter">{</span> +<span id="L439" class="LineNr">439 </span> compare limit, n +<span id="L440" class="LineNr">440 </span> <span class="PreProc">break-if-<=</span> +<span id="L441" class="LineNr">441 </span> limit <span class="SpecialChar"><-</span> copy n +<span id="L442" class="LineNr">442 </span> <span class="Delimiter">}</span> +<span id="L443" class="LineNr">443 </span> <span class="Delimiter">{</span> +<span id="L444" class="LineNr">444 </span> compare i, limit +<span id="L445" class="LineNr">445 </span> <span class="PreProc">break-if->=</span> +<span id="L446" class="LineNr">446 </span> <span class="muComment"># print '.' if necessary</span> +<span id="L447" class="LineNr">447 </span> compare i, dp +<span id="L448" class="LineNr">448 </span> <span class="Delimiter">{</span> +<span id="L449" class="LineNr">449 </span> <span class="PreProc">break-if-!=</span> +<span id="L450" class="LineNr">450 </span> <a href='500text-screen.mu.html#L94'>draw-code-point</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x2e</span>/decimal-point, x, y, color, background-color +<span id="L451" class="LineNr">451 </span> increment x +<span id="L452" class="LineNr">452 </span> <span class="Delimiter">}</span> +<span id="L453" class="LineNr">453 </span> <span class="PreProc">var</span> curr-a/<span class="Constant">ecx</span>: (addr byte) <span class="SpecialChar"><-</span> index buf, i +<span id="L454" class="LineNr">454 </span> <span class="PreProc">var</span> curr/<span class="Constant">ecx</span>: byte <span class="SpecialChar"><-</span> copy-byte *curr-a +<span id="L455" class="LineNr">455 </span> curr <span class="SpecialChar"><-</span> add <span class="Constant">0x30</span>/<span class="Constant">0</span> +<span id="L456" class="LineNr">456 </span> <span class="PreProc">var</span> curr-grapheme/<span class="Constant">ecx</span>: grapheme <span class="SpecialChar"><-</span> copy curr +<span id="L457" class="LineNr">457 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, curr-grapheme, x, y, color, background-color +<span id="L458" class="LineNr">458 </span> increment x +<span id="L459" class="LineNr">459 </span> i <span class="SpecialChar"><-</span> increment +<span id="L460" class="LineNr">460 </span> <span class="PreProc">loop</span> +<span id="L461" class="LineNr">461 </span> <span class="Delimiter">}</span> +<span id="L462" class="LineNr">462 </span> <span class="PreProc">return</span> x +<span id="L463" class="LineNr">463 </span><span class="Delimiter">}</span> +<span id="L464" class="LineNr">464 </span> +<span id="L465" class="LineNr">465 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='412render-float-decimal.mu.html#L465'>render-float-buffer-in-scientific-notation</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), _buf: (addr array byte), n: int, dp: int, precision: int, x: int, y: int, color: int, background-color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L466" class="LineNr">466 </span> <span class="PreProc">var</span> buf/<span class="Constant">edi</span>: (addr array byte) <span class="SpecialChar"><-</span> copy _buf +<span id="L467" class="LineNr">467 </span> <span class="PreProc">var</span> i/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L468" class="LineNr">468 </span> <span class="Delimiter">{</span> +<span id="L469" class="LineNr">469 </span> compare i, n +<span id="L470" class="LineNr">470 </span> <span class="PreProc">break-if->=</span> +<span id="L471" class="LineNr">471 </span> compare i, precision +<span id="L472" class="LineNr">472 </span> <span class="PreProc">break-if->=</span> +<span id="L473" class="LineNr">473 </span> compare i, <span class="Constant">1</span> +<span id="L474" class="LineNr">474 </span> <span class="Delimiter">{</span> +<span id="L475" class="LineNr">475 </span> <span class="PreProc">break-if-!=</span> +<span id="L476" class="LineNr">476 </span> <a href='500text-screen.mu.html#L94'>draw-code-point</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x2e</span>/decimal-point, x, y, color, background-color +<span id="L477" class="LineNr">477 </span> increment x +<span id="L478" class="LineNr">478 </span> <span class="Delimiter">}</span> +<span id="L479" class="LineNr">479 </span> <span class="PreProc">var</span> curr-a/<span class="Constant">ecx</span>: (addr byte) <span class="SpecialChar"><-</span> index buf, i +<span id="L480" class="LineNr">480 </span> <span class="PreProc">var</span> curr/<span class="Constant">ecx</span>: byte <span class="SpecialChar"><-</span> copy-byte *curr-a +<span id="L481" class="LineNr">481 </span> curr <span class="SpecialChar"><-</span> add <span class="Constant">0x30</span>/<span class="Constant">0</span> +<span id="L482" class="LineNr">482 </span> <span class="PreProc">var</span> curr-grapheme/<span class="Constant">ecx</span>: grapheme <span class="SpecialChar"><-</span> copy curr +<span id="L483" class="LineNr">483 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, curr-grapheme, x, y, color, background-color +<span id="L484" class="LineNr">484 </span> increment x +<span id="L485" class="LineNr">485 </span> <span class="muComment">#</span> +<span id="L486" class="LineNr">486 </span> i <span class="SpecialChar"><-</span> increment +<span id="L487" class="LineNr">487 </span> <span class="PreProc">loop</span> +<span id="L488" class="LineNr">488 </span> <span class="Delimiter">}</span> +<span id="L489" class="LineNr">489 </span> <a href='500text-screen.mu.html#L94'>draw-code-point</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x65</span>/e, x, y, color, background-color +<span id="L490" class="LineNr">490 </span> increment x +<span id="L491" class="LineNr">491 </span> decrement dp +<span id="L492" class="LineNr">492 </span> <span class="PreProc">var</span> new-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L493" class="LineNr">493 </span> <span class="PreProc">var</span> new-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L494" class="LineNr">494 </span> new-x, new-y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L357'>draw-int32-decimal-wrapping-right-then-down-over-full-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, dp, x, y, color, background-color +<span id="L495" class="LineNr">495 </span> <span class="PreProc">return</span> new-x +<span id="L496" class="LineNr">496 </span><span class="Delimiter">}</span> +<span id="L497" class="LineNr">497 </span> +<span id="L498" class="LineNr">498 </span><span class="muComment"># follows the structure of render-float-decimal</span> +<span id="L499" class="LineNr">499 </span><span class="muComment"># 'precision' controls the maximum width past which we resort to scientific notation</span> +<span id="L500" class="LineNr">500 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='412render-float-decimal.mu.html#L500'>float-size</a></span> in: float, precision: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L501" class="LineNr">501 </span> <span class="muComment"># - special names</span> +<span id="L502" class="LineNr">502 </span> <span class="PreProc">var</span> bits/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> reinterpret in +<span id="L503" class="LineNr">503 </span> compare bits, <span class="Constant">0</span> +<span id="L504" class="LineNr">504 </span> <span class="Delimiter">{</span> +<span id="L505" class="LineNr">505 </span> <span class="PreProc">break-if-!=</span> +<span id="L506" class="LineNr">506 </span> <span class="PreProc">return</span> <span class="Constant">1</span> <span class="muComment"># for "0"</span> +<span id="L507" class="LineNr">507 </span> <span class="Delimiter">}</span> +<span id="L508" class="LineNr">508 </span> compare bits, <span class="Constant">0x80000000</span> +<span id="L509" class="LineNr">509 </span> <span class="Delimiter">{</span> +<span id="L510" class="LineNr">510 </span> <span class="PreProc">break-if-!=</span> +<span id="L511" class="LineNr">511 </span> <span class="PreProc">return</span> <span class="Constant">2</span> <span class="muComment"># for "-0"</span> +<span id="L512" class="LineNr">512 </span> <span class="Delimiter">}</span> +<span id="L513" class="LineNr">513 </span> compare bits, <span class="Constant">0x7f800000</span> +<span id="L514" class="LineNr">514 </span> <span class="Delimiter">{</span> +<span id="L515" class="LineNr">515 </span> <span class="PreProc">break-if-!=</span> +<span id="L516" class="LineNr">516 </span> <span class="PreProc">return</span> <span class="Constant">3</span> <span class="muComment"># for "Inf"</span> +<span id="L517" class="LineNr">517 </span> <span class="Delimiter">}</span> +<span id="L518" class="LineNr">518 </span> compare bits, <span class="Constant">0xff800000</span> +<span id="L519" class="LineNr">519 </span> <span class="Delimiter">{</span> +<span id="L520" class="LineNr">520 </span> <span class="PreProc">break-if-!=</span> +<span id="L521" class="LineNr">521 </span> <span class="PreProc">return</span> <span class="Constant">4</span> <span class="muComment"># for "-Inf"</span> +<span id="L522" class="LineNr">522 </span> <span class="Delimiter">}</span> +<span id="L523" class="LineNr">523 </span> <span class="PreProc">var</span> exponent/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy bits +<span id="L524" class="LineNr">524 </span> exponent <span class="SpecialChar"><-</span> shift-right <span class="Constant">0x17</span> <span class="muComment"># 23 bits of mantissa</span> +<span id="L525" class="LineNr">525 </span> exponent <span class="SpecialChar"><-</span> and <span class="Constant">0xff</span> +<span id="L526" class="LineNr">526 </span> exponent <span class="SpecialChar"><-</span> subtract <span class="Constant">0x7f</span> +<span id="L527" class="LineNr">527 </span> compare exponent, <span class="Constant">0x80</span> +<span id="L528" class="LineNr">528 </span> <span class="Delimiter">{</span> +<span id="L529" class="LineNr">529 </span> <span class="PreProc">break-if-!=</span> +<span id="L530" class="LineNr">530 </span> <span class="PreProc">return</span> <span class="Constant">3</span> <span class="muComment"># for "NaN"</span> +<span id="L531" class="LineNr">531 </span> <span class="Delimiter">}</span> +<span id="L532" class="LineNr">532 </span> <span class="muComment"># - regular numbers</span> +<span id="L533" class="LineNr">533 </span> <span class="muComment"># v = 1.mantissa (in base 2) << 0x17</span> +<span id="L534" class="LineNr">534 </span> <span class="PreProc">var</span> v/<span class="Constant">ebx</span>: int <span class="SpecialChar"><-</span> copy bits +<span id="L535" class="LineNr">535 </span> v <span class="SpecialChar"><-</span> and <span class="Constant">0x7fffff</span> +<span id="L536" class="LineNr">536 </span> v <span class="SpecialChar"><-</span> or <span class="Constant">0x00800000</span> <span class="muComment"># insert implicit 1</span> +<span id="L537" class="LineNr">537 </span> <span class="muComment"># e = exponent - 0x17</span> +<span id="L538" class="LineNr">538 </span> <span class="PreProc">var</span> e/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy exponent +<span id="L539" class="LineNr">539 </span> e <span class="SpecialChar"><-</span> subtract <span class="Constant">0x17</span> <span class="muComment"># move decimal place from before mantissa to after</span> +<span id="L540" class="LineNr">540 </span> +<span id="L541" class="LineNr">541 </span> <span class="muComment"># initialize buffer with decimal representation of v</span> +<span id="L542" class="LineNr">542 </span> <span class="PreProc">var</span> buf-storage: (array byte <span class="Constant">0x7f</span>) +<span id="L543" class="LineNr">543 </span> <span class="PreProc">var</span> buf/<span class="Constant">edi</span>: (addr array byte) <span class="SpecialChar"><-</span> address buf-storage +<span id="L544" class="LineNr">544 </span> <span class="PreProc">var</span> n/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L249'>decimal-digits</a> v, buf +<span id="L545" class="LineNr">545 </span> <a href='412render-float-decimal.mu.html#L266'>reverse-digits</a> buf, n +<span id="L546" class="LineNr">546 </span> +<span id="L547" class="LineNr">547 </span> <span class="muComment"># loop if e > 0</span> +<span id="L548" class="LineNr">548 </span> <span class="Delimiter">{</span> +<span id="L549" class="LineNr">549 </span> compare e, <span class="Constant">0</span> +<span id="L550" class="LineNr">550 </span> <span class="PreProc">break-if-<=</span> +<span id="L551" class="LineNr">551 </span> n <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L288'>double-array-of-decimal-digits</a> buf, n +<span id="L552" class="LineNr">552 </span> e <span class="SpecialChar"><-</span> decrement +<span id="L553" class="LineNr">553 </span> <span class="PreProc">loop</span> +<span id="L554" class="LineNr">554 </span> <span class="Delimiter">}</span> +<span id="L555" class="LineNr">555 </span> +<span id="L556" class="LineNr">556 </span> <span class="PreProc">var</span> dp/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy n +<span id="L557" class="LineNr">557 </span> +<span id="L558" class="LineNr">558 </span> <span class="muComment"># loop if e < 0</span> +<span id="L559" class="LineNr">559 </span> <span class="Delimiter">{</span> +<span id="L560" class="LineNr">560 </span> compare e, <span class="Constant">0</span> +<span id="L561" class="LineNr">561 </span> <span class="PreProc">break-if->=</span> +<span id="L562" class="LineNr">562 </span> n, dp <span class="SpecialChar"><-</span> <a href='412render-float-decimal.mu.html#L339'>halve-array-of-decimal-digits</a> buf, n, dp +<span id="L563" class="LineNr">563 </span> e <span class="SpecialChar"><-</span> increment +<span id="L564" class="LineNr">564 </span> <span class="PreProc">loop</span> +<span id="L565" class="LineNr">565 </span> <span class="Delimiter">}</span> +<span id="L566" class="LineNr">566 </span> +<span id="L567" class="LineNr">567 </span> compare dp, <span class="Constant">0</span> +<span id="L568" class="LineNr">568 </span> <span class="Delimiter">{</span> +<span id="L569" class="LineNr">569 </span> <span class="PreProc">break-if->=</span> +<span id="L570" class="LineNr">570 </span> <span class="PreProc">return</span> <span class="Constant">8</span> <span class="muComment"># hacky for scientific notation</span> +<span id="L571" class="LineNr">571 </span> <span class="Delimiter">}</span> +<span id="L572" class="LineNr">572 </span> <span class="Delimiter">{</span> +<span id="L573" class="LineNr">573 </span> <span class="PreProc">var</span> dp2/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy dp +<span id="L574" class="LineNr">574 </span> compare dp2, precision +<span id="L575" class="LineNr">575 </span> <span class="PreProc">break-if-<=</span> +<span id="L576" class="LineNr">576 </span> <span class="PreProc">return</span> <span class="Constant">8</span> <span class="muComment"># hacky for scientific notation</span> +<span id="L577" class="LineNr">577 </span> <span class="Delimiter">}</span> +<span id="L578" class="LineNr">578 </span> +<span id="L579" class="LineNr">579 </span> <span class="muComment"># result = min(n, dp+3)</span> +<span id="L580" class="LineNr">580 </span> <span class="PreProc">var</span> result/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy dp +<span id="L581" class="LineNr">581 </span> result <span class="SpecialChar"><-</span> add <span class="Constant">3</span> +<span id="L582" class="LineNr">582 </span> <span class="Delimiter">{</span> +<span id="L583" class="LineNr">583 </span> compare result, n +<span id="L584" class="LineNr">584 </span> <span class="PreProc">break-if-<=</span> +<span id="L585" class="LineNr">585 </span> result <span class="SpecialChar"><-</span> copy n +<span id="L586" class="LineNr">586 </span> <span class="Delimiter">}</span> +<span id="L587" class="LineNr">587 </span> +<span id="L588" class="LineNr">588 </span> <span class="muComment"># account for decimal point</span> +<span id="L589" class="LineNr">589 </span> compare dp, n +<span id="L590" class="LineNr">590 </span> <span class="Delimiter">{</span> +<span id="L591" class="LineNr">591 </span> <span class="PreProc">break-if->=</span> +<span id="L592" class="LineNr">592 </span> result <span class="SpecialChar"><-</span> increment +<span id="L593" class="LineNr">593 </span> <span class="Delimiter">}</span> +<span id="L594" class="LineNr">594 </span> +<span id="L595" class="LineNr">595 </span> <span class="muComment"># account for sign</span> +<span id="L596" class="LineNr">596 </span> <span class="PreProc">var</span> sign/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> reinterpret in +<span id="L597" class="LineNr">597 </span> sign <span class="SpecialChar"><-</span> shift-right <span class="Constant">0x1f</span> +<span id="L598" class="LineNr">598 </span> <span class="Delimiter">{</span> +<span id="L599" class="LineNr">599 </span> compare sign, <span class="Constant">1</span> +<span id="L600" class="LineNr">600 </span> <span class="PreProc">break-if-!=</span> +<span id="L601" class="LineNr">601 </span> result <span class="SpecialChar"><-</span> increment +<span id="L602" class="LineNr">602 </span> <span class="Delimiter">}</span> +<span id="L603" class="LineNr">603 </span> <span class="PreProc">return</span> result +<span id="L604" class="LineNr">604 </span><span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/baremetal/500text-screen.mu.html b/html/baremetal/500text-screen.mu.html index 0f28c86d..04bd8548 100644 --- a/html/baremetal/500text-screen.mu.html +++ b/html/baremetal/500text-screen.mu.html @@ -75,64 +75,64 @@ if ('onhashchange' in window) { <span id="L17" class="LineNr"> 17 </span><span class="PreProc">type</span> <a href='500text-screen.mu.html#L17'>screen-cell</a> <span class="Delimiter">{</span> <span id="L18" class="LineNr"> 18 </span> data: grapheme <span id="L19" class="LineNr"> 19 </span> color: int -<span id="L20" class="LineNr"> 20 </span><span class="Delimiter">}</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='500text-screen.mu.html#L22'>initialize-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), width: int, height: int <span class="Delimiter">{</span> -<span id="L23" class="LineNr"> 23 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L24" class="LineNr"> 24 </span> <span class="PreProc">var</span> tmp/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L25" class="LineNr"> 25 </span> <span class="PreProc">var</span> dest/<span class="Constant">edi</span>: (addr int) <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L26" class="LineNr"> 26 </span> <span class="muComment"># screen->width = width</span> -<span id="L27" class="LineNr"> 27 </span> dest <span class="SpecialChar"><-</span> get screen-addr, width -<span id="L28" class="LineNr"> 28 </span> tmp <span class="SpecialChar"><-</span> copy width -<span id="L29" class="LineNr"> 29 </span> copy-to *dest, tmp -<span id="L30" class="LineNr"> 30 </span> <span class="muComment"># screen->height = height</span> -<span id="L31" class="LineNr"> 31 </span> dest <span class="SpecialChar"><-</span> get screen-addr, height -<span id="L32" class="LineNr"> 32 </span> tmp <span class="SpecialChar"><-</span> copy height -<span id="L33" class="LineNr"> 33 </span> copy-to *dest, tmp -<span id="L34" class="LineNr"> 34 </span> <span class="muComment"># screen->data = new screen-cell[width*height]</span> -<span id="L35" class="LineNr"> 35 </span> <span class="Delimiter">{</span> -<span id="L36" class="LineNr"> 36 </span> <span class="PreProc">var</span> data-addr/<span class="Constant">edi</span>: (addr handle array <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> get screen-addr, data -<span id="L37" class="LineNr"> 37 </span> tmp <span class="SpecialChar"><-</span> multiply width -<span id="L38" class="LineNr"> 38 </span> populate data-addr, tmp -<span id="L39" class="LineNr"> 39 </span> <span class="Delimiter">}</span> -<span id="L40" class="LineNr"> 40 </span> <span class="muComment"># screen->cursor-x = 0</span> -<span id="L41" class="LineNr"> 41 </span> dest <span class="SpecialChar"><-</span> get screen-addr, cursor-x -<span id="L42" class="LineNr"> 42 </span> copy-to *dest, <span class="Constant">0</span> -<span id="L43" class="LineNr"> 43 </span> <span class="muComment"># screen->cursor-y = 0</span> -<span id="L44" class="LineNr"> 44 </span> dest <span class="SpecialChar"><-</span> get screen-addr, cursor-y -<span id="L45" class="LineNr"> 45 </span> copy-to *dest, <span class="Constant">0</span> -<span id="L46" class="LineNr"> 46 </span><span class="Delimiter">}</span> -<span id="L47" class="LineNr"> 47 </span> -<span id="L48" class="LineNr"> 48 </span><span class="muComment"># in graphemes</span> -<span id="L49" class="LineNr"> 49 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L49'>screen-size</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> -<span id="L50" class="LineNr"> 50 </span> <span class="PreProc">var</span> width/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L51" class="LineNr"> 51 </span> <span class="PreProc">var</span> height/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L52" class="LineNr"> 52 </span> compare <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span> -<span id="L53" class="LineNr"> 53 </span> <span class="Delimiter">{</span> -<span id="L54" class="LineNr"> 54 </span> <span class="PreProc">break-if-!=</span> -<span id="L55" class="LineNr"> 55 </span> <span class="PreProc">return</span> <span class="Constant">0x80</span>, <span class="Constant">0x30</span> <span class="muComment"># 128x48</span> -<span id="L56" class="LineNr"> 56 </span> <span class="Delimiter">}</span> -<span id="L57" class="LineNr"> 57 </span> <span class="muComment"># fake screen</span> -<span id="L58" class="LineNr"> 58 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L59" class="LineNr"> 59 </span> <span class="PreProc">var</span> tmp/<span class="Constant">edx</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, width -<span id="L60" class="LineNr"> 60 </span> width <span class="SpecialChar"><-</span> copy *tmp -<span id="L61" class="LineNr"> 61 </span> tmp <span class="SpecialChar"><-</span> get screen-addr, height -<span id="L62" class="LineNr"> 62 </span> height <span class="SpecialChar"><-</span> copy *tmp -<span id="L63" class="LineNr"> 63 </span> <span class="PreProc">return</span> width, height -<span id="L64" class="LineNr"> 64 </span><span class="Delimiter">}</span> -<span id="L65" class="LineNr"> 65 </span> -<span id="L66" class="LineNr"> 66 </span><span class="muComment"># testable screen primitive</span> -<span id="L67" class="LineNr"> 67 </span><span class="muComment"># background color isn't configurable yet</span> -<span id="L68" class="LineNr"> 68 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L68'>draw-grapheme</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), g: grapheme, x: int, y: int, color: int <span class="Delimiter">{</span> +<span id="L20" class="LineNr"> 20 </span> background-color: int +<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">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L23'>initialize-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), width: int, height: int <span class="Delimiter">{</span> +<span id="L24" class="LineNr"> 24 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L25" class="LineNr"> 25 </span> <span class="PreProc">var</span> tmp/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L26" class="LineNr"> 26 </span> <span class="PreProc">var</span> dest/<span class="Constant">edi</span>: (addr int) <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L27" class="LineNr"> 27 </span> <span class="muComment"># screen->width = width</span> +<span id="L28" class="LineNr"> 28 </span> dest <span class="SpecialChar"><-</span> get screen-addr, width +<span id="L29" class="LineNr"> 29 </span> tmp <span class="SpecialChar"><-</span> copy width +<span id="L30" class="LineNr"> 30 </span> copy-to *dest, tmp +<span id="L31" class="LineNr"> 31 </span> <span class="muComment"># screen->height = height</span> +<span id="L32" class="LineNr"> 32 </span> dest <span class="SpecialChar"><-</span> get screen-addr, height +<span id="L33" class="LineNr"> 33 </span> tmp <span class="SpecialChar"><-</span> copy height +<span id="L34" class="LineNr"> 34 </span> copy-to *dest, tmp +<span id="L35" class="LineNr"> 35 </span> <span class="muComment"># screen->data = new screen-cell[width*height]</span> +<span id="L36" class="LineNr"> 36 </span> <span class="Delimiter">{</span> +<span id="L37" class="LineNr"> 37 </span> <span class="PreProc">var</span> data-addr/<span class="Constant">edi</span>: (addr handle array <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> get screen-addr, data +<span id="L38" class="LineNr"> 38 </span> tmp <span class="SpecialChar"><-</span> multiply width +<span id="L39" class="LineNr"> 39 </span> populate data-addr, tmp +<span id="L40" class="LineNr"> 40 </span> <span class="Delimiter">}</span> +<span id="L41" class="LineNr"> 41 </span> <span class="muComment"># screen->cursor-x = 0</span> +<span id="L42" class="LineNr"> 42 </span> dest <span class="SpecialChar"><-</span> get screen-addr, cursor-x +<span id="L43" class="LineNr"> 43 </span> copy-to *dest, <span class="Constant">0</span> +<span id="L44" class="LineNr"> 44 </span> <span class="muComment"># screen->cursor-y = 0</span> +<span id="L45" class="LineNr"> 45 </span> dest <span class="SpecialChar"><-</span> get screen-addr, cursor-y +<span id="L46" class="LineNr"> 46 </span> copy-to *dest, <span class="Constant">0</span> +<span id="L47" class="LineNr"> 47 </span><span class="Delimiter">}</span> +<span id="L48" class="LineNr"> 48 </span> +<span id="L49" class="LineNr"> 49 </span><span class="muComment"># in graphemes</span> +<span id="L50" class="LineNr"> 50 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L50'>screen-size</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> +<span id="L51" class="LineNr"> 51 </span> <span class="PreProc">var</span> width/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L52" class="LineNr"> 52 </span> <span class="PreProc">var</span> height/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L53" class="LineNr"> 53 </span> compare <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span> +<span id="L54" class="LineNr"> 54 </span> <span class="Delimiter">{</span> +<span id="L55" class="LineNr"> 55 </span> <span class="PreProc">break-if-!=</span> +<span id="L56" class="LineNr"> 56 </span> <span class="PreProc">return</span> <span class="Constant">0x80</span>/<span class="Constant">128</span>, <span class="Constant">0x30</span>/<span class="Constant">48</span> +<span id="L57" class="LineNr"> 57 </span> <span class="Delimiter">}</span> +<span id="L58" class="LineNr"> 58 </span> <span class="muComment"># fake screen</span> +<span id="L59" class="LineNr"> 59 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L60" class="LineNr"> 60 </span> <span class="PreProc">var</span> tmp/<span class="Constant">edx</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, width +<span id="L61" class="LineNr"> 61 </span> width <span class="SpecialChar"><-</span> copy *tmp +<span id="L62" class="LineNr"> 62 </span> tmp <span class="SpecialChar"><-</span> get screen-addr, height +<span id="L63" class="LineNr"> 63 </span> height <span class="SpecialChar"><-</span> copy *tmp +<span id="L64" class="LineNr"> 64 </span> <span class="PreProc">return</span> width, height +<span id="L65" class="LineNr"> 65 </span><span class="Delimiter">}</span> +<span id="L66" class="LineNr"> 66 </span> +<span id="L67" class="LineNr"> 67 </span><span class="muComment"># testable screen primitive</span> +<span id="L68" class="LineNr"> 68 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L68'>draw-grapheme</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), g: grapheme, x: int, y: int, color: int, background-color: int <span class="Delimiter">{</span> <span id="L69" class="LineNr"> 69 </span> <span class="Delimiter">{</span> <span id="L70" class="LineNr"> 70 </span> compare <a href='500text-screen.mu.html#L9'>screen</a>, <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> <a href='103grapheme.subx.html#L15'>draw-grapheme-on-real-screen</a> g, x, y, color, <span class="Constant">0</span> +<span id="L72" class="LineNr"> 72 </span> <a href='103grapheme.subx.html#L17'>draw-grapheme-on-real-screen</a> g, x, y, color, background-color <span id="L73" class="LineNr"> 73 </span> <span class="PreProc">return</span> <span id="L74" class="LineNr"> 74 </span> <span class="Delimiter">}</span> <span id="L75" class="LineNr"> 75 </span> <span class="muComment"># fake screen</span> <span id="L76" class="LineNr"> 76 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L77" class="LineNr"> 77 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L90'>screen-cell-index</a> screen-addr, x, y +<span id="L77" class="LineNr"> 77 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L100'>screen-cell-index</a> screen-addr, x, y <span id="L78" class="LineNr"> 78 </span> <span class="PreProc">var</span> data-ah/<span class="Constant">eax</span>: (addr handle array <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> get screen-addr, data <span id="L79" class="LineNr"> 79 </span> <span class="PreProc">var</span> data/<span class="Constant">eax</span>: (addr array <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *data-ah <span id="L80" class="LineNr"> 80 </span> <span class="PreProc">var</span> offset/<span class="Constant">ecx</span>: (offset <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> compute-offset data, idx @@ -141,183 +141,219 @@ if ('onhashchange' in window) { <span id="L83" class="LineNr"> 83 </span> <span class="PreProc">var</span> g2/<span class="Constant">edx</span>: grapheme <span class="SpecialChar"><-</span> copy g <span id="L84" class="LineNr"> 84 </span> copy-to *dest-grapheme, g2 <span id="L85" class="LineNr"> 85 </span> <span class="PreProc">var</span> dest-color/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> get dest-cell, color -<span id="L86" class="LineNr"> 86 </span> <span class="PreProc">var</span> color2/<span class="Constant">edx</span>: grapheme <span class="SpecialChar"><-</span> copy color -<span id="L87" class="LineNr"> 87 </span> copy-to *dest-color, color2 -<span id="L88" class="LineNr"> 88 </span><span class="Delimiter">}</span> -<span id="L89" class="LineNr"> 89 </span> -<span id="L90" class="LineNr"> 90 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L90'>screen-cell-index</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), x: int, y: int<span class="PreProc"> -> </span>_/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> -<span id="L91" class="LineNr"> 91 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack -<span id="L92" class="LineNr"> 92 </span> <span class="PreProc">var</span> height-addr/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> get <a href='500text-screen.mu.html#L9'>screen</a>, height -<span id="L93" class="LineNr"> 93 </span> <span class="PreProc">var</span> result/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy y -<span id="L94" class="LineNr"> 94 </span> result <span class="SpecialChar"><-</span> multiply *height-addr -<span id="L95" class="LineNr"> 95 </span> result <span class="SpecialChar"><-</span> add x -<span id="L96" class="LineNr"> 96 </span> <span class="PreProc">return</span> result +<span id="L86" class="LineNr"> 86 </span> <span class="PreProc">var</span> src-color/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy color +<span id="L87" class="LineNr"> 87 </span> copy-to *dest-color, src-color +<span id="L88" class="LineNr"> 88 </span> dest-color <span class="SpecialChar"><-</span> get dest-cell, background-color +<span id="L89" class="LineNr"> 89 </span> src-color <span class="SpecialChar"><-</span> copy background-color +<span id="L90" class="LineNr"> 90 </span> copy-to *dest-color, src-color +<span id="L91" class="LineNr"> 91 </span><span class="Delimiter">}</span> +<span id="L92" class="LineNr"> 92 </span> +<span id="L93" class="LineNr"> 93 </span><span class="muComment"># we can't really render non-ASCII yet, but when we do we'll be ready</span> +<span id="L94" class="LineNr"> 94 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L94'>draw-code-point</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), c: code-point, x: int, y: int, color: int, background-color: int <span class="Delimiter">{</span> +<span id="L95" class="LineNr"> 95 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> copy c +<span id="L96" class="LineNr"> 96 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, x, y, color, background-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='500text-screen.mu.html#L99'>cursor-position</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> -<span id="L100" class="LineNr">100 </span> <span class="Delimiter">{</span> -<span id="L101" class="LineNr">101 </span> compare <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span> -<span id="L102" class="LineNr">102 </span> <span class="PreProc">break-if-!=</span> -<span id="L103" class="LineNr">103 </span> <span class="PreProc">var</span> x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L104" class="LineNr">104 </span> <span class="PreProc">var</span> y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L105" class="LineNr">105 </span> x, y <span class="SpecialChar"><-</span> <a href='103grapheme.subx.html#L94'>cursor-position-on-real-screen</a> -<span id="L106" class="LineNr">106 </span> <span class="PreProc">return</span> x, y -<span id="L107" class="LineNr">107 </span> <span class="Delimiter">}</span> -<span id="L108" class="LineNr">108 </span> <span class="muComment"># fake screen</span> -<span id="L109" class="LineNr">109 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L110" class="LineNr">110 </span> <span class="PreProc">var</span> cursor-x-addr/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, cursor-x -<span id="L111" class="LineNr">111 </span> <span class="PreProc">var</span> cursor-y-addr/<span class="Constant">ecx</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, cursor-y -<span id="L112" class="LineNr">112 </span> <span class="PreProc">return</span> *cursor-x-addr, *cursor-y-addr -<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='500text-screen.mu.html#L115'>set-cursor-position</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), x: int, y: int <span class="Delimiter">{</span> -<span id="L116" class="LineNr">116 </span> <span class="Delimiter">{</span> -<span id="L117" class="LineNr">117 </span> compare <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span> -<span id="L118" class="LineNr">118 </span> <span class="PreProc">break-if-!=</span> -<span id="L119" class="LineNr">119 </span> <a href='103grapheme.subx.html#L107'>set-cursor-position-on-real-screen</a> x, y -<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="muComment"># fake screen</span> -<span id="L123" class="LineNr">123 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L124" class="LineNr">124 </span> <span class="muComment"># ignore x < 0</span> -<span id="L125" class="LineNr">125 </span> <span class="Delimiter">{</span> -<span id="L126" class="LineNr">126 </span> compare x, <span class="Constant">0</span> -<span id="L127" class="LineNr">127 </span> <span class="PreProc">break-if->=</span> -<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="muComment"># ignore x >= width</span> -<span id="L131" class="LineNr">131 </span> <span class="Delimiter">{</span> -<span id="L132" class="LineNr">132 </span> <span class="PreProc">var</span> width-addr/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, width -<span id="L133" class="LineNr">133 </span> <span class="PreProc">var</span> width/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy *width-addr -<span id="L134" class="LineNr">134 </span> compare x, width -<span id="L135" class="LineNr">135 </span> <span class="PreProc">break-if-<=</span> -<span id="L136" class="LineNr">136 </span> <span class="PreProc">return</span> -<span id="L137" class="LineNr">137 </span> <span class="Delimiter">}</span> -<span id="L138" class="LineNr">138 </span> <span class="muComment"># ignore y < 0</span> -<span id="L139" class="LineNr">139 </span> <span class="Delimiter">{</span> -<span id="L140" class="LineNr">140 </span> compare y, <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 id="L143" class="LineNr">143 </span> <span class="Delimiter">}</span> -<span id="L144" class="LineNr">144 </span> <span class="muComment"># ignore y >= height</span> -<span id="L145" class="LineNr">145 </span> <span class="Delimiter">{</span> -<span id="L146" class="LineNr">146 </span> <span class="PreProc">var</span> height-addr/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, height -<span id="L147" class="LineNr">147 </span> <span class="PreProc">var</span> height/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy *height-addr -<span id="L148" class="LineNr">148 </span> compare y, height -<span id="L149" class="LineNr">149 </span> <span class="PreProc">break-if-<</span> -<span id="L150" class="LineNr">150 </span> <span class="PreProc">return</span> -<span id="L151" class="LineNr">151 </span> <span class="Delimiter">}</span> -<span id="L152" class="LineNr">152 </span> <span class="muComment"># screen->cursor-x = x</span> -<span id="L153" class="LineNr">153 </span> <span class="PreProc">var</span> dest/<span class="Constant">edi</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, cursor-x -<span id="L154" class="LineNr">154 </span> <span class="PreProc">var</span> src/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy x -<span id="L155" class="LineNr">155 </span> copy-to *dest, src -<span id="L156" class="LineNr">156 </span> <span class="muComment"># screen->cursor-y = y</span> -<span id="L157" class="LineNr">157 </span> dest <span class="SpecialChar"><-</span> get screen-addr, cursor-y -<span id="L158" class="LineNr">158 </span> src <span class="SpecialChar"><-</span> copy y -<span id="L159" class="LineNr">159 </span> copy-to *dest, src -<span id="L160" class="LineNr">160 </span><span class="Delimiter">}</span> -<span id="L161" class="LineNr">161 </span> -<span id="L162" class="LineNr">162 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L162'>show-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), g: grapheme <span class="Delimiter">{</span> +<span id="L99" class="LineNr"> 99 </span><span class="muComment"># not really needed for a real screen, though it shouldn't do any harm</span> +<span id="L100" class="LineNr">100 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L100'>screen-cell-index</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), x: int, y: int<span class="PreProc"> -> </span>_/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> +<span id="L101" class="LineNr">101 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack +<span id="L102" class="LineNr">102 </span> <span class="muComment"># only one bounds check isn't automatically handled</span> +<span id="L103" class="LineNr">103 </span> <span class="Delimiter">{</span> +<span id="L104" class="LineNr">104 </span> <span class="PreProc">var</span> xmax/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> get <a href='500text-screen.mu.html#L9'>screen</a>, width +<span id="L105" class="LineNr">105 </span> <span class="PreProc">var</span> xcurr/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy x +<span id="L106" class="LineNr">106 </span> compare xcurr, *xmax +<span id="L107" class="LineNr">107 </span> <span class="PreProc">break-if-<</span> +<span id="L108" class="LineNr">108 </span> <a href='501draw-text.mu.html#L519'>abort</a> <span class="Constant">"tried to print out of <a href='500text-screen.mu.html#L9'>screen</a> bounds"</span> +<span id="L109" class="LineNr">109 </span> <span class="Delimiter">}</span> +<span id="L110" class="LineNr">110 </span> <span class="PreProc">var</span> height-addr/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> get <a href='500text-screen.mu.html#L9'>screen</a>, height +<span id="L111" class="LineNr">111 </span> <span class="PreProc">var</span> result/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy y +<span id="L112" class="LineNr">112 </span> result <span class="SpecialChar"><-</span> multiply *height-addr +<span id="L113" class="LineNr">113 </span> result <span class="SpecialChar"><-</span> add x +<span id="L114" class="LineNr">114 </span> <span class="PreProc">return</span> result +<span id="L115" class="LineNr">115 </span><span class="Delimiter">}</span> +<span id="L116" class="LineNr">116 </span> +<span id="L117" class="LineNr">117 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L117'>cursor-position</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> +<span id="L118" class="LineNr">118 </span> <span class="Delimiter">{</span> +<span id="L119" class="LineNr">119 </span> compare <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span> +<span id="L120" class="LineNr">120 </span> <span class="PreProc">break-if-!=</span> +<span id="L121" class="LineNr">121 </span> <span class="PreProc">var</span> x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L122" class="LineNr">122 </span> <span class="PreProc">var</span> y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L123" class="LineNr">123 </span> x, y <span class="SpecialChar"><-</span> <a href='103grapheme.subx.html#L96'>cursor-position-on-real-screen</a> +<span id="L124" class="LineNr">124 </span> <span class="PreProc">return</span> x, y +<span id="L125" class="LineNr">125 </span> <span class="Delimiter">}</span> +<span id="L126" class="LineNr">126 </span> <span class="muComment"># fake screen</span> +<span id="L127" class="LineNr">127 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L128" class="LineNr">128 </span> <span class="PreProc">var</span> cursor-x-addr/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, cursor-x +<span id="L129" class="LineNr">129 </span> <span class="PreProc">var</span> cursor-y-addr/<span class="Constant">ecx</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, cursor-y +<span id="L130" class="LineNr">130 </span> <span class="PreProc">return</span> *cursor-x-addr, *cursor-y-addr +<span id="L131" class="LineNr">131 </span><span class="Delimiter">}</span> +<span id="L132" class="LineNr">132 </span> +<span id="L133" class="LineNr">133 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L133'>set-cursor-position</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), x: int, y: int <span class="Delimiter">{</span> +<span id="L134" class="LineNr">134 </span> <span class="Delimiter">{</span> +<span id="L135" class="LineNr">135 </span> compare <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span> +<span id="L136" class="LineNr">136 </span> <span class="PreProc">break-if-!=</span> +<span id="L137" class="LineNr">137 </span> <a href='103grapheme.subx.html#L109'>set-cursor-position-on-real-screen</a> x, y +<span id="L138" class="LineNr">138 </span> <span class="PreProc">return</span> +<span id="L139" class="LineNr">139 </span> <span class="Delimiter">}</span> +<span id="L140" class="LineNr">140 </span> <span class="muComment"># fake screen</span> +<span id="L141" class="LineNr">141 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L142" class="LineNr">142 </span> <span class="muComment"># ignore x < 0</span> +<span id="L143" class="LineNr">143 </span> <span class="Delimiter">{</span> +<span id="L144" class="LineNr">144 </span> compare x, <span class="Constant">0</span> +<span id="L145" class="LineNr">145 </span> <span class="PreProc">break-if->=</span> +<span id="L146" class="LineNr">146 </span> <span class="PreProc">return</span> +<span id="L147" class="LineNr">147 </span> <span class="Delimiter">}</span> +<span id="L148" class="LineNr">148 </span> <span class="muComment"># ignore x >= width</span> +<span id="L149" class="LineNr">149 </span> <span class="Delimiter">{</span> +<span id="L150" class="LineNr">150 </span> <span class="PreProc">var</span> width-addr/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, width +<span id="L151" class="LineNr">151 </span> <span class="PreProc">var</span> width/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy *width-addr +<span id="L152" class="LineNr">152 </span> compare x, width +<span id="L153" class="LineNr">153 </span> <span class="PreProc">break-if-<=</span> +<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="muComment"># ignore y < 0</span> +<span id="L157" class="LineNr">157 </span> <span class="Delimiter">{</span> +<span id="L158" class="LineNr">158 </span> compare y, <span class="Constant">0</span> +<span id="L159" class="LineNr">159 </span> <span class="PreProc">break-if->=</span> +<span id="L160" class="LineNr">160 </span> <span class="PreProc">return</span> +<span id="L161" class="LineNr">161 </span> <span class="Delimiter">}</span> +<span id="L162" class="LineNr">162 </span> <span class="muComment"># ignore y >= height</span> <span id="L163" class="LineNr">163 </span> <span class="Delimiter">{</span> -<span id="L164" class="LineNr">164 </span> compare <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span> -<span id="L165" class="LineNr">165 </span> <span class="PreProc">break-if-!=</span> -<span id="L166" class="LineNr">166 </span> <a href='103grapheme.subx.html#L131'>show-cursor-on-real-screen</a> g -<span id="L167" class="LineNr">167 </span> <span class="PreProc">return</span> -<span id="L168" class="LineNr">168 </span> <span class="Delimiter">}</span> -<span id="L169" class="LineNr">169 </span> <span class="muComment"># fake screen</span> -<span id="L170" class="LineNr">170 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L171" class="LineNr">171 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L172" class="LineNr">172 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L99'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L173" class="LineNr">173 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, cursor-x, cursor-y, <span class="Constant">0</span> <span class="muComment"># cursor color not tracked for fake screen</span> -<span id="L174" class="LineNr">174 </span><span class="Delimiter">}</span> -<span id="L175" class="LineNr">175 </span> -<span id="L176" class="LineNr">176 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L176'>clear-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="Delimiter">{</span> -<span id="L177" class="LineNr">177 </span> <span class="Delimiter">{</span> -<span id="L178" class="LineNr">178 </span> compare <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span> -<span id="L179" class="LineNr">179 </span> <span class="PreProc">break-if-!=</span> -<span id="L180" class="LineNr">180 </span> <a href='500text-screen.mu.html#L209'>clear-real-screen</a> -<span id="L181" class="LineNr">181 </span> <span class="PreProc">return</span> -<span id="L182" class="LineNr">182 </span> <span class="Delimiter">}</span> -<span id="L183" class="LineNr">183 </span> <span class="muComment"># fake screen</span> -<span id="L184" class="LineNr">184 </span> <span class="PreProc">var</span> space/<span class="Constant">edi</span>: grapheme <span class="SpecialChar"><-</span> copy <span class="Constant">0x20</span> -<span id="L185" class="LineNr">185 </span> <a href='500text-screen.mu.html#L115'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>, <span class="Constant">0</span> -<span id="L186" class="LineNr">186 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L187" class="LineNr">187 </span> <span class="PreProc">var</span> y/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">1</span> -<span id="L188" class="LineNr">188 </span> <span class="PreProc">var</span> height/<span class="Constant">ecx</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, height -<span id="L189" class="LineNr">189 </span> <span class="Delimiter">{</span> -<span id="L190" class="LineNr">190 </span> compare y, *height -<span id="L191" class="LineNr">191 </span> <span class="PreProc">break-if-></span> -<span id="L192" class="LineNr">192 </span> <span class="PreProc">var</span> x/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">1</span> -<span id="L193" class="LineNr">193 </span> <span class="PreProc">var</span> width/<span class="Constant">ebx</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, width -<span id="L194" class="LineNr">194 </span> <span class="Delimiter">{</span> -<span id="L195" class="LineNr">195 </span> compare x, *width -<span id="L196" class="LineNr">196 </span> <span class="PreProc">break-if-></span> -<span id="L197" class="LineNr">197 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, space, x, y, <span class="Constant">0</span> <span class="muComment"># color=black</span> -<span id="L198" class="LineNr">198 </span> x <span class="SpecialChar"><-</span> increment -<span id="L199" class="LineNr">199 </span> <span class="PreProc">loop</span> -<span id="L200" class="LineNr">200 </span> <span class="Delimiter">}</span> -<span id="L201" class="LineNr">201 </span> y <span class="SpecialChar"><-</span> increment -<span id="L202" class="LineNr">202 </span> <span class="PreProc">loop</span> -<span id="L203" class="LineNr">203 </span> <span class="Delimiter">}</span> -<span id="L204" class="LineNr">204 </span> <a href='500text-screen.mu.html#L115'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>, <span class="Constant">0</span> -<span id="L205" class="LineNr">205 </span><span class="Delimiter">}</span> -<span id="L206" class="LineNr">206 </span> -<span id="L207" class="LineNr">207 </span><span class="muComment"># there's no grapheme that guarantees to cover every pixel, so we'll bump down</span> -<span id="L208" class="LineNr">208 </span><span class="muComment"># to pixels for a real screen</span> -<span id="L209" class="LineNr">209 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L209'>clear-real-screen</a></span> <span class="Delimiter">{</span> -<span id="L210" class="LineNr">210 </span> <span class="PreProc">var</span> y/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L211" class="LineNr">211 </span> <span class="Delimiter">{</span> -<span id="L212" class="LineNr">212 </span> compare y, <span class="Constant">0x300</span> <span class="muComment"># screen-height = 768</span> -<span id="L213" class="LineNr">213 </span> <span class="PreProc">break-if->=</span> -<span id="L214" class="LineNr">214 </span> <span class="PreProc">var</span> x/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L215" class="LineNr">215 </span> <span class="Delimiter">{</span> -<span id="L216" class="LineNr">216 </span> compare x, <span class="Constant">0x400</span> <span class="muComment"># screen-width = 1024</span> -<span id="L217" class="LineNr">217 </span> <span class="PreProc">break-if->=</span> -<span id="L218" class="LineNr">218 </span> <a href='101screen.subx.html#L8'>pixel-on-real-screen</a> x, y, <span class="Constant">0</span> <span class="muComment"># black</span> -<span id="L219" class="LineNr">219 </span> x <span class="SpecialChar"><-</span> increment -<span id="L220" class="LineNr">220 </span> <span class="PreProc">loop</span> -<span id="L221" class="LineNr">221 </span> <span class="Delimiter">}</span> -<span id="L222" class="LineNr">222 </span> y <span class="SpecialChar"><-</span> increment -<span id="L223" class="LineNr">223 </span> <span class="PreProc">loop</span> -<span id="L224" class="LineNr">224 </span> <span class="Delimiter">}</span> -<span id="L225" class="LineNr">225 </span><span class="Delimiter">}</span> -<span id="L226" class="LineNr">226 </span> -<span id="L227" class="LineNr">227 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L227'>screen-grapheme-at</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), x: int, y: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: grapheme <span class="Delimiter">{</span> -<span id="L228" class="LineNr">228 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack -<span id="L229" class="LineNr">229 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L90'>screen-cell-index</a> screen-addr, x, y -<span id="L230" class="LineNr">230 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L234'>screen-grapheme-at-idx</a> screen-addr, idx -<span id="L231" class="LineNr">231 </span> <span class="PreProc">return</span> result -<span id="L232" class="LineNr">232 </span><span class="Delimiter">}</span> -<span id="L233" class="LineNr">233 </span> -<span id="L234" class="LineNr">234 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L234'>screen-grapheme-at-idx</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), idx-on-stack: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: grapheme <span class="Delimiter">{</span> -<span id="L235" class="LineNr">235 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack -<span id="L236" class="LineNr">236 </span> <span class="PreProc">var</span> data-ah/<span class="Constant">eax</span>: (addr handle array <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> get screen-addr, data -<span id="L237" class="LineNr">237 </span> <span class="PreProc">var</span> data/<span class="Constant">eax</span>: (addr array <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *data-ah -<span id="L238" class="LineNr">238 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy idx-on-stack -<span id="L239" class="LineNr">239 </span> <span class="PreProc">var</span> offset/<span class="Constant">ecx</span>: (offset <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> compute-offset data, idx -<span id="L240" class="LineNr">240 </span> <span class="PreProc">var</span> cell/<span class="Constant">eax</span>: (addr <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> index data, offset -<span id="L241" class="LineNr">241 </span> <span class="PreProc">var</span> src/<span class="Constant">eax</span>: (addr grapheme) <span class="SpecialChar"><-</span> get cell, data -<span id="L242" class="LineNr">242 </span> <span class="PreProc">return</span> *src -<span id="L243" class="LineNr">243 </span><span class="Delimiter">}</span> -<span id="L244" class="LineNr">244 </span> -<span id="L245" class="LineNr">245 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L245'>screen-color-at</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), x: int, y: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> -<span id="L246" class="LineNr">246 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack -<span id="L247" class="LineNr">247 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L90'>screen-cell-index</a> screen-addr, x, y -<span id="L248" class="LineNr">248 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L252'>screen-color-at-idx</a> screen-addr, idx -<span id="L249" class="LineNr">249 </span> <span class="PreProc">return</span> result -<span id="L250" class="LineNr">250 </span><span class="Delimiter">}</span> -<span id="L251" class="LineNr">251 </span> -<span id="L252" class="LineNr">252 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L252'>screen-color-at-idx</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), idx-on-stack: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> -<span id="L253" class="LineNr">253 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack -<span id="L254" class="LineNr">254 </span> <span class="PreProc">var</span> data-ah/<span class="Constant">eax</span>: (addr handle array <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> get screen-addr, data -<span id="L255" class="LineNr">255 </span> <span class="PreProc">var</span> data/<span class="Constant">eax</span>: (addr array <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *data-ah -<span id="L256" class="LineNr">256 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy idx-on-stack -<span id="L257" class="LineNr">257 </span> <span class="PreProc">var</span> offset/<span class="Constant">ecx</span>: (offset <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> compute-offset data, idx -<span id="L258" class="LineNr">258 </span> <span class="PreProc">var</span> cell/<span class="Constant">eax</span>: (addr <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> index data, offset -<span id="L259" class="LineNr">259 </span> <span class="PreProc">var</span> src/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> get cell, color -<span id="L260" class="LineNr">260 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy *src -<span id="L261" class="LineNr">261 </span> <span class="PreProc">return</span> result -<span id="L262" class="LineNr">262 </span><span class="Delimiter">}</span> +<span id="L164" class="LineNr">164 </span> <span class="PreProc">var</span> height-addr/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, height +<span id="L165" class="LineNr">165 </span> <span class="PreProc">var</span> height/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy *height-addr +<span id="L166" class="LineNr">166 </span> compare y, height +<span id="L167" class="LineNr">167 </span> <span class="PreProc">break-if-<</span> +<span id="L168" class="LineNr">168 </span> <span class="PreProc">return</span> +<span id="L169" class="LineNr">169 </span> <span class="Delimiter">}</span> +<span id="L170" class="LineNr">170 </span> <span class="muComment"># screen->cursor-x = x</span> +<span id="L171" class="LineNr">171 </span> <span class="PreProc">var</span> dest/<span class="Constant">edi</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, cursor-x +<span id="L172" class="LineNr">172 </span> <span class="PreProc">var</span> src/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy x +<span id="L173" class="LineNr">173 </span> copy-to *dest, src +<span id="L174" class="LineNr">174 </span> <span class="muComment"># screen->cursor-y = y</span> +<span id="L175" class="LineNr">175 </span> dest <span class="SpecialChar"><-</span> get screen-addr, cursor-y +<span id="L176" class="LineNr">176 </span> src <span class="SpecialChar"><-</span> copy y +<span id="L177" class="LineNr">177 </span> copy-to *dest, src +<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='500text-screen.mu.html#L180'>show-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), g: grapheme <span class="Delimiter">{</span> +<span id="L181" class="LineNr">181 </span> <span class="Delimiter">{</span> +<span id="L182" class="LineNr">182 </span> compare <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span> +<span id="L183" class="LineNr">183 </span> <span class="PreProc">break-if-!=</span> +<span id="L184" class="LineNr">184 </span> <a href='103grapheme.subx.html#L134'>show-cursor-on-real-screen</a> g +<span id="L185" class="LineNr">185 </span> <span class="PreProc">return</span> +<span id="L186" class="LineNr">186 </span> <span class="Delimiter">}</span> +<span id="L187" class="LineNr">187 </span> <span class="muComment"># fake screen</span> +<span id="L188" class="LineNr">188 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L189" class="LineNr">189 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L190" class="LineNr">190 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L117'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L191" class="LineNr">191 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, cursor-x, cursor-y, <span class="Constant">0</span>/fg, <span class="Constant">7</span>/bg +<span id="L192" class="LineNr">192 </span><span class="Delimiter">}</span> +<span id="L193" class="LineNr">193 </span> +<span id="L194" class="LineNr">194 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L194'>clear-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="Delimiter">{</span> +<span id="L195" class="LineNr">195 </span> <span class="Delimiter">{</span> +<span id="L196" class="LineNr">196 </span> compare <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span> +<span id="L197" class="LineNr">197 </span> <span class="PreProc">break-if-!=</span> +<span id="L198" class="LineNr">198 </span> <a href='500text-screen.mu.html#L226'>clear-real-screen</a> +<span id="L199" class="LineNr">199 </span> <span class="PreProc">return</span> +<span id="L200" class="LineNr">200 </span> <span class="Delimiter">}</span> +<span id="L201" class="LineNr">201 </span> <span class="muComment"># fake screen</span> +<span id="L202" class="LineNr">202 </span> <a href='500text-screen.mu.html#L133'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>, <span class="Constant">0</span> +<span id="L203" class="LineNr">203 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L204" class="LineNr">204 </span> <span class="PreProc">var</span> y/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L205" class="LineNr">205 </span> <span class="PreProc">var</span> height/<span class="Constant">ecx</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, height +<span id="L206" class="LineNr">206 </span> <span class="Delimiter">{</span> +<span id="L207" class="LineNr">207 </span> compare y, *height +<span id="L208" class="LineNr">208 </span> <span class="PreProc">break-if->=</span> +<span id="L209" class="LineNr">209 </span> <span class="PreProc">var</span> x/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L210" class="LineNr">210 </span> <span class="PreProc">var</span> width/<span class="Constant">ebx</span>: (addr int) <span class="SpecialChar"><-</span> get screen-addr, width +<span id="L211" class="LineNr">211 </span> <span class="Delimiter">{</span> +<span id="L212" class="LineNr">212 </span> compare x, *width +<span id="L213" class="LineNr">213 </span> <span class="PreProc">break-if->=</span> +<span id="L214" class="LineNr">214 </span> <a href='500text-screen.mu.html#L94'>draw-code-point</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x20</span>/space, x, y, <span class="Constant">0</span>/fg=black, <span class="Constant">0</span>/bg=black +<span id="L215" class="LineNr">215 </span> x <span class="SpecialChar"><-</span> increment +<span id="L216" class="LineNr">216 </span> <span class="PreProc">loop</span> +<span id="L217" class="LineNr">217 </span> <span class="Delimiter">}</span> +<span id="L218" class="LineNr">218 </span> y <span class="SpecialChar"><-</span> increment +<span id="L219" class="LineNr">219 </span> <span class="PreProc">loop</span> +<span id="L220" class="LineNr">220 </span> <span class="Delimiter">}</span> +<span id="L221" class="LineNr">221 </span> <a href='500text-screen.mu.html#L133'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>, <span class="Constant">0</span> +<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="muComment"># there's no grapheme that guarantees to cover every pixel, so we'll bump down</span> +<span id="L225" class="LineNr">225 </span><span class="muComment"># to pixels for a real screen</span> +<span id="L226" class="LineNr">226 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L226'>clear-real-screen</a></span> <span class="Delimiter">{</span> +<span id="L227" class="LineNr">227 </span> <span class="PreProc">var</span> y/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L228" class="LineNr">228 </span> <span class="Delimiter">{</span> +<span id="L229" class="LineNr">229 </span> compare y, <span class="Constant">0x300</span>/screen-height=<span class="Constant">768</span> +<span id="L230" class="LineNr">230 </span> <span class="PreProc">break-if->=</span> +<span id="L231" class="LineNr">231 </span> <span class="PreProc">var</span> x/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L232" class="LineNr">232 </span> <span class="Delimiter">{</span> +<span id="L233" class="LineNr">233 </span> compare x, <span class="Constant">0x400</span>/screen-width=<span class="Constant">1024</span> +<span id="L234" class="LineNr">234 </span> <span class="PreProc">break-if->=</span> +<span id="L235" class="LineNr">235 </span> <a href='101screen.subx.html#L8'>pixel-on-real-screen</a> x, y, <span class="Constant">0</span>/color=black +<span id="L236" class="LineNr">236 </span> x <span class="SpecialChar"><-</span> increment +<span id="L237" class="LineNr">237 </span> <span class="PreProc">loop</span> +<span id="L238" class="LineNr">238 </span> <span class="Delimiter">}</span> +<span id="L239" class="LineNr">239 </span> y <span class="SpecialChar"><-</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="L243" class="LineNr">243 </span> +<span id="L244" class="LineNr">244 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L244'>screen-grapheme-at</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), x: int, y: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: grapheme <span class="Delimiter">{</span> +<span id="L245" class="LineNr">245 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack +<span id="L246" class="LineNr">246 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L100'>screen-cell-index</a> screen-addr, x, y +<span id="L247" class="LineNr">247 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L251'>screen-grapheme-at-idx</a> screen-addr, idx +<span id="L248" class="LineNr">248 </span> <span class="PreProc">return</span> result +<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='500text-screen.mu.html#L251'>screen-grapheme-at-idx</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), idx-on-stack: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: grapheme <span class="Delimiter">{</span> +<span id="L252" class="LineNr">252 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack +<span id="L253" class="LineNr">253 </span> <span class="PreProc">var</span> data-ah/<span class="Constant">eax</span>: (addr handle array <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> get screen-addr, data +<span id="L254" class="LineNr">254 </span> <span class="PreProc">var</span> data/<span class="Constant">eax</span>: (addr array <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *data-ah +<span id="L255" class="LineNr">255 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy idx-on-stack +<span id="L256" class="LineNr">256 </span> <span class="PreProc">var</span> offset/<span class="Constant">ecx</span>: (offset <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> compute-offset data, idx +<span id="L257" class="LineNr">257 </span> <span class="PreProc">var</span> cell/<span class="Constant">eax</span>: (addr <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> index data, offset +<span id="L258" class="LineNr">258 </span> <span class="PreProc">var</span> src/<span class="Constant">eax</span>: (addr grapheme) <span class="SpecialChar"><-</span> get cell, data +<span id="L259" class="LineNr">259 </span> <span class="PreProc">return</span> *src +<span id="L260" class="LineNr">260 </span><span class="Delimiter">}</span> +<span id="L261" class="LineNr">261 </span> +<span id="L262" class="LineNr">262 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L262'>screen-color-at</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), x: int, y: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L263" class="LineNr">263 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack +<span id="L264" class="LineNr">264 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L100'>screen-cell-index</a> screen-addr, x, y +<span id="L265" class="LineNr">265 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L269'>screen-color-at-idx</a> screen-addr, idx +<span id="L266" class="LineNr">266 </span> <span class="PreProc">return</span> result +<span id="L267" class="LineNr">267 </span><span class="Delimiter">}</span> +<span id="L268" class="LineNr">268 </span> +<span id="L269" class="LineNr">269 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L269'>screen-color-at-idx</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), idx-on-stack: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L270" class="LineNr">270 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack +<span id="L271" class="LineNr">271 </span> <span class="PreProc">var</span> data-ah/<span class="Constant">eax</span>: (addr handle array <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> get screen-addr, data +<span id="L272" class="LineNr">272 </span> <span class="PreProc">var</span> data/<span class="Constant">eax</span>: (addr array <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *data-ah +<span id="L273" class="LineNr">273 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy idx-on-stack +<span id="L274" class="LineNr">274 </span> <span class="PreProc">var</span> offset/<span class="Constant">ecx</span>: (offset <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> compute-offset data, idx +<span id="L275" class="LineNr">275 </span> <span class="PreProc">var</span> cell/<span class="Constant">eax</span>: (addr <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> index data, offset +<span id="L276" class="LineNr">276 </span> <span class="PreProc">var</span> src/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> get cell, color +<span id="L277" class="LineNr">277 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy *src +<span id="L278" class="LineNr">278 </span> <span class="PreProc">return</span> result +<span id="L279" class="LineNr">279 </span><span class="Delimiter">}</span> +<span id="L280" class="LineNr">280 </span> +<span id="L281" class="LineNr">281 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L281'>screen-background-color-at</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), x: int, y: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L282" class="LineNr">282 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack +<span id="L283" class="LineNr">283 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L100'>screen-cell-index</a> screen-addr, x, y +<span id="L284" class="LineNr">284 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L288'>screen-background-color-at-idx</a> screen-addr, idx +<span id="L285" class="LineNr">285 </span> <span class="PreProc">return</span> result +<span id="L286" class="LineNr">286 </span><span class="Delimiter">}</span> +<span id="L287" class="LineNr">287 </span> +<span id="L288" class="LineNr">288 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='500text-screen.mu.html#L288'>screen-background-color-at-idx</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), idx-on-stack: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L289" class="LineNr">289 </span> <span class="PreProc">var</span> screen-addr/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack +<span id="L290" class="LineNr">290 </span> <span class="PreProc">var</span> data-ah/<span class="Constant">eax</span>: (addr handle array <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> get screen-addr, data +<span id="L291" class="LineNr">291 </span> <span class="PreProc">var</span> data/<span class="Constant">eax</span>: (addr array <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *data-ah +<span id="L292" class="LineNr">292 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy idx-on-stack +<span id="L293" class="LineNr">293 </span> <span class="PreProc">var</span> offset/<span class="Constant">ecx</span>: (offset <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> compute-offset data, idx +<span id="L294" class="LineNr">294 </span> <span class="PreProc">var</span> cell/<span class="Constant">eax</span>: (addr <a href='500text-screen.mu.html#L17'>screen-cell</a>) <span class="SpecialChar"><-</span> index data, offset +<span id="L295" class="LineNr">295 </span> <span class="PreProc">var</span> src/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> get cell, background-color +<span id="L296" class="LineNr">296 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy *src +<span id="L297" class="LineNr">297 </span> <span class="PreProc">return</span> result +<span id="L298" class="LineNr">298 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/baremetal/501draw-text.mu.html b/html/baremetal/501draw-text.mu.html index 31ee49c4..9b81ae73 100644 --- a/html/baremetal/501draw-text.mu.html +++ b/html/baremetal/501draw-text.mu.html @@ -58,503 +58,530 @@ if ('onhashchange' in window) { <pre id='vimCodeElement'> <span id="L1" class="LineNr"> 1 </span><span class="muComment"># some primitives for moving the cursor without making assumptions about</span> <span id="L2" class="LineNr"> 2 </span><span class="muComment"># raster order</span> -<span id="L3" class="LineNr"> 3 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L3'>cursor-left</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="Delimiter">{</span> +<span id="L3" class="LineNr"> 3 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L3'>move-cursor-left</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="Delimiter">{</span> <span id="L4" class="LineNr"> 4 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> <span id="L5" class="LineNr"> 5 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L6" class="LineNr"> 6 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L99'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L6" class="LineNr"> 6 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L117'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> <span id="L7" class="LineNr"> 7 </span> compare cursor-x, <span class="Constant">0</span> <span id="L8" class="LineNr"> 8 </span> <span class="Delimiter">{</span> <span id="L9" class="LineNr"> 9 </span> <span class="PreProc">break-if-></span> <span id="L10" class="LineNr"> 10 </span> <span class="PreProc">return</span> <span id="L11" class="LineNr"> 11 </span> <span class="Delimiter">}</span> <span id="L12" class="LineNr"> 12 </span> cursor-x <span class="SpecialChar"><-</span> decrement -<span id="L13" class="LineNr"> 13 </span> <a href='500text-screen.mu.html#L115'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, cursor-x, cursor-y +<span id="L13" class="LineNr"> 13 </span> <a href='500text-screen.mu.html#L133'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, cursor-x, cursor-y <span id="L14" class="LineNr"> 14 </span><span class="Delimiter">}</span> <span id="L15" class="LineNr"> 15 </span> -<span id="L16" class="LineNr"> 16 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L16'>cursor-right</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="Delimiter">{</span> +<span id="L16" class="LineNr"> 16 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L16'>move-cursor-right</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="Delimiter">{</span> <span id="L17" class="LineNr"> 17 </span> <span class="PreProc">var</span> _width/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> <span id="L18" class="LineNr"> 18 </span> <span class="PreProc">var</span> dummy/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L19" class="LineNr"> 19 </span> _width, dummy <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L49'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L20" class="LineNr"> 20 </span> <span class="PreProc">var</span> width/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy _width -<span id="L21" class="LineNr"> 21 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L22" class="LineNr"> 22 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L23" class="LineNr"> 23 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L99'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L24" class="LineNr"> 24 </span> compare cursor-x, width -<span id="L25" class="LineNr"> 25 </span> <span class="Delimiter">{</span> -<span id="L26" class="LineNr"> 26 </span> <span class="PreProc">break-if-<</span> -<span id="L27" class="LineNr"> 27 </span> <span class="PreProc">return</span> -<span id="L28" class="LineNr"> 28 </span> <span class="Delimiter">}</span> -<span id="L29" class="LineNr"> 29 </span> cursor-x <span class="SpecialChar"><-</span> increment -<span id="L30" class="LineNr"> 30 </span> <a href='500text-screen.mu.html#L115'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, cursor-x, cursor-y -<span id="L31" class="LineNr"> 31 </span><span class="Delimiter">}</span> -<span id="L32" class="LineNr"> 32 </span> -<span id="L33" class="LineNr"> 33 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L33'>cursor-up</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="Delimiter">{</span> -<span id="L34" class="LineNr"> 34 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L35" class="LineNr"> 35 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L36" class="LineNr"> 36 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L99'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L37" class="LineNr"> 37 </span> compare cursor-y, <span class="Constant">0</span> -<span id="L38" class="LineNr"> 38 </span> <span class="Delimiter">{</span> -<span id="L39" class="LineNr"> 39 </span> <span class="PreProc">break-if-></span> -<span id="L40" class="LineNr"> 40 </span> <span class="PreProc">return</span> -<span id="L41" class="LineNr"> 41 </span> <span class="Delimiter">}</span> -<span id="L42" class="LineNr"> 42 </span> cursor-y <span class="SpecialChar"><-</span> decrement -<span id="L43" class="LineNr"> 43 </span> <a href='500text-screen.mu.html#L115'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, cursor-x, cursor-y -<span id="L44" class="LineNr"> 44 </span><span class="Delimiter">}</span> -<span id="L45" class="LineNr"> 45 </span> -<span id="L46" class="LineNr"> 46 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L46'>cursor-down</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="Delimiter">{</span> -<span id="L47" class="LineNr"> 47 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L48" class="LineNr"> 48 </span> <span class="PreProc">var</span> _height/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L49" class="LineNr"> 49 </span> dummy, _height <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L49'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L50" class="LineNr"> 50 </span> <span class="PreProc">var</span> height/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy _height -<span id="L51" class="LineNr"> 51 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L52" class="LineNr"> 52 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L53" class="LineNr"> 53 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L99'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L54" class="LineNr"> 54 </span> compare cursor-y, height -<span id="L55" class="LineNr"> 55 </span> <span class="Delimiter">{</span> -<span id="L56" class="LineNr"> 56 </span> <span class="PreProc">break-if-<</span> -<span id="L57" class="LineNr"> 57 </span> <span class="PreProc">return</span> -<span id="L58" class="LineNr"> 58 </span> <span class="Delimiter">}</span> -<span id="L59" class="LineNr"> 59 </span> cursor-y <span class="SpecialChar"><-</span> increment -<span id="L60" class="LineNr"> 60 </span> <a href='500text-screen.mu.html#L115'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, cursor-x, cursor-y -<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="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L63'>draw-grapheme-at-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), g: grapheme, color: int <span class="Delimiter">{</span> -<span id="L64" class="LineNr"> 64 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L65" class="LineNr"> 65 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L66" class="LineNr"> 66 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L99'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L67" class="LineNr"> 67 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, cursor-x, cursor-y, color -<span id="L68" class="LineNr"> 68 </span><span class="Delimiter">}</span> -<span id="L69" class="LineNr"> 69 </span> -<span id="L70" class="LineNr"> 70 </span><span class="muComment"># draw a single line of text from x, y to xmax</span> -<span id="L71" class="LineNr"> 71 </span><span class="muComment"># return the next 'x' coordinate</span> -<span id="L72" class="LineNr"> 72 </span><span class="muComment"># if there isn't enough space, return 0 without modifying the screen</span> -<span id="L73" class="LineNr"> 73 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L73'>draw-text-rightward</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), x: int, xmax: int, y: int, color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> -<span id="L74" class="LineNr"> 74 </span> <span class="PreProc">var</span> stream-storage: (stream byte <span class="Constant">0x100</span>) -<span id="L75" class="LineNr"> 75 </span> <span class="PreProc">var</span> stream/<span class="Constant">esi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address stream-storage -<span id="L76" class="LineNr"> 76 </span> <a href='108write.subx.html#L11'>write</a> stream, text -<span id="L77" class="LineNr"> 77 </span> <span class="muComment"># check if we have enough space</span> -<span id="L78" class="LineNr"> 78 </span> <span class="PreProc">var</span> xcurr/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy x -<span id="L79" class="LineNr"> 79 </span> <span class="Delimiter">{</span> -<span id="L80" class="LineNr"> 80 </span> compare xcurr, xmax -<span id="L81" class="LineNr"> 81 </span> <span class="PreProc">break-if-></span> -<span id="L82" class="LineNr"> 82 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream -<span id="L83" class="LineNr"> 83 </span> compare g, <span class="Constant">0xffffffff</span> <span class="muComment"># end-of-file</span> -<span id="L84" class="LineNr"> 84 </span> <span class="PreProc">break-if-=</span> -<span id="L85" class="LineNr"> 85 </span> xcurr <span class="SpecialChar"><-</span> increment -<span id="L86" class="LineNr"> 86 </span> <span class="PreProc">loop</span> -<span id="L87" class="LineNr"> 87 </span> <span class="Delimiter">}</span> -<span id="L88" class="LineNr"> 88 </span> compare xcurr, xmax -<span id="L89" class="LineNr"> 89 </span> <span class="Delimiter">{</span> -<span id="L90" class="LineNr"> 90 </span> <span class="PreProc">break-if-<=</span> -<span id="L91" class="LineNr"> 91 </span> <span class="PreProc">return</span> <span class="Constant">0</span> -<span id="L92" class="LineNr"> 92 </span> <span class="Delimiter">}</span> -<span id="L93" class="LineNr"> 93 </span> <span class="muComment"># we do; actually draw</span> -<span id="L94" class="LineNr"> 94 </span> <a href='106stream.subx.html#L59'>rewind-stream</a> stream -<span id="L95" class="LineNr"> 95 </span> xcurr <span class="SpecialChar"><-</span> copy x -<span id="L96" class="LineNr"> 96 </span> <span class="Delimiter">{</span> -<span id="L97" class="LineNr"> 97 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream -<span id="L98" class="LineNr"> 98 </span> compare g, <span class="Constant">0xffffffff</span> <span class="muComment"># end-of-file</span> -<span id="L99" class="LineNr"> 99 </span> <span class="PreProc">break-if-=</span> -<span id="L100" class="LineNr">100 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, xcurr, y, color -<span id="L101" class="LineNr">101 </span> xcurr <span class="SpecialChar"><-</span> increment -<span id="L102" class="LineNr">102 </span> <span class="PreProc">loop</span> -<span id="L103" class="LineNr">103 </span> <span class="Delimiter">}</span> -<span id="L104" class="LineNr">104 </span> <a href='500text-screen.mu.html#L115'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, xcurr, y -<span id="L105" class="LineNr">105 </span> <span class="PreProc">return</span> xcurr -<span id="L106" class="LineNr">106 </span><span class="Delimiter">}</span> -<span id="L107" class="LineNr">107 </span> -<span id="L108" class="LineNr">108 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L108'>draw-text-rightward-from-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), xmax: int, color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> -<span id="L109" class="LineNr">109 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L110" class="LineNr">110 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L111" class="LineNr">111 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L99'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L112" class="LineNr">112 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L73'>draw-text-rightward</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, cursor-x, xmax, cursor-y, color -<span id="L113" class="LineNr">113 </span> <span class="PreProc">return</span> result +<span id="L19" class="LineNr"> 19 </span> _width, dummy <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L50'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L20" class="LineNr"> 20 </span> <span class="PreProc">var</span> limit/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy _width +<span id="L21" class="LineNr"> 21 </span> limit <span class="SpecialChar"><-</span> decrement +<span id="L22" class="LineNr"> 22 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L23" class="LineNr"> 23 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L24" class="LineNr"> 24 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L117'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L25" class="LineNr"> 25 </span> compare cursor-x, limit +<span id="L26" class="LineNr"> 26 </span> <span class="Delimiter">{</span> +<span id="L27" class="LineNr"> 27 </span> <span class="PreProc">break-if-<</span> +<span id="L28" class="LineNr"> 28 </span> <span class="PreProc">return</span> +<span id="L29" class="LineNr"> 29 </span> <span class="Delimiter">}</span> +<span id="L30" class="LineNr"> 30 </span> cursor-x <span class="SpecialChar"><-</span> increment +<span id="L31" class="LineNr"> 31 </span> <a href='500text-screen.mu.html#L133'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, cursor-x, cursor-y +<span id="L32" class="LineNr"> 32 </span><span class="Delimiter">}</span> +<span id="L33" class="LineNr"> 33 </span> +<span id="L34" class="LineNr"> 34 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L34'>move-cursor-up</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="Delimiter">{</span> +<span id="L35" class="LineNr"> 35 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L36" class="LineNr"> 36 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L37" class="LineNr"> 37 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L117'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L38" class="LineNr"> 38 </span> compare cursor-y, <span class="Constant">0</span> +<span id="L39" class="LineNr"> 39 </span> <span class="Delimiter">{</span> +<span id="L40" class="LineNr"> 40 </span> <span class="PreProc">break-if-></span> +<span id="L41" class="LineNr"> 41 </span> <span class="PreProc">return</span> +<span id="L42" class="LineNr"> 42 </span> <span class="Delimiter">}</span> +<span id="L43" class="LineNr"> 43 </span> cursor-y <span class="SpecialChar"><-</span> decrement +<span id="L44" class="LineNr"> 44 </span> <a href='500text-screen.mu.html#L133'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, cursor-x, cursor-y +<span id="L45" class="LineNr"> 45 </span><span class="Delimiter">}</span> +<span id="L46" class="LineNr"> 46 </span> +<span id="L47" class="LineNr"> 47 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L47'>move-cursor-down</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="Delimiter">{</span> +<span id="L48" class="LineNr"> 48 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L49" class="LineNr"> 49 </span> <span class="PreProc">var</span> _height/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L50" class="LineNr"> 50 </span> dummy, _height <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L50'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L51" class="LineNr"> 51 </span> <span class="PreProc">var</span> limit/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy _height +<span id="L52" class="LineNr"> 52 </span> limit <span class="SpecialChar"><-</span> decrement +<span id="L53" class="LineNr"> 53 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L54" class="LineNr"> 54 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L55" class="LineNr"> 55 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L117'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L56" class="LineNr"> 56 </span> compare cursor-y, limit +<span id="L57" class="LineNr"> 57 </span> <span class="Delimiter">{</span> +<span id="L58" class="LineNr"> 58 </span> <span class="PreProc">break-if-<</span> +<span id="L59" class="LineNr"> 59 </span> <span class="PreProc">return</span> +<span id="L60" class="LineNr"> 60 </span> <span class="Delimiter">}</span> +<span id="L61" class="LineNr"> 61 </span> cursor-y <span class="SpecialChar"><-</span> increment +<span id="L62" class="LineNr"> 62 </span> <a href='500text-screen.mu.html#L133'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, cursor-x, cursor-y +<span id="L63" class="LineNr"> 63 </span><span class="Delimiter">}</span> +<span id="L64" class="LineNr"> 64 </span> +<span id="L65" class="LineNr"> 65 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L65'>draw-grapheme-at-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), g: grapheme, color: int, background-color: int <span class="Delimiter">{</span> +<span id="L66" class="LineNr"> 66 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L67" class="LineNr"> 67 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L68" class="LineNr"> 68 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L117'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L69" class="LineNr"> 69 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, cursor-x, cursor-y, color, background-color +<span id="L70" class="LineNr"> 70 </span><span class="Delimiter">}</span> +<span id="L71" class="LineNr"> 71 </span> +<span id="L72" class="LineNr"> 72 </span><span class="muComment"># we can't really render non-ASCII yet, but when we do we'll be ready</span> +<span id="L73" class="LineNr"> 73 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L73'>draw-code-point-at-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), c: code-point, color: int, background-color: int <span class="Delimiter">{</span> +<span id="L74" class="LineNr"> 74 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> copy c +<span id="L75" class="LineNr"> 75 </span> <a href='501draw-text.mu.html#L65'>draw-grapheme-at-cursor</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, color, background-color +<span id="L76" class="LineNr"> 76 </span><span class="Delimiter">}</span> +<span id="L77" class="LineNr"> 77 </span> +<span id="L78" class="LineNr"> 78 </span><span class="muComment"># draw a single line of text from x, y to xmax</span> +<span id="L79" class="LineNr"> 79 </span><span class="muComment"># return the next 'x' coordinate</span> +<span id="L80" class="LineNr"> 80 </span><span class="muComment"># if there isn't enough space, return 0 without modifying the screen</span> +<span id="L81" class="LineNr"> 81 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L81'>draw-text-rightward</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), x: int, xmax: int, y: int, color: int, background-color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L82" class="LineNr"> 82 </span> <span class="PreProc">var</span> stream-storage: (stream byte <span class="Constant">0x100</span>) +<span id="L83" class="LineNr"> 83 </span> <span class="PreProc">var</span> stream/<span class="Constant">esi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address stream-storage +<span id="L84" class="LineNr"> 84 </span> <a href='108write.subx.html#L11'>write</a> stream, text +<span id="L85" class="LineNr"> 85 </span> <span class="muComment"># check if we have enough space</span> +<span id="L86" class="LineNr"> 86 </span> <span class="PreProc">var</span> xcurr/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy x +<span id="L87" class="LineNr"> 87 </span> <span class="Delimiter">{</span> +<span id="L88" class="LineNr"> 88 </span> compare xcurr, xmax +<span id="L89" class="LineNr"> 89 </span> <span class="PreProc">break-if-></span> +<span id="L90" class="LineNr"> 90 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream +<span id="L91" class="LineNr"> 91 </span> compare g, <span class="Constant">0xffffffff</span>/end-of-file +<span id="L92" class="LineNr"> 92 </span> <span class="PreProc">break-if-=</span> +<span id="L93" class="LineNr"> 93 </span> xcurr <span class="SpecialChar"><-</span> increment +<span id="L94" class="LineNr"> 94 </span> <span class="PreProc">loop</span> +<span id="L95" class="LineNr"> 95 </span> <span class="Delimiter">}</span> +<span id="L96" class="LineNr"> 96 </span> compare xcurr, xmax +<span id="L97" class="LineNr"> 97 </span> <span class="Delimiter">{</span> +<span id="L98" class="LineNr"> 98 </span> <span class="PreProc">break-if-<=</span> +<span id="L99" class="LineNr"> 99 </span> <span class="PreProc">return</span> <span class="Constant">0</span> +<span id="L100" class="LineNr">100 </span> <span class="Delimiter">}</span> +<span id="L101" class="LineNr">101 </span> <span class="muComment"># we do; actually draw</span> +<span id="L102" class="LineNr">102 </span> <a href='106stream.subx.html#L59'>rewind-stream</a> stream +<span id="L103" class="LineNr">103 </span> xcurr <span class="SpecialChar"><-</span> copy x +<span id="L104" class="LineNr">104 </span> <span class="Delimiter">{</span> +<span id="L105" class="LineNr">105 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream +<span id="L106" class="LineNr">106 </span> compare g, <span class="Constant">0xffffffff</span>/end-of-file +<span id="L107" class="LineNr">107 </span> <span class="PreProc">break-if-=</span> +<span id="L108" class="LineNr">108 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, xcurr, y, color, background-color +<span id="L109" class="LineNr">109 </span> xcurr <span class="SpecialChar"><-</span> increment +<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> <a href='500text-screen.mu.html#L133'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, xcurr, y +<span id="L113" class="LineNr">113 </span> <span class="PreProc">return</span> xcurr <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="muComment"># draw text in the rectangle from (xmin, ymin) to (xmax, ymax), starting from (x, y), wrapping as necessary</span> -<span id="L117" class="LineNr">117 </span><span class="muComment"># return the next (x, y) coordinate in raster order where drawing stopped</span> -<span id="L118" class="LineNr">118 </span><span class="muComment"># that way the caller can draw more if given the same min and max bounding-box.</span> -<span id="L119" class="LineNr">119 </span><span class="muComment"># if there isn't enough space, return 0 without modifying the screen</span> -<span id="L120" class="LineNr">120 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L120'>draw-text-wrapping-right-then-down</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> -<span id="L121" class="LineNr">121 </span> <span class="PreProc">var</span> stream-storage: (stream byte <span class="Constant">0x100</span>) -<span id="L122" class="LineNr">122 </span> <span class="PreProc">var</span> stream/<span class="Constant">esi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address stream-storage -<span id="L123" class="LineNr">123 </span> <a href='108write.subx.html#L11'>write</a> stream, text -<span id="L124" class="LineNr">124 </span> <span class="muComment"># check if we have enough space</span> -<span id="L125" class="LineNr">125 </span> <span class="PreProc">var</span> xcurr/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy x -<span id="L126" class="LineNr">126 </span> <span class="PreProc">var</span> ycurr/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy y -<span id="L127" class="LineNr">127 </span> <span class="Delimiter">{</span> -<span id="L128" class="LineNr">128 </span> compare ycurr, ymax -<span id="L129" class="LineNr">129 </span> <span class="PreProc">break-if->=</span> -<span id="L130" class="LineNr">130 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream -<span id="L131" class="LineNr">131 </span> compare g, <span class="Constant">0xffffffff</span> <span class="muComment"># end-of-file</span> -<span id="L132" class="LineNr">132 </span> <span class="PreProc">break-if-=</span> -<span id="L133" class="LineNr">133 </span> xcurr <span class="SpecialChar"><-</span> increment -<span id="L134" class="LineNr">134 </span> compare xcurr, xmax -<span id="L135" class="LineNr">135 </span> <span class="Delimiter">{</span> -<span id="L136" class="LineNr">136 </span> <span class="PreProc">break-if-<</span> -<span id="L137" class="LineNr">137 </span> xcurr <span class="SpecialChar"><-</span> copy xmin -<span id="L138" class="LineNr">138 </span> ycurr <span class="SpecialChar"><-</span> increment -<span id="L139" class="LineNr">139 </span> <span class="Delimiter">}</span> -<span id="L140" class="LineNr">140 </span> <span class="PreProc">loop</span> -<span id="L141" class="LineNr">141 </span> <span class="Delimiter">}</span> -<span id="L142" class="LineNr">142 </span> compare ycurr, ymax +<span id="L116" class="LineNr">116 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L116'>draw-text-rightward-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), x: int, y: int, color: int, background-color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L117" class="LineNr">117 </span> <span class="PreProc">var</span> width/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L118" class="LineNr">118 </span> <span class="PreProc">var</span> height/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L119" class="LineNr">119 </span> width, height <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L50'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L120" class="LineNr">120 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L81'>draw-text-rightward</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, x, width, y, color, background-color +<span id="L121" class="LineNr">121 </span> <span class="PreProc">return</span> result +<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='501draw-text.mu.html#L124'>draw-text-rightward-from-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), xmax: int, color: int, background-color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L125" class="LineNr">125 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L126" class="LineNr">126 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L127" class="LineNr">127 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L117'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L128" class="LineNr">128 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L81'>draw-text-rightward</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, cursor-x, xmax, cursor-y, color, background-color +<span id="L129" class="LineNr">129 </span> <span class="PreProc">return</span> result +<span id="L130" class="LineNr">130 </span><span class="Delimiter">}</span> +<span id="L131" class="LineNr">131 </span> +<span id="L132" class="LineNr">132 </span><span class="muComment"># draw text in the rectangle from (xmin, ymin) to (xmax, ymax), starting from (x, y), wrapping as necessary</span> +<span id="L133" class="LineNr">133 </span><span class="muComment"># return the next (x, y) coordinate in raster order where drawing stopped</span> +<span id="L134" class="LineNr">134 </span><span class="muComment"># that way the caller can draw more if given the same min and max bounding-box.</span> +<span id="L135" class="LineNr">135 </span><span class="muComment"># if there isn't enough space, return 0 without modifying the screen</span> +<span id="L136" class="LineNr">136 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L136'>draw-text-wrapping-right-then-down</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int, background-color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> +<span id="L137" class="LineNr">137 </span> <span class="PreProc">var</span> stream-storage: (stream byte <span class="Constant">0x100</span>) +<span id="L138" class="LineNr">138 </span> <span class="PreProc">var</span> stream/<span class="Constant">esi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address stream-storage +<span id="L139" class="LineNr">139 </span> <a href='108write.subx.html#L11'>write</a> stream, text +<span id="L140" class="LineNr">140 </span> <span class="muComment"># check if we have enough space</span> +<span id="L141" class="LineNr">141 </span> <span class="PreProc">var</span> xcurr/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy x +<span id="L142" class="LineNr">142 </span> <span class="PreProc">var</span> ycurr/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy y <span id="L143" class="LineNr">143 </span> <span class="Delimiter">{</span> -<span id="L144" class="LineNr">144 </span> <span class="PreProc">break-if-<</span> -<span id="L145" class="LineNr">145 </span> <span class="PreProc">return</span> <span class="Constant">0</span>, <span class="Constant">0</span> -<span id="L146" class="LineNr">146 </span> <span class="Delimiter">}</span> -<span id="L147" class="LineNr">147 </span> <span class="muComment"># we do; actually draw</span> -<span id="L148" class="LineNr">148 </span> <a href='106stream.subx.html#L59'>rewind-stream</a> stream -<span id="L149" class="LineNr">149 </span> xcurr <span class="SpecialChar"><-</span> copy x -<span id="L150" class="LineNr">150 </span> ycurr <span class="SpecialChar"><-</span> copy y -<span id="L151" class="LineNr">151 </span> <span class="Delimiter">{</span> -<span id="L152" class="LineNr">152 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream -<span id="L153" class="LineNr">153 </span> compare g, <span class="Constant">0xffffffff</span> <span class="muComment"># end-of-file</span> -<span id="L154" class="LineNr">154 </span> <span class="PreProc">break-if-=</span> -<span id="L155" class="LineNr">155 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, xcurr, ycurr, color -<span id="L156" class="LineNr">156 </span> xcurr <span class="SpecialChar"><-</span> increment -<span id="L157" class="LineNr">157 </span> compare xcurr, xmax -<span id="L158" class="LineNr">158 </span> <span class="Delimiter">{</span> -<span id="L159" class="LineNr">159 </span> <span class="PreProc">break-if-<</span> -<span id="L160" class="LineNr">160 </span> xcurr <span class="SpecialChar"><-</span> copy xmin -<span id="L161" class="LineNr">161 </span> ycurr <span class="SpecialChar"><-</span> increment -<span id="L162" class="LineNr">162 </span> <span class="Delimiter">}</span> -<span id="L163" class="LineNr">163 </span> <span class="PreProc">loop</span> -<span id="L164" class="LineNr">164 </span> <span class="Delimiter">}</span> -<span id="L165" class="LineNr">165 </span> <a href='500text-screen.mu.html#L115'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, xcurr, ycurr -<span id="L166" class="LineNr">166 </span> <span class="PreProc">return</span> xcurr, ycurr -<span id="L167" class="LineNr">167 </span><span class="Delimiter">}</span> -<span id="L168" class="LineNr">168 </span> -<span id="L169" class="LineNr">169 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L169'>move-cursor-rightward-and-downward</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), xmin: int, xmax: int <span class="Delimiter">{</span> -<span id="L170" class="LineNr">170 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L171" class="LineNr">171 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L172" class="LineNr">172 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L99'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L173" class="LineNr">173 </span> cursor-x <span class="SpecialChar"><-</span> increment -<span id="L174" class="LineNr">174 </span> compare cursor-x, xmax -<span id="L175" class="LineNr">175 </span> <span class="Delimiter">{</span> -<span id="L176" class="LineNr">176 </span> <span class="PreProc">break-if-<</span> -<span id="L177" class="LineNr">177 </span> cursor-x <span class="SpecialChar"><-</span> copy xmin -<span id="L178" class="LineNr">178 </span> cursor-y <span class="SpecialChar"><-</span> increment -<span id="L179" class="LineNr">179 </span> <span class="Delimiter">}</span> -<span id="L180" class="LineNr">180 </span> <a href='500text-screen.mu.html#L115'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, cursor-x, cursor-y -<span id="L181" class="LineNr">181 </span><span class="Delimiter">}</span> -<span id="L182" class="LineNr">182 </span> -<span id="L183" class="LineNr">183 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L183'>draw-text-wrapping-right-then-down-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), x: int, y: int, color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> -<span id="L184" class="LineNr">184 </span> <span class="PreProc">var</span> x2/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L185" class="LineNr">185 </span> <span class="PreProc">var</span> y2/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L186" class="LineNr">186 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L49'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> <span class="muComment"># width, height</span> -<span id="L187" class="LineNr">187 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L120'>draw-text-wrapping-right-then-down</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, <span class="Constant">0</span>, <span class="Constant">0</span>, x2, y2, x, y, color -<span id="L188" class="LineNr">188 </span> <span class="PreProc">return</span> x2, y2 <span class="muComment"># cursor-x, cursor-y</span> -<span id="L189" class="LineNr">189 </span><span class="Delimiter">}</span> -<span id="L190" class="LineNr">190 </span> -<span id="L191" class="LineNr">191 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L191'>draw-text-wrapping-right-then-down-from-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, color: int <span class="Delimiter">{</span> -<span id="L192" class="LineNr">192 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L193" class="LineNr">193 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L194" class="LineNr">194 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L99'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L195" class="LineNr">195 </span> <span class="PreProc">var</span> end-x/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy cursor-x -<span id="L196" class="LineNr">196 </span> end-x <span class="SpecialChar"><-</span> increment -<span id="L197" class="LineNr">197 </span> compare end-x, xmax -<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> cursor-x <span class="SpecialChar"><-</span> copy xmin -<span id="L201" class="LineNr">201 </span> cursor-y <span class="SpecialChar"><-</span> increment -<span id="L202" class="LineNr">202 </span> <span class="Delimiter">}</span> -<span id="L203" class="LineNr">203 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L120'>draw-text-wrapping-right-then-down</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color -<span id="L204" class="LineNr">204 </span><span class="Delimiter">}</span> -<span id="L205" class="LineNr">205 </span> -<span id="L206" class="LineNr">206 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), color: int <span class="Delimiter">{</span> -<span id="L207" class="LineNr">207 </span> <span class="PreProc">var</span> width/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L208" class="LineNr">208 </span> <span class="PreProc">var</span> height/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L209" class="LineNr">209 </span> width, height <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L49'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L210" class="LineNr">210 </span> <a href='501draw-text.mu.html#L191'>draw-text-wrapping-right-then-down-from-cursor</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, <span class="Constant">0</span>, <span class="Constant">0</span>, width, height, color -<span id="L211" class="LineNr">211 </span><span class="Delimiter">}</span> -<span id="L212" class="LineNr">212 </span> -<span id="L213" class="LineNr">213 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L213'>draw-int32-hex-wrapping-right-then-down</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> -<span id="L214" class="LineNr">214 </span> <span class="PreProc">var</span> stream-storage: (stream byte <span class="Constant">0x100</span>) -<span id="L215" class="LineNr">215 </span> <span class="PreProc">var</span> stream/<span class="Constant">esi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address stream-storage -<span id="L216" class="LineNr">216 </span> <a href='117write-int-hex.subx.html#L92'>write-int32-hex</a> stream, n -<span id="L217" class="LineNr">217 </span> <span class="muComment"># check if we have enough space</span> -<span id="L218" class="LineNr">218 </span> <span class="PreProc">var</span> xcurr/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy x -<span id="L219" class="LineNr">219 </span> <span class="PreProc">var</span> ycurr/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy y -<span id="L220" class="LineNr">220 </span> <span class="Delimiter">{</span> -<span id="L221" class="LineNr">221 </span> compare ycurr, ymax -<span id="L222" class="LineNr">222 </span> <span class="PreProc">break-if->=</span> -<span id="L223" class="LineNr">223 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream -<span id="L224" class="LineNr">224 </span> compare g, <span class="Constant">0xffffffff</span> <span class="muComment"># end-of-file</span> -<span id="L225" class="LineNr">225 </span> <span class="PreProc">break-if-=</span> -<span id="L226" class="LineNr">226 </span> xcurr <span class="SpecialChar"><-</span> increment -<span id="L227" class="LineNr">227 </span> compare xcurr, xmax -<span id="L228" class="LineNr">228 </span> <span class="Delimiter">{</span> -<span id="L229" class="LineNr">229 </span> <span class="PreProc">break-if-<</span> -<span id="L230" class="LineNr">230 </span> xcurr <span class="SpecialChar"><-</span> copy xmin -<span id="L231" class="LineNr">231 </span> ycurr <span class="SpecialChar"><-</span> increment -<span id="L232" class="LineNr">232 </span> <span class="Delimiter">}</span> -<span id="L233" class="LineNr">233 </span> <span class="PreProc">loop</span> -<span id="L234" class="LineNr">234 </span> <span class="Delimiter">}</span> -<span id="L235" class="LineNr">235 </span> compare ycurr, ymax +<span id="L144" class="LineNr">144 </span> compare ycurr, ymax +<span id="L145" class="LineNr">145 </span> <span class="PreProc">break-if->=</span> +<span id="L146" class="LineNr">146 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream +<span id="L147" class="LineNr">147 </span> compare g, <span class="Constant">0xffffffff</span>/end-of-file +<span id="L148" class="LineNr">148 </span> <span class="PreProc">break-if-=</span> +<span id="L149" class="LineNr">149 </span> xcurr <span class="SpecialChar"><-</span> increment +<span id="L150" class="LineNr">150 </span> compare xcurr, xmax +<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> xcurr <span class="SpecialChar"><-</span> copy xmin +<span id="L154" class="LineNr">154 </span> ycurr <span class="SpecialChar"><-</span> increment +<span id="L155" class="LineNr">155 </span> <span class="Delimiter">}</span> +<span id="L156" class="LineNr">156 </span> <span class="PreProc">loop</span> +<span id="L157" class="LineNr">157 </span> <span class="Delimiter">}</span> +<span id="L158" class="LineNr">158 </span> compare ycurr, ymax +<span id="L159" class="LineNr">159 </span> <span class="Delimiter">{</span> +<span id="L160" class="LineNr">160 </span> <span class="PreProc">break-if-<</span> +<span id="L161" class="LineNr">161 </span> <span class="PreProc">return</span> <span class="Constant">0</span>, <span class="Constant">0</span> +<span id="L162" class="LineNr">162 </span> <span class="Delimiter">}</span> +<span id="L163" class="LineNr">163 </span> <span class="muComment"># we do; actually draw</span> +<span id="L164" class="LineNr">164 </span> <a href='106stream.subx.html#L59'>rewind-stream</a> stream +<span id="L165" class="LineNr">165 </span> xcurr <span class="SpecialChar"><-</span> copy x +<span id="L166" class="LineNr">166 </span> ycurr <span class="SpecialChar"><-</span> copy y +<span id="L167" class="LineNr">167 </span> <span class="Delimiter">{</span> +<span id="L168" class="LineNr">168 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream +<span id="L169" class="LineNr">169 </span> compare g, <span class="Constant">0xffffffff</span>/end-of-file +<span id="L170" class="LineNr">170 </span> <span class="PreProc">break-if-=</span> +<span id="L171" class="LineNr">171 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, xcurr, ycurr, color, background-color +<span id="L172" class="LineNr">172 </span> xcurr <span class="SpecialChar"><-</span> increment +<span id="L173" class="LineNr">173 </span> compare xcurr, xmax +<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> xcurr <span class="SpecialChar"><-</span> copy xmin +<span id="L177" class="LineNr">177 </span> ycurr <span class="SpecialChar"><-</span> increment +<span id="L178" class="LineNr">178 </span> <span class="Delimiter">}</span> +<span id="L179" class="LineNr">179 </span> <span class="PreProc">loop</span> +<span id="L180" class="LineNr">180 </span> <span class="Delimiter">}</span> +<span id="L181" class="LineNr">181 </span> <a href='500text-screen.mu.html#L133'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, xcurr, ycurr +<span id="L182" class="LineNr">182 </span> <span class="PreProc">return</span> xcurr, ycurr +<span id="L183" class="LineNr">183 </span><span class="Delimiter">}</span> +<span id="L184" class="LineNr">184 </span> +<span id="L185" class="LineNr">185 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L185'>move-cursor-rightward-and-downward</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), xmin: int, xmax: int <span class="Delimiter">{</span> +<span id="L186" class="LineNr">186 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L187" class="LineNr">187 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L188" class="LineNr">188 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L117'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L189" class="LineNr">189 </span> cursor-x <span class="SpecialChar"><-</span> increment +<span id="L190" class="LineNr">190 </span> compare cursor-x, xmax +<span id="L191" class="LineNr">191 </span> <span class="Delimiter">{</span> +<span id="L192" class="LineNr">192 </span> <span class="PreProc">break-if-<</span> +<span id="L193" class="LineNr">193 </span> cursor-x <span class="SpecialChar"><-</span> copy xmin +<span id="L194" class="LineNr">194 </span> cursor-y <span class="SpecialChar"><-</span> increment +<span id="L195" class="LineNr">195 </span> <span class="Delimiter">}</span> +<span id="L196" class="LineNr">196 </span> <a href='500text-screen.mu.html#L133'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, cursor-x, cursor-y +<span id="L197" class="LineNr">197 </span><span class="Delimiter">}</span> +<span id="L198" class="LineNr">198 </span> +<span id="L199" class="LineNr">199 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L199'>draw-text-wrapping-right-then-down-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), x: int, y: int, color: int, background-color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> +<span id="L200" class="LineNr">200 </span> <span class="PreProc">var</span> x2/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L201" class="LineNr">201 </span> <span class="PreProc">var</span> y2/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L202" class="LineNr">202 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L50'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> <span class="muComment"># width, height</span> +<span id="L203" class="LineNr">203 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L136'>draw-text-wrapping-right-then-down</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, <span class="Constant">0</span>/xmin, <span class="Constant">0</span>/ymin, x2, y2, x, y, color, background-color +<span id="L204" class="LineNr">204 </span> <span class="PreProc">return</span> x2, y2 <span class="muComment"># cursor-x, cursor-y</span> +<span id="L205" class="LineNr">205 </span><span class="Delimiter">}</span> +<span id="L206" class="LineNr">206 </span> +<span id="L207" class="LineNr">207 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L207'>draw-text-wrapping-right-then-down-from-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, color: int, background-color: int <span class="Delimiter">{</span> +<span id="L208" class="LineNr">208 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L209" class="LineNr">209 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L210" class="LineNr">210 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L117'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L211" class="LineNr">211 </span> <span class="PreProc">var</span> end-x/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy cursor-x +<span id="L212" class="LineNr">212 </span> end-x <span class="SpecialChar"><-</span> increment +<span id="L213" class="LineNr">213 </span> compare end-x, xmax +<span id="L214" class="LineNr">214 </span> <span class="Delimiter">{</span> +<span id="L215" class="LineNr">215 </span> <span class="PreProc">break-if-<</span> +<span id="L216" class="LineNr">216 </span> cursor-x <span class="SpecialChar"><-</span> copy xmin +<span id="L217" class="LineNr">217 </span> cursor-y <span class="SpecialChar"><-</span> increment +<span id="L218" class="LineNr">218 </span> <span class="Delimiter">}</span> +<span id="L219" class="LineNr">219 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L136'>draw-text-wrapping-right-then-down</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color, background-color +<span id="L220" class="LineNr">220 </span><span class="Delimiter">}</span> +<span id="L221" class="LineNr">221 </span> +<span id="L222" class="LineNr">222 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), color: int, background-color: int <span class="Delimiter">{</span> +<span id="L223" class="LineNr">223 </span> <span class="PreProc">var</span> width/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L224" class="LineNr">224 </span> <span class="PreProc">var</span> height/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L225" class="LineNr">225 </span> width, height <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L50'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L226" class="LineNr">226 </span> <a href='501draw-text.mu.html#L207'>draw-text-wrapping-right-then-down-from-cursor</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, <span class="Constant">0</span>/xmin, <span class="Constant">0</span>/ymin, width, height, color, background-color +<span id="L227" class="LineNr">227 </span><span class="Delimiter">}</span> +<span id="L228" class="LineNr">228 </span> +<span id="L229" class="LineNr">229 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L229'>draw-int32-hex-wrapping-right-then-down</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int, background-color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> +<span id="L230" class="LineNr">230 </span> <span class="PreProc">var</span> stream-storage: (stream byte <span class="Constant">0x100</span>) +<span id="L231" class="LineNr">231 </span> <span class="PreProc">var</span> stream/<span class="Constant">esi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address stream-storage +<span id="L232" class="LineNr">232 </span> <a href='117write-int-hex.subx.html#L92'>write-int32-hex</a> stream, n +<span id="L233" class="LineNr">233 </span> <span class="muComment"># check if we have enough space</span> +<span id="L234" class="LineNr">234 </span> <span class="PreProc">var</span> xcurr/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy x +<span id="L235" class="LineNr">235 </span> <span class="PreProc">var</span> ycurr/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy y <span id="L236" class="LineNr">236 </span> <span class="Delimiter">{</span> -<span id="L237" class="LineNr">237 </span> <span class="PreProc">break-if-<</span> -<span id="L238" class="LineNr">238 </span> <span class="PreProc">return</span> <span class="Constant">0</span>, <span class="Constant">0</span> -<span id="L239" class="LineNr">239 </span> <span class="Delimiter">}</span> -<span id="L240" class="LineNr">240 </span> <span class="muComment"># we do; actually draw</span> -<span id="L241" class="LineNr">241 </span> <a href='106stream.subx.html#L59'>rewind-stream</a> stream -<span id="L242" class="LineNr">242 </span> xcurr <span class="SpecialChar"><-</span> copy x -<span id="L243" class="LineNr">243 </span> ycurr <span class="SpecialChar"><-</span> copy y -<span id="L244" class="LineNr">244 </span> <span class="Delimiter">{</span> -<span id="L245" class="LineNr">245 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream -<span id="L246" class="LineNr">246 </span> compare g, <span class="Constant">0xffffffff</span> <span class="muComment"># end-of-file</span> -<span id="L247" class="LineNr">247 </span> <span class="PreProc">break-if-=</span> -<span id="L248" class="LineNr">248 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, xcurr, ycurr, color -<span id="L249" class="LineNr">249 </span> xcurr <span class="SpecialChar"><-</span> increment -<span id="L250" class="LineNr">250 </span> compare xcurr, xmax -<span id="L251" class="LineNr">251 </span> <span class="Delimiter">{</span> -<span id="L252" class="LineNr">252 </span> <span class="PreProc">break-if-<</span> -<span id="L253" class="LineNr">253 </span> xcurr <span class="SpecialChar"><-</span> copy xmin -<span id="L254" class="LineNr">254 </span> ycurr <span class="SpecialChar"><-</span> increment -<span id="L255" class="LineNr">255 </span> <span class="Delimiter">}</span> -<span id="L256" class="LineNr">256 </span> <span class="PreProc">loop</span> -<span id="L257" class="LineNr">257 </span> <span class="Delimiter">}</span> -<span id="L258" class="LineNr">258 </span> <a href='500text-screen.mu.html#L115'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, xcurr, ycurr -<span id="L259" class="LineNr">259 </span> <span class="PreProc">return</span> xcurr, ycurr -<span id="L260" class="LineNr">260 </span><span class="Delimiter">}</span> -<span id="L261" class="LineNr">261 </span> -<span id="L262" class="LineNr">262 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L262'>draw-int32-hex-wrapping-right-then-down-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, x: int, y: int, color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> -<span id="L263" class="LineNr">263 </span> <span class="PreProc">var</span> x2/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L264" class="LineNr">264 </span> <span class="PreProc">var</span> y2/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L265" class="LineNr">265 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L49'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> <span class="muComment"># width, height</span> -<span id="L266" class="LineNr">266 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L213'>draw-int32-hex-wrapping-right-then-down</a> <a href='500text-screen.mu.html#L9'>screen</a>, n, <span class="Constant">0</span>, <span class="Constant">0</span>, x2, y2, x, y, color -<span id="L267" class="LineNr">267 </span> <span class="PreProc">return</span> x2, y2 <span class="muComment"># cursor-x, cursor-y</span> -<span id="L268" class="LineNr">268 </span><span class="Delimiter">}</span> -<span id="L269" class="LineNr">269 </span> -<span id="L270" class="LineNr">270 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L270'>draw-int32-hex-wrapping-right-then-down-from-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, xmin: int, ymin: int, xmax: int, ymax: int, color: int <span class="Delimiter">{</span> -<span id="L271" class="LineNr">271 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L272" class="LineNr">272 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L273" class="LineNr">273 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L99'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L274" class="LineNr">274 </span> <span class="PreProc">var</span> end-x/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy cursor-x -<span id="L275" class="LineNr">275 </span> end-x <span class="SpecialChar"><-</span> increment -<span id="L276" class="LineNr">276 </span> compare end-x, xmax -<span id="L277" class="LineNr">277 </span> <span class="Delimiter">{</span> -<span id="L278" class="LineNr">278 </span> <span class="PreProc">break-if-<</span> -<span id="L279" class="LineNr">279 </span> cursor-x <span class="SpecialChar"><-</span> copy xmin -<span id="L280" class="LineNr">280 </span> cursor-y <span class="SpecialChar"><-</span> increment -<span id="L281" class="LineNr">281 </span> <span class="Delimiter">}</span> -<span id="L282" class="LineNr">282 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L213'>draw-int32-hex-wrapping-right-then-down</a> <a href='500text-screen.mu.html#L9'>screen</a>, n, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color -<span id="L283" class="LineNr">283 </span><span class="Delimiter">}</span> -<span id="L284" class="LineNr">284 </span> -<span id="L285" class="LineNr">285 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L285'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, color: int <span class="Delimiter">{</span> -<span id="L286" class="LineNr">286 </span> <span class="PreProc">var</span> width/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L287" class="LineNr">287 </span> <span class="PreProc">var</span> height/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L288" class="LineNr">288 </span> width, height <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L49'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L289" class="LineNr">289 </span> <a href='501draw-text.mu.html#L270'>draw-int32-hex-wrapping-right-then-down-from-cursor</a> <a href='500text-screen.mu.html#L9'>screen</a>, n, <span class="Constant">0</span>, <span class="Constant">0</span>, width, height, color -<span id="L290" class="LineNr">290 </span><span class="Delimiter">}</span> -<span id="L291" class="LineNr">291 </span> -<span id="L292" class="LineNr">292 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L292'>draw-int32-decimal-wrapping-right-then-down</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> -<span id="L293" class="LineNr">293 </span> <span class="PreProc">var</span> stream-storage: (stream byte <span class="Constant">0x100</span>) -<span id="L294" class="LineNr">294 </span> <span class="PreProc">var</span> stream/<span class="Constant">esi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address stream-storage -<span id="L295" class="LineNr">295 </span> <a href='126write-int-decimal.subx.html#L8'>write-int32-decimal</a> stream, n -<span id="L296" class="LineNr">296 </span> <span class="muComment"># check if we have enough space</span> -<span id="L297" class="LineNr">297 </span> <span class="PreProc">var</span> xcurr/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy x -<span id="L298" class="LineNr">298 </span> <span class="PreProc">var</span> ycurr/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy y -<span id="L299" class="LineNr">299 </span> <span class="Delimiter">{</span> -<span id="L300" class="LineNr">300 </span> compare ycurr, ymax -<span id="L301" class="LineNr">301 </span> <span class="PreProc">break-if->=</span> -<span id="L302" class="LineNr">302 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream -<span id="L303" class="LineNr">303 </span> compare g, <span class="Constant">0xffffffff</span> <span class="muComment"># end-of-file</span> -<span id="L304" class="LineNr">304 </span> <span class="PreProc">break-if-=</span> -<span id="L305" class="LineNr">305 </span> xcurr <span class="SpecialChar"><-</span> increment -<span id="L306" class="LineNr">306 </span> compare xcurr, xmax -<span id="L307" class="LineNr">307 </span> <span class="Delimiter">{</span> -<span id="L308" class="LineNr">308 </span> <span class="PreProc">break-if-<</span> -<span id="L309" class="LineNr">309 </span> xcurr <span class="SpecialChar"><-</span> copy xmin -<span id="L310" class="LineNr">310 </span> ycurr <span class="SpecialChar"><-</span> increment -<span id="L311" class="LineNr">311 </span> <span class="Delimiter">}</span> -<span id="L312" class="LineNr">312 </span> <span class="PreProc">loop</span> -<span id="L313" class="LineNr">313 </span> <span class="Delimiter">}</span> -<span id="L314" class="LineNr">314 </span> compare ycurr, ymax +<span id="L237" class="LineNr">237 </span> compare ycurr, ymax +<span id="L238" class="LineNr">238 </span> <span class="PreProc">break-if->=</span> +<span id="L239" class="LineNr">239 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream +<span id="L240" class="LineNr">240 </span> compare g, <span class="Constant">0xffffffff</span>/end-of-file +<span id="L241" class="LineNr">241 </span> <span class="PreProc">break-if-=</span> +<span id="L242" class="LineNr">242 </span> xcurr <span class="SpecialChar"><-</span> increment +<span id="L243" class="LineNr">243 </span> compare xcurr, xmax +<span id="L244" class="LineNr">244 </span> <span class="Delimiter">{</span> +<span id="L245" class="LineNr">245 </span> <span class="PreProc">break-if-<</span> +<span id="L246" class="LineNr">246 </span> xcurr <span class="SpecialChar"><-</span> copy xmin +<span id="L247" class="LineNr">247 </span> ycurr <span class="SpecialChar"><-</span> increment +<span id="L248" class="LineNr">248 </span> <span class="Delimiter">}</span> +<span id="L249" class="LineNr">249 </span> <span class="PreProc">loop</span> +<span id="L250" class="LineNr">250 </span> <span class="Delimiter">}</span> +<span id="L251" class="LineNr">251 </span> compare ycurr, ymax +<span id="L252" class="LineNr">252 </span> <span class="Delimiter">{</span> +<span id="L253" class="LineNr">253 </span> <span class="PreProc">break-if-<</span> +<span id="L254" class="LineNr">254 </span> <span class="PreProc">return</span> <span class="Constant">0</span>, <span class="Constant">0</span> +<span id="L255" class="LineNr">255 </span> <span class="Delimiter">}</span> +<span id="L256" class="LineNr">256 </span> <span class="muComment"># we do; actually draw</span> +<span id="L257" class="LineNr">257 </span> <a href='106stream.subx.html#L59'>rewind-stream</a> stream +<span id="L258" class="LineNr">258 </span> xcurr <span class="SpecialChar"><-</span> copy x +<span id="L259" class="LineNr">259 </span> ycurr <span class="SpecialChar"><-</span> copy y +<span id="L260" class="LineNr">260 </span> <span class="Delimiter">{</span> +<span id="L261" class="LineNr">261 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream +<span id="L262" class="LineNr">262 </span> compare g, <span class="Constant">0xffffffff</span>/end-of-file +<span id="L263" class="LineNr">263 </span> <span class="PreProc">break-if-=</span> +<span id="L264" class="LineNr">264 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, xcurr, ycurr, color, background-color +<span id="L265" class="LineNr">265 </span> xcurr <span class="SpecialChar"><-</span> increment +<span id="L266" class="LineNr">266 </span> compare xcurr, xmax +<span id="L267" class="LineNr">267 </span> <span class="Delimiter">{</span> +<span id="L268" class="LineNr">268 </span> <span class="PreProc">break-if-<</span> +<span id="L269" class="LineNr">269 </span> xcurr <span class="SpecialChar"><-</span> copy xmin +<span id="L270" class="LineNr">270 </span> ycurr <span class="SpecialChar"><-</span> increment +<span id="L271" class="LineNr">271 </span> <span class="Delimiter">}</span> +<span id="L272" class="LineNr">272 </span> <span class="PreProc">loop</span> +<span id="L273" class="LineNr">273 </span> <span class="Delimiter">}</span> +<span id="L274" class="LineNr">274 </span> <a href='500text-screen.mu.html#L133'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, xcurr, ycurr +<span id="L275" class="LineNr">275 </span> <span class="PreProc">return</span> xcurr, ycurr +<span id="L276" class="LineNr">276 </span><span class="Delimiter">}</span> +<span id="L277" class="LineNr">277 </span> +<span id="L278" class="LineNr">278 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L278'>draw-int32-hex-wrapping-right-then-down-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, x: int, y: int, color: int, background-color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> +<span id="L279" class="LineNr">279 </span> <span class="PreProc">var</span> x2/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L280" class="LineNr">280 </span> <span class="PreProc">var</span> y2/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L281" class="LineNr">281 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L50'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> <span class="muComment"># width, height</span> +<span id="L282" class="LineNr">282 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L229'>draw-int32-hex-wrapping-right-then-down</a> <a href='500text-screen.mu.html#L9'>screen</a>, n, <span class="Constant">0</span>/xmin, <span class="Constant">0</span>/ymin, x2, y2, x, y, color, background-color +<span id="L283" class="LineNr">283 </span> <span class="PreProc">return</span> x2, y2 <span class="muComment"># cursor-x, cursor-y</span> +<span id="L284" class="LineNr">284 </span><span class="Delimiter">}</span> +<span id="L285" class="LineNr">285 </span> +<span id="L286" class="LineNr">286 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L286'>draw-int32-hex-wrapping-right-then-down-from-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, xmin: int, ymin: int, xmax: int, ymax: int, color: int, background-color: int <span class="Delimiter">{</span> +<span id="L287" class="LineNr">287 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L288" class="LineNr">288 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L289" class="LineNr">289 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L117'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L290" class="LineNr">290 </span> <span class="PreProc">var</span> end-x/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy cursor-x +<span id="L291" class="LineNr">291 </span> end-x <span class="SpecialChar"><-</span> increment +<span id="L292" class="LineNr">292 </span> compare end-x, xmax +<span id="L293" class="LineNr">293 </span> <span class="Delimiter">{</span> +<span id="L294" class="LineNr">294 </span> <span class="PreProc">break-if-<</span> +<span id="L295" class="LineNr">295 </span> cursor-x <span class="SpecialChar"><-</span> copy xmin +<span id="L296" class="LineNr">296 </span> cursor-y <span class="SpecialChar"><-</span> increment +<span id="L297" class="LineNr">297 </span> <span class="Delimiter">}</span> +<span id="L298" class="LineNr">298 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L229'>draw-int32-hex-wrapping-right-then-down</a> <a href='500text-screen.mu.html#L9'>screen</a>, n, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color, background-color +<span id="L299" class="LineNr">299 </span><span class="Delimiter">}</span> +<span id="L300" class="LineNr">300 </span> +<span id="L301" class="LineNr">301 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, color: int, background-color: int <span class="Delimiter">{</span> +<span id="L302" class="LineNr">302 </span> <span class="PreProc">var</span> width/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L303" class="LineNr">303 </span> <span class="PreProc">var</span> height/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L304" class="LineNr">304 </span> width, height <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L50'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L305" class="LineNr">305 </span> <a href='501draw-text.mu.html#L286'>draw-int32-hex-wrapping-right-then-down-from-cursor</a> <a href='500text-screen.mu.html#L9'>screen</a>, n, <span class="Constant">0</span>/xmin, <span class="Constant">0</span>/ymin, width, height, color, background-color +<span id="L306" class="LineNr">306 </span><span class="Delimiter">}</span> +<span id="L307" class="LineNr">307 </span> +<span id="L308" class="LineNr">308 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L308'>draw-int32-decimal-wrapping-right-then-down</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int, background-color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> +<span id="L309" class="LineNr">309 </span> <span class="PreProc">var</span> stream-storage: (stream byte <span class="Constant">0x100</span>) +<span id="L310" class="LineNr">310 </span> <span class="PreProc">var</span> stream/<span class="Constant">esi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address stream-storage +<span id="L311" class="LineNr">311 </span> <a href='126write-int-decimal.subx.html#L8'>write-int32-decimal</a> stream, n +<span id="L312" class="LineNr">312 </span> <span class="muComment"># check if we have enough space</span> +<span id="L313" class="LineNr">313 </span> <span class="PreProc">var</span> xcurr/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy x +<span id="L314" class="LineNr">314 </span> <span class="PreProc">var</span> ycurr/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy y <span id="L315" class="LineNr">315 </span> <span class="Delimiter">{</span> -<span id="L316" class="LineNr">316 </span> <span class="PreProc">break-if-<</span> -<span id="L317" class="LineNr">317 </span> <span class="PreProc">return</span> <span class="Constant">0</span>, <span class="Constant">0</span> -<span id="L318" class="LineNr">318 </span> <span class="Delimiter">}</span> -<span id="L319" class="LineNr">319 </span> <span class="muComment"># we do; actually draw</span> -<span id="L320" class="LineNr">320 </span> <a href='106stream.subx.html#L59'>rewind-stream</a> stream -<span id="L321" class="LineNr">321 </span> xcurr <span class="SpecialChar"><-</span> copy x -<span id="L322" class="LineNr">322 </span> ycurr <span class="SpecialChar"><-</span> copy y -<span id="L323" class="LineNr">323 </span> <span class="Delimiter">{</span> -<span id="L324" class="LineNr">324 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream -<span id="L325" class="LineNr">325 </span> compare g, <span class="Constant">0xffffffff</span> <span class="muComment"># end-of-file</span> -<span id="L326" class="LineNr">326 </span> <span class="PreProc">break-if-=</span> -<span id="L327" class="LineNr">327 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, xcurr, ycurr, color -<span id="L328" class="LineNr">328 </span> xcurr <span class="SpecialChar"><-</span> increment -<span id="L329" class="LineNr">329 </span> compare xcurr, xmax -<span id="L330" class="LineNr">330 </span> <span class="Delimiter">{</span> -<span id="L331" class="LineNr">331 </span> <span class="PreProc">break-if-<</span> -<span id="L332" class="LineNr">332 </span> xcurr <span class="SpecialChar"><-</span> copy xmin -<span id="L333" class="LineNr">333 </span> ycurr <span class="SpecialChar"><-</span> increment -<span id="L334" class="LineNr">334 </span> <span class="Delimiter">}</span> -<span id="L335" class="LineNr">335 </span> <span class="PreProc">loop</span> -<span id="L336" class="LineNr">336 </span> <span class="Delimiter">}</span> -<span id="L337" class="LineNr">337 </span> <a href='500text-screen.mu.html#L115'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, xcurr, ycurr -<span id="L338" class="LineNr">338 </span> <span class="PreProc">return</span> xcurr, ycurr -<span id="L339" class="LineNr">339 </span><span class="Delimiter">}</span> -<span id="L340" class="LineNr">340 </span> -<span id="L341" class="LineNr">341 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L341'>draw-int32-decimal-wrapping-right-then-down-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, x: int, y: int, color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> -<span id="L342" class="LineNr">342 </span> <span class="PreProc">var</span> x2/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L343" class="LineNr">343 </span> <span class="PreProc">var</span> y2/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L344" class="LineNr">344 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L49'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> <span class="muComment"># width, height</span> -<span id="L345" class="LineNr">345 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L292'>draw-int32-decimal-wrapping-right-then-down</a> <a href='500text-screen.mu.html#L9'>screen</a>, n, <span class="Constant">0</span>, <span class="Constant">0</span>, x2, y2, x, y, color -<span id="L346" class="LineNr">346 </span> <span class="PreProc">return</span> x2, y2 <span class="muComment"># cursor-x, cursor-y</span> -<span id="L347" class="LineNr">347 </span><span class="Delimiter">}</span> -<span id="L348" class="LineNr">348 </span> -<span id="L349" class="LineNr">349 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L349'>draw-int32-decimal-wrapping-right-then-down-from-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, xmin: int, ymin: int, xmax: int, ymax: int, color: int <span class="Delimiter">{</span> -<span id="L350" class="LineNr">350 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L351" class="LineNr">351 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L352" class="LineNr">352 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L99'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L353" class="LineNr">353 </span> <span class="PreProc">var</span> end-x/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy cursor-x -<span id="L354" class="LineNr">354 </span> end-x <span class="SpecialChar"><-</span> increment -<span id="L355" class="LineNr">355 </span> compare end-x, xmax -<span id="L356" class="LineNr">356 </span> <span class="Delimiter">{</span> -<span id="L357" class="LineNr">357 </span> <span class="PreProc">break-if-<</span> -<span id="L358" class="LineNr">358 </span> cursor-x <span class="SpecialChar"><-</span> copy xmin -<span id="L359" class="LineNr">359 </span> cursor-y <span class="SpecialChar"><-</span> increment -<span id="L360" class="LineNr">360 </span> <span class="Delimiter">}</span> -<span id="L361" class="LineNr">361 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L292'>draw-int32-decimal-wrapping-right-then-down</a> <a href='500text-screen.mu.html#L9'>screen</a>, n, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color -<span id="L362" class="LineNr">362 </span><span class="Delimiter">}</span> -<span id="L363" class="LineNr">363 </span> -<span id="L364" class="LineNr">364 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L364'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, color: int <span class="Delimiter">{</span> -<span id="L365" class="LineNr">365 </span> <span class="PreProc">var</span> width/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L366" class="LineNr">366 </span> <span class="PreProc">var</span> height/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L367" class="LineNr">367 </span> width, height <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L49'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L368" class="LineNr">368 </span> <a href='501draw-text.mu.html#L349'>draw-int32-decimal-wrapping-right-then-down-from-cursor</a> <a href='500text-screen.mu.html#L9'>screen</a>, n, <span class="Constant">0</span>, <span class="Constant">0</span>, width, height, color -<span id="L369" class="LineNr">369 </span><span class="Delimiter">}</span> -<span id="L370" class="LineNr">370 </span> -<span id="L371" class="LineNr">371 </span><span class="muComment">## Text direction: down then right</span> -<span id="L372" class="LineNr">372 </span> -<span id="L373" class="LineNr">373 </span><span class="muComment"># draw a single line of text vertically from x, y to ymax</span> -<span id="L374" class="LineNr">374 </span><span class="muComment"># return the next 'y' coordinate</span> -<span id="L375" class="LineNr">375 </span><span class="muComment"># if there isn't enough space, return 0 without modifying the screen</span> -<span id="L376" class="LineNr">376 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L376'>draw-text-downward</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), x: int, y: int, ymax: int, color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> -<span id="L377" class="LineNr">377 </span> <span class="PreProc">var</span> stream-storage: (stream byte <span class="Constant">0x100</span>) -<span id="L378" class="LineNr">378 </span> <span class="PreProc">var</span> stream/<span class="Constant">esi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address stream-storage -<span id="L379" class="LineNr">379 </span> <a href='108write.subx.html#L11'>write</a> stream, text -<span id="L380" class="LineNr">380 </span> <span class="muComment"># check if we have enough space</span> -<span id="L381" class="LineNr">381 </span> <span class="PreProc">var</span> ycurr/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy y -<span id="L382" class="LineNr">382 </span> <span class="Delimiter">{</span> -<span id="L383" class="LineNr">383 </span> compare ycurr, ymax -<span id="L384" class="LineNr">384 </span> <span class="PreProc">break-if-></span> -<span id="L385" class="LineNr">385 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream -<span id="L386" class="LineNr">386 </span> compare g, <span class="Constant">0xffffffff</span> <span class="muComment"># end-of-file</span> -<span id="L387" class="LineNr">387 </span> <span class="PreProc">break-if-=</span> -<span id="L388" class="LineNr">388 </span> ycurr <span class="SpecialChar"><-</span> increment -<span id="L389" class="LineNr">389 </span> <span class="PreProc">loop</span> -<span id="L390" class="LineNr">390 </span> <span class="Delimiter">}</span> -<span id="L391" class="LineNr">391 </span> compare ycurr, ymax -<span id="L392" class="LineNr">392 </span> <span class="Delimiter">{</span> -<span id="L393" class="LineNr">393 </span> <span class="PreProc">break-if-<=</span> -<span id="L394" class="LineNr">394 </span> <span class="PreProc">return</span> <span class="Constant">0</span> -<span id="L395" class="LineNr">395 </span> <span class="Delimiter">}</span> -<span id="L396" class="LineNr">396 </span> <span class="muComment"># we do; actually draw</span> -<span id="L397" class="LineNr">397 </span> <a href='106stream.subx.html#L59'>rewind-stream</a> stream -<span id="L398" class="LineNr">398 </span> ycurr <span class="SpecialChar"><-</span> copy y -<span id="L399" class="LineNr">399 </span> <span class="Delimiter">{</span> -<span id="L400" class="LineNr">400 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream -<span id="L401" class="LineNr">401 </span> compare g, <span class="Constant">0xffffffff</span> <span class="muComment"># end-of-file</span> -<span id="L402" class="LineNr">402 </span> <span class="PreProc">break-if-=</span> -<span id="L403" class="LineNr">403 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, x, ycurr, color +<span id="L316" class="LineNr">316 </span> compare ycurr, ymax +<span id="L317" class="LineNr">317 </span> <span class="PreProc">break-if->=</span> +<span id="L318" class="LineNr">318 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream +<span id="L319" class="LineNr">319 </span> compare g, <span class="Constant">0xffffffff</span>/end-of-file +<span id="L320" class="LineNr">320 </span> <span class="PreProc">break-if-=</span> +<span id="L321" class="LineNr">321 </span> xcurr <span class="SpecialChar"><-</span> increment +<span id="L322" class="LineNr">322 </span> compare xcurr, xmax +<span id="L323" class="LineNr">323 </span> <span class="Delimiter">{</span> +<span id="L324" class="LineNr">324 </span> <span class="PreProc">break-if-<</span> +<span id="L325" class="LineNr">325 </span> xcurr <span class="SpecialChar"><-</span> copy xmin +<span id="L326" class="LineNr">326 </span> ycurr <span class="SpecialChar"><-</span> increment +<span id="L327" class="LineNr">327 </span> <span class="Delimiter">}</span> +<span id="L328" class="LineNr">328 </span> <span class="PreProc">loop</span> +<span id="L329" class="LineNr">329 </span> <span class="Delimiter">}</span> +<span id="L330" class="LineNr">330 </span> compare ycurr, ymax +<span id="L331" class="LineNr">331 </span> <span class="Delimiter">{</span> +<span id="L332" class="LineNr">332 </span> <span class="PreProc">break-if-<</span> +<span id="L333" class="LineNr">333 </span> <span class="PreProc">return</span> <span class="Constant">0</span>, <span class="Constant">0</span> +<span id="L334" class="LineNr">334 </span> <span class="Delimiter">}</span> +<span id="L335" class="LineNr">335 </span> <span class="muComment"># we do; actually draw</span> +<span id="L336" class="LineNr">336 </span> <a href='106stream.subx.html#L59'>rewind-stream</a> stream +<span id="L337" class="LineNr">337 </span> xcurr <span class="SpecialChar"><-</span> copy x +<span id="L338" class="LineNr">338 </span> ycurr <span class="SpecialChar"><-</span> copy y +<span id="L339" class="LineNr">339 </span> <span class="Delimiter">{</span> +<span id="L340" class="LineNr">340 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream +<span id="L341" class="LineNr">341 </span> compare g, <span class="Constant">0xffffffff</span>/end-of-file +<span id="L342" class="LineNr">342 </span> <span class="PreProc">break-if-=</span> +<span id="L343" class="LineNr">343 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, xcurr, ycurr, color, background-color +<span id="L344" class="LineNr">344 </span> xcurr <span class="SpecialChar"><-</span> increment +<span id="L345" class="LineNr">345 </span> compare xcurr, xmax +<span id="L346" class="LineNr">346 </span> <span class="Delimiter">{</span> +<span id="L347" class="LineNr">347 </span> <span class="PreProc">break-if-<</span> +<span id="L348" class="LineNr">348 </span> xcurr <span class="SpecialChar"><-</span> copy xmin +<span id="L349" class="LineNr">349 </span> ycurr <span class="SpecialChar"><-</span> increment +<span id="L350" class="LineNr">350 </span> <span class="Delimiter">}</span> +<span id="L351" class="LineNr">351 </span> <span class="PreProc">loop</span> +<span id="L352" class="LineNr">352 </span> <span class="Delimiter">}</span> +<span id="L353" class="LineNr">353 </span> <a href='500text-screen.mu.html#L133'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, xcurr, ycurr +<span id="L354" class="LineNr">354 </span> <span class="PreProc">return</span> xcurr, ycurr +<span id="L355" class="LineNr">355 </span><span class="Delimiter">}</span> +<span id="L356" class="LineNr">356 </span> +<span id="L357" class="LineNr">357 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L357'>draw-int32-decimal-wrapping-right-then-down-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, x: int, y: int, color: int, background-color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> +<span id="L358" class="LineNr">358 </span> <span class="PreProc">var</span> x2/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L359" class="LineNr">359 </span> <span class="PreProc">var</span> y2/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L360" class="LineNr">360 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L50'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> <span class="muComment"># width, height</span> +<span id="L361" class="LineNr">361 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L308'>draw-int32-decimal-wrapping-right-then-down</a> <a href='500text-screen.mu.html#L9'>screen</a>, n, <span class="Constant">0</span>/xmin, <span class="Constant">0</span>/ymin, x2, y2, x, y, color, background-color +<span id="L362" class="LineNr">362 </span> <span class="PreProc">return</span> x2, y2 <span class="muComment"># cursor-x, cursor-y</span> +<span id="L363" class="LineNr">363 </span><span class="Delimiter">}</span> +<span id="L364" class="LineNr">364 </span> +<span id="L365" class="LineNr">365 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L365'>draw-int32-decimal-wrapping-right-then-down-from-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, xmin: int, ymin: int, xmax: int, ymax: int, color: int, background-color: int <span class="Delimiter">{</span> +<span id="L366" class="LineNr">366 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L367" class="LineNr">367 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L368" class="LineNr">368 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L117'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L369" class="LineNr">369 </span> <span class="PreProc">var</span> end-x/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy cursor-x +<span id="L370" class="LineNr">370 </span> end-x <span class="SpecialChar"><-</span> increment +<span id="L371" class="LineNr">371 </span> compare end-x, xmax +<span id="L372" class="LineNr">372 </span> <span class="Delimiter">{</span> +<span id="L373" class="LineNr">373 </span> <span class="PreProc">break-if-<</span> +<span id="L374" class="LineNr">374 </span> cursor-x <span class="SpecialChar"><-</span> copy xmin +<span id="L375" class="LineNr">375 </span> cursor-y <span class="SpecialChar"><-</span> increment +<span id="L376" class="LineNr">376 </span> <span class="Delimiter">}</span> +<span id="L377" class="LineNr">377 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L308'>draw-int32-decimal-wrapping-right-then-down</a> <a href='500text-screen.mu.html#L9'>screen</a>, n, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color, background-color +<span id="L378" class="LineNr">378 </span><span class="Delimiter">}</span> +<span id="L379" class="LineNr">379 </span> +<span id="L380" class="LineNr">380 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L380'>draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), n: int, color: int, background-color: int <span class="Delimiter">{</span> +<span id="L381" class="LineNr">381 </span> <span class="PreProc">var</span> width/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L382" class="LineNr">382 </span> <span class="PreProc">var</span> height/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L383" class="LineNr">383 </span> width, height <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L50'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L384" class="LineNr">384 </span> <a href='501draw-text.mu.html#L365'>draw-int32-decimal-wrapping-right-then-down-from-cursor</a> <a href='500text-screen.mu.html#L9'>screen</a>, n, <span class="Constant">0</span>/xmin, <span class="Constant">0</span>/ymin, width, height, color, background-color +<span id="L385" class="LineNr">385 </span><span class="Delimiter">}</span> +<span id="L386" class="LineNr">386 </span> +<span id="L387" class="LineNr">387 </span><span class="muComment">## Text direction: down then right</span> +<span id="L388" class="LineNr">388 </span> +<span id="L389" class="LineNr">389 </span><span class="muComment"># draw a single line of text vertically from x, y to ymax</span> +<span id="L390" class="LineNr">390 </span><span class="muComment"># return the next 'y' coordinate</span> +<span id="L391" class="LineNr">391 </span><span class="muComment"># if there isn't enough space, return 0 without modifying the screen</span> +<span id="L392" class="LineNr">392 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L392'>draw-text-downward</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), x: int, y: int, ymax: int, color: int, background-color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L393" class="LineNr">393 </span> <span class="PreProc">var</span> stream-storage: (stream byte <span class="Constant">0x100</span>) +<span id="L394" class="LineNr">394 </span> <span class="PreProc">var</span> stream/<span class="Constant">esi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address stream-storage +<span id="L395" class="LineNr">395 </span> <a href='108write.subx.html#L11'>write</a> stream, text +<span id="L396" class="LineNr">396 </span> <span class="muComment"># check if we have enough space</span> +<span id="L397" class="LineNr">397 </span> <span class="PreProc">var</span> ycurr/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy y +<span id="L398" class="LineNr">398 </span> <span class="Delimiter">{</span> +<span id="L399" class="LineNr">399 </span> compare ycurr, ymax +<span id="L400" class="LineNr">400 </span> <span class="PreProc">break-if-></span> +<span id="L401" class="LineNr">401 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream +<span id="L402" class="LineNr">402 </span> compare g, <span class="Constant">0xffffffff</span>/end-of-file +<span id="L403" class="LineNr">403 </span> <span class="PreProc">break-if-=</span> <span id="L404" class="LineNr">404 </span> ycurr <span class="SpecialChar"><-</span> increment <span id="L405" class="LineNr">405 </span> <span class="PreProc">loop</span> <span id="L406" class="LineNr">406 </span> <span class="Delimiter">}</span> -<span id="L407" class="LineNr">407 </span> <a href='500text-screen.mu.html#L115'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, x, ycurr -<span id="L408" class="LineNr">408 </span> <span class="PreProc">return</span> ycurr -<span id="L409" class="LineNr">409 </span><span class="Delimiter">}</span> -<span id="L410" class="LineNr">410 </span> -<span id="L411" class="LineNr">411 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L411'>draw-text-downward-from-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), ymax: int, color: int <span class="Delimiter">{</span> -<span id="L412" class="LineNr">412 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L413" class="LineNr">413 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L414" class="LineNr">414 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L99'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L415" class="LineNr">415 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L376'>draw-text-downward</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, cursor-x, cursor-y, ymax, color -<span id="L416" class="LineNr">416 </span><span class="Delimiter">}</span> -<span id="L417" class="LineNr">417 </span> -<span id="L418" class="LineNr">418 </span><span class="muComment"># draw text down and right in the rectangle from (xmin, ymin) to (xmax, ymax), starting from (x, y), wrapping as necessary</span> -<span id="L419" class="LineNr">419 </span><span class="muComment"># return the next (x, y) coordinate in raster order where drawing stopped</span> -<span id="L420" class="LineNr">420 </span><span class="muComment"># that way the caller can draw more if given the same min and max bounding-box.</span> -<span id="L421" class="LineNr">421 </span><span class="muComment"># if there isn't enough space, return 0 without modifying the screen</span> -<span id="L422" class="LineNr">422 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L422'>draw-text-wrapping-down-then-right</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> -<span id="L423" class="LineNr">423 </span> <span class="PreProc">var</span> stream-storage: (stream byte <span class="Constant">0x100</span>) -<span id="L424" class="LineNr">424 </span> <span class="PreProc">var</span> stream/<span class="Constant">esi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address stream-storage -<span id="L425" class="LineNr">425 </span> <a href='108write.subx.html#L11'>write</a> stream, text -<span id="L426" class="LineNr">426 </span> <span class="muComment"># check if we have enough space</span> -<span id="L427" class="LineNr">427 </span> <span class="PreProc">var</span> xcurr/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy x -<span id="L428" class="LineNr">428 </span> <span class="PreProc">var</span> ycurr/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy y -<span id="L429" class="LineNr">429 </span> <span class="Delimiter">{</span> -<span id="L430" class="LineNr">430 </span> compare xcurr, xmax -<span id="L431" class="LineNr">431 </span> <span class="PreProc">break-if->=</span> -<span id="L432" class="LineNr">432 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream -<span id="L433" class="LineNr">433 </span> compare g, <span class="Constant">0xffffffff</span> <span class="muComment"># end-of-file</span> -<span id="L434" class="LineNr">434 </span> <span class="PreProc">break-if-=</span> -<span id="L435" class="LineNr">435 </span> ycurr <span class="SpecialChar"><-</span> increment -<span id="L436" class="LineNr">436 </span> compare ycurr, ymax -<span id="L437" class="LineNr">437 </span> <span class="Delimiter">{</span> -<span id="L438" class="LineNr">438 </span> <span class="PreProc">break-if-<</span> -<span id="L439" class="LineNr">439 </span> xcurr <span class="SpecialChar"><-</span> increment -<span id="L440" class="LineNr">440 </span> ycurr <span class="SpecialChar"><-</span> copy ymin -<span id="L441" class="LineNr">441 </span> <span class="Delimiter">}</span> -<span id="L442" class="LineNr">442 </span> <span class="PreProc">loop</span> -<span id="L443" class="LineNr">443 </span> <span class="Delimiter">}</span> -<span id="L444" class="LineNr">444 </span> compare xcurr, xmax +<span id="L407" class="LineNr">407 </span> compare ycurr, ymax +<span id="L408" class="LineNr">408 </span> <span class="Delimiter">{</span> +<span id="L409" class="LineNr">409 </span> <span class="PreProc">break-if-<=</span> +<span id="L410" class="LineNr">410 </span> <span class="PreProc">return</span> <span class="Constant">0</span> +<span id="L411" class="LineNr">411 </span> <span class="Delimiter">}</span> +<span id="L412" class="LineNr">412 </span> <span class="muComment"># we do; actually draw</span> +<span id="L413" class="LineNr">413 </span> <a href='106stream.subx.html#L59'>rewind-stream</a> stream +<span id="L414" class="LineNr">414 </span> ycurr <span class="SpecialChar"><-</span> copy y +<span id="L415" class="LineNr">415 </span> <span class="Delimiter">{</span> +<span id="L416" class="LineNr">416 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream +<span id="L417" class="LineNr">417 </span> compare g, <span class="Constant">0xffffffff</span>/end-of-file +<span id="L418" class="LineNr">418 </span> <span class="PreProc">break-if-=</span> +<span id="L419" class="LineNr">419 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, x, ycurr, color, background-color +<span id="L420" class="LineNr">420 </span> ycurr <span class="SpecialChar"><-</span> increment +<span id="L421" class="LineNr">421 </span> <span class="PreProc">loop</span> +<span id="L422" class="LineNr">422 </span> <span class="Delimiter">}</span> +<span id="L423" class="LineNr">423 </span> <a href='500text-screen.mu.html#L133'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, x, ycurr +<span id="L424" class="LineNr">424 </span> <span class="PreProc">return</span> ycurr +<span id="L425" class="LineNr">425 </span><span class="Delimiter">}</span> +<span id="L426" class="LineNr">426 </span> +<span id="L427" class="LineNr">427 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L427'>draw-text-downward-from-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), ymax: int, color: int, background-color: int <span class="Delimiter">{</span> +<span id="L428" class="LineNr">428 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L429" class="LineNr">429 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L430" class="LineNr">430 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L117'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L431" class="LineNr">431 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L392'>draw-text-downward</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, cursor-x, cursor-y, ymax, color, background-color +<span id="L432" class="LineNr">432 </span><span class="Delimiter">}</span> +<span id="L433" class="LineNr">433 </span> +<span id="L434" class="LineNr">434 </span><span class="muComment"># draw text down and right in the rectangle from (xmin, ymin) to (xmax, ymax), starting from (x, y), wrapping as necessary</span> +<span id="L435" class="LineNr">435 </span><span class="muComment"># return the next (x, y) coordinate in raster order where drawing stopped</span> +<span id="L436" class="LineNr">436 </span><span class="muComment"># that way the caller can draw more if given the same min and max bounding-box.</span> +<span id="L437" class="LineNr">437 </span><span class="muComment"># if there isn't enough space, return 0 without modifying the screen</span> +<span id="L438" class="LineNr">438 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L438'>draw-text-wrapping-down-then-right</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int, background-color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> +<span id="L439" class="LineNr">439 </span> <span class="PreProc">var</span> stream-storage: (stream byte <span class="Constant">0x100</span>) +<span id="L440" class="LineNr">440 </span> <span class="PreProc">var</span> stream/<span class="Constant">esi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address stream-storage +<span id="L441" class="LineNr">441 </span> <a href='108write.subx.html#L11'>write</a> stream, text +<span id="L442" class="LineNr">442 </span> <span class="muComment"># check if we have enough space</span> +<span id="L443" class="LineNr">443 </span> <span class="PreProc">var</span> xcurr/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy x +<span id="L444" class="LineNr">444 </span> <span class="PreProc">var</span> ycurr/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy y <span id="L445" class="LineNr">445 </span> <span class="Delimiter">{</span> -<span id="L446" class="LineNr">446 </span> <span class="PreProc">break-if-<</span> -<span id="L447" class="LineNr">447 </span> <span class="PreProc">return</span> <span class="Constant">0</span>, <span class="Constant">0</span> -<span id="L448" class="LineNr">448 </span> <span class="Delimiter">}</span> -<span id="L449" class="LineNr">449 </span> <span class="muComment"># we do; actually draw</span> -<span id="L450" class="LineNr">450 </span> <a href='106stream.subx.html#L59'>rewind-stream</a> stream -<span id="L451" class="LineNr">451 </span> xcurr <span class="SpecialChar"><-</span> copy x -<span id="L452" class="LineNr">452 </span> ycurr <span class="SpecialChar"><-</span> copy y -<span id="L453" class="LineNr">453 </span> <span class="Delimiter">{</span> -<span id="L454" class="LineNr">454 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream -<span id="L455" class="LineNr">455 </span> compare g, <span class="Constant">0xffffffff</span> <span class="muComment"># end-of-file</span> -<span id="L456" class="LineNr">456 </span> <span class="PreProc">break-if-=</span> -<span id="L457" class="LineNr">457 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, xcurr, ycurr, color -<span id="L458" class="LineNr">458 </span> ycurr <span class="SpecialChar"><-</span> increment -<span id="L459" class="LineNr">459 </span> compare ycurr, ymax -<span id="L460" class="LineNr">460 </span> <span class="Delimiter">{</span> -<span id="L461" class="LineNr">461 </span> <span class="PreProc">break-if-<</span> -<span id="L462" class="LineNr">462 </span> xcurr <span class="SpecialChar"><-</span> increment -<span id="L463" class="LineNr">463 </span> ycurr <span class="SpecialChar"><-</span> copy ymin -<span id="L464" class="LineNr">464 </span> <span class="Delimiter">}</span> -<span id="L465" class="LineNr">465 </span> <span class="PreProc">loop</span> -<span id="L466" class="LineNr">466 </span> <span class="Delimiter">}</span> -<span id="L467" class="LineNr">467 </span> <a href='500text-screen.mu.html#L115'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, xcurr, ycurr -<span id="L468" class="LineNr">468 </span> <span class="PreProc">return</span> xcurr, ycurr -<span id="L469" class="LineNr">469 </span><span class="Delimiter">}</span> -<span id="L470" class="LineNr">470 </span> -<span id="L471" class="LineNr">471 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L471'>draw-text-wrapping-down-then-right-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), x: int, y: int, color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> -<span id="L472" class="LineNr">472 </span> <span class="PreProc">var</span> x2/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L473" class="LineNr">473 </span> <span class="PreProc">var</span> y2/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L474" class="LineNr">474 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L49'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> <span class="muComment"># width, height</span> -<span id="L475" class="LineNr">475 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L422'>draw-text-wrapping-down-then-right</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, <span class="Constant">0</span>, <span class="Constant">0</span>, x2, y2, x, y, color -<span id="L476" class="LineNr">476 </span> <span class="PreProc">return</span> x2, y2 <span class="muComment"># cursor-x, cursor-y</span> -<span id="L477" class="LineNr">477 </span><span class="Delimiter">}</span> -<span id="L478" class="LineNr">478 </span> -<span id="L479" class="LineNr">479 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L479'>draw-text-wrapping-down-then-right-from-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, color: int <span class="Delimiter">{</span> -<span id="L480" class="LineNr">480 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L481" class="LineNr">481 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L482" class="LineNr">482 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L99'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L483" class="LineNr">483 </span> <span class="PreProc">var</span> end-y/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy cursor-y -<span id="L484" class="LineNr">484 </span> end-y <span class="SpecialChar"><-</span> increment -<span id="L485" class="LineNr">485 </span> compare end-y, ymax -<span id="L486" class="LineNr">486 </span> <span class="Delimiter">{</span> -<span id="L487" class="LineNr">487 </span> <span class="PreProc">break-if-<</span> -<span id="L488" class="LineNr">488 </span> cursor-x <span class="SpecialChar"><-</span> increment -<span id="L489" class="LineNr">489 </span> cursor-y <span class="SpecialChar"><-</span> copy ymin -<span id="L490" class="LineNr">490 </span> <span class="Delimiter">}</span> -<span id="L491" class="LineNr">491 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L422'>draw-text-wrapping-down-then-right</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color -<span id="L492" class="LineNr">492 </span><span class="Delimiter">}</span> -<span id="L493" class="LineNr">493 </span> -<span id="L494" class="LineNr">494 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L494'>draw-text-wrapping-down-then-right-from-cursor-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), color: int <span class="Delimiter">{</span> -<span id="L495" class="LineNr">495 </span> <span class="PreProc">var</span> width/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L496" class="LineNr">496 </span> <span class="PreProc">var</span> height/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> -<span id="L497" class="LineNr">497 </span> width, height <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L49'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L498" class="LineNr">498 </span> <a href='501draw-text.mu.html#L479'>draw-text-wrapping-down-then-right-from-cursor</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, <span class="Constant">0</span>, <span class="Constant">0</span>, width, height, color -<span id="L499" class="LineNr">499 </span><span class="Delimiter">}</span> +<span id="L446" class="LineNr">446 </span> compare xcurr, xmax +<span id="L447" class="LineNr">447 </span> <span class="PreProc">break-if->=</span> +<span id="L448" class="LineNr">448 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream +<span id="L449" class="LineNr">449 </span> compare g, <span class="Constant">0xffffffff</span>/end-of-file +<span id="L450" class="LineNr">450 </span> <span class="PreProc">break-if-=</span> +<span id="L451" class="LineNr">451 </span> ycurr <span class="SpecialChar"><-</span> increment +<span id="L452" class="LineNr">452 </span> compare ycurr, ymax +<span id="L453" class="LineNr">453 </span> <span class="Delimiter">{</span> +<span id="L454" class="LineNr">454 </span> <span class="PreProc">break-if-<</span> +<span id="L455" class="LineNr">455 </span> xcurr <span class="SpecialChar"><-</span> increment +<span id="L456" class="LineNr">456 </span> ycurr <span class="SpecialChar"><-</span> copy ymin +<span id="L457" class="LineNr">457 </span> <span class="Delimiter">}</span> +<span id="L458" class="LineNr">458 </span> <span class="PreProc">loop</span> +<span id="L459" class="LineNr">459 </span> <span class="Delimiter">}</span> +<span id="L460" class="LineNr">460 </span> compare xcurr, xmax +<span id="L461" class="LineNr">461 </span> <span class="Delimiter">{</span> +<span id="L462" class="LineNr">462 </span> <span class="PreProc">break-if-<</span> +<span id="L463" class="LineNr">463 </span> <span class="PreProc">return</span> <span class="Constant">0</span>, <span class="Constant">0</span> +<span id="L464" class="LineNr">464 </span> <span class="Delimiter">}</span> +<span id="L465" class="LineNr">465 </span> <span class="muComment"># we do; actually draw</span> +<span id="L466" class="LineNr">466 </span> <a href='106stream.subx.html#L59'>rewind-stream</a> stream +<span id="L467" class="LineNr">467 </span> xcurr <span class="SpecialChar"><-</span> copy x +<span id="L468" class="LineNr">468 </span> ycurr <span class="SpecialChar"><-</span> copy y +<span id="L469" class="LineNr">469 </span> <span class="Delimiter">{</span> +<span id="L470" class="LineNr">470 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> stream +<span id="L471" class="LineNr">471 </span> compare g, <span class="Constant">0xffffffff</span>/end-of-file +<span id="L472" class="LineNr">472 </span> <span class="PreProc">break-if-=</span> +<span id="L473" class="LineNr">473 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, g, xcurr, ycurr, color, background-color +<span id="L474" class="LineNr">474 </span> ycurr <span class="SpecialChar"><-</span> increment +<span id="L475" class="LineNr">475 </span> compare ycurr, ymax +<span id="L476" class="LineNr">476 </span> <span class="Delimiter">{</span> +<span id="L477" class="LineNr">477 </span> <span class="PreProc">break-if-<</span> +<span id="L478" class="LineNr">478 </span> xcurr <span class="SpecialChar"><-</span> increment +<span id="L479" class="LineNr">479 </span> ycurr <span class="SpecialChar"><-</span> copy ymin +<span id="L480" class="LineNr">480 </span> <span class="Delimiter">}</span> +<span id="L481" class="LineNr">481 </span> <span class="PreProc">loop</span> +<span id="L482" class="LineNr">482 </span> <span class="Delimiter">}</span> +<span id="L483" class="LineNr">483 </span> <a href='500text-screen.mu.html#L133'>set-cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a>, xcurr, ycurr +<span id="L484" class="LineNr">484 </span> <span class="PreProc">return</span> xcurr, ycurr +<span id="L485" class="LineNr">485 </span><span class="Delimiter">}</span> +<span id="L486" class="LineNr">486 </span> +<span id="L487" class="LineNr">487 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L487'>draw-text-wrapping-down-then-right-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), x: int, y: int, color: int, background-color: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int, _/<span class="Constant">ecx</span>: int <span class="Delimiter">{</span> +<span id="L488" class="LineNr">488 </span> <span class="PreProc">var</span> x2/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L489" class="LineNr">489 </span> <span class="PreProc">var</span> y2/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L490" class="LineNr">490 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L50'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> <span class="muComment"># width, height</span> +<span id="L491" class="LineNr">491 </span> x2, y2 <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L438'>draw-text-wrapping-down-then-right</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, <span class="Constant">0</span>/xmin, <span class="Constant">0</span>/ymin, x2, y2, x, y, color, background-color +<span id="L492" class="LineNr">492 </span> <span class="PreProc">return</span> x2, y2 <span class="muComment"># cursor-x, cursor-y</span> +<span id="L493" class="LineNr">493 </span><span class="Delimiter">}</span> +<span id="L494" class="LineNr">494 </span> +<span id="L495" class="LineNr">495 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L495'>draw-text-wrapping-down-then-right-from-cursor</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, color: int, background-color: int <span class="Delimiter">{</span> +<span id="L496" class="LineNr">496 </span> <span class="PreProc">var</span> cursor-x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L497" class="LineNr">497 </span> <span class="PreProc">var</span> cursor-y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L498" class="LineNr">498 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L117'>cursor-position</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L499" class="LineNr">499 </span> <span class="PreProc">var</span> end-y/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy cursor-y +<span id="L500" class="LineNr">500 </span> end-y <span class="SpecialChar"><-</span> increment +<span id="L501" class="LineNr">501 </span> compare end-y, ymax +<span id="L502" class="LineNr">502 </span> <span class="Delimiter">{</span> +<span id="L503" class="LineNr">503 </span> <span class="PreProc">break-if-<</span> +<span id="L504" class="LineNr">504 </span> cursor-x <span class="SpecialChar"><-</span> increment +<span id="L505" class="LineNr">505 </span> cursor-y <span class="SpecialChar"><-</span> copy ymin +<span id="L506" class="LineNr">506 </span> <span class="Delimiter">}</span> +<span id="L507" class="LineNr">507 </span> cursor-x, cursor-y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L438'>draw-text-wrapping-down-then-right</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, xmin, ymin, xmax, ymax, cursor-x, cursor-y, color, background-color +<span id="L508" class="LineNr">508 </span><span class="Delimiter">}</span> +<span id="L509" class="LineNr">509 </span> +<span id="L510" class="LineNr">510 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L510'>draw-text-wrapping-down-then-right-from-cursor-over-full-screen</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), text: (addr array byte), color: int, background-color: int <span class="Delimiter">{</span> +<span id="L511" class="LineNr">511 </span> <span class="PreProc">var</span> width/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L512" class="LineNr">512 </span> <span class="PreProc">var</span> height/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L513" class="LineNr">513 </span> width, height <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L50'>screen-size</a> <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L514" class="LineNr">514 </span> <a href='501draw-text.mu.html#L495'>draw-text-wrapping-down-then-right-from-cursor</a> <a href='500text-screen.mu.html#L9'>screen</a>, text, <span class="Constant">0</span>/xmin, <span class="Constant">0</span>/ymin, width, height, color, background-color +<span id="L515" class="LineNr">515 </span><span class="Delimiter">}</span> +<span id="L516" class="LineNr">516 </span> +<span id="L517" class="LineNr">517 </span><span class="muComment"># hacky error-handling</span> +<span id="L518" class="LineNr">518 </span><span class="muComment"># just go into an infinite loop</span> +<span id="L519" class="LineNr">519 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='501draw-text.mu.html#L519'>abort</a></span> e: (addr array byte) <span class="Delimiter">{</span> +<span id="L520" class="LineNr">520 </span> <span class="PreProc">var</span> dummy1/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L521" class="LineNr">521 </span> <span class="PreProc">var</span> dummy2/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L522" class="LineNr">522 </span> dummy1, dummy2 <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L199'>draw-text-wrapping-right-then-down-over-full-screen</a> <span class="Constant">0</span>/screen, e, <span class="Constant">0</span>/x, <span class="Constant">0x2f</span>/y, <span class="Constant">0xf</span>/fg=white, <span class="Constant">0xc</span>/bg=red +<span id="L523" class="LineNr">523 </span> <span class="Delimiter">{</span> +<span id="L524" class="LineNr">524 </span> <span class="PreProc">loop</span> +<span id="L525" class="LineNr">525 </span> <span class="Delimiter">}</span> +<span id="L526" class="LineNr">526 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/baremetal/502test.mu.html b/html/baremetal/502test.mu.html index 00a5d854..8bce697e 100644 --- a/html/baremetal/502test.mu.html +++ b/html/baremetal/502test.mu.html @@ -62,20 +62,41 @@ if ('onhashchange' in window) { <span id="L3" class="LineNr"> 3 </span> <span class="PreProc">var</span> a/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy _a <span id="L4" class="LineNr"> 4 </span> compare a, b <span id="L5" class="LineNr"> 5 </span> <span class="Delimiter">{</span> -<span id="L6" class="LineNr"> 6 </span> <span class="PreProc">break-if-=</span> -<span id="L7" class="LineNr"> 7 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, msg, <span class="Constant">3</span> <span class="muComment"># 3=cyan</span> -<span id="L8" class="LineNr"> 8 </span> <a href='104test.subx.html#L5'>count-test-failure</a> -<span id="L9" class="LineNr"> 9 </span> <span class="PreProc">return</span> -<span id="L10" class="LineNr">10 </span> <span class="Delimiter">}</span> -<span id="L11" class="LineNr">11 </span> <span class="Delimiter">{</span> -<span id="L12" class="LineNr">12 </span> <span class="PreProc">break-if-!=</span> -<span id="L13" class="LineNr">13 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">"."</span>, <span class="Constant">3</span> <span class="muComment"># 3=cyan</span> -<span id="L14" class="LineNr">14 </span> <span class="Delimiter">}</span> -<span id="L15" class="LineNr">15 </span><span class="Delimiter">}</span> -<span id="L16" class="LineNr">16 </span> -<span id="L17" class="LineNr">17 </span><span class="PreProc">fn</span> <span class="muTest"><a href='502test.mu.html#L17'>test-check-ints-equal</a></span> <span class="Delimiter">{</span> -<span id="L18" class="LineNr">18 </span> <a href='502test.mu.html#L2'>check-ints-equal</a> <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">"abc"</span> -<span id="L19" class="LineNr">19 </span><span class="Delimiter">}</span> +<span id="L6" class="LineNr"> 6 </span> <span class="PreProc">break-if-!=</span> +<span id="L7" class="LineNr"> 7 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"."</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L8" class="LineNr"> 8 </span> <span class="PreProc">return</span> +<span id="L9" class="LineNr"> 9 </span> <span class="Delimiter">}</span> +<span id="L10" class="LineNr">10 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, msg, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L11" class="LineNr">11 </span> <a href='104test.subx.html#L5'>count-test-failure</a> +<span id="L12" class="LineNr">12 </span><span class="Delimiter">}</span> +<span id="L13" class="LineNr">13 </span> +<span id="L14" class="LineNr">14 </span><span class="PreProc">fn</span> <span class="muTest"><a href='502test.mu.html#L14'>test-check-ints-equal</a></span> <span class="Delimiter">{</span> +<span id="L15" class="LineNr">15 </span> <a href='502test.mu.html#L2'>check-ints-equal</a> <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">"abc"</span> +<span id="L16" class="LineNr">16 </span><span class="Delimiter">}</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='502test.mu.html#L18'>check</a></span> _a: boolean, msg: (addr array byte) <span class="Delimiter">{</span> +<span id="L19" class="LineNr">19 </span> <span class="PreProc">var</span> a/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy _a +<span id="L20" class="LineNr">20 </span> compare a, <span class="Constant">0</span>/false +<span id="L21" class="LineNr">21 </span> <span class="Delimiter">{</span> +<span id="L22" class="LineNr">22 </span> <span class="PreProc">break-if-=</span> +<span id="L23" class="LineNr">23 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"."</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L24" class="LineNr">24 </span> <span class="PreProc">return</span> +<span id="L25" class="LineNr">25 </span> <span class="Delimiter">}</span> +<span id="L26" class="LineNr">26 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, msg, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L27" class="LineNr">27 </span> <a href='104test.subx.html#L5'>count-test-failure</a> +<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='502test.mu.html#L30'>check-not</a></span> _a: boolean, msg: (addr array byte) <span class="Delimiter">{</span> +<span id="L31" class="LineNr">31 </span> <span class="PreProc">var</span> a/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy _a +<span id="L32" class="LineNr">32 </span> compare a, <span class="Constant">0</span>/false +<span id="L33" class="LineNr">33 </span> <span class="Delimiter">{</span> +<span id="L34" class="LineNr">34 </span> <span class="PreProc">break-if-!=</span> +<span id="L35" class="LineNr">35 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"."</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L36" class="LineNr">36 </span> <span class="PreProc">return</span> +<span id="L37" class="LineNr">37 </span> <span class="Delimiter">}</span> +<span id="L38" class="LineNr">38 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, msg, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L39" class="LineNr">39 </span> <a href='104test.subx.html#L5'>count-test-failure</a> +<span id="L40" class="LineNr">40 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/baremetal/504test-screen.mu.html b/html/baremetal/504test-screen.mu.html index edea0c33..aa3894a4 100644 --- a/html/baremetal/504test-screen.mu.html +++ b/html/baremetal/504test-screen.mu.html @@ -64,12 +64,12 @@ if ('onhashchange' in window) { <span id="L5" class="LineNr"> 5 </span><span class="muComment"># Tab characters (that translate into multiple screen cells) not supported.</span> <span id="L6" class="LineNr"> 6 </span> <span id="L7" class="LineNr"> 7 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='504test-screen.mu.html#L7'>check-screen-row</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), y: int, expected: (addr array byte), msg: (addr array byte) <span class="Delimiter">{</span> -<span id="L8" class="LineNr"> 8 </span> <a href='504test-screen.mu.html#L11'>check-screen-row-from</a> <a href='500text-screen.mu.html#L9'>screen</a>, y, <span class="Constant">0</span>, expected, msg +<span id="L8" class="LineNr"> 8 </span> <a href='504test-screen.mu.html#L11'>check-screen-row-from</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/x, y, expected, msg <span id="L9" class="LineNr"> 9 </span><span class="Delimiter">}</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='504test-screen.mu.html#L11'>check-screen-row-from</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), x: int, y: int, expected: (addr array byte), msg: (addr array byte) <span class="Delimiter">{</span> <span id="L12" class="LineNr"> 12 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack -<span id="L13" class="LineNr"> 13 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L90'>screen-cell-index</a> <a href='500text-screen.mu.html#L9'>screen</a>, y, x +<span id="L13" class="LineNr"> 13 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L100'>screen-cell-index</a> <a href='500text-screen.mu.html#L9'>screen</a>, x, y <span id="L14" class="LineNr"> 14 </span> <span class="muComment"># compare 'expected' with the screen contents starting at 'idx', grapheme by grapheme</span> <span id="L15" class="LineNr"> 15 </span> <span class="PreProc">var</span> e: (stream byte <span class="Constant">0x100</span>) <span id="L16" class="LineNr"> 16 </span> <span class="PreProc">var</span> e-addr/<span class="Constant">edx</span>: (addr stream byte) <span class="SpecialChar"><-</span> address e @@ -78,7 +78,7 @@ if ('onhashchange' in window) { <span id="L19" class="LineNr"> 19 </span> <span class="PreProc">var</span> done?/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='309stream.subx.html#L6'>stream-empty?</a> e-addr <span id="L20" class="LineNr"> 20 </span> compare done?, <span class="Constant">0</span> <span id="L21" class="LineNr"> 21 </span> <span class="PreProc">break-if-!=</span> -<span id="L22" class="LineNr"> 22 </span> <span class="PreProc">var</span> _g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L234'>screen-grapheme-at-idx</a> <a href='500text-screen.mu.html#L9'>screen</a>, idx +<span id="L22" class="LineNr"> 22 </span> <span class="PreProc">var</span> _g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L251'>screen-grapheme-at-idx</a> <a href='500text-screen.mu.html#L9'>screen</a>, idx <span id="L23" class="LineNr"> 23 </span> <span class="PreProc">var</span> g/<span class="Constant">ebx</span>: grapheme <span class="SpecialChar"><-</span> copy _g <span id="L24" class="LineNr"> 24 </span> <span class="PreProc">var</span> expected-grapheme/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> e-addr <span id="L25" class="LineNr"> 25 </span> <span class="muComment"># compare graphemes</span> @@ -94,23 +94,23 @@ if ('onhashchange' in window) { <span id="L35" class="LineNr"> 35 </span> compare g, expected-grapheme <span id="L36" class="LineNr"> 36 </span> <span class="Delimiter">{</span> <span id="L37" class="LineNr"> 37 </span> <span class="PreProc">break-if-!=</span> -<span id="L38" class="LineNr"> 38 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">"."</span>, <span class="Constant">3</span> <span class="muComment"># 3=cyan</span> +<span id="L38" class="LineNr"> 38 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"."</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg <span id="L39" class="LineNr"> 39 </span> <span class="PreProc">break</span> $check-screen-row-from:compare-graphemes <span id="L40" class="LineNr"> 40 </span> <span class="Delimiter">}</span> <span id="L41" class="LineNr"> 41 </span> <span class="muComment"># otherwise print an error</span> <span id="L42" class="LineNr"> 42 </span> <a href='104test.subx.html#L5'>count-test-failure</a> -<span id="L43" class="LineNr"> 43 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, msg, <span class="Constant">3</span> <span class="muComment"># 3=cyan</span> -<span id="L44" class="LineNr"> 44 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">": expected '"</span>, <span class="Constant">3</span> -<span id="L45" class="LineNr"> 45 </span> <a href='501draw-text.mu.html#L63'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>, expected-grapheme, <span class="Constant">3</span> -<span id="L46" class="LineNr"> 46 </span> <a href='501draw-text.mu.html#L169'>move-cursor-rightward-and-downward</a> <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">0x80</span> <span class="muComment"># screen-width</span> -<span id="L47" class="LineNr"> 47 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">"' at ("</span>, <span class="Constant">3</span> -<span id="L48" class="LineNr"> 48 </span> <a href='501draw-text.mu.html#L285'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, x, <span class="Constant">3</span> -<span id="L49" class="LineNr"> 49 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">", "</span>, <span class="Constant">3</span> -<span id="L50" class="LineNr"> 50 </span> <a href='501draw-text.mu.html#L285'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, y, <span class="Constant">3</span> -<span id="L51" class="LineNr"> 51 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">") but observed '"</span>, <span class="Constant">3</span> -<span id="L52" class="LineNr"> 52 </span> <a href='501draw-text.mu.html#L63'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>, g, <span class="Constant">3</span> -<span id="L53" class="LineNr"> 53 </span> <a href='501draw-text.mu.html#L169'>move-cursor-rightward-and-downward</a> <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">0x80</span> <span class="muComment"># screen-width</span> -<span id="L54" class="LineNr"> 54 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">"'"</span>, <span class="Constant">3</span> +<span id="L43" class="LineNr"> 43 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, msg, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L44" class="LineNr"> 44 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">": expected '"</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L45" class="LineNr"> 45 </span> <a href='501draw-text.mu.html#L65'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>/screen, expected-grapheme, <span class="Constant">3</span>/cyan, <span class="Constant">0</span>/bg +<span id="L46" class="LineNr"> 46 </span> <a href='501draw-text.mu.html#L185'>move-cursor-rightward-and-downward</a> <span class="Constant">0</span>/screen, <span class="Constant">0</span>/xmin, <span class="Constant">0x80</span>/xmax=screen-width +<span id="L47" class="LineNr"> 47 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"' at ("</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L48" class="LineNr"> 48 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, x, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L49" class="LineNr"> 49 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">", "</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L50" class="LineNr"> 50 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, y, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L51" class="LineNr"> 51 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">") but observed '"</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L52" class="LineNr"> 52 </span> <a href='501draw-text.mu.html#L65'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>/screen, g, <span class="Constant">3</span>/cyan, <span class="Constant">0</span>/bg +<span id="L53" class="LineNr"> 53 </span> <a href='501draw-text.mu.html#L185'>move-cursor-rightward-and-downward</a> <span class="Constant">0</span>/screen, <span class="Constant">0</span>/xmin, <span class="Constant">0x80</span>/xmax=screen-width +<span id="L54" class="LineNr"> 54 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"'"</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg <span id="L55" class="LineNr"> 55 </span> <span class="Delimiter">}</span> <span id="L56" class="LineNr"> 56 </span> idx <span class="SpecialChar"><-</span> increment <span id="L57" class="LineNr"> 57 </span> increment x @@ -121,12 +121,12 @@ if ('onhashchange' in window) { <span id="L62" class="LineNr"> 62 </span><span class="muComment"># various variants by screen-cell attribute; spaces in the 'expected' data should not match the attribute</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='504test-screen.mu.html#L64'>check-screen-row-in-color</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), fg: int, y: int, expected: (addr array byte), msg: (addr array byte) <span class="Delimiter">{</span> -<span id="L65" class="LineNr"> 65 </span> <a href='504test-screen.mu.html#L68'>check-screen-row-in-color-from</a> <a href='500text-screen.mu.html#L9'>screen</a>, fg, y, <span class="Constant">0</span>, expected, msg +<span id="L65" class="LineNr"> 65 </span> <a href='504test-screen.mu.html#L68'>check-screen-row-in-color-from</a> <a href='500text-screen.mu.html#L9'>screen</a>, fg, y, <span class="Constant">0</span>/x, expected, msg <span id="L66" class="LineNr"> 66 </span><span class="Delimiter">}</span> <span id="L67" class="LineNr"> 67 </span> <span id="L68" class="LineNr"> 68 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='504test-screen.mu.html#L68'>check-screen-row-in-color-from</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), fg: int, y: int, x: int, expected: (addr array byte), msg: (addr array byte) <span class="Delimiter">{</span> <span id="L69" class="LineNr"> 69 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack -<span id="L70" class="LineNr"> 70 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L90'>screen-cell-index</a> <a href='500text-screen.mu.html#L9'>screen</a>, y, x +<span id="L70" class="LineNr"> 70 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L100'>screen-cell-index</a> <a href='500text-screen.mu.html#L9'>screen</a>, x, y <span id="L71" class="LineNr"> 71 </span> <span class="muComment"># compare 'expected' with the screen contents starting at 'idx', grapheme by grapheme</span> <span id="L72" class="LineNr"> 72 </span> <span class="PreProc">var</span> e: (stream byte <span class="Constant">0x100</span>) <span id="L73" class="LineNr"> 73 </span> <span class="PreProc">var</span> e-addr/<span class="Constant">edx</span>: (addr stream byte) <span class="SpecialChar"><-</span> address e @@ -135,7 +135,7 @@ if ('onhashchange' in window) { <span id="L76" class="LineNr"> 76 </span> <span class="PreProc">var</span> done?/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='309stream.subx.html#L6'>stream-empty?</a> e-addr <span id="L77" class="LineNr"> 77 </span> compare done?, <span class="Constant">0</span> <span id="L78" class="LineNr"> 78 </span> <span class="PreProc">break-if-!=</span> -<span id="L79" class="LineNr"> 79 </span> <span class="PreProc">var</span> _g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L234'>screen-grapheme-at-idx</a> <a href='500text-screen.mu.html#L9'>screen</a>, idx +<span id="L79" class="LineNr"> 79 </span> <span class="PreProc">var</span> _g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L251'>screen-grapheme-at-idx</a> <a href='500text-screen.mu.html#L9'>screen</a>, idx <span id="L80" class="LineNr"> 80 </span> <span class="PreProc">var</span> g/<span class="Constant">ebx</span>: grapheme <span class="SpecialChar"><-</span> copy _g <span id="L81" class="LineNr"> 81 </span> <span class="PreProc">var</span> _expected-grapheme/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> e-addr <span id="L82" class="LineNr"> 82 </span> <span class="PreProc">var</span> expected-grapheme/<span class="Constant">edi</span>: grapheme <span class="SpecialChar"><-</span> copy _expected-grapheme @@ -151,7 +151,7 @@ if ('onhashchange' in window) { <span id="L92" class="LineNr"> 92 </span> <span class="Delimiter">{</span> <span id="L93" class="LineNr"> 93 </span> compare expected-grapheme, <span class="Constant">0x20</span> <span id="L94" class="LineNr"> 94 </span> <span class="PreProc">break-if-!=</span> -<span id="L95" class="LineNr"> 95 </span> <span class="PreProc">var</span> color/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L252'>screen-color-at-idx</a> <a href='500text-screen.mu.html#L9'>screen</a>, idx +<span id="L95" class="LineNr"> 95 </span> <span class="PreProc">var</span> color/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L269'>screen-color-at-idx</a> <a href='500text-screen.mu.html#L9'>screen</a>, idx <span id="L96" class="LineNr"> 96 </span> compare color, fg <span id="L97" class="LineNr"> 97 </span> <span class="PreProc">break-if-!=</span> $check-screen-row-in-color-from:compare-cells <span id="L98" class="LineNr"> 98 </span> <span class="Delimiter">}</span> @@ -161,46 +161,46 @@ if ('onhashchange' in window) { <span id="L102" class="LineNr">102 </span> compare g, expected-grapheme <span id="L103" class="LineNr">103 </span> <span class="Delimiter">{</span> <span id="L104" class="LineNr">104 </span> <span class="PreProc">break-if-!=</span> -<span id="L105" class="LineNr">105 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">"."</span>, <span class="Constant">3</span> <span class="muComment"># 3=cyan</span> +<span id="L105" class="LineNr">105 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"."</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg <span id="L106" class="LineNr">106 </span> <span class="PreProc">break</span> $check-screen-row-in-color-from:compare-graphemes <span id="L107" class="LineNr">107 </span> <span class="Delimiter">}</span> <span id="L108" class="LineNr">108 </span> <span class="muComment"># otherwise print an error</span> <span id="L109" class="LineNr">109 </span> <a href='104test.subx.html#L5'>count-test-failure</a> -<span id="L110" class="LineNr">110 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, msg, <span class="Constant">3</span> <span class="muComment"># 3=cyan</span> -<span id="L111" class="LineNr">111 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">": expected '"</span>, <span class="Constant">3</span> -<span id="L112" class="LineNr">112 </span> <a href='501draw-text.mu.html#L63'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>, expected-grapheme, <span class="Constant">3</span> -<span id="L113" class="LineNr">113 </span> <a href='501draw-text.mu.html#L169'>move-cursor-rightward-and-downward</a> <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">0x80</span> <span class="muComment"># screen-width</span> -<span id="L114" class="LineNr">114 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">"' at ("</span>, <span class="Constant">3</span> -<span id="L115" class="LineNr">115 </span> <a href='501draw-text.mu.html#L285'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, x, <span class="Constant">3</span> -<span id="L116" class="LineNr">116 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">", "</span>, <span class="Constant">3</span> -<span id="L117" class="LineNr">117 </span> <a href='501draw-text.mu.html#L285'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, y, <span class="Constant">3</span> -<span id="L118" class="LineNr">118 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">") but observed '"</span>, <span class="Constant">3</span> -<span id="L119" class="LineNr">119 </span> <a href='501draw-text.mu.html#L63'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>, g, <span class="Constant">3</span> -<span id="L120" class="LineNr">120 </span> <a href='501draw-text.mu.html#L169'>move-cursor-rightward-and-downward</a> <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">0x80</span> <span class="muComment"># screen-width</span> -<span id="L121" class="LineNr">121 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">"'"</span>, <span class="Constant">3</span> +<span id="L110" class="LineNr">110 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, msg, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L111" class="LineNr">111 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">": expected '"</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L112" class="LineNr">112 </span> <a href='501draw-text.mu.html#L65'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>/screen, expected-grapheme, <span class="Constant">3</span>/cyan, <span class="Constant">0</span>/bg +<span id="L113" class="LineNr">113 </span> <a href='501draw-text.mu.html#L185'>move-cursor-rightward-and-downward</a> <span class="Constant">0</span>/screen, <span class="Constant">0</span>/xmin, <span class="Constant">0x80</span>/xmax=screen-width +<span id="L114" class="LineNr">114 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"' at ("</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L115" class="LineNr">115 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, x, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L116" class="LineNr">116 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">", "</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L117" class="LineNr">117 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, y, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L118" class="LineNr">118 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">") but observed '"</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L119" class="LineNr">119 </span> <a href='501draw-text.mu.html#L65'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>/screen, g, <span class="Constant">3</span>/cyan, <span class="Constant">0</span>/bg +<span id="L120" class="LineNr">120 </span> <a href='501draw-text.mu.html#L185'>move-cursor-rightward-and-downward</a> <span class="Constant">0</span>/screen, <span class="Constant">0</span>/xmin, <span class="Constant">0x80</span>/xmax=screen-width +<span id="L121" class="LineNr">121 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"'"</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg <span id="L122" class="LineNr">122 </span> <span class="Delimiter">}</span> <span id="L123" class="LineNr">123 </span> $check-screen-row-in-color-from:compare-colors: <span class="Delimiter">{</span> -<span id="L124" class="LineNr">124 </span> <span class="PreProc">var</span> color/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L252'>screen-color-at-idx</a> <a href='500text-screen.mu.html#L9'>screen</a>, idx +<span id="L124" class="LineNr">124 </span> <span class="PreProc">var</span> color/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L269'>screen-color-at-idx</a> <a href='500text-screen.mu.html#L9'>screen</a>, idx <span id="L125" class="LineNr">125 </span> compare fg, color <span id="L126" class="LineNr">126 </span> <span class="Delimiter">{</span> <span id="L127" class="LineNr">127 </span> <span class="PreProc">break-if-!=</span> -<span id="L128" class="LineNr">128 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">"."</span>, <span class="Constant">3</span> <span class="muComment"># 3=cyan</span> +<span id="L128" class="LineNr">128 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"."</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg <span id="L129" class="LineNr">129 </span> <span class="PreProc">break</span> $check-screen-row-in-color-from:compare-colors <span id="L130" class="LineNr">130 </span> <span class="Delimiter">}</span> <span id="L131" class="LineNr">131 </span> <span class="muComment"># otherwise print an error</span> <span id="L132" class="LineNr">132 </span> <a href='104test.subx.html#L5'>count-test-failure</a> -<span id="L133" class="LineNr">133 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, msg, <span class="Constant">3</span> <span class="muComment"># 3=cyan</span> -<span id="L134" class="LineNr">134 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">": expected '"</span>, <span class="Constant">3</span> -<span id="L135" class="LineNr">135 </span> <a href='501draw-text.mu.html#L63'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>, expected-grapheme, <span class="Constant">3</span> -<span id="L136" class="LineNr">136 </span> <a href='501draw-text.mu.html#L169'>move-cursor-rightward-and-downward</a> <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">0x80</span> <span class="muComment"># screen-width</span> -<span id="L137" class="LineNr">137 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">"' at ("</span>, <span class="Constant">3</span> -<span id="L138" class="LineNr">138 </span> <a href='501draw-text.mu.html#L285'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, x, <span class="Constant">3</span> -<span id="L139" class="LineNr">139 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">", "</span>, <span class="Constant">3</span> -<span id="L140" class="LineNr">140 </span> <a href='501draw-text.mu.html#L285'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, y, <span class="Constant">3</span> -<span id="L141" class="LineNr">141 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">") in color "</span>, <span class="Constant">3</span> -<span id="L142" class="LineNr">142 </span> <a href='501draw-text.mu.html#L285'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, fg, <span class="Constant">3</span> -<span id="L143" class="LineNr">143 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">" but observed color "</span>, <span class="Constant">3</span> -<span id="L144" class="LineNr">144 </span> <a href='501draw-text.mu.html#L285'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, color, <span class="Constant">3</span> +<span id="L133" class="LineNr">133 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, msg, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L134" class="LineNr">134 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">": expected '"</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L135" class="LineNr">135 </span> <a href='501draw-text.mu.html#L65'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>/screen, expected-grapheme, <span class="Constant">3</span>/cyan, <span class="Constant">0</span>/bg +<span id="L136" class="LineNr">136 </span> <a href='501draw-text.mu.html#L185'>move-cursor-rightward-and-downward</a> <span class="Constant">0</span>/screen, <span class="Constant">0</span>/xmin, <span class="Constant">0x80</span>/xmax=screen-width +<span id="L137" class="LineNr">137 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"' at ("</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L138" class="LineNr">138 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, x, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L139" class="LineNr">139 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">", "</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L140" class="LineNr">140 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, y, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L141" class="LineNr">141 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">") in color "</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L142" class="LineNr">142 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, fg, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L143" class="LineNr">143 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">" but observed color "</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L144" class="LineNr">144 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, color, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg <span id="L145" class="LineNr">145 </span> <span class="Delimiter">}</span> <span id="L146" class="LineNr">146 </span> <span class="Delimiter">}</span> <span id="L147" class="LineNr">147 </span> idx <span class="SpecialChar"><-</span> increment @@ -209,22 +209,173 @@ if ('onhashchange' in window) { <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 id="L153" class="LineNr">153 </span><span class="PreProc">fn</span> <span class="muTest"><a href='504test-screen.mu.html#L153'>test-draw-single-grapheme</a></span> <span class="Delimiter">{</span> -<span id="L154" class="LineNr">154 </span> <span class="PreProc">var</span> screen-on-stack: <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L155" class="LineNr">155 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> address screen-on-stack -<span id="L156" class="LineNr">156 </span> <a href='500text-screen.mu.html#L22'>initialize-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">5</span>, <span class="Constant">4</span> -<span id="L157" class="LineNr">157 </span> <span class="PreProc">var</span> c/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> copy <span class="Constant">0x61</span> <span class="muComment"># 'a'</span> -<span id="L158" class="LineNr">158 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <a href='500text-screen.mu.html#L9'>screen</a>, c, <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">1</span> <span class="muComment"># color=1</span> -<span id="L159" class="LineNr">159 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>, <span class="Constant">"a"</span>, <span class="Constant">"F - test-draw-single-grapheme"</span> <span class="muComment"># top-left corner of the screen</span> -<span id="L160" class="LineNr">160 </span><span class="Delimiter">}</span> -<span id="L161" class="LineNr">161 </span> -<span id="L162" class="LineNr">162 </span><span class="PreProc">fn</span> <span class="muTest"><a href='504test-screen.mu.html#L162'>test-draw-multiple-graphemes</a></span> <span class="Delimiter">{</span> -<span id="L163" class="LineNr">163 </span> <span class="PreProc">var</span> screen-on-stack: <a href='500text-screen.mu.html#L9'>screen</a> -<span id="L164" class="LineNr">164 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> address screen-on-stack -<span id="L165" class="LineNr">165 </span> <a href='500text-screen.mu.html#L22'>initialize-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x10</span>, <span class="Constant">4</span> -<span id="L166" class="LineNr">166 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">"Hello, 世界"</span>, <span class="Constant">1</span> <span class="muComment"># color=1</span> -<span id="L167" class="LineNr">167 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>, <span class="Constant">"Hello, 世界"</span>, <span class="Constant">"F - test-draw-multiple-graphemes"</span> -<span id="L168" class="LineNr">168 </span><span class="Delimiter">}</span> +<span id="L153" class="LineNr">153 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='504test-screen.mu.html#L153'>check-screen-row-in-background-color</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), bg: int, y: int, expected: (addr array byte), msg: (addr array byte) <span class="Delimiter">{</span> +<span id="L154" class="LineNr">154 </span> <a href='504test-screen.mu.html#L157'>check-screen-row-in-background-color-from</a> <a href='500text-screen.mu.html#L9'>screen</a>, bg, y, <span class="Constant">0</span>/x, expected, msg +<span id="L155" class="LineNr">155 </span><span class="Delimiter">}</span> +<span id="L156" class="LineNr">156 </span> +<span id="L157" class="LineNr">157 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='504test-screen.mu.html#L157'>check-screen-row-in-background-color-from</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), bg: int, y: int, x: int, expected: (addr array byte), msg: (addr array byte) <span class="Delimiter">{</span> +<span id="L158" class="LineNr">158 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack +<span id="L159" class="LineNr">159 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L100'>screen-cell-index</a> <a href='500text-screen.mu.html#L9'>screen</a>, x, y +<span id="L160" class="LineNr">160 </span> <span class="muComment"># compare 'expected' with the screen contents starting at 'idx', grapheme by grapheme</span> +<span id="L161" class="LineNr">161 </span> <span class="PreProc">var</span> e: (stream byte <span class="Constant">0x100</span>) +<span id="L162" class="LineNr">162 </span> <span class="PreProc">var</span> e-addr/<span class="Constant">edx</span>: (addr stream byte) <span class="SpecialChar"><-</span> address e +<span id="L163" class="LineNr">163 </span> <a href='108write.subx.html#L11'>write</a> e-addr, expected +<span id="L164" class="LineNr">164 </span> <span class="Delimiter">{</span> +<span id="L165" class="LineNr">165 </span> <span class="PreProc">var</span> done?/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='309stream.subx.html#L6'>stream-empty?</a> e-addr +<span id="L166" class="LineNr">166 </span> compare done?, <span class="Constant">0</span> +<span id="L167" class="LineNr">167 </span> <span class="PreProc">break-if-!=</span> +<span id="L168" class="LineNr">168 </span> <span class="PreProc">var</span> _g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L251'>screen-grapheme-at-idx</a> <a href='500text-screen.mu.html#L9'>screen</a>, idx +<span id="L169" class="LineNr">169 </span> <span class="PreProc">var</span> g/<span class="Constant">ebx</span>: grapheme <span class="SpecialChar"><-</span> copy _g +<span id="L170" class="LineNr">170 </span> <span class="PreProc">var</span> _expected-grapheme/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> e-addr +<span id="L171" class="LineNr">171 </span> <span class="PreProc">var</span> expected-grapheme/<span class="Constant">edi</span>: grapheme <span class="SpecialChar"><-</span> copy _expected-grapheme +<span id="L172" class="LineNr">172 </span> $check-screen-row-in-background-color-from:compare-cells: <span class="Delimiter">{</span> +<span id="L173" class="LineNr">173 </span> <span class="muComment"># if expected-grapheme is space, null grapheme is also ok</span> +<span id="L174" class="LineNr">174 </span> <span class="Delimiter">{</span> +<span id="L175" class="LineNr">175 </span> compare expected-grapheme, <span class="Constant">0x20</span> +<span id="L176" class="LineNr">176 </span> <span class="PreProc">break-if-!=</span> +<span id="L177" class="LineNr">177 </span> compare g, <span class="Constant">0</span> +<span id="L178" class="LineNr">178 </span> <span class="PreProc">break-if-=</span> $check-screen-row-in-background-color-from:compare-cells +<span id="L179" class="LineNr">179 </span> <span class="Delimiter">}</span> +<span id="L180" class="LineNr">180 </span> <span class="muComment"># if expected-grapheme is space, a different background-color is ok</span> +<span id="L181" class="LineNr">181 </span> <span class="Delimiter">{</span> +<span id="L182" class="LineNr">182 </span> compare expected-grapheme, <span class="Constant">0x20</span> +<span id="L183" class="LineNr">183 </span> <span class="PreProc">break-if-!=</span> +<span id="L184" class="LineNr">184 </span> <span class="PreProc">var</span> background-color/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L288'>screen-background-color-at-idx</a> <a href='500text-screen.mu.html#L9'>screen</a>, idx +<span id="L185" class="LineNr">185 </span> compare background-color, bg +<span id="L186" class="LineNr">186 </span> <span class="PreProc">break-if-!=</span> $check-screen-row-in-background-color-from:compare-cells +<span id="L187" class="LineNr">187 </span> <span class="Delimiter">}</span> +<span id="L188" class="LineNr">188 </span> <span class="muComment"># compare graphemes</span> +<span id="L189" class="LineNr">189 </span> $check-screen-row-in-background-color-from:compare-graphemes: <span class="Delimiter">{</span> +<span id="L190" class="LineNr">190 </span> <span class="muComment"># if (g == expected-grapheme) print "."</span> +<span id="L191" class="LineNr">191 </span> compare g, expected-grapheme +<span id="L192" class="LineNr">192 </span> <span class="Delimiter">{</span> +<span id="L193" class="LineNr">193 </span> <span class="PreProc">break-if-!=</span> +<span id="L194" class="LineNr">194 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"."</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L195" class="LineNr">195 </span> <span class="PreProc">break</span> $check-screen-row-in-background-color-from:compare-graphemes +<span id="L196" class="LineNr">196 </span> <span class="Delimiter">}</span> +<span id="L197" class="LineNr">197 </span> <span class="muComment"># otherwise print an error</span> +<span id="L198" class="LineNr">198 </span> <a href='104test.subx.html#L5'>count-test-failure</a> +<span id="L199" class="LineNr">199 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, msg, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L200" class="LineNr">200 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">": expected '"</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L201" class="LineNr">201 </span> <a href='501draw-text.mu.html#L65'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>/screen, expected-grapheme, <span class="Constant">3</span>/cyan, <span class="Constant">0</span>/bg +<span id="L202" class="LineNr">202 </span> <a href='501draw-text.mu.html#L185'>move-cursor-rightward-and-downward</a> <span class="Constant">0</span>/screen, <span class="Constant">0</span>/xmin, <span class="Constant">0x80</span>/xmax=screen-width +<span id="L203" class="LineNr">203 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"' at ("</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L204" class="LineNr">204 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, x, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L205" class="LineNr">205 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">", "</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L206" class="LineNr">206 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, y, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L207" class="LineNr">207 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">") but observed '"</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L208" class="LineNr">208 </span> <a href='501draw-text.mu.html#L65'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>/screen, g, <span class="Constant">3</span>/cyan, <span class="Constant">0</span>/bg +<span id="L209" class="LineNr">209 </span> <a href='501draw-text.mu.html#L185'>move-cursor-rightward-and-downward</a> <span class="Constant">0</span>/screen, <span class="Constant">0</span>/xmin, <span class="Constant">0x80</span>/xmax=screen-width +<span id="L210" class="LineNr">210 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"'"</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L211" class="LineNr">211 </span> <span class="Delimiter">}</span> +<span id="L212" class="LineNr">212 </span> $check-screen-row-in-background-color-from:compare-background-colors: <span class="Delimiter">{</span> +<span id="L213" class="LineNr">213 </span> <span class="PreProc">var</span> background-color/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L288'>screen-background-color-at-idx</a> <a href='500text-screen.mu.html#L9'>screen</a>, idx +<span id="L214" class="LineNr">214 </span> compare bg, background-color +<span id="L215" class="LineNr">215 </span> <span class="Delimiter">{</span> +<span id="L216" class="LineNr">216 </span> <span class="PreProc">break-if-!=</span> +<span id="L217" class="LineNr">217 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"."</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L218" class="LineNr">218 </span> <span class="PreProc">break</span> $check-screen-row-in-background-color-from:compare-background-colors +<span id="L219" class="LineNr">219 </span> <span class="Delimiter">}</span> +<span id="L220" class="LineNr">220 </span> <span class="muComment"># otherwise print an error</span> +<span id="L221" class="LineNr">221 </span> <a href='104test.subx.html#L5'>count-test-failure</a> +<span id="L222" class="LineNr">222 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, msg, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L223" class="LineNr">223 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">": expected '"</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L224" class="LineNr">224 </span> <a href='501draw-text.mu.html#L65'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>/screen, expected-grapheme, <span class="Constant">3</span>/cyan, <span class="Constant">0</span>/bg +<span id="L225" class="LineNr">225 </span> <a href='501draw-text.mu.html#L185'>move-cursor-rightward-and-downward</a> <span class="Constant">0</span>/screen, <span class="Constant">0</span>/xmin, <span class="Constant">0x80</span>/xmax=screen-width +<span id="L226" class="LineNr">226 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"' at ("</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L227" class="LineNr">227 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, x, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L228" class="LineNr">228 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">", "</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L229" class="LineNr">229 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, y, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L230" class="LineNr">230 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">") in background-color "</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L231" class="LineNr">231 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, bg, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L232" class="LineNr">232 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">" but observed background-color "</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L233" class="LineNr">233 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, background-color, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L234" class="LineNr">234 </span> <span class="Delimiter">}</span> +<span id="L235" class="LineNr">235 </span> <span class="Delimiter">}</span> +<span id="L236" class="LineNr">236 </span> idx <span class="SpecialChar"><-</span> increment +<span id="L237" class="LineNr">237 </span> increment x +<span id="L238" class="LineNr">238 </span> <span class="PreProc">loop</span> +<span id="L239" class="LineNr">239 </span> <span class="Delimiter">}</span> +<span id="L240" class="LineNr">240 </span><span class="Delimiter">}</span> +<span id="L241" class="LineNr">241 </span> +<span id="L242" class="LineNr">242 </span><span class="muComment"># helpers for checking just background color, not screen contents</span> +<span id="L243" class="LineNr">243 </span><span class="muComment"># these can validate bg for spaces</span> +<span id="L244" class="LineNr">244 </span> +<span id="L245" class="LineNr">245 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='504test-screen.mu.html#L245'>check-background-color-in-screen-row</a></span> <a href='500text-screen.mu.html#L9'>screen</a>: (addr <a href='500text-screen.mu.html#L9'>screen</a>), bg: int, y: int, expected-bitmap: (addr array byte), msg: (addr array byte) <span class="Delimiter">{</span> +<span id="L246" class="LineNr">246 </span> <a href='504test-screen.mu.html#L249'>check-background-color-in-screen-row-from</a> <a href='500text-screen.mu.html#L9'>screen</a>, bg, y, <span class="Constant">0</span>/x, expected-bitmap, msg +<span id="L247" class="LineNr">247 </span><span class="Delimiter">}</span> +<span id="L248" class="LineNr">248 </span> +<span id="L249" class="LineNr">249 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='504test-screen.mu.html#L249'>check-background-color-in-screen-row-from</a></span> screen-on-stack: (addr <a href='500text-screen.mu.html#L9'>screen</a>), bg: int, y: int, x: int, expected-bitmap: (addr array byte), msg: (addr array byte) <span class="Delimiter">{</span> +<span id="L250" class="LineNr">250 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> copy screen-on-stack +<span id="L251" class="LineNr">251 </span> <span class="PreProc">var</span> idx/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L100'>screen-cell-index</a> <a href='500text-screen.mu.html#L9'>screen</a>, x, y +<span id="L252" class="LineNr">252 </span> <span class="muComment"># compare background color where 'expected-bitmap' is a non-space</span> +<span id="L253" class="LineNr">253 </span> <span class="PreProc">var</span> e: (stream byte <span class="Constant">0x100</span>) +<span id="L254" class="LineNr">254 </span> <span class="PreProc">var</span> e-addr/<span class="Constant">edx</span>: (addr stream byte) <span class="SpecialChar"><-</span> address e +<span id="L255" class="LineNr">255 </span> <a href='108write.subx.html#L11'>write</a> e-addr, expected-bitmap +<span id="L256" class="LineNr">256 </span> <span class="Delimiter">{</span> +<span id="L257" class="LineNr">257 </span> <span class="PreProc">var</span> done?/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='309stream.subx.html#L6'>stream-empty?</a> e-addr +<span id="L258" class="LineNr">258 </span> compare done?, <span class="Constant">0</span> +<span id="L259" class="LineNr">259 </span> <span class="PreProc">break-if-!=</span> +<span id="L260" class="LineNr">260 </span> <span class="PreProc">var</span> _expected-bit/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> <a href='403unicode.mu.html#L92'>read-grapheme</a> e-addr +<span id="L261" class="LineNr">261 </span> <span class="PreProc">var</span> expected-bit/<span class="Constant">edi</span>: grapheme <span class="SpecialChar"><-</span> copy _expected-bit +<span id="L262" class="LineNr">262 </span> $check-background-color-in-screen-row-from:compare-cells: <span class="Delimiter">{</span> +<span id="L263" class="LineNr">263 </span> <span class="PreProc">var</span> background-color/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='500text-screen.mu.html#L288'>screen-background-color-at-idx</a> <a href='500text-screen.mu.html#L9'>screen</a>, idx +<span id="L264" class="LineNr">264 </span> <span class="muComment"># if expected-bit is space, assert that background is NOT bg</span> +<span id="L265" class="LineNr">265 </span> compare expected-bit, <span class="Constant">0x20</span> +<span id="L266" class="LineNr">266 </span> <span class="Delimiter">{</span> +<span id="L267" class="LineNr">267 </span> <span class="PreProc">break-if-!=</span> +<span id="L268" class="LineNr">268 </span> compare background-color, bg +<span id="L269" class="LineNr">269 </span> <span class="PreProc">break-if-!=</span> $check-background-color-in-screen-row-from:compare-cells +<span id="L270" class="LineNr">270 </span> <a href='104test.subx.html#L5'>count-test-failure</a> +<span id="L271" class="LineNr">271 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, msg, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L272" class="LineNr">272 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">": expected ("</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L273" class="LineNr">273 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, x, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L274" class="LineNr">274 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">", "</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L275" class="LineNr">275 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, y, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L276" class="LineNr">276 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">") to not be in background-color "</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L277" class="LineNr">277 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, bg, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L278" class="LineNr">278 </span> <span class="PreProc">break</span> $check-background-color-in-screen-row-from:compare-cells +<span id="L279" class="LineNr">279 </span> <span class="Delimiter">}</span> +<span id="L280" class="LineNr">280 </span> <span class="muComment"># otherwise assert that background IS bg</span> +<span id="L281" class="LineNr">281 </span> compare background-color, bg +<span id="L282" class="LineNr">282 </span> <span class="PreProc">break-if-=</span> $check-background-color-in-screen-row-from:compare-cells +<span id="L283" class="LineNr">283 </span> <a href='104test.subx.html#L5'>count-test-failure</a> +<span id="L284" class="LineNr">284 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, msg, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L285" class="LineNr">285 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">": expected ("</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L286" class="LineNr">286 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, x, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L287" class="LineNr">287 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">", "</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L288" class="LineNr">288 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, y, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L289" class="LineNr">289 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">") in background-color "</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L290" class="LineNr">290 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, bg, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L291" class="LineNr">291 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">" but observed background-color "</span>, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L292" class="LineNr">292 </span> <a href='501draw-text.mu.html#L301'>draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, background-color, <span class="Constant">3</span>/fg/cyan, <span class="Constant">0</span>/bg +<span id="L293" class="LineNr">293 </span> <span class="Delimiter">}</span> +<span id="L294" class="LineNr">294 </span> idx <span class="SpecialChar"><-</span> increment +<span id="L295" class="LineNr">295 </span> increment x +<span id="L296" class="LineNr">296 </span> <span class="PreProc">loop</span> +<span id="L297" class="LineNr">297 </span> <span class="Delimiter">}</span> +<span id="L298" class="LineNr">298 </span><span class="Delimiter">}</span> +<span id="L299" class="LineNr">299 </span> +<span id="L300" class="LineNr">300 </span><span class="PreProc">fn</span> <span class="muTest"><a href='504test-screen.mu.html#L300'>test-draw-single-grapheme</a></span> <span class="Delimiter">{</span> +<span id="L301" class="LineNr">301 </span> <span class="PreProc">var</span> screen-on-stack: <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L302" class="LineNr">302 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> address screen-on-stack +<span id="L303" class="LineNr">303 </span> <a href='500text-screen.mu.html#L23'>initialize-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">5</span>, <span class="Constant">4</span> +<span id="L304" class="LineNr">304 </span> <a href='500text-screen.mu.html#L94'>draw-code-point</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x61</span>/a, <span class="Constant">0</span>/x, <span class="Constant">0</span>/y, <span class="Constant">1</span>/fg, <span class="Constant">2</span>/bg +<span id="L305" class="LineNr">305 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"a"</span>, <span class="Constant">"F - test-draw-single-grapheme"</span> <span class="muComment"># top-left corner of the screen</span> +<span id="L306" class="LineNr">306 </span> <a href='504test-screen.mu.html#L64'>check-screen-row-in-color</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">1</span>/fg, <span class="Constant">0</span>/y, <span class="Constant">"a"</span>, <span class="Constant">"F - test-draw-single-grapheme-fg"</span> +<span id="L307" class="LineNr">307 </span> <a href='504test-screen.mu.html#L153'>check-screen-row-in-background-color</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">2</span>/bg, <span class="Constant">0</span>/y, <span class="Constant">"a"</span>, <span class="Constant">"F - test-draw-single-grapheme-bg"</span> +<span id="L308" class="LineNr">308 </span> <a href='504test-screen.mu.html#L245'>check-background-color-in-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">2</span>/bg, <span class="Constant">0</span>/y, <span class="Constant">"x "</span>, <span class="Constant">"F - test-draw-single-grapheme-bg2"</span> +<span id="L309" class="LineNr">309 </span><span class="Delimiter">}</span> +<span id="L310" class="LineNr">310 </span> +<span id="L311" class="LineNr">311 </span><span class="PreProc">fn</span> <span class="muTest"><a href='504test-screen.mu.html#L311'>test-draw-multiple-graphemes</a></span> <span class="Delimiter">{</span> +<span id="L312" class="LineNr">312 </span> <span class="PreProc">var</span> screen-on-stack: <a href='500text-screen.mu.html#L9'>screen</a> +<span id="L313" class="LineNr">313 </span> <span class="PreProc">var</span> <a href='500text-screen.mu.html#L9'>screen</a>/<span class="Constant">esi</span>: (addr <a href='500text-screen.mu.html#L9'>screen</a>) <span class="SpecialChar"><-</span> address screen-on-stack +<span id="L314" class="LineNr">314 </span> <a href='500text-screen.mu.html#L23'>initialize-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0x10</span>/rows, <span class="Constant">4</span>/cols +<span id="L315" class="LineNr">315 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">"Hello, 世界"</span>, <span class="Constant">1</span>/fg, <span class="Constant">2</span>/bg +<span id="L316" class="LineNr">316 </span> <a href='504test-screen.mu.html#L7'>check-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">0</span>/y, <span class="Constant">"Hello, 世界"</span>, <span class="Constant">"F - test-draw-multiple-graphemes"</span> +<span id="L317" class="LineNr">317 </span> <a href='504test-screen.mu.html#L64'>check-screen-row-in-color</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">1</span>/fg, <span class="Constant">0</span>/y, <span class="Constant">"Hello, 世界"</span>, <span class="Constant">"F - test-draw-multiple-graphemes-fg"</span> +<span id="L318" class="LineNr">318 </span> <a href='504test-screen.mu.html#L245'>check-background-color-in-screen-row</a> <a href='500text-screen.mu.html#L9'>screen</a>, <span class="Constant">2</span>/bg, <span class="Constant">0</span>/y, <span class="Constant">"xxxxxxxxx "</span>, <span class="Constant">"F - test-draw-multiple-graphemes-bg2"</span> +<span id="L319" class="LineNr">319 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/baremetal/boot.hex.html b/html/baremetal/boot.hex.html index fc47698f..bbcd38e1 100644 --- a/html/baremetal/boot.hex.html +++ b/html/baremetal/boot.hex.html @@ -120,7 +120,7 @@ if ('onhashchange' in window) { <span id="L65" class="LineNr"> 65 </span><span class="subxComment"># offset 1800 (address 9400): entrypoint for applications (don't forget to adjust survey_baremetal if this changes)</span> <span id="L66" class="LineNr"> 66 </span> <span id="L67" class="LineNr"> 67 </span><span class="subxComment"># Other details of the current memory map:</span> -<span id="L68" class="LineNr"> 68 </span><span class="subxComment"># code: first two default-sized disk tracks get loaded to [0x00007c00, 0x00017800)</span> +<span id="L68" class="LineNr"> 68 </span><span class="subxComment"># code: 4 tracks of disk to [0x00007c00, 0x00027400)</span> <span id="L69" class="LineNr"> 69 </span><span class="subxComment"># stack grows down from 0x00070000</span> <span id="L70" class="LineNr"> 70 </span><span class="subxComment"># see below</span> <span id="L71" class="LineNr"> 71 </span><span class="subxComment"># heap: [0x01000000, 0x02000000)</span> @@ -162,7 +162,7 @@ if ('onhashchange' in window) { <span id="L107" class="LineNr"> 107 </span> b5 00 <span class="subxComment"># ch <- 0 # cylinder 0</span> <span id="L108" class="LineNr"> 108 </span> b6 00 <span class="subxComment"># dh <- 0 # track 0</span> <span id="L109" class="LineNr"> 109 </span> b1 02 <span class="subxComment"># cl <- 2 # second sector, 1-based</span> -<span id="L110" class="LineNr"> 110 </span> b0 7d <span class="subxComment"># al <- 125 # number of sectors to read</span> +<span id="L110" class="LineNr"> 110 </span> b0 7d <span class="subxComment"># al <- 125 # number of sectors to read = 2*63 - 1</span> <span id="L111" class="LineNr"> 111 </span> <span class="subxComment"># address to write sectors to = es:bx = 0x7e00, contiguous with boot segment</span> <span id="L112" class="LineNr"> 112 </span> bb 00 00 <span class="subxComment"># bx <- 0</span> <span id="L113" class="LineNr"> 113 </span> 8e c3 <span class="subxComment"># es <- bx</span> @@ -171,394 +171,419 @@ if ('onhashchange' in window) { <span id="L116" class="LineNr"> 116 </span> 0f 82 a3 00 <span class="subxComment"># jump-if-carry disk_error [label]</span> <span id="L117" class="LineNr"> 117 </span> <span id="L118" class="LineNr"> 118 </span><span class="subxComment"># 2c:</span> -<span id="L119" class="LineNr"> 119 </span> <span class="subxComment"># undo the A20 hack: <a href="https://en.wikipedia.org/wiki/A20_line">https://en.wikipedia.org/wiki/A20_line</a></span> -<span id="L120" class="LineNr"> 120 </span> <span class="subxComment"># this is from <a href="https://github.com/mit-pdos/xv6-public/blob/master/bootasm.S">https://github.com/mit-pdos/xv6-public/blob/master/bootasm.S</a></span> -<span id="L121" class="LineNr"> 121 </span> <span class="subxComment"># seta20.1:</span> -<span id="L122" class="LineNr"> 122 </span> e4 64 <span class="subxComment"># al <- port 0x64</span> -<span id="L123" class="LineNr"> 123 </span> a8 02 <span class="subxComment"># set zf if bit 1 (second-least significant) is not set</span> -<span id="L124" class="LineNr"> 124 </span> 75 fa <span class="subxComment"># if zf not set, goto seta20.1 (-6)</span> -<span id="L125" class="LineNr"> 125 </span> -<span id="L126" class="LineNr"> 126 </span> b0 d1 <span class="subxComment"># al <- 0xd1</span> -<span id="L127" class="LineNr"> 127 </span> e6 64 <span class="subxComment"># port 0x64 <- al</span> -<span id="L128" class="LineNr"> 128 </span> -<span id="L129" class="LineNr"> 129 </span><span class="subxComment"># 36:</span> -<span id="L130" class="LineNr"> 130 </span> <span class="subxComment"># seta20.2:</span> -<span id="L131" class="LineNr"> 131 </span> e4 64 <span class="subxComment"># al <- port 0x64</span> -<span id="L132" class="LineNr"> 132 </span> a8 02 <span class="subxComment"># set zf if bit 1 (second-least significant) is not set</span> -<span id="L133" class="LineNr"> 133 </span> 75 fa <span class="subxComment"># if zf not set, goto seta20.2 (-6)</span> -<span id="L134" class="LineNr"> 134 </span> -<span id="L135" class="LineNr"> 135 </span> b0 df <span class="subxComment"># al <- 0xdf</span> -<span id="L136" class="LineNr"> 136 </span> e6 64 <span class="subxComment"># port 0x64 <- al</span> -<span id="L137" class="LineNr"> 137 </span> -<span id="L138" class="LineNr"> 138 </span><span class="subxComment"># 40:</span> -<span id="L139" class="LineNr"> 139 </span> <span class="subxComment"># adjust video mode</span> -<span id="L140" class="LineNr"> 140 </span> b4 4f <span class="subxComment"># ah <- 4f (VBE)</span> -<span id="L141" class="LineNr"> 141 </span> b0 02 <span class="subxComment"># al <- 02 (set video mode)</span> -<span id="L142" class="LineNr"> 142 </span> bb 05 41 <span class="subxComment"># bx <- 0x0105 (graphics 1024x768x256</span> -<span id="L143" class="LineNr"> 143 </span> <span class="subxComment"># 0x4000 bit = configure linear frame buffer in Bochs emulator; hopefully this doesn't hurt anything when running natively)</span> -<span id="L144" class="LineNr"> 144 </span> <span class="subxComment"># fallback mode: 0x0101 (640x480x256)</span> -<span id="L145" class="LineNr"> 145 </span> cd 10 <span class="subxComment"># int 10h, Vesa BIOS extensions</span> +<span id="L119" class="LineNr"> 119 </span> <span class="subxComment"># load two more tracks of disk into addresses [0x17800, 0x27400)</span> +<span id="L120" class="LineNr"> 120 </span> b4 02 <span class="subxComment"># ah <- 2 # read sectors from disk</span> +<span id="L121" class="LineNr"> 121 </span> <span class="subxComment"># dl comes conveniently initialized at boot time with the index of the device being booted</span> +<span id="L122" class="LineNr"> 122 </span> b5 00 <span class="subxComment"># ch <- 0 # cylinder 0</span> +<span id="L123" class="LineNr"> 123 </span> b6 02 <span class="subxComment"># dh <- 2 # track 0</span> +<span id="L124" class="LineNr"> 124 </span> b1 01 <span class="subxComment"># cl <- 1 # first sector, 1-based</span> +<span id="L125" class="LineNr"> 125 </span> b0 7e <span class="subxComment"># al <- 126 # number of sectors to read = 2*63</span> +<span id="L126" class="LineNr"> 126 </span> <span class="subxComment"># address to write sectors to = es:bx = 0x17800</span> +<span id="L127" class="LineNr"> 127 </span> bb 80 17 <span class="subxComment"># bx <- 0x1780 [label]</span> +<span id="L128" class="LineNr"> 128 </span> 8e c3 <span class="subxComment"># es <- bx</span> +<span id="L129" class="LineNr"> 129 </span> bb 00 00 <span class="subxComment"># bx <- 0</span> +<span id="L130" class="LineNr"> 130 </span> cd 13 <span class="subxComment"># int 13h, BIOS disk service</span> +<span id="L131" class="LineNr"> 131 </span> 0f 82 9b 00 <span class="subxComment"># jump-if-carry disk_error [label]</span> +<span id="L132" class="LineNr"> 132 </span> <span class="subxComment"># reset es</span> +<span id="L133" class="LineNr"> 133 </span> bb 00 00 <span class="subxComment"># bx <- 0</span> +<span id="L134" class="LineNr"> 134 </span> 8e c3 <span class="subxComment"># es <- bx</span> +<span id="L135" class="LineNr"> 135 </span> +<span id="L136" class="LineNr"> 136 </span><span class="subxComment"># 39:</span> +<span id="L137" class="LineNr"> 137 </span> <span class="subxComment"># undo the A20 hack: <a href="https://en.wikipedia.org/wiki/A20_line">https://en.wikipedia.org/wiki/A20_line</a></span> +<span id="L138" class="LineNr"> 138 </span> <span class="subxComment"># this is from <a href="https://github.com/mit-pdos/xv6-public/blob/master/bootasm.S">https://github.com/mit-pdos/xv6-public/blob/master/bootasm.S</a></span> +<span id="L139" class="LineNr"> 139 </span> <span class="subxComment"># seta20.1:</span> +<span id="L140" class="LineNr"> 140 </span> e4 64 <span class="subxComment"># al <- port 0x64</span> +<span id="L141" class="LineNr"> 141 </span> a8 02 <span class="subxComment"># set zf if bit 1 (second-least significant) is not set</span> +<span id="L142" class="LineNr"> 142 </span> 75 fa <span class="subxComment"># if zf not set, goto seta20.1 (-6)</span> +<span id="L143" class="LineNr"> 143 </span> +<span id="L144" class="LineNr"> 144 </span> b0 d1 <span class="subxComment"># al <- 0xd1</span> +<span id="L145" class="LineNr"> 145 </span> e6 64 <span class="subxComment"># port 0x64 <- al</span> <span id="L146" class="LineNr"> 146 </span> -<span id="L147" class="LineNr"> 147 </span><span class="subxComment"># 49:</span> -<span id="L148" class="LineNr"> 148 </span> <span class="subxComment"># load information for the (hopefully) current video mode</span> -<span id="L149" class="LineNr"> 149 </span> <span class="subxComment"># mostly just for the address to the linear frame buffer</span> -<span id="L150" class="LineNr"> 150 </span> b4 4f <span class="subxComment"># ah <- 4f (VBE)</span> -<span id="L151" class="LineNr"> 151 </span> b0 01 <span class="subxComment"># al <- 01 (get video mode)</span> -<span id="L152" class="LineNr"> 152 </span> b9 07 01 <span class="subxComment"># cx <- 0x0107 (mode we requested)</span> -<span id="L153" class="LineNr"> 153 </span> bf 00 81 <span class="subxComment"># di <- 0x7f00 (video mode info) [label]</span> -<span id="L154" class="LineNr"> 154 </span> cd 10 +<span id="L147" class="LineNr"> 147 </span><span class="subxComment"># 43:</span> +<span id="L148" class="LineNr"> 148 </span> <span class="subxComment"># seta20.2:</span> +<span id="L149" class="LineNr"> 149 </span> e4 64 <span class="subxComment"># al <- port 0x64</span> +<span id="L150" class="LineNr"> 150 </span> a8 02 <span class="subxComment"># set zf if bit 1 (second-least significant) is not set</span> +<span id="L151" class="LineNr"> 151 </span> 75 fa <span class="subxComment"># if zf not set, goto seta20.2 (-6)</span> +<span id="L152" class="LineNr"> 152 </span> +<span id="L153" class="LineNr"> 153 </span> b0 df <span class="subxComment"># al <- 0xdf</span> +<span id="L154" class="LineNr"> 154 </span> e6 64 <span class="subxComment"># port 0x64 <- al</span> <span id="L155" class="LineNr"> 155 </span> -<span id="L156" class="LineNr"> 156 </span><span class="subxComment"># 55:</span> -<span id="L157" class="LineNr"> 157 </span> <span class="subxComment"># switch to 32-bit mode</span> -<span id="L158" class="LineNr"> 158 </span> 0f 01 16 <span class="subxComment"># lgdt 00/mod/indirect 010/subop 110/rm/use-disp16</span> -<span id="L159" class="LineNr"> 159 </span> f8 7c <span class="subxComment"># *gdt_descriptor [label]</span> -<span id="L160" class="LineNr"> 160 </span> 0f 20 c0 <span class="subxComment"># eax <- cr0</span> -<span id="L161" class="LineNr"> 161 </span> 66 83 c8 01 <span class="subxComment"># eax <- or 0x1</span> -<span id="L162" class="LineNr"> 162 </span> 0f 22 c0 <span class="subxComment"># cr0 <- eax</span> -<span id="L163" class="LineNr"> 163 </span> ea 00 7d 08 00 <span class="subxComment"># far jump to initialize_32bit_mode after setting cs to the record at offset 8 in the gdt (gdt_code) [label]</span> +<span id="L156" class="LineNr"> 156 </span><span class="subxComment"># 4d:</span> +<span id="L157" class="LineNr"> 157 </span> <span class="subxComment"># adjust video mode</span> +<span id="L158" class="LineNr"> 158 </span> b4 4f <span class="subxComment"># ah <- 4f (VBE)</span> +<span id="L159" class="LineNr"> 159 </span> b0 02 <span class="subxComment"># al <- 02 (set video mode)</span> +<span id="L160" class="LineNr"> 160 </span> bb 05 41 <span class="subxComment"># bx <- 0x0105 (graphics 1024x768x256</span> +<span id="L161" class="LineNr"> 161 </span> <span class="subxComment"># 0x4000 bit = configure linear frame buffer in Bochs emulator; hopefully this doesn't hurt anything when running natively)</span> +<span id="L162" class="LineNr"> 162 </span> <span class="subxComment"># fallback mode: 0x0101 (640x480x256)</span> +<span id="L163" class="LineNr"> 163 </span> cd 10 <span class="subxComment"># int 10h, Vesa BIOS extensions</span> <span id="L164" class="LineNr"> 164 </span> -<span id="L165" class="LineNr"> 165 </span><span class="subxComment"># padding</span> -<span id="L166" class="LineNr"> 166 </span><span class="subxComment"># 69:</span> -<span id="L167" class="LineNr"> 167 </span> 00 00 00 00 00 00 00 -<span id="L168" class="LineNr"> 168 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L169" class="LineNr"> 169 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L170" class="LineNr"> 170 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L171" class="LineNr"> 171 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L172" class="LineNr"> 172 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L173" class="LineNr"> 173 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L174" class="LineNr"> 174 </span> -<span id="L175" class="LineNr"> 175 </span><span class="subxComment"># cf:</span> -<span id="L176" class="LineNr"> 176 </span><span class="subxComment"># disk_error:</span> -<span id="L177" class="LineNr"> 177 </span> <span class="subxComment"># print 'D' to top-left of screen to indicate disk error</span> -<span id="L178" class="LineNr"> 178 </span> <span class="subxComment"># *0xb8000 <- 0x0f44</span> -<span id="L179" class="LineNr"> 179 </span> <span class="subxComment"># bx <- 0xb800</span> -<span id="L180" class="LineNr"> 180 </span> bb 00 b8 -<span id="L181" class="LineNr"> 181 </span> <span class="subxComment"># ds <- bx</span> -<span id="L182" class="LineNr"> 182 </span> 8e db <span class="subxComment"># 11b/mod 011b/reg/ds 011b/rm/bx</span> -<span id="L183" class="LineNr"> 183 </span> <span class="subxComment"># al <- 'D'</span> -<span id="L184" class="LineNr"> 184 </span> b0 44 -<span id="L185" class="LineNr"> 185 </span> <span class="subxComment"># ah <- 0x0f # white on black</span> -<span id="L186" class="LineNr"> 186 </span> b4 0f -<span id="L187" class="LineNr"> 187 </span> <span class="subxComment"># bx <- 0</span> -<span id="L188" class="LineNr"> 188 </span> bb 00 00 -<span id="L189" class="LineNr"> 189 </span> <span class="subxComment"># *ds:bx <- ax</span> -<span id="L190" class="LineNr"> 190 </span> 89 07 <span class="subxComment"># 00b/mod/indirect 000b/reg/ax 111b/rm/bx</span> -<span id="L191" class="LineNr"> 191 </span> -<span id="L192" class="LineNr"> 192 </span>e9 fd ff <span class="subxComment"># loop forever</span> -<span id="L193" class="LineNr"> 193 </span> -<span id="L194" class="LineNr"> 194 </span><span class="subxComment">## GDT: 3 records of 8 bytes each</span> -<span id="L195" class="LineNr"> 195 </span> -<span id="L196" class="LineNr"> 196 </span><span class="subxComment"># e0:</span> -<span id="L197" class="LineNr"> 197 </span><span class="subxComment"># gdt_start:</span> -<span id="L198" class="LineNr"> 198 </span><span class="subxComment"># gdt_null: mandatory null descriptor</span> -<span id="L199" class="LineNr"> 199 </span> 00 00 00 00 00 00 00 00 -<span id="L200" class="LineNr"> 200 </span><span class="subxComment"># gdt_code: (offset 8 from gdt_start)</span> -<span id="L201" class="LineNr"> 201 </span> ff ff <span class="subxComment"># limit[0:16]</span> -<span id="L202" class="LineNr"> 202 </span> 00 00 00 <span class="subxComment"># base[0:24]</span> -<span id="L203" class="LineNr"> 203 </span> 9a <span class="subxComment"># 1/present 00/privilege 1/descriptor type = 1001b</span> -<span id="L204" class="LineNr"> 204 </span> <span class="subxComment"># 1/code 0/conforming 1/readable 0/accessed = 1010b</span> -<span id="L205" class="LineNr"> 205 </span> cf <span class="subxComment"># 1/granularity 1/32-bit 0/64-bit-segment 0/AVL = 1100b</span> -<span id="L206" class="LineNr"> 206 </span> <span class="subxComment"># limit[16:20] = 1111b</span> -<span id="L207" class="LineNr"> 207 </span> 00 <span class="subxComment"># base[24:32]</span> -<span id="L208" class="LineNr"> 208 </span><span class="subxComment"># gdt_data: (offset 16 from gdt_start)</span> -<span id="L209" class="LineNr"> 209 </span> ff ff <span class="subxComment"># limit[0:16]</span> -<span id="L210" class="LineNr"> 210 </span> 00 00 00 <span class="subxComment"># base[0:24]</span> -<span id="L211" class="LineNr"> 211 </span> 92 <span class="subxComment"># 1/present 00/privilege 1/descriptor type = 1001b</span> -<span id="L212" class="LineNr"> 212 </span> <span class="subxComment"># 0/data 0/conforming 1/readable 0/accessed = 0010b</span> -<span id="L213" class="LineNr"> 213 </span> cf <span class="subxComment"># same as gdt_code</span> -<span id="L214" class="LineNr"> 214 </span> 00 <span class="subxComment"># base[24:32]</span> -<span id="L215" class="LineNr"> 215 </span><span class="subxComment"># gdt_end:</span> -<span id="L216" class="LineNr"> 216 </span> -<span id="L217" class="LineNr"> 217 </span><span class="subxComment"># f8:</span> -<span id="L218" class="LineNr"> 218 </span><span class="subxComment"># gdt_descriptor:</span> -<span id="L219" class="LineNr"> 219 </span> 17 00 <span class="subxComment"># final index of gdt = gdt_end - gdt_start - 1</span> -<span id="L220" class="LineNr"> 220 </span> e0 7c 00 00 <span class="subxComment"># start = gdt_start [label]</span> -<span id="L221" class="LineNr"> 221 </span> -<span id="L222" class="LineNr"> 222 </span><span class="subxComment"># padding</span> -<span id="L223" class="LineNr"> 223 </span><span class="subxComment"># fe:</span> -<span id="L224" class="LineNr"> 224 </span> 00 00 -<span id="L225" class="LineNr"> 225 </span> -<span id="L226" class="LineNr"> 226 </span><span class="subxComment">## 32-bit code from this point (still some instructions not in SubX)</span> -<span id="L227" class="LineNr"> 227 </span> -<span id="L228" class="LineNr"> 228 </span><span class="subxComment"># offset 100 (address 0x7d00):</span> -<span id="L229" class="LineNr"> 229 </span><span class="subxComment"># initialize_32bit_mode:</span> -<span id="L230" class="LineNr"> 230 </span> 66 b8 10 00 <span class="subxComment"># ax <- offset 16 from gdt_start</span> -<span id="L231" class="LineNr"> 231 </span> 8e d8 <span class="subxComment"># ds <- ax</span> -<span id="L232" class="LineNr"> 232 </span> 8e d0 <span class="subxComment"># ss <- ax</span> -<span id="L233" class="LineNr"> 233 </span> 8e c0 <span class="subxComment"># es <- ax</span> -<span id="L234" class="LineNr"> 234 </span> 8e e0 <span class="subxComment"># fs <- ax</span> -<span id="L235" class="LineNr"> 235 </span> 8e e8 <span class="subxComment"># gs <- ax</span> -<span id="L236" class="LineNr"> 236 </span> -<span id="L237" class="LineNr"> 237 </span><span class="subxComment"># 10e:</span> -<span id="L238" class="LineNr"> 238 </span> bc 00 00 07 00 <span class="subxComment"># esp <- 0x00070000</span> -<span id="L239" class="LineNr"> 239 </span> -<span id="L240" class="LineNr"> 240 </span><span class="subxComment"># 113:</span> -<span id="L241" class="LineNr"> 241 </span> <span class="subxComment"># load interrupt handlers</span> -<span id="L242" class="LineNr"> 242 </span> 0f 01 1d <span class="subxComment"># lidt 00/mod/indirect 011/subop 101/rm32/use-disp32</span> -<span id="L243" class="LineNr"> 243 </span> 00 80 00 00 <span class="subxComment"># *idt_descriptor [label]</span> -<span id="L244" class="LineNr"> 244 </span> -<span id="L245" class="LineNr"> 245 </span> <span class="subxComment"># For now, not bothering reprogramming the IRQ to not conflict with software</span> -<span id="L246" class="LineNr"> 246 </span> <span class="subxComment"># exceptions.</span> -<span id="L247" class="LineNr"> 247 </span> <span class="subxComment"># <a href="https://wiki.osdev.org/index.php?title=8259_PIC&oldid=24650#Protected_Mode">https://wiki.osdev.org/index.php?title=8259_PIC&oldid=24650#Protected_Mode</a></span> -<span id="L248" class="LineNr"> 248 </span> <span class="subxComment">#</span> -<span id="L249" class="LineNr"> 249 </span> <span class="subxComment"># Interrupt 1 (keyboard) conflicts with debugger faults. We don't use a</span> -<span id="L250" class="LineNr"> 250 </span> <span class="subxComment"># debugger.</span> -<span id="L251" class="LineNr"> 251 </span> <span class="subxComment"># Reference:</span> -<span id="L252" class="LineNr"> 252 </span> <span class="subxComment"># <a href="https://wiki.osdev.org/Exceptions">https://wiki.osdev.org/Exceptions</a></span> -<span id="L253" class="LineNr"> 253 </span> -<span id="L254" class="LineNr"> 254 </span><span class="subxComment"># 11a:</span> -<span id="L255" class="LineNr"> 255 </span> <span class="subxComment"># enable keyboard IRQ (1)</span> -<span id="L256" class="LineNr"> 256 </span> b0 fd <span class="subxComment"># al <- 0xfd # disable mask for IRQ1</span> -<span id="L257" class="LineNr"> 257 </span> e6 21 <span class="subxComment"># port 0x21 <- al</span> -<span id="L258" class="LineNr"> 258 </span> -<span id="L259" class="LineNr"> 259 </span><span class="subxComment"># 11e:</span> -<span id="L260" class="LineNr"> 260 </span> <span class="subxComment"># initialization is done; enable interrupts</span> -<span id="L261" class="LineNr"> 261 </span> fb -<span id="L262" class="LineNr"> 262 </span> e9 dc 16 00 00 <span class="subxComment"># jump to 0x9400 [label]</span> -<span id="L263" class="LineNr"> 263 </span> -<span id="L264" class="LineNr"> 264 </span><span class="subxComment"># padding</span> -<span id="L265" class="LineNr"> 265 </span><span class="subxComment"># 124:</span> -<span id="L266" class="LineNr"> 266 </span> 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L267" class="LineNr"> 267 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L268" class="LineNr"> 268 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L269" class="LineNr"> 269 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L270" class="LineNr"> 270 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L271" class="LineNr"> 271 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L272" class="LineNr"> 272 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L273" class="LineNr"> 273 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L274" class="LineNr"> 274 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L275" class="LineNr"> 275 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L276" class="LineNr"> 276 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L277" class="LineNr"> 277 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L278" class="LineNr"> 278 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L279" class="LineNr"> 279 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L280" class="LineNr"> 280 </span> -<span id="L281" class="LineNr"> 281 </span><span class="subxComment"># 1fe:</span> -<span id="L282" class="LineNr"> 282 </span><span class="subxComment"># final 2 bytes of boot sector</span> -<span id="L283" class="LineNr"> 283 </span>55 aa -<span id="L284" class="LineNr"> 284 </span> -<span id="L285" class="LineNr"> 285 </span><span class="subxComment">## sector 2 onwards loaded by load_disk, not automatically on boot</span> -<span id="L286" class="LineNr"> 286 </span> -<span id="L287" class="LineNr"> 287 </span><span class="subxComment"># offset 200 (address 0x7e00):</span> -<span id="L288" class="LineNr"> 288 </span><span class="subxComment"># null interrupt handler:</span> -<span id="L289" class="LineNr"> 289 </span> cf <span class="subxComment"># iret</span> -<span id="L290" class="LineNr"> 290 </span> -<span id="L291" class="LineNr"> 291 </span><span class="subxComment"># padding</span> -<span id="L292" class="LineNr"> 292 </span><span class="subxComment"># 201:</span> -<span id="L293" class="LineNr"> 293 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L294" class="LineNr"> 294 </span> -<span id="L295" class="LineNr"> 295 </span><span class="subxComment"># 210:</span> -<span id="L296" class="LineNr"> 296 </span><span class="subxComment"># keyboard interrupt handler:</span> -<span id="L297" class="LineNr"> 297 </span> <span class="subxComment"># prologue</span> -<span id="L298" class="LineNr"> 298 </span> fa <span class="subxComment"># disable interrupts</span> -<span id="L299" class="LineNr"> 299 </span> 60 <span class="subxComment"># push all registers to stack</span> -<span id="L300" class="LineNr"> 300 </span> <span class="subxComment"># acknowledge interrupt</span> -<span id="L301" class="LineNr"> 301 </span> b0 20 <span class="subxComment"># al <- 0x20</span> -<span id="L302" class="LineNr"> 302 </span> e6 20 <span class="subxComment"># port 0x20 <- al</span> -<span id="L303" class="LineNr"> 303 </span> 31 c0 <span class="subxComment"># eax <- xor eax; 11/direct 000/r32/eax 000/rm32/eax</span> -<span id="L304" class="LineNr"> 304 </span> <span class="subxComment"># check output buffer of 8042 keyboard controller (<a href="https://web.archive.org/web/20040604041507/http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/keyboard/atkeyboard.html)">https://web.archive.org/web/20040604041507/http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/keyboard/atkeyboard.html)</a></span> -<span id="L305" class="LineNr"> 305 </span> e4 64 <span class="subxComment"># al <- port 0x64</span> -<span id="L306" class="LineNr"> 306 </span> a8 01 <span class="subxComment"># set zf if bit 0 (least significant) is not set</span> -<span id="L307" class="LineNr"> 307 </span> 74 89 <span class="subxComment"># jump to epilogue if 0 bit is not set [label]</span> -<span id="L308" class="LineNr"> 308 </span><span class="subxComment"># 21e:</span> -<span id="L309" class="LineNr"> 309 </span> <span class="subxH1Comment"># - if keyboard buffer is full, return</span> -<span id="L310" class="LineNr"> 310 </span> 31 c9 <span class="subxComment"># ecx <- xor ecx; 11/direct 001/r32/ecx 001/rm32/ecx</span> -<span id="L311" class="LineNr"> 311 </span> <span class="subxComment"># var index/ecx: byte</span> -<span id="L312" class="LineNr"> 312 </span> 8a <span class="subxComment"># copy m8 at r32 to r8</span> -<span id="L313" class="LineNr"> 313 </span> 0d <span class="subxComment"># 00/mod/indirect 001/r8/cl 101/rm32/use-disp32</span> -<span id="L314" class="LineNr"> 314 </span> 28 80 00 00 <span class="subxComment"># disp32 [label]</span> -<span id="L315" class="LineNr"> 315 </span> <span class="subxComment"># al = *(keyboard buffer + index)</span> -<span id="L316" class="LineNr"> 316 </span> 8a <span class="subxComment"># copy m8 at r32 to r8</span> -<span id="L317" class="LineNr"> 317 </span> 81 <span class="subxComment"># 10/mod/*+disp32 000/r8/al 001/rm32/ecx</span> -<span id="L318" class="LineNr"> 318 </span> 30 80 00 00 <span class="subxComment"># disp32 [label]</span> -<span id="L319" class="LineNr"> 319 </span> <span class="subxComment"># if (al != 0) return</span> -<span id="L320" class="LineNr"> 320 </span> 3c 00 <span class="subxComment"># compare al, 0</span> -<span id="L321" class="LineNr"> 321 </span> 75 77 <span class="subxComment"># jump to epilogue if != [label]</span> -<span id="L322" class="LineNr"> 322 </span><span class="subxComment"># 230:</span> -<span id="L323" class="LineNr"> 323 </span> <span class="subxH1Comment"># - read keycode</span> -<span id="L324" class="LineNr"> 324 </span> e4 60 <span class="subxComment"># al <- port 0x60</span> -<span id="L325" class="LineNr"> 325 </span> <span class="subxH1Comment"># - key released</span> -<span id="L326" class="LineNr"> 326 </span> <span class="subxComment"># if (al == 0xaa) shift = false # left shift is being lifted</span> -<span id="L327" class="LineNr"> 327 </span> 3c aa <span class="subxComment"># compare al, 0xaa</span> -<span id="L328" class="LineNr"> 328 </span> 75 0a <span class="subxComment"># jump to $1 if != [label]</span> -<span id="L329" class="LineNr"> 329 </span> <span class="subxComment"># *shift = 0</span> -<span id="L330" class="LineNr"> 330 </span> c7 <span class="subxComment"># copy imm32 to rm32</span> -<span id="L331" class="LineNr"> 331 </span> 05 <span class="subxComment"># 00/mod/indirect 000/subop/copy 101/rm32/use-disp32</span> -<span id="L332" class="LineNr"> 332 </span> 10 80 00 00 <span class="subxComment"># disp32 [label]</span> -<span id="L333" class="LineNr"> 333 </span> 00 00 00 00 <span class="subxComment"># imm32</span> -<span id="L334" class="LineNr"> 334 </span><span class="subxComment"># 240:</span> -<span id="L335" class="LineNr"> 335 </span><span class="subxComment"># $1:</span> -<span id="L336" class="LineNr"> 336 </span> <span class="subxComment"># if (al == 0xb6) shift = false # right shift is being lifted</span> -<span id="L337" class="LineNr"> 337 </span> 3c b6 <span class="subxComment"># compare al, 0xb6</span> -<span id="L338" class="LineNr"> 338 </span> 75 0a <span class="subxComment"># jump to $1 if != [label]</span> -<span id="L339" class="LineNr"> 339 </span> <span class="subxComment"># *shift = 0</span> -<span id="L340" class="LineNr"> 340 </span> c7 <span class="subxComment"># copy imm32 to rm32</span> -<span id="L341" class="LineNr"> 341 </span> 05 <span class="subxComment"># 00/mod/indirect 000/subop/copy 101/rm32/use-disp32</span> -<span id="L342" class="LineNr"> 342 </span> 10 80 00 00 <span class="subxComment"># disp32 [label]</span> -<span id="L343" class="LineNr"> 343 </span> 00 00 00 00 <span class="subxComment"># imm32</span> -<span id="L344" class="LineNr"> 344 </span><span class="subxComment"># $2:</span> -<span id="L345" class="LineNr"> 345 </span> <span class="subxComment"># if (al & 0x80) a key is being lifted; return</span> -<span id="L346" class="LineNr"> 346 </span> 50 <span class="subxComment"># push eax</span> -<span id="L347" class="LineNr"> 347 </span> 24 80 <span class="subxComment"># al <- and 0x80</span> -<span id="L348" class="LineNr"> 348 </span> 3c 00 <span class="subxComment"># compare al, 0</span> -<span id="L349" class="LineNr"> 349 </span> 58 <span class="subxComment"># pop to eax (without touching flags)</span> -<span id="L350" class="LineNr"> 350 </span> 75 51 <span class="subxComment"># jump to epilogue if != [label]</span> -<span id="L351" class="LineNr"> 351 </span><span class="subxComment"># 256:</span> -<span id="L352" class="LineNr"> 352 </span> <span class="subxH1Comment"># - key pressed</span> -<span id="L353" class="LineNr"> 353 </span> <span class="subxComment"># if (al == 0x2a) shift = true, return # left shift pressed</span> -<span id="L354" class="LineNr"> 354 </span> 3c 2a <span class="subxComment"># compare al, 0x2a</span> -<span id="L355" class="LineNr"> 355 </span> 75 0c <span class="subxComment"># jump to $3 if != [label]</span> -<span id="L356" class="LineNr"> 356 </span> <span class="subxComment"># *shift = 1</span> -<span id="L357" class="LineNr"> 357 </span> c7 <span class="subxComment"># copy imm32 to rm32</span> -<span id="L358" class="LineNr"> 358 </span> 05 <span class="subxComment"># 00/mod/indirect 000/subop/copy 101/rm32/use-disp32</span> -<span id="L359" class="LineNr"> 359 </span> 10 80 00 00 <span class="subxComment"># disp32 [label]</span> -<span id="L360" class="LineNr"> 360 </span> 01 00 00 00 <span class="subxComment"># imm32</span> -<span id="L361" class="LineNr"> 361 </span> eb 41 <span class="subxComment"># jump to epilogue [label]</span> -<span id="L362" class="LineNr"> 362 </span><span class="subxComment"># 266:</span> -<span id="L363" class="LineNr"> 363 </span><span class="subxComment"># $3:</span> -<span id="L364" class="LineNr"> 364 </span> <span class="subxComment"># if (al == 0x36) shift = true, return # right shift pressed</span> -<span id="L365" class="LineNr"> 365 </span> 3c 36 <span class="subxComment"># compare al, 0x36</span> -<span id="L366" class="LineNr"> 366 </span> 75 0c <span class="subxComment"># jump to $4 if != [label]</span> -<span id="L367" class="LineNr"> 367 </span> <span class="subxComment"># *shift = 1</span> -<span id="L368" class="LineNr"> 368 </span> c7 <span class="subxComment"># copy imm32 to rm32</span> -<span id="L369" class="LineNr"> 369 </span> 05 <span class="subxComment"># 00/mod/indirect 000/subop/copy 101/rm32/use-disp32</span> -<span id="L370" class="LineNr"> 370 </span> 10 80 00 00 <span class="subxComment"># disp32 [label]</span> -<span id="L371" class="LineNr"> 371 </span> 01 00 00 00 <span class="subxComment"># imm32</span> -<span id="L372" class="LineNr"> 372 </span> eb 31 <span class="subxComment"># jump to epilogue [label]</span> -<span id="L373" class="LineNr"> 373 </span><span class="subxComment"># 276:</span> -<span id="L374" class="LineNr"> 374 </span><span class="subxComment"># $4:</span> -<span id="L375" class="LineNr"> 375 </span> <span class="subxH1Comment"># - convert key to character</span> -<span id="L376" class="LineNr"> 376 </span> <span class="subxComment"># if (shift) use keyboard normal map</span> -<span id="L377" class="LineNr"> 377 </span> 81 <span class="subxComment"># operate on rm32 and imm32</span> -<span id="L378" class="LineNr"> 378 </span> 3d <span class="subxComment"># 00/mod/indirect 111/subop/compare 101/rm32/use-disp32</span> -<span id="L379" class="LineNr"> 379 </span> 10 80 00 00 <span class="subxComment"># disp32 = shift [label]</span> -<span id="L380" class="LineNr"> 380 </span> 00 00 00 00 <span class="subxComment"># imm32</span> -<span id="L381" class="LineNr"> 381 </span> 74 08 <span class="subxComment"># jump to $5 if = [label]</span> -<span id="L382" class="LineNr"> 382 </span> <span class="subxComment"># otherwise use keyboard shift map</span> -<span id="L383" class="LineNr"> 383 </span> <span class="subxComment"># al <- *(keyboard shift map + eax)</span> -<span id="L384" class="LineNr"> 384 </span> 8a <span class="subxComment"># copy m8 at rm32 to r8</span> -<span id="L385" class="LineNr"> 385 </span> 80 <span class="subxComment"># 10/mod/*+disp32 000/r8/al 000/rm32/eax</span> -<span id="L386" class="LineNr"> 386 </span> 00 87 00 00 <span class="subxComment"># disp32 [label]</span> -<span id="L387" class="LineNr"> 387 </span> eb 06 <span class="subxComment"># jump to $6 [label]</span> -<span id="L388" class="LineNr"> 388 </span><span class="subxComment"># 28a:</span> -<span id="L389" class="LineNr"> 389 </span><span class="subxComment"># $5:</span> -<span id="L390" class="LineNr"> 390 </span> <span class="subxComment"># al <- *(keyboard normal map + eax)</span> -<span id="L391" class="LineNr"> 391 </span> 8a <span class="subxComment"># copy m8 at rm32 to r8</span> -<span id="L392" class="LineNr"> 392 </span> 80 <span class="subxComment"># 10/mod/*+disp32 000/r8/al 000/rm32/eax</span> -<span id="L393" class="LineNr"> 393 </span> 00 86 00 00 <span class="subxComment"># disp32 [label]</span> -<span id="L394" class="LineNr"> 394 </span><span class="subxComment"># $6:</span> -<span id="L395" class="LineNr"> 395 </span> <span class="subxH1Comment"># - if there's no character mapping, return</span> -<span id="L396" class="LineNr"> 396 </span> 3c 00 <span class="subxComment"># compare al, 0</span> -<span id="L397" class="LineNr"> 397 </span> 74 13 <span class="subxComment"># jump to epilogue if = [label]</span> -<span id="L398" class="LineNr"> 398 </span><span class="subxComment"># 294:</span> -<span id="L399" class="LineNr"> 399 </span> <span class="subxH1Comment"># - store al in keyboard buffer</span> -<span id="L400" class="LineNr"> 400 </span> 88 <span class="subxComment"># copy r8 to m8 at r32</span> -<span id="L401" class="LineNr"> 401 </span> 81 <span class="subxComment"># 10/mod/*+disp32 000/r8/al 001/rm32/ecx</span> -<span id="L402" class="LineNr"> 402 </span> 30 80 00 00 <span class="subxComment"># disp32 [label]</span> -<span id="L403" class="LineNr"> 403 </span> <span class="subxComment"># increment index</span> -<span id="L404" class="LineNr"> 404 </span> fe <span class="subxComment"># increment byte</span> -<span id="L405" class="LineNr"> 405 </span> 05 <span class="subxComment"># 00/mod/indirect 000/subop/increment 101/rm32/use-disp32</span> -<span id="L406" class="LineNr"> 406 </span> 28 80 00 00 <span class="subxComment"># disp32 [label]</span> -<span id="L407" class="LineNr"> 407 </span> <span class="subxComment"># clear top nibble of index (keyboard buffer is circular)</span> -<span id="L408" class="LineNr"> 408 </span> 80 <span class="subxComment"># and byte</span> -<span id="L409" class="LineNr"> 409 </span> 25 <span class="subxComment"># 00/mod/indirect 100/subop/and 101/rm32/use-disp32</span> -<span id="L410" class="LineNr"> 410 </span> 28 80 00 00 <span class="subxComment"># disp32 [label]</span> -<span id="L411" class="LineNr"> 411 </span> 0f <span class="subxComment"># imm8</span> -<span id="L412" class="LineNr"> 412 </span><span class="subxComment"># 2a9:</span> -<span id="L413" class="LineNr"> 413 </span> <span class="subxComment"># epilogue</span> -<span id="L414" class="LineNr"> 414 </span> 61 <span class="subxComment"># pop all registers</span> -<span id="L415" class="LineNr"> 415 </span> fb <span class="subxComment"># enable interrupts</span> -<span id="L416" class="LineNr"> 416 </span> cf <span class="subxComment"># iret</span> -<span id="L417" class="LineNr"> 417 </span> -<span id="L418" class="LineNr"> 418 </span><span class="subxComment"># padding</span> -<span id="L419" class="LineNr"> 419 </span><span class="subxComment"># 2aa:</span> -<span id="L420" class="LineNr"> 420 </span> 00 00 00 00 00 00 -<span id="L421" class="LineNr"> 421 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L422" class="LineNr"> 422 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L423" class="LineNr"> 423 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L424" class="LineNr"> 424 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L425" class="LineNr"> 425 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L426" class="LineNr"> 426 </span><span class="subxComment"># 300:</span> -<span id="L427" class="LineNr"> 427 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L428" class="LineNr"> 428 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L429" class="LineNr"> 429 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L430" class="LineNr"> 430 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L431" class="LineNr"> 431 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L432" class="LineNr"> 432 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L433" class="LineNr"> 433 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L434" class="LineNr"> 434 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L435" class="LineNr"> 435 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L436" class="LineNr"> 436 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L437" class="LineNr"> 437 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L438" class="LineNr"> 438 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L439" class="LineNr"> 439 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L440" class="LineNr"> 440 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L441" class="LineNr"> 441 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L442" class="LineNr"> 442 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L443" class="LineNr"> 443 </span> -<span id="L444" class="LineNr"> 444 </span><span class="subxComment"># offset 400 (address 0x8000): interrupt handler data</span> -<span id="L445" class="LineNr"> 445 </span><span class="subxComment"># idt_descriptor:</span> -<span id="L446" class="LineNr"> 446 </span> ff 03 <span class="subxComment"># idt_end - idt_start - 1</span> -<span id="L447" class="LineNr"> 447 </span> 00 82 00 00 <span class="subxComment"># start = idt_start [label]</span> -<span id="L448" class="LineNr"> 448 </span> -<span id="L449" class="LineNr"> 449 </span><span class="subxComment"># padding</span> -<span id="L450" class="LineNr"> 450 </span><span class="subxComment"># 406:</span> -<span id="L451" class="LineNr"> 451 </span> 00 00 00 00 00 00 00 00 00 00 -<span id="L452" class="LineNr"> 452 </span> -<span id="L453" class="LineNr"> 453 </span><span class="subxComment"># 410:</span> -<span id="L454" class="LineNr"> 454 </span><span class="subxComment"># var shift: boolean</span> -<span id="L455" class="LineNr"> 455 </span> 00 00 00 00 -<span id="L456" class="LineNr"> 456 </span> -<span id="L457" class="LineNr"> 457 </span><span class="subxComment"># padding</span> -<span id="L458" class="LineNr"> 458 </span><span class="subxComment"># 414:</span> -<span id="L459" class="LineNr"> 459 </span> 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L460" class="LineNr"> 460 </span>00 00 00 00 00 00 00 00 -<span id="L461" class="LineNr"> 461 </span> -<span id="L462" class="LineNr"> 462 </span><span class="subxComment"># 428:</span> -<span id="L463" class="LineNr"> 463 </span><span class="subxComment"># var keyboard circular buffer</span> -<span id="L464" class="LineNr"> 464 </span><span class="subxComment"># write index: nibble</span> -<span id="L465" class="LineNr"> 465 </span><span class="subxComment"># still take up 4 bytes so SubX can handle it</span> -<span id="L466" class="LineNr"> 466 </span> 00 00 00 00 -<span id="L467" class="LineNr"> 467 </span><span class="subxComment"># 42c:</span> -<span id="L468" class="LineNr"> 468 </span><span class="subxComment"># read index: nibble</span> -<span id="L469" class="LineNr"> 469 </span><span class="subxComment"># still take up 4 bytes so SubX can handle it</span> -<span id="L470" class="LineNr"> 470 </span> 00 00 00 00 -<span id="L471" class="LineNr"> 471 </span><span class="subxComment"># 430:</span> -<span id="L472" class="LineNr"> 472 </span><span class="subxComment"># circular buffer: byte[16]</span> -<span id="L473" class="LineNr"> 473 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L474" class="LineNr"> 474 </span> -<span id="L475" class="LineNr"> 475 </span><span class="subxComment"># padding</span> -<span id="L476" class="LineNr"> 476 </span><span class="subxComment"># 440:</span> -<span id="L477" class="LineNr"> 477 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L478" class="LineNr"> 478 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L479" class="LineNr"> 479 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L480" class="LineNr"> 480 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L481" class="LineNr"> 481 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L482" class="LineNr"> 482 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L483" class="LineNr"> 483 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L484" class="LineNr"> 484 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L485" class="LineNr"> 485 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L486" class="LineNr"> 486 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L487" class="LineNr"> 487 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L488" class="LineNr"> 488 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -<span id="L489" class="LineNr"> 489 </span> -<span id="L490" class="LineNr"> 490 </span><span class="subxComment"># offset 500 (address 0x8100):</span> -<span id="L491" class="Folded"> 491 </span><span class="Folded">+-- 53 lines: # video mode info ---------------------------------------------------------------------------------------------------------------------------------------</span> -<span id="L544" class="LineNr"> 544 </span> -<span id="L545" class="LineNr"> 545 </span><span class="subxComment"># offset 600 (address 0x8200):</span> -<span id="L546" class="Folded"> 546 </span><span class="Folded">+--161 lines: # interrupt descriptor table ----------------------------------------------------------------------------------------------------------------------------</span> -<span id="L707" class="LineNr"> 707 </span> -<span id="L708" class="LineNr"> 708 </span><span class="subxComment">## the rest of this file has data</span> -<span id="L709" class="LineNr"> 709 </span> -<span id="L710" class="LineNr"> 710 </span><span class="subxComment"># offset a00 (address 0x8600):</span> -<span id="L711" class="Folded"> 711 </span><span class="Folded">+--152 lines: # translating keys to ASCII -----------------------------------------------------------------------------------------------------------------------------</span> -<span id="L863" class="LineNr"> 863 </span> -<span id="L864" class="LineNr"> 864 </span><span class="subxComment"># offset 1000 (address 0x8c00)</span> -<span id="L865" class="Folded"> 865 </span><span class="Folded">+--236 lines: # Bitmaps for some ASCII characters (soon Unicode) ------------------------------------------------------------------------------------------------------</span> -<span id="L1101" class="LineNr">1101 </span> -<span id="L1102" class="LineNr">1102 </span><span class="subxComment"># offset 1800 (address 0x9400)</span> -<span id="L1103" class="LineNr">1103 </span> -<span id="L1104" class="LineNr">1104 </span><span class="subxComment"># vim:ft=subx</span> +<span id="L165" class="LineNr"> 165 </span><span class="subxComment"># 56:</span> +<span id="L166" class="LineNr"> 166 </span> <span class="subxComment"># load information for the (hopefully) current video mode</span> +<span id="L167" class="LineNr"> 167 </span> <span class="subxComment"># mostly just for the address to the linear frame buffer</span> +<span id="L168" class="LineNr"> 168 </span> b4 4f <span class="subxComment"># ah <- 4f (VBE)</span> +<span id="L169" class="LineNr"> 169 </span> b0 01 <span class="subxComment"># al <- 01 (get video mode info)</span> +<span id="L170" class="LineNr"> 170 </span> b9 07 01 <span class="subxComment"># cx <- 0x0107 (mode we requested)</span> +<span id="L171" class="LineNr"> 171 </span> bf 00 81 <span class="subxComment"># di <- 0x8100 (video mode info) [label]</span> +<span id="L172" class="LineNr"> 172 </span> cd 10 +<span id="L173" class="LineNr"> 173 </span> +<span id="L174" class="LineNr"> 174 </span><span class="subxComment"># 62:</span> +<span id="L175" class="LineNr"> 175 </span> <span class="subxComment"># switch to 32-bit mode</span> +<span id="L176" class="LineNr"> 176 </span> 0f 01 16 <span class="subxComment"># lgdt 00/mod/indirect 010/subop 110/rm/use-disp16</span> +<span id="L177" class="LineNr"> 177 </span> f8 7c <span class="subxComment"># *gdt_descriptor [label]</span> +<span id="L178" class="LineNr"> 178 </span> 0f 20 c0 <span class="subxComment"># eax <- cr0</span> +<span id="L179" class="LineNr"> 179 </span> 66 83 c8 01 <span class="subxComment"># eax <- or 0x1</span> +<span id="L180" class="LineNr"> 180 </span> 0f 22 c0 <span class="subxComment"># cr0 <- eax</span> +<span id="L181" class="LineNr"> 181 </span> ea 00 7d 08 00 <span class="subxComment"># far jump to initialize_32bit_mode after setting cs to the record at offset 8 in the gdt (gdt_code) [label]</span> +<span id="L182" class="LineNr"> 182 </span> +<span id="L183" class="LineNr"> 183 </span><span class="subxComment"># padding</span> +<span id="L184" class="LineNr"> 184 </span><span class="subxComment"># 76:</span> +<span id="L185" class="LineNr"> 185 </span> 00 00 00 00 00 00 00 00 00 00 +<span id="L186" class="LineNr"> 186 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L187" class="LineNr"> 187 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L188" class="LineNr"> 188 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L189" class="LineNr"> 189 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L190" class="LineNr"> 190 </span> +<span id="L191" class="LineNr"> 191 </span><span class="subxComment"># cf:</span> +<span id="L192" class="LineNr"> 192 </span><span class="subxComment"># disk_error:</span> +<span id="L193" class="LineNr"> 193 </span> <span class="subxComment"># print 'D' to top-left of screen to indicate disk error</span> +<span id="L194" class="LineNr"> 194 </span> <span class="subxComment"># *0xb8000 <- 0x0f44</span> +<span id="L195" class="LineNr"> 195 </span> <span class="subxComment"># bx <- 0xb800</span> +<span id="L196" class="LineNr"> 196 </span> bb 00 b8 +<span id="L197" class="LineNr"> 197 </span> <span class="subxComment"># ds <- bx</span> +<span id="L198" class="LineNr"> 198 </span> 8e db <span class="subxComment"># 11b/mod 011b/reg/ds 011b/rm/bx</span> +<span id="L199" class="LineNr"> 199 </span> <span class="subxComment"># al <- 'D'</span> +<span id="L200" class="LineNr"> 200 </span> b0 44 +<span id="L201" class="LineNr"> 201 </span> <span class="subxComment"># ah <- 0x0f # white on black</span> +<span id="L202" class="LineNr"> 202 </span> b4 0f +<span id="L203" class="LineNr"> 203 </span> <span class="subxComment"># bx <- 0</span> +<span id="L204" class="LineNr"> 204 </span> bb 00 00 +<span id="L205" class="LineNr"> 205 </span> <span class="subxComment"># *ds:bx <- ax</span> +<span id="L206" class="LineNr"> 206 </span> 89 07 <span class="subxComment"># 00b/mod/indirect 000b/reg/ax 111b/rm/bx</span> +<span id="L207" class="LineNr"> 207 </span> +<span id="L208" class="LineNr"> 208 </span>e9 fd ff <span class="subxComment"># loop forever</span> +<span id="L209" class="LineNr"> 209 </span> +<span id="L210" class="LineNr"> 210 </span><span class="subxComment">## GDT: 3 records of 8 bytes each</span> +<span id="L211" class="LineNr"> 211 </span> +<span id="L212" class="LineNr"> 212 </span><span class="subxComment"># e0:</span> +<span id="L213" class="LineNr"> 213 </span><span class="subxComment"># gdt_start:</span> +<span id="L214" class="LineNr"> 214 </span><span class="subxComment"># gdt_null: mandatory null descriptor</span> +<span id="L215" class="LineNr"> 215 </span> 00 00 00 00 00 00 00 00 +<span id="L216" class="LineNr"> 216 </span><span class="subxComment"># gdt_code: (offset 8 from gdt_start)</span> +<span id="L217" class="LineNr"> 217 </span> ff ff <span class="subxComment"># limit[0:16]</span> +<span id="L218" class="LineNr"> 218 </span> 00 00 00 <span class="subxComment"># base[0:24]</span> +<span id="L219" class="LineNr"> 219 </span> 9a <span class="subxComment"># 1/present 00/privilege 1/descriptor type = 1001b</span> +<span id="L220" class="LineNr"> 220 </span> <span class="subxComment"># 1/code 0/conforming 1/readable 0/accessed = 1010b</span> +<span id="L221" class="LineNr"> 221 </span> cf <span class="subxComment"># 1/granularity 1/32-bit 0/64-bit-segment 0/AVL = 1100b</span> +<span id="L222" class="LineNr"> 222 </span> <span class="subxComment"># limit[16:20] = 1111b</span> +<span id="L223" class="LineNr"> 223 </span> 00 <span class="subxComment"># base[24:32]</span> +<span id="L224" class="LineNr"> 224 </span><span class="subxComment"># gdt_data: (offset 16 from gdt_start)</span> +<span id="L225" class="LineNr"> 225 </span> ff ff <span class="subxComment"># limit[0:16]</span> +<span id="L226" class="LineNr"> 226 </span> 00 00 00 <span class="subxComment"># base[0:24]</span> +<span id="L227" class="LineNr"> 227 </span> 92 <span class="subxComment"># 1/present 00/privilege 1/descriptor type = 1001b</span> +<span id="L228" class="LineNr"> 228 </span> <span class="subxComment"># 0/data 0/conforming 1/readable 0/accessed = 0010b</span> +<span id="L229" class="LineNr"> 229 </span> cf <span class="subxComment"># same as gdt_code</span> +<span id="L230" class="LineNr"> 230 </span> 00 <span class="subxComment"># base[24:32]</span> +<span id="L231" class="LineNr"> 231 </span><span class="subxComment"># gdt_end:</span> +<span id="L232" class="LineNr"> 232 </span> +<span id="L233" class="LineNr"> 233 </span><span class="subxComment"># f8:</span> +<span id="L234" class="LineNr"> 234 </span><span class="subxComment"># gdt_descriptor:</span> +<span id="L235" class="LineNr"> 235 </span> 17 00 <span class="subxComment"># final index of gdt = gdt_end - gdt_start - 1</span> +<span id="L236" class="LineNr"> 236 </span> e0 7c 00 00 <span class="subxComment"># start = gdt_start [label]</span> +<span id="L237" class="LineNr"> 237 </span> +<span id="L238" class="LineNr"> 238 </span><span class="subxComment"># padding</span> +<span id="L239" class="LineNr"> 239 </span><span class="subxComment"># fe:</span> +<span id="L240" class="LineNr"> 240 </span> 00 00 +<span id="L241" class="LineNr"> 241 </span> +<span id="L242" class="LineNr"> 242 </span><span class="subxComment">## 32-bit code from this point (still some instructions not in SubX)</span> +<span id="L243" class="LineNr"> 243 </span> +<span id="L244" class="LineNr"> 244 </span><span class="subxComment"># offset 100 (address 0x7d00):</span> +<span id="L245" class="LineNr"> 245 </span><span class="subxComment"># initialize_32bit_mode:</span> +<span id="L246" class="LineNr"> 246 </span> 66 b8 10 00 <span class="subxComment"># ax <- offset 16 from gdt_start</span> +<span id="L247" class="LineNr"> 247 </span> 8e d8 <span class="subxComment"># ds <- ax</span> +<span id="L248" class="LineNr"> 248 </span> 8e d0 <span class="subxComment"># ss <- ax</span> +<span id="L249" class="LineNr"> 249 </span> 8e c0 <span class="subxComment"># es <- ax</span> +<span id="L250" class="LineNr"> 250 </span> 8e e0 <span class="subxComment"># fs <- ax</span> +<span id="L251" class="LineNr"> 251 </span> 8e e8 <span class="subxComment"># gs <- ax</span> +<span id="L252" class="LineNr"> 252 </span> +<span id="L253" class="LineNr"> 253 </span><span class="subxComment"># 10e:</span> +<span id="L254" class="LineNr"> 254 </span> bc 00 00 07 00 <span class="subxComment"># esp <- 0x00070000</span> +<span id="L255" class="LineNr"> 255 </span> +<span id="L256" class="LineNr"> 256 </span><span class="subxComment"># 113:</span> +<span id="L257" class="LineNr"> 257 </span> <span class="subxComment"># load interrupt handlers</span> +<span id="L258" class="LineNr"> 258 </span> 0f 01 1d <span class="subxComment"># lidt 00/mod/indirect 011/subop 101/rm32/use-disp32</span> +<span id="L259" class="LineNr"> 259 </span> 00 80 00 00 <span class="subxComment"># *idt_descriptor [label]</span> +<span id="L260" class="LineNr"> 260 </span> +<span id="L261" class="LineNr"> 261 </span> <span class="subxComment"># For now, not bothering reprogramming the IRQ to not conflict with software</span> +<span id="L262" class="LineNr"> 262 </span> <span class="subxComment"># exceptions.</span> +<span id="L263" class="LineNr"> 263 </span> <span class="subxComment"># <a href="https://wiki.osdev.org/index.php?title=8259_PIC&oldid=24650#Protected_Mode">https://wiki.osdev.org/index.php?title=8259_PIC&oldid=24650#Protected_Mode</a></span> +<span id="L264" class="LineNr"> 264 </span> <span class="subxComment">#</span> +<span id="L265" class="LineNr"> 265 </span> <span class="subxComment"># Interrupt 1 (keyboard) conflicts with debugger faults. We don't use a</span> +<span id="L266" class="LineNr"> 266 </span> <span class="subxComment"># debugger.</span> +<span id="L267" class="LineNr"> 267 </span> <span class="subxComment"># Reference:</span> +<span id="L268" class="LineNr"> 268 </span> <span class="subxComment"># <a href="https://wiki.osdev.org/Exceptions">https://wiki.osdev.org/Exceptions</a></span> +<span id="L269" class="LineNr"> 269 </span> +<span id="L270" class="LineNr"> 270 </span><span class="subxComment"># 11a:</span> +<span id="L271" class="LineNr"> 271 </span> <span class="subxComment"># enable keyboard IRQ (1)</span> +<span id="L272" class="LineNr"> 272 </span> b0 fd <span class="subxComment"># al <- 0xfd # disable mask for IRQ1</span> +<span id="L273" class="LineNr"> 273 </span> e6 21 <span class="subxComment"># port 0x21 <- al</span> +<span id="L274" class="LineNr"> 274 </span> +<span id="L275" class="LineNr"> 275 </span><span class="subxComment"># 11e:</span> +<span id="L276" class="LineNr"> 276 </span> fb <span class="subxComment"># enable interrupts</span> +<span id="L277" class="LineNr"> 277 </span> db e3 <span class="subxComment"># initialize FPU</span> +<span id="L278" class="LineNr"> 278 </span> <span class="subxComment"># eax <- cr4</span> +<span id="L279" class="LineNr"> 279 </span> 0f 20 <span class="subxComment"># copy cr4 to rm32</span> +<span id="L280" class="LineNr"> 280 </span> e0 <span class="subxComment"># 11/mod/direct 100/r32/CR4 000/rm32/eax</span> +<span id="L281" class="LineNr"> 281 </span> <span class="subxComment"># eax <- or bit 9</span> +<span id="L282" class="LineNr"> 282 </span> 0f ba +<span id="L283" class="LineNr"> 283 </span> e8 <span class="subxComment"># 11/mod/direct 101/subop/bit-test-and-set 000/rm32/eax</span> +<span id="L284" class="LineNr"> 284 </span> 09 <span class="subxComment"># imm8</span> +<span id="L285" class="LineNr"> 285 </span> <span class="subxComment"># cr4 <- eax</span> +<span id="L286" class="LineNr"> 286 </span> 0f 22 <span class="subxComment"># copy rm32 to cr4</span> +<span id="L287" class="LineNr"> 287 </span> e0 <span class="subxComment"># 11/mod/direct 100/r32/CR4 000/rm32/eax</span> +<span id="L288" class="LineNr"> 288 </span> e9 d0 16 00 00 <span class="subxComment"># jump to 0x9400 [label]</span> +<span id="L289" class="LineNr"> 289 </span> +<span id="L290" class="LineNr"> 290 </span><span class="subxComment"># padding</span> +<span id="L291" class="LineNr"> 291 </span><span class="subxComment"># 130:</span> +<span id="L292" class="LineNr"> 292 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L293" class="LineNr"> 293 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L294" class="LineNr"> 294 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L295" class="LineNr"> 295 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L296" class="LineNr"> 296 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L297" class="LineNr"> 297 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L298" class="LineNr"> 298 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L299" class="LineNr"> 299 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L300" class="LineNr"> 300 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L301" class="LineNr"> 301 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L302" class="LineNr"> 302 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L303" class="LineNr"> 303 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L304" class="LineNr"> 304 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L305" class="LineNr"> 305 </span> +<span id="L306" class="LineNr"> 306 </span><span class="subxComment"># 1fe:</span> +<span id="L307" class="LineNr"> 307 </span><span class="subxComment"># final 2 bytes of boot sector</span> +<span id="L308" class="LineNr"> 308 </span>55 aa +<span id="L309" class="LineNr"> 309 </span> +<span id="L310" class="LineNr"> 310 </span><span class="subxComment">## sector 2 onwards loaded by load_disk, not automatically on boot</span> +<span id="L311" class="LineNr"> 311 </span> +<span id="L312" class="LineNr"> 312 </span><span class="subxComment"># offset 200 (address 0x7e00):</span> +<span id="L313" class="LineNr"> 313 </span><span class="subxComment"># null interrupt handler:</span> +<span id="L314" class="LineNr"> 314 </span> cf <span class="subxComment"># iret</span> +<span id="L315" class="LineNr"> 315 </span> +<span id="L316" class="LineNr"> 316 </span><span class="subxComment"># padding</span> +<span id="L317" class="LineNr"> 317 </span><span class="subxComment"># 201:</span> +<span id="L318" class="LineNr"> 318 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L319" class="LineNr"> 319 </span> +<span id="L320" class="LineNr"> 320 </span><span class="subxComment"># 210:</span> +<span id="L321" class="LineNr"> 321 </span><span class="subxComment"># keyboard interrupt handler:</span> +<span id="L322" class="LineNr"> 322 </span> <span class="subxComment"># prologue</span> +<span id="L323" class="LineNr"> 323 </span> fa <span class="subxComment"># disable interrupts</span> +<span id="L324" class="LineNr"> 324 </span> 60 <span class="subxComment"># push all registers to stack</span> +<span id="L325" class="LineNr"> 325 </span> <span class="subxComment"># acknowledge interrupt</span> +<span id="L326" class="LineNr"> 326 </span> b0 20 <span class="subxComment"># al <- 0x20</span> +<span id="L327" class="LineNr"> 327 </span> e6 20 <span class="subxComment"># port 0x20 <- al</span> +<span id="L328" class="LineNr"> 328 </span> 31 c0 <span class="subxComment"># eax <- xor eax; 11/direct 000/r32/eax 000/rm32/eax</span> +<span id="L329" class="LineNr"> 329 </span> <span class="subxComment"># check output buffer of 8042 keyboard controller (<a href="https://web.archive.org/web/20040604041507/http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/keyboard/atkeyboard.html">https://web.archive.org/web/20040604041507/http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/keyboard/atkeyboard.html</a>)</span> +<span id="L330" class="LineNr"> 330 </span> e4 64 <span class="subxComment"># al <- port 0x64</span> +<span id="L331" class="LineNr"> 331 </span> a8 01 <span class="subxComment"># set zf if bit 0 (least significant) is not set</span> +<span id="L332" class="LineNr"> 332 </span> 74 89 <span class="subxComment"># jump to epilogue if 0 bit is not set [label]</span> +<span id="L333" class="LineNr"> 333 </span><span class="subxComment"># 21e:</span> +<span id="L334" class="LineNr"> 334 </span> <span class="subxH1Comment"># - if keyboard buffer is full, return</span> +<span id="L335" class="LineNr"> 335 </span> 31 c9 <span class="subxComment"># ecx <- xor ecx; 11/direct 001/r32/ecx 001/rm32/ecx</span> +<span id="L336" class="LineNr"> 336 </span> <span class="subxComment"># var index/ecx: byte</span> +<span id="L337" class="LineNr"> 337 </span> 8a <span class="subxComment"># copy m8 at r32 to r8</span> +<span id="L338" class="LineNr"> 338 </span> 0d <span class="subxComment"># 00/mod/indirect 001/r8/cl 101/rm32/use-disp32</span> +<span id="L339" class="LineNr"> 339 </span> 28 80 00 00 <span class="subxComment"># disp32 [label]</span> +<span id="L340" class="LineNr"> 340 </span> <span class="subxComment"># al = *(keyboard buffer + index)</span> +<span id="L341" class="LineNr"> 341 </span> 8a <span class="subxComment"># copy m8 at r32 to r8</span> +<span id="L342" class="LineNr"> 342 </span> 81 <span class="subxComment"># 10/mod/*+disp32 000/r8/al 001/rm32/ecx</span> +<span id="L343" class="LineNr"> 343 </span> 30 80 00 00 <span class="subxComment"># disp32 [label]</span> +<span id="L344" class="LineNr"> 344 </span> <span class="subxComment"># if (al != 0) return</span> +<span id="L345" class="LineNr"> 345 </span> 3c 00 <span class="subxComment"># compare al, 0</span> +<span id="L346" class="LineNr"> 346 </span> 75 77 <span class="subxComment"># jump to epilogue if != [label]</span> +<span id="L347" class="LineNr"> 347 </span><span class="subxComment"># 230:</span> +<span id="L348" class="LineNr"> 348 </span> <span class="subxH1Comment"># - read keycode</span> +<span id="L349" class="LineNr"> 349 </span> e4 60 <span class="subxComment"># al <- port 0x60</span> +<span id="L350" class="LineNr"> 350 </span> <span class="subxH1Comment"># - key released</span> +<span id="L351" class="LineNr"> 351 </span> <span class="subxComment"># if (al == 0xaa) shift = false # left shift is being lifted</span> +<span id="L352" class="LineNr"> 352 </span> 3c aa <span class="subxComment"># compare al, 0xaa</span> +<span id="L353" class="LineNr"> 353 </span> 75 0a <span class="subxComment"># jump to $1 if != [label]</span> +<span id="L354" class="LineNr"> 354 </span> <span class="subxComment"># *shift = 0</span> +<span id="L355" class="LineNr"> 355 </span> c7 <span class="subxComment"># copy imm32 to rm32</span> +<span id="L356" class="LineNr"> 356 </span> 05 <span class="subxComment"># 00/mod/indirect 000/subop/copy 101/rm32/use-disp32</span> +<span id="L357" class="LineNr"> 357 </span> 10 80 00 00 <span class="subxComment"># disp32 [label]</span> +<span id="L358" class="LineNr"> 358 </span> 00 00 00 00 <span class="subxComment"># imm32</span> +<span id="L359" class="LineNr"> 359 </span><span class="subxComment"># 240:</span> +<span id="L360" class="LineNr"> 360 </span><span class="subxComment"># $1:</span> +<span id="L361" class="LineNr"> 361 </span> <span class="subxComment"># if (al == 0xb6) shift = false # right shift is being lifted</span> +<span id="L362" class="LineNr"> 362 </span> 3c b6 <span class="subxComment"># compare al, 0xb6</span> +<span id="L363" class="LineNr"> 363 </span> 75 0a <span class="subxComment"># jump to $1 if != [label]</span> +<span id="L364" class="LineNr"> 364 </span> <span class="subxComment"># *shift = 0</span> +<span id="L365" class="LineNr"> 365 </span> c7 <span class="subxComment"># copy imm32 to rm32</span> +<span id="L366" class="LineNr"> 366 </span> 05 <span class="subxComment"># 00/mod/indirect 000/subop/copy 101/rm32/use-disp32</span> +<span id="L367" class="LineNr"> 367 </span> 10 80 00 00 <span class="subxComment"># disp32 [label]</span> +<span id="L368" class="LineNr"> 368 </span> 00 00 00 00 <span class="subxComment"># imm32</span> +<span id="L369" class="LineNr"> 369 </span><span class="subxComment"># $2:</span> +<span id="L370" class="LineNr"> 370 </span> <span class="subxComment"># if (al & 0x80) a key is being lifted; return</span> +<span id="L371" class="LineNr"> 371 </span> 50 <span class="subxComment"># push eax</span> +<span id="L372" class="LineNr"> 372 </span> 24 80 <span class="subxComment"># al <- and 0x80</span> +<span id="L373" class="LineNr"> 373 </span> 3c 00 <span class="subxComment"># compare al, 0</span> +<span id="L374" class="LineNr"> 374 </span> 58 <span class="subxComment"># pop to eax (without touching flags)</span> +<span id="L375" class="LineNr"> 375 </span> 75 51 <span class="subxComment"># jump to epilogue if != [label]</span> +<span id="L376" class="LineNr"> 376 </span><span class="subxComment"># 256:</span> +<span id="L377" class="LineNr"> 377 </span> <span class="subxH1Comment"># - key pressed</span> +<span id="L378" class="LineNr"> 378 </span> <span class="subxComment"># if (al == 0x2a) shift = true, return # left shift pressed</span> +<span id="L379" class="LineNr"> 379 </span> 3c 2a <span class="subxComment"># compare al, 0x2a</span> +<span id="L380" class="LineNr"> 380 </span> 75 0c <span class="subxComment"># jump to $3 if != [label]</span> +<span id="L381" class="LineNr"> 381 </span> <span class="subxComment"># *shift = 1</span> +<span id="L382" class="LineNr"> 382 </span> c7 <span class="subxComment"># copy imm32 to rm32</span> +<span id="L383" class="LineNr"> 383 </span> 05 <span class="subxComment"># 00/mod/indirect 000/subop/copy 101/rm32/use-disp32</span> +<span id="L384" class="LineNr"> 384 </span> 10 80 00 00 <span class="subxComment"># disp32 [label]</span> +<span id="L385" class="LineNr"> 385 </span> 01 00 00 00 <span class="subxComment"># imm32</span> +<span id="L386" class="LineNr"> 386 </span> eb 41 <span class="subxComment"># jump to epilogue [label]</span> +<span id="L387" class="LineNr"> 387 </span><span class="subxComment"># 266:</span> +<span id="L388" class="LineNr"> 388 </span><span class="subxComment"># $3:</span> +<span id="L389" class="LineNr"> 389 </span> <span class="subxComment"># if (al == 0x36) shift = true, return # right shift pressed</span> +<span id="L390" class="LineNr"> 390 </span> 3c 36 <span class="subxComment"># compare al, 0x36</span> +<span id="L391" class="LineNr"> 391 </span> 75 0c <span class="subxComment"># jump to $4 if != [label]</span> +<span id="L392" class="LineNr"> 392 </span> <span class="subxComment"># *shift = 1</span> +<span id="L393" class="LineNr"> 393 </span> c7 <span class="subxComment"># copy imm32 to rm32</span> +<span id="L394" class="LineNr"> 394 </span> 05 <span class="subxComment"># 00/mod/indirect 000/subop/copy 101/rm32/use-disp32</span> +<span id="L395" class="LineNr"> 395 </span> 10 80 00 00 <span class="subxComment"># disp32 [label]</span> +<span id="L396" class="LineNr"> 396 </span> 01 00 00 00 <span class="subxComment"># imm32</span> +<span id="L397" class="LineNr"> 397 </span> eb 31 <span class="subxComment"># jump to epilogue [label]</span> +<span id="L398" class="LineNr"> 398 </span><span class="subxComment"># 276:</span> +<span id="L399" class="LineNr"> 399 </span><span class="subxComment"># $4:</span> +<span id="L400" class="LineNr"> 400 </span> <span class="subxH1Comment"># - convert key to character</span> +<span id="L401" class="LineNr"> 401 </span> <span class="subxComment"># if (shift) use keyboard normal map</span> +<span id="L402" class="LineNr"> 402 </span> 81 <span class="subxComment"># operate on rm32 and imm32</span> +<span id="L403" class="LineNr"> 403 </span> 3d <span class="subxComment"># 00/mod/indirect 111/subop/compare 101/rm32/use-disp32</span> +<span id="L404" class="LineNr"> 404 </span> 10 80 00 00 <span class="subxComment"># disp32 = shift [label]</span> +<span id="L405" class="LineNr"> 405 </span> 00 00 00 00 <span class="subxComment"># imm32</span> +<span id="L406" class="LineNr"> 406 </span> 74 08 <span class="subxComment"># jump to $5 if = [label]</span> +<span id="L407" class="LineNr"> 407 </span> <span class="subxComment"># otherwise use keyboard shift map</span> +<span id="L408" class="LineNr"> 408 </span> <span class="subxComment"># al <- *(keyboard shift map + eax)</span> +<span id="L409" class="LineNr"> 409 </span> 8a <span class="subxComment"># copy m8 at rm32 to r8</span> +<span id="L410" class="LineNr"> 410 </span> 80 <span class="subxComment"># 10/mod/*+disp32 000/r8/al 000/rm32/eax</span> +<span id="L411" class="LineNr"> 411 </span> 00 87 00 00 <span class="subxComment"># disp32 [label]</span> +<span id="L412" class="LineNr"> 412 </span> eb 06 <span class="subxComment"># jump to $6 [label]</span> +<span id="L413" class="LineNr"> 413 </span><span class="subxComment"># 28a:</span> +<span id="L414" class="LineNr"> 414 </span><span class="subxComment"># $5:</span> +<span id="L415" class="LineNr"> 415 </span> <span class="subxComment"># al <- *(keyboard normal map + eax)</span> +<span id="L416" class="LineNr"> 416 </span> 8a <span class="subxComment"># copy m8 at rm32 to r8</span> +<span id="L417" class="LineNr"> 417 </span> 80 <span class="subxComment"># 10/mod/*+disp32 000/r8/al 000/rm32/eax</span> +<span id="L418" class="LineNr"> 418 </span> 00 86 00 00 <span class="subxComment"># disp32 [label]</span> +<span id="L419" class="LineNr"> 419 </span><span class="subxComment"># $6:</span> +<span id="L420" class="LineNr"> 420 </span> <span class="subxH1Comment"># - if there's no character mapping, return</span> +<span id="L421" class="LineNr"> 421 </span> 3c 00 <span class="subxComment"># compare al, 0</span> +<span id="L422" class="LineNr"> 422 </span> 74 13 <span class="subxComment"># jump to epilogue if = [label]</span> +<span id="L423" class="LineNr"> 423 </span><span class="subxComment"># 294:</span> +<span id="L424" class="LineNr"> 424 </span> <span class="subxH1Comment"># - store al in keyboard buffer</span> +<span id="L425" class="LineNr"> 425 </span> 88 <span class="subxComment"># copy r8 to m8 at r32</span> +<span id="L426" class="LineNr"> 426 </span> 81 <span class="subxComment"># 10/mod/*+disp32 000/r8/al 001/rm32/ecx</span> +<span id="L427" class="LineNr"> 427 </span> 30 80 00 00 <span class="subxComment"># disp32 [label]</span> +<span id="L428" class="LineNr"> 428 </span> <span class="subxComment"># increment index</span> +<span id="L429" class="LineNr"> 429 </span> fe <span class="subxComment"># increment byte</span> +<span id="L430" class="LineNr"> 430 </span> 05 <span class="subxComment"># 00/mod/indirect 000/subop/increment 101/rm32/use-disp32</span> +<span id="L431" class="LineNr"> 431 </span> 28 80 00 00 <span class="subxComment"># disp32 [label]</span> +<span id="L432" class="LineNr"> 432 </span> <span class="subxComment"># clear top nibble of index (keyboard buffer is circular)</span> +<span id="L433" class="LineNr"> 433 </span> 80 <span class="subxComment"># and byte</span> +<span id="L434" class="LineNr"> 434 </span> 25 <span class="subxComment"># 00/mod/indirect 100/subop/and 101/rm32/use-disp32</span> +<span id="L435" class="LineNr"> 435 </span> 28 80 00 00 <span class="subxComment"># disp32 [label]</span> +<span id="L436" class="LineNr"> 436 </span> 0f <span class="subxComment"># imm8</span> +<span id="L437" class="LineNr"> 437 </span><span class="subxComment"># 2a9:</span> +<span id="L438" class="LineNr"> 438 </span> <span class="subxComment"># epilogue</span> +<span id="L439" class="LineNr"> 439 </span> 61 <span class="subxComment"># pop all registers</span> +<span id="L440" class="LineNr"> 440 </span> fb <span class="subxComment"># enable interrupts</span> +<span id="L441" class="LineNr"> 441 </span> cf <span class="subxComment"># iret</span> +<span id="L442" class="LineNr"> 442 </span> +<span id="L443" class="LineNr"> 443 </span><span class="subxComment"># padding</span> +<span id="L444" class="LineNr"> 444 </span><span class="subxComment"># 2aa:</span> +<span id="L445" class="LineNr"> 445 </span> 00 00 00 00 00 00 +<span id="L446" class="LineNr"> 446 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L447" class="LineNr"> 447 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L448" class="LineNr"> 448 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L449" class="LineNr"> 449 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L450" class="LineNr"> 450 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L451" class="LineNr"> 451 </span><span class="subxComment"># 300:</span> +<span id="L452" class="LineNr"> 452 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L453" class="LineNr"> 453 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L454" class="LineNr"> 454 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L455" class="LineNr"> 455 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L456" class="LineNr"> 456 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L457" class="LineNr"> 457 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L458" class="LineNr"> 458 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L459" class="LineNr"> 459 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L460" class="LineNr"> 460 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L461" class="LineNr"> 461 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L462" class="LineNr"> 462 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L463" class="LineNr"> 463 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L464" class="LineNr"> 464 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L465" class="LineNr"> 465 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L466" class="LineNr"> 466 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L467" class="LineNr"> 467 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L468" class="LineNr"> 468 </span> +<span id="L469" class="LineNr"> 469 </span><span class="subxComment"># offset 400 (address 0x8000): interrupt handler data</span> +<span id="L470" class="LineNr"> 470 </span><span class="subxComment"># idt_descriptor:</span> +<span id="L471" class="LineNr"> 471 </span> ff 03 <span class="subxComment"># idt_end - idt_start - 1</span> +<span id="L472" class="LineNr"> 472 </span> 00 82 00 00 <span class="subxComment"># start = idt_start [label]</span> +<span id="L473" class="LineNr"> 473 </span> +<span id="L474" class="LineNr"> 474 </span><span class="subxComment"># padding</span> +<span id="L475" class="LineNr"> 475 </span><span class="subxComment"># 406:</span> +<span id="L476" class="LineNr"> 476 </span> 00 00 00 00 00 00 00 00 00 00 +<span id="L477" class="LineNr"> 477 </span> +<span id="L478" class="LineNr"> 478 </span><span class="subxComment"># 410:</span> +<span id="L479" class="LineNr"> 479 </span><span class="subxComment"># var shift: boolean</span> +<span id="L480" class="LineNr"> 480 </span> 00 00 00 00 +<span id="L481" class="LineNr"> 481 </span> +<span id="L482" class="LineNr"> 482 </span><span class="subxComment"># padding</span> +<span id="L483" class="LineNr"> 483 </span><span class="subxComment"># 414:</span> +<span id="L484" class="LineNr"> 484 </span> 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L485" class="LineNr"> 485 </span>00 00 00 00 00 00 00 00 +<span id="L486" class="LineNr"> 486 </span> +<span id="L487" class="LineNr"> 487 </span><span class="subxComment"># 428:</span> +<span id="L488" class="LineNr"> 488 </span><span class="subxComment"># var keyboard circular buffer</span> +<span id="L489" class="LineNr"> 489 </span><span class="subxComment"># write index: nibble</span> +<span id="L490" class="LineNr"> 490 </span><span class="subxComment"># still take up 4 bytes so SubX can handle it</span> +<span id="L491" class="LineNr"> 491 </span> 00 00 00 00 +<span id="L492" class="LineNr"> 492 </span><span class="subxComment"># 42c:</span> +<span id="L493" class="LineNr"> 493 </span><span class="subxComment"># read index: nibble</span> +<span id="L494" class="LineNr"> 494 </span><span class="subxComment"># still take up 4 bytes so SubX can handle it</span> +<span id="L495" class="LineNr"> 495 </span> 00 00 00 00 +<span id="L496" class="LineNr"> 496 </span><span class="subxComment"># 430:</span> +<span id="L497" class="LineNr"> 497 </span><span class="subxComment"># circular buffer: byte[16]</span> +<span id="L498" class="LineNr"> 498 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L499" class="LineNr"> 499 </span> +<span id="L500" class="LineNr"> 500 </span><span class="subxComment"># padding</span> +<span id="L501" class="LineNr"> 501 </span><span class="subxComment"># 440:</span> +<span id="L502" class="LineNr"> 502 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L503" class="LineNr"> 503 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L504" class="LineNr"> 504 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L505" class="LineNr"> 505 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L506" class="LineNr"> 506 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L507" class="LineNr"> 507 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L508" class="LineNr"> 508 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L509" class="LineNr"> 509 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L510" class="LineNr"> 510 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L511" class="LineNr"> 511 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L512" class="LineNr"> 512 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L513" class="LineNr"> 513 </span>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +<span id="L514" class="LineNr"> 514 </span> +<span id="L515" class="LineNr"> 515 </span><span class="subxComment"># offset 500 (address 0x8100):</span> +<span id="L516" class="Folded"> 516 </span><span class="Folded">+-- 53 lines: # video mode info ---------------------------------------------------------------------------------------------------------------------------------------------------------</span> +<span id="L569" class="LineNr"> 569 </span> +<span id="L570" class="LineNr"> 570 </span><span class="subxComment"># offset 600 (address 0x8200):</span> +<span id="L571" class="Folded"> 571 </span><span class="Folded">+--161 lines: # interrupt descriptor table ----------------------------------------------------------------------------------------------------------------------------------------------</span> +<span id="L732" class="LineNr"> 732 </span> +<span id="L733" class="LineNr"> 733 </span><span class="subxComment">## the rest of this file has data</span> +<span id="L734" class="LineNr"> 734 </span> +<span id="L735" class="LineNr"> 735 </span><span class="subxComment"># offset a00 (address 0x8600):</span> +<span id="L736" class="Folded"> 736 </span><span class="Folded">+--152 lines: # translating keys to ASCII -----------------------------------------------------------------------------------------------------------------------------------------------</span> +<span id="L888" class="LineNr"> 888 </span> +<span id="L889" class="LineNr"> 889 </span><span class="subxComment"># offset 1000 (address 0x8c00)</span> +<span id="L890" class="Folded"> 890 </span><span class="Folded">+--236 lines: # Bitmaps for some ASCII characters (soon Unicode) ------------------------------------------------------------------------------------------------------------------------</span> +<span id="L1126" class="LineNr">1126 </span> +<span id="L1127" class="LineNr">1127 </span><span class="subxComment"># offset 1800 (address 0x9400)</span> +<span id="L1128" class="LineNr">1128 </span> +<span id="L1129" class="LineNr">1129 </span><span class="subxComment"># vim:ft=subx</span> </pre> </body> </html> diff --git a/html/baremetal/ex2.mu.html b/html/baremetal/ex2.mu.html index 585e281d..0f696fcf 100644 --- a/html/baremetal/ex2.mu.html +++ b/html/baremetal/ex2.mu.html @@ -71,11 +71,11 @@ if ('onhashchange' in window) { <span id="L13" class="LineNr">13 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex2.mu.html#L13'>main</a></span> <span class="Delimiter">{</span> <span id="L14" class="LineNr">14 </span> <span class="PreProc">var</span> y/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</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> compare y, <span class="Constant">0x300</span> <span class="muComment"># screen-height = 768</span> +<span id="L16" class="LineNr">16 </span> compare y, <span class="Constant">0x300</span>/screen-height=<span class="Constant">768</span> <span id="L17" class="LineNr">17 </span> <span class="PreProc">break-if->=</span> <span id="L18" class="LineNr">18 </span> <span class="PreProc">var</span> x/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> <span id="L19" class="LineNr">19 </span> <span class="Delimiter">{</span> -<span id="L20" class="LineNr">20 </span> compare x, <span class="Constant">0x400</span> <span class="muComment"># screen-width = 1024</span> +<span id="L20" class="LineNr">20 </span> compare x, <span class="Constant">0x400</span>/screen-width=<span class="Constant">1024</span> <span id="L21" class="LineNr">21 </span> <span class="PreProc">break-if->=</span> <span id="L22" class="LineNr">22 </span> <span class="PreProc">var</span> color/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy x <span id="L23" class="LineNr">23 </span> color <span class="SpecialChar"><-</span> and <span class="Constant">0xff</span> diff --git a/html/baremetal/ex3.mu.html b/html/baremetal/ex3.mu.html index 7b58231f..9da377c2 100644 --- a/html/baremetal/ex3.mu.html +++ b/html/baremetal/ex3.mu.html @@ -73,12 +73,12 @@ if ('onhashchange' in window) { <span id="L15" class="LineNr">15 </span> <span class="PreProc">var</span> x/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> <span id="L16" class="LineNr">16 </span> <span class="PreProc">var</span> y/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</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/<span class="Constant">eax</span>: byte <span class="SpecialChar"><-</span> <a href='102keyboard.subx.html#L9'>read-key</a> <span class="Constant">0</span> <span class="muComment"># real keyboard</span> +<span id="L18" class="LineNr">18 </span> <span class="PreProc">var</span> key/<span class="Constant">eax</span>: byte <span class="SpecialChar"><-</span> <a href='102keyboard.subx.html#L9'>read-key</a> <span class="Constant">0</span>/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> <span class="muComment"># green</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="SpecialChar"><-</span> increment -<span id="L23" class="LineNr">23 </span> compare x, <span class="Constant">0x400</span> <span class="muComment"># screen-width</span> +<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="SpecialChar"><-</span> increment diff --git a/html/baremetal/ex4.mu.html b/html/baremetal/ex4.mu.html index 2a44bb75..e1553b88 100644 --- a/html/baremetal/ex4.mu.html +++ b/html/baremetal/ex4.mu.html @@ -17,7 +17,6 @@ a { color:inherit; } .PreProc { color: #c000c0; } .LineNr { } .Constant { color: #008787; } -.SpecialChar { color: #d70000; } .Delimiter { color: #c000c0; } .muFunction { color: #af5f00; text-decoration: underline; } .muComment { color: #005faf; } @@ -68,9 +67,8 @@ if ('onhashchange' in window) { <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> <span class="Delimiter">{</span> -<span id="L13" class="LineNr">13 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> copy <span class="Constant">0x41</span> <span class="muComment"># 'A'</span> -<span id="L14" class="LineNr">14 </span> <a href='500text-screen.mu.html#L68'>draw-grapheme</a> <span class="Constant">0</span>, g, <span class="Constant">2</span>, <span class="Constant">1</span>, <span class="Constant">0xa</span> <span class="muComment"># x of 2 graphemes = 16px from top-left; y of 1 grapheme = 16px down from top-left</span> -<span id="L15" class="LineNr">15 </span><span class="Delimiter">}</span> +<span id="L13" class="LineNr">13 </span> draw-codepoint <span class="Constant">0</span>/screen, <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="L14" class="LineNr">14 </span><span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/baremetal/ex5.mu.html b/html/baremetal/ex5.mu.html index 1d661e78..4f5f0d2e 100644 --- a/html/baremetal/ex5.mu.html +++ b/html/baremetal/ex5.mu.html @@ -69,8 +69,8 @@ if ('onhashchange' in window) { <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> <span class="Delimiter">{</span> -<span id="L14" class="LineNr">14 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L73'>draw-text-rightward</a> <span class="Constant">0</span>, <span class="Constant">"hello from baremetal Mu!"</span>, <span class="Constant">0x10</span>, <span class="Constant">0x400</span>, <span class="Constant">0x10</span>, <span class="Constant">0xa</span> <span class="muComment"># xmax = end of screen, plenty of space</span> -<span id="L15" class="LineNr">15 </span> dummy <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L73'>draw-text-rightward</a> <span class="Constant">0</span>, <span class="Constant">"you shouldn't see this"</span>, <span class="Constant">0x10</span>, <span class="Constant">0xa0</span>, <span class="Constant">0x30</span>, <span class="Constant">0x3</span> <span class="muComment"># xmax = 0xa0, which is too narrow</span> +<span id="L14" class="LineNr">14 </span> <span class="PreProc">var</span> dummy/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L81'>draw-text-rightward</a> <span class="Constant">0</span>/screen, <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>/color +<span id="L15" class="LineNr">15 </span> dummy <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L81'>draw-text-rightward</a> <span class="Constant">0</span>/screen, <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">0x3</span>/color <span class="muComment"># xmax is too narrow</span> <span id="L16" class="LineNr">16 </span><span class="Delimiter">}</span> </pre> </body> diff --git a/html/baremetal/ex6.mu.html b/html/baremetal/ex6.mu.html index f870f80e..a6f1ce7a 100644 --- a/html/baremetal/ex6.mu.html +++ b/html/baremetal/ex6.mu.html @@ -72,21 +72,21 @@ if ('onhashchange' in window) { <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/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0x20</span> <span id="L16" class="LineNr">16 </span> <span class="PreProc">var</span> y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0x20</span> -<span id="L17" class="LineNr">17 </span> x, y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L120'>draw-text-wrapping-right-then-down</a> <span class="Constant">0</span>, <span class="Constant">"hello "</span>, <span class="Constant">0x10</span>, <span class="Constant">0x20</span>, <span class="Constant">0x78</span>, <span class="Constant">0x50</span>, x, y, <span class="Constant">0xa</span> <span class="muComment"># (0x10, 0x20) -> (0x78, 0x50)</span> -<span id="L18" class="LineNr">18 </span> x, y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L120'>draw-text-wrapping-right-then-down</a> <span class="Constant">0</span>, <span class="Constant">"from "</span>, <span class="Constant">0x10</span>, <span class="Constant">0x20</span>, <span class="Constant">0x78</span>, <span class="Constant">0x50</span>, x, y, <span class="Constant">0xa</span> -<span id="L19" class="LineNr">19 </span> x, y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L120'>draw-text-wrapping-right-then-down</a> <span class="Constant">0</span>, <span class="Constant">"baremetal "</span>, <span class="Constant">0x10</span>, <span class="Constant">0x20</span>, <span class="Constant">0x78</span>, <span class="Constant">0x50</span>, x, y, <span class="Constant">0xa</span> -<span id="L20" class="LineNr">20 </span> x, y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L120'>draw-text-wrapping-right-then-down</a> <span class="Constant">0</span>, <span class="Constant">"Mu!"</span>, <span class="Constant">0x10</span>, <span class="Constant">0x20</span>, <span class="Constant">0x78</span>, <span class="Constant">0x50</span>, x, y, <span class="Constant">0xa</span> +<span id="L17" class="LineNr">17 </span> x, y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L136'>draw-text-wrapping-right-then-down</a> <span class="Constant">0</span>/screen, <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>/color +<span id="L18" class="LineNr">18 </span> x, y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L136'>draw-text-wrapping-right-then-down</a> <span class="Constant">0</span>/screen, <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>/color +<span id="L19" class="LineNr">19 </span> x, y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L136'>draw-text-wrapping-right-then-down</a> <span class="Constant">0</span>/screen, <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>/color +<span id="L20" class="LineNr">20 </span> x, y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L136'>draw-text-wrapping-right-then-down</a> <span class="Constant">0</span>/screen, <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>/color <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#L494'>draw-text-wrapping-down-then-right-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">"abc"</span>, <span class="Constant">0xa</span> -<span id="L24" class="LineNr">24 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">"def"</span>, <span class="Constant">0xa</span> +<span id="L23" class="LineNr">23 </span> <a href='501draw-text.mu.html#L510'>draw-text-wrapping-down-then-right-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"abc"</span>, <span class="Constant">0xa</span> +<span id="L24" class="LineNr">24 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"def"</span>, <span class="Constant">0xa</span> <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="SpecialChar"><-</span> <a href='501draw-text.mu.html#L73'>draw-text-rightward</a> <span class="Constant">0</span>, <span class="Constant">"R"</span>, <span class="Constant">0x3f8</span>, <span class="Constant">0x400</span>, <span class="Constant">0x100</span>, <span class="Constant">0xa</span> <span class="muComment"># 0x400 = screen-width</span> -<span id="L28" class="LineNr">28 </span> <a href='501draw-text.mu.html#L206'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">"wrapped from R"</span>, <span class="Constant">0xa</span> +<span id="L27" class="LineNr">27 </span> x <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L81'>draw-text-rightward</a> <span class="Constant">0</span>/screen, <span class="Constant">"R"</span>, <span class="Constant">0x3f8</span>/x, <span class="Constant">0x400</span>/xmax=screen-width, <span class="Constant">0x100</span>/y, <span class="Constant">0xa</span>/color +<span id="L28" class="LineNr">28 </span> <a href='501draw-text.mu.html#L222'>draw-text-wrapping-right-then-down-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"wrapped from R"</span>, <span class="Constant">0xa</span> <span id="L29" class="LineNr">29 </span> -<span id="L30" class="LineNr">30 </span> x <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L376'>draw-text-downward</a> <span class="Constant">0</span>, <span class="Constant">"D"</span>, <span class="Constant">0x100</span>, <span class="Constant">0x2f0</span>, <span class="Constant">0x300</span>, <span class="Constant">0xa</span> <span class="muComment"># 0x300 = screen-height</span> -<span id="L31" class="LineNr">31 </span> <a href='501draw-text.mu.html#L494'>draw-text-wrapping-down-then-right-from-cursor-over-full-screen</a> <span class="Constant">0</span>, <span class="Constant">"wrapped from D"</span>, <span class="Constant">0xa</span> +<span id="L30" class="LineNr">30 </span> x <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L392'>draw-text-downward</a> <span class="Constant">0</span>/screen, <span class="Constant">"D"</span>, <span class="Constant">0x100</span>/x, <span class="Constant">0x2f0</span>/y, <span class="Constant">0x300</span>/ymax=screen-height, <span class="Constant">0xa</span>/color +<span id="L31" class="LineNr">31 </span> <a href='501draw-text.mu.html#L510'>draw-text-wrapping-down-then-right-from-cursor-over-full-screen</a> <span class="Constant">0</span>/screen, <span class="Constant">"wrapped from D"</span>, <span class="Constant">0xa</span> <span id="L32" class="LineNr">32 </span><span class="Delimiter">}</span> </pre> </body> diff --git a/html/baremetal/ex7.mu.html b/html/baremetal/ex7.mu.html index 3df63b64..0235d49f 100644 --- a/html/baremetal/ex7.mu.html +++ b/html/baremetal/ex7.mu.html @@ -70,41 +70,38 @@ if ('onhashchange' in window) { <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> <span class="Delimiter">{</span> <span id="L14" class="LineNr">14 </span> <span class="PreProc">var</span> space/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> copy <span class="Constant">0x20</span> -<span id="L15" class="LineNr">15 </span> <a href='500text-screen.mu.html#L115'>set-cursor-position</a> <span class="Constant">0</span>, <span class="Constant">0</span>, <span class="Constant">0</span> +<span id="L15" class="LineNr">15 </span> <a href='500text-screen.mu.html#L133'>set-cursor-position</a> <span class="Constant">0</span>/screen, <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='500text-screen.mu.html#L162'>show-cursor</a> <span class="Constant">0</span>, space -<span id="L18" class="LineNr">18 </span> <span class="PreProc">var</span> key/<span class="Constant">eax</span>: byte <span class="SpecialChar"><-</span> <a href='102keyboard.subx.html#L9'>read-key</a> <span class="Constant">0</span> +<span id="L17" class="LineNr">17 </span> <a href='500text-screen.mu.html#L180'>show-cursor</a> <span class="Constant">0</span>/screen, space +<span id="L18" class="LineNr">18 </span> <span class="PreProc">var</span> key/<span class="Constant">eax</span>: byte <span class="SpecialChar"><-</span> <a href='102keyboard.subx.html#L9'>read-key</a> <span class="Constant">0</span>/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> <span class="muComment"># 'h'</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> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> copy <span class="Constant">0x2d</span> <span class="muComment"># '-'</span> -<span id="L23" class="LineNr">23 </span> <a href='501draw-text.mu.html#L63'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>, g, <span class="Constant">0x31</span> -<span id="L24" class="LineNr">24 </span> <a href='501draw-text.mu.html#L3'>cursor-left</a> <span class="Constant">0</span> -<span id="L25" class="LineNr">25 </span> <span class="Delimiter">}</span> -<span id="L26" class="LineNr">26 </span> <span class="Delimiter">{</span> -<span id="L27" class="LineNr">27 </span> compare key, <span class="Constant">0x6a</span> <span class="muComment"># 'j'</span> -<span id="L28" class="LineNr">28 </span> <span class="PreProc">break-if-!=</span> -<span id="L29" class="LineNr">29 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> copy <span class="Constant">0x7c</span> <span class="muComment"># '|'</span> -<span id="L30" class="LineNr">30 </span> <a href='501draw-text.mu.html#L63'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>, g, <span class="Constant">0x31</span> -<span id="L31" class="LineNr">31 </span> <a href='501draw-text.mu.html#L46'>cursor-down</a> <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="Delimiter">{</span> -<span id="L34" class="LineNr">34 </span> compare key, <span class="Constant">0x6b</span> <span class="muComment"># 'k'</span> -<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/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> copy <span class="Constant">0x7c</span> <span class="muComment"># '|'</span> -<span id="L37" class="LineNr">37 </span> <a href='501draw-text.mu.html#L63'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>, g, <span class="Constant">0x31</span> -<span id="L38" class="LineNr">38 </span> <a href='501draw-text.mu.html#L33'>cursor-up</a> <span class="Constant">0</span> -<span id="L39" class="LineNr">39 </span> <span class="Delimiter">}</span> -<span id="L40" class="LineNr">40 </span> <span class="Delimiter">{</span> -<span id="L41" class="LineNr">41 </span> compare key, <span class="Constant">0x6c</span> <span class="muComment"># 'l'</span> -<span id="L42" class="LineNr">42 </span> <span class="PreProc">break-if-!=</span> -<span id="L43" class="LineNr">43 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> copy <span class="Constant">0x2d</span> <span class="muComment"># '-'</span> -<span id="L44" class="LineNr">44 </span> <a href='501draw-text.mu.html#L63'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>, g, <span class="Constant">0x31</span> -<span id="L45" class="LineNr">45 </span> <a href='501draw-text.mu.html#L16'>cursor-right</a> <span class="Constant">0</span> -<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="Delimiter">}</span> +<span id="L22" class="LineNr">22 </span> <a href='501draw-text.mu.html#L73'>draw-code-point-at-cursor</a> <span class="Constant">0</span>/screen, <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#L73'>draw-code-point-at-cursor</a> <span class="Constant">0</span>/screen, <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#L73'>draw-code-point-at-cursor</a> <span class="Constant">0</span>/screen, <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/<span class="Constant">eax</span>: code-point <span class="SpecialChar"><-</span> copy <span class="Constant">0x2d</span>/dash +<span id="L41" class="LineNr">41 </span> <a href='501draw-text.mu.html#L73'>draw-code-point-at-cursor</a> <span class="Constant">0</span>/screen, <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> </pre> </body> </html> diff --git a/html/baremetal/ex8.mu.html b/html/baremetal/ex8.mu.html new file mode 100644 index 00000000..aef19cae --- /dev/null +++ b/html/baremetal/ex8.mu.html @@ -0,0 +1,68 @@ +<!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 - baremetal/ex8.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: #c6c6c6; } +body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } +a { color:inherit; } +* { font-size:12pt; font-size: 1em; } +.PreProc { color: #c000c0; } +.LineNr { } +.Constant { color: #008787; } +.SpecialChar { color: #d70000; } +.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/baremetal/ex8.mu'>https://github.com/akkartik/mu/blob/main/baremetal/ex8.mu</a> +<pre id='vimCodeElement'> +<span id="L1" class="LineNr">1 </span><span class="muComment"># Demo of floating-point</span> +<span id="L2" class="LineNr">2 </span> +<span id="L3" class="LineNr">3 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='ex8.mu.html#L3'>main</a></span> <span class="Delimiter">{</span> +<span id="L4" class="LineNr">4 </span> <span class="PreProc">var</span> n/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L5" class="LineNr">5 </span> <span class="PreProc">var</span> result/<span class="Constant">xmm0</span>: float <span class="SpecialChar"><-</span> convert n +<span id="L6" class="LineNr">6 </span><span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/baremetal/life.mu.html b/html/baremetal/life.mu.html new file mode 100644 index 00000000..0d3c9170 --- /dev/null +++ b/html/baremetal/life.mu.html @@ -0,0 +1,318 @@ +<!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 - baremetal/life.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: #c6c6c6; } +body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } +a { color:inherit; } +* { font-size:12pt; font-size: 1em; } +.PreProc { color: #c000c0; } +.LineNr { } +.CommentedCode { color: #8a8a8a; } +.Delimiter { color: #c000c0; } +.SpecialChar { color: #d70000; } +.Constant { color: #008787; } +.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/baremetal/life.mu'>https://github.com/akkartik/mu/blob/main/baremetal/life.mu</a> +<pre id='vimCodeElement'> +<span id="L1" class="LineNr"> 1 </span><span class="muComment"># Conway's Game of Life</span> +<span id="L2" class="LineNr"> 2 </span><span class="muComment">#</span> +<span id="L3" class="LineNr"> 3 </span><span class="muComment"># To build:</span> +<span id="L4" class="LineNr"> 4 </span><span class="muComment"># $ ./translate_mu_baremetal baremetal/life.mu</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 disk.img</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='life.mu.html#L8'>state</a></span> _grid: (addr array boolean), x: int, y: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: boolean <span class="Delimiter">{</span> +<span id="L9" class="LineNr"> 9 </span> <span class="muComment"># clip at the edge</span> +<span id="L10" class="LineNr"> 10 </span> compare x, <span class="Constant">0</span> +<span id="L11" class="LineNr"> 11 </span> <span class="Delimiter">{</span> +<span id="L12" class="LineNr"> 12 </span> <span class="PreProc">break-if->=</span> +<span id="L13" class="LineNr"> 13 </span> <span class="PreProc">return</span> <span class="Constant">0</span>/false +<span id="L14" class="LineNr"> 14 </span> <span class="Delimiter">}</span> +<span id="L15" class="LineNr"> 15 </span> compare y, <span class="Constant">0</span> +<span id="L16" class="LineNr"> 16 </span> <span class="Delimiter">{</span> +<span id="L17" class="LineNr"> 17 </span> <span class="PreProc">break-if->=</span> +<span id="L18" class="LineNr"> 18 </span> <span class="PreProc">return</span> <span class="Constant">0</span>/false +<span id="L19" class="LineNr"> 19 </span> <span class="Delimiter">}</span> +<span id="L20" class="LineNr"> 20 </span> compare x, <span class="Constant">0x100</span>/width +<span id="L21" class="LineNr"> 21 </span> <span class="Delimiter">{</span> +<span id="L22" class="LineNr"> 22 </span> <span class="PreProc">break-if-<</span> +<span id="L23" class="LineNr"> 23 </span> <span class="PreProc">return</span> <span class="Constant">0</span>/false +<span id="L24" class="LineNr"> 24 </span> <span class="Delimiter">}</span> +<span id="L25" class="LineNr"> 25 </span> compare y, <span class="Constant">0xc0</span>/height +<span id="L26" class="LineNr"> 26 </span> <span class="Delimiter">{</span> +<span id="L27" class="LineNr"> 27 </span> <span class="PreProc">break-if-<</span> +<span id="L28" class="LineNr"> 28 </span> <span class="PreProc">return</span> <span class="Constant">0</span>/false +<span id="L29" class="LineNr"> 29 </span> <span class="Delimiter">}</span> +<span id="L30" class="LineNr"> 30 </span> <span class="PreProc">var</span> idx/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy y +<span id="L31" class="LineNr"> 31 </span> idx <span class="SpecialChar"><-</span> shift-left <span class="Constant">8</span>/log2width +<span id="L32" class="LineNr"> 32 </span> idx <span class="SpecialChar"><-</span> add x +<span id="L33" class="LineNr"> 33 </span> <span class="PreProc">var</span> grid/<span class="Constant">esi</span>: (addr array boolean) <span class="SpecialChar"><-</span> copy _grid +<span id="L34" class="LineNr"> 34 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: (addr boolean) <span class="SpecialChar"><-</span> index grid, idx +<span id="L35" class="LineNr"> 35 </span> <span class="PreProc">return</span> *result +<span id="L36" class="LineNr"> 36 </span><span class="Delimiter">}</span> +<span id="L37" class="LineNr"> 37 </span> +<span id="L38" class="LineNr"> 38 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='life.mu.html#L38'>set-state</a></span> _grid: (addr array boolean), x: int, y: int, val: boolean <span class="Delimiter">{</span> +<span id="L39" class="LineNr"> 39 </span> <span class="muComment"># don't bother checking bounds</span> +<span id="L40" class="LineNr"> 40 </span> <span class="PreProc">var</span> idx/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy y +<span id="L41" class="LineNr"> 41 </span> idx <span class="SpecialChar"><-</span> shift-left <span class="Constant">8</span>/log2width +<span id="L42" class="LineNr"> 42 </span> idx <span class="SpecialChar"><-</span> add x +<span id="L43" class="LineNr"> 43 </span> <span class="PreProc">var</span> grid/<span class="Constant">esi</span>: (addr array boolean) <span class="SpecialChar"><-</span> copy _grid +<span id="L44" class="LineNr"> 44 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: (addr boolean) <span class="SpecialChar"><-</span> index grid, idx +<span id="L45" class="LineNr"> 45 </span> <span class="PreProc">var</span> src/<span class="Constant">ecx</span>: boolean <span class="SpecialChar"><-</span> copy val +<span id="L46" class="LineNr"> 46 </span> copy-to *result, src +<span id="L47" class="LineNr"> 47 </span><span class="Delimiter">}</span> +<span id="L48" class="LineNr"> 48 </span> +<span id="L49" class="LineNr"> 49 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='life.mu.html#L49'>num-live-neighbors</a></span> grid: (addr array boolean), x: int, y: int<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L50" class="LineNr"> 50 </span> <span class="PreProc">var</span> result/<span class="Constant">edi</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L51" class="LineNr"> 51 </span> <span class="muComment"># row above: zig</span> +<span id="L52" class="LineNr"> 52 </span> decrement y +<span id="L53" class="LineNr"> 53 </span> decrement x +<span id="L54" class="LineNr"> 54 </span> <span class="PreProc">var</span> s/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='life.mu.html#L8'>state</a> grid, x, y +<span id="L55" class="LineNr"> 55 </span> <span class="Delimiter">{</span> +<span id="L56" class="LineNr"> 56 </span> compare s, <span class="Constant">0</span>/false +<span id="L57" class="LineNr"> 57 </span> <span class="PreProc">break-if-=</span> +<span id="L58" class="LineNr"> 58 </span> result <span class="SpecialChar"><-</span> increment +<span id="L59" class="LineNr"> 59 </span> <span class="Delimiter">}</span> +<span id="L60" class="LineNr"> 60 </span> increment x +<span id="L61" class="LineNr"> 61 </span> s <span class="SpecialChar"><-</span> <a href='life.mu.html#L8'>state</a> grid, x, y +<span id="L62" class="LineNr"> 62 </span> <span class="Delimiter">{</span> +<span id="L63" class="LineNr"> 63 </span> compare s, <span class="Constant">0</span>/false +<span id="L64" class="LineNr"> 64 </span> <span class="PreProc">break-if-=</span> +<span id="L65" class="LineNr"> 65 </span> result <span class="SpecialChar"><-</span> increment +<span id="L66" class="LineNr"> 66 </span> <span class="Delimiter">}</span> +<span id="L67" class="LineNr"> 67 </span> increment x +<span id="L68" class="LineNr"> 68 </span> s <span class="SpecialChar"><-</span> <a href='life.mu.html#L8'>state</a> grid, x, y +<span id="L69" class="LineNr"> 69 </span> <span class="Delimiter">{</span> +<span id="L70" class="LineNr"> 70 </span> compare s, <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> result <span class="SpecialChar"><-</span> increment +<span id="L73" class="LineNr"> 73 </span> <span class="Delimiter">}</span> +<span id="L74" class="LineNr"> 74 </span> <span class="muComment"># curr row: zag</span> +<span id="L75" class="LineNr"> 75 </span> increment y +<span id="L76" class="LineNr"> 76 </span> s <span class="SpecialChar"><-</span> <a href='life.mu.html#L8'>state</a> grid, x, y +<span id="L77" class="LineNr"> 77 </span> <span class="Delimiter">{</span> +<span id="L78" class="LineNr"> 78 </span> compare s, <span class="Constant">0</span>/false +<span id="L79" class="LineNr"> 79 </span> <span class="PreProc">break-if-=</span> +<span id="L80" class="LineNr"> 80 </span> result <span class="SpecialChar"><-</span> increment +<span id="L81" class="LineNr"> 81 </span> <span class="Delimiter">}</span> +<span id="L82" class="LineNr"> 82 </span> subtract-from x, <span class="Constant">2</span> +<span id="L83" class="LineNr"> 83 </span> s <span class="SpecialChar"><-</span> <a href='life.mu.html#L8'>state</a> grid, x, y +<span id="L84" class="LineNr"> 84 </span> <span class="Delimiter">{</span> +<span id="L85" class="LineNr"> 85 </span> compare s, <span class="Constant">0</span>/false +<span id="L86" class="LineNr"> 86 </span> <span class="PreProc">break-if-=</span> +<span id="L87" class="LineNr"> 87 </span> result <span class="SpecialChar"><-</span> increment +<span id="L88" class="LineNr"> 88 </span> <span class="Delimiter">}</span> +<span id="L89" class="LineNr"> 89 </span> <span class="muComment"># row below: zig</span> +<span id="L90" class="LineNr"> 90 </span> increment y +<span id="L91" class="LineNr"> 91 </span> s <span class="SpecialChar"><-</span> <a href='life.mu.html#L8'>state</a> grid, x, y +<span id="L92" class="LineNr"> 92 </span> <span class="Delimiter">{</span> +<span id="L93" class="LineNr"> 93 </span> compare s, <span class="Constant">0</span>/false +<span id="L94" class="LineNr"> 94 </span> <span class="PreProc">break-if-=</span> +<span id="L95" class="LineNr"> 95 </span> result <span class="SpecialChar"><-</span> increment +<span id="L96" class="LineNr"> 96 </span> <span class="Delimiter">}</span> +<span id="L97" class="LineNr"> 97 </span> increment x +<span id="L98" class="LineNr"> 98 </span> s <span class="SpecialChar"><-</span> <a href='life.mu.html#L8'>state</a> grid, x, y +<span id="L99" class="LineNr"> 99 </span> <span class="Delimiter">{</span> +<span id="L100" class="LineNr">100 </span> compare s, <span class="Constant">0</span>/false +<span id="L101" class="LineNr">101 </span> <span class="PreProc">break-if-=</span> +<span id="L102" class="LineNr">102 </span> result <span class="SpecialChar"><-</span> increment +<span id="L103" class="LineNr">103 </span> <span class="Delimiter">}</span> +<span id="L104" class="LineNr">104 </span> increment x +<span id="L105" class="LineNr">105 </span> s <span class="SpecialChar"><-</span> <a href='life.mu.html#L8'>state</a> grid, x, y +<span id="L106" class="LineNr">106 </span> <span class="Delimiter">{</span> +<span id="L107" class="LineNr">107 </span> compare s, <span class="Constant">0</span>/false +<span id="L108" class="LineNr">108 </span> <span class="PreProc">break-if-=</span> +<span id="L109" class="LineNr">109 </span> result <span class="SpecialChar"><-</span> increment +<span id="L110" class="LineNr">110 </span> <span class="Delimiter">}</span> +<span id="L111" class="LineNr">111 </span> <span class="PreProc">return</span> result +<span id="L112" class="LineNr">112 </span><span class="Delimiter">}</span> +<span id="L113" class="LineNr">113 </span> +<span id="L114" class="LineNr">114 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='life.mu.html#L114'>step</a></span> old-grid: (addr array boolean), new-grid: (addr array boolean) <span class="Delimiter">{</span> +<span id="L115" class="LineNr">115 </span> <span class="PreProc">var</span> y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L116" class="LineNr">116 </span> <span class="Delimiter">{</span> +<span id="L117" class="LineNr">117 </span> compare y, <span class="Constant">0xc0</span>/height +<span id="L118" class="LineNr">118 </span> <span class="PreProc">break-if->=</span> +<span id="L119" class="LineNr">119 </span> <span class="PreProc">var</span> x/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L120" class="LineNr">120 </span> <span class="Delimiter">{</span> +<span id="L121" class="LineNr">121 </span> compare x, <span class="Constant">0x100</span>/width +<span id="L122" class="LineNr">122 </span> <span class="PreProc">break-if->=</span> +<span id="L123" class="LineNr">123 </span> <span class="PreProc">var</span> n/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='life.mu.html#L49'>num-live-neighbors</a> old-grid, x, y +<span id="L124" class="LineNr">124 </span> <span class="muComment"># if neighbors < 2, die of loneliness</span> +<span id="L125" class="LineNr">125 </span> <span class="Delimiter">{</span> +<span id="L126" class="LineNr">126 </span> compare n, <span class="Constant">2</span> +<span id="L127" class="LineNr">127 </span> <span class="PreProc">break-if->=</span> +<span id="L128" class="LineNr">128 </span> <a href='life.mu.html#L38'>set-state</a> new-grid, x, y, <span class="Constant">0</span>/dead +<span id="L129" class="LineNr">129 </span> <span class="Delimiter">}</span> +<span id="L130" class="LineNr">130 </span> <span class="muComment"># if neighbors > 3, die of overcrowding</span> +<span id="L131" class="LineNr">131 </span> <span class="Delimiter">{</span> +<span id="L132" class="LineNr">132 </span> compare n, <span class="Constant">3</span> +<span id="L133" class="LineNr">133 </span> <span class="PreProc">break-if-<=</span> +<span id="L134" class="LineNr">134 </span> <a href='life.mu.html#L38'>set-state</a> new-grid, x, y, <span class="Constant">0</span>/dead +<span id="L135" class="LineNr">135 </span> <span class="Delimiter">}</span> +<span id="L136" class="LineNr">136 </span> <span class="muComment"># if neighbors = 2, preserve state</span> +<span id="L137" class="LineNr">137 </span> <span class="Delimiter">{</span> +<span id="L138" class="LineNr">138 </span> compare n, <span class="Constant">2</span> +<span id="L139" class="LineNr">139 </span> <span class="PreProc">break-if-!=</span> +<span id="L140" class="LineNr">140 </span> <span class="PreProc">var</span> old-state/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='life.mu.html#L8'>state</a> old-grid, x, y +<span id="L141" class="LineNr">141 </span> <a href='life.mu.html#L38'>set-state</a> new-grid, x, y, old-state +<span id="L142" class="LineNr">142 </span> <span class="Delimiter">}</span> +<span id="L143" class="LineNr">143 </span> <span class="muComment"># if neighbors = 3, cell quickens to life</span> +<span id="L144" class="LineNr">144 </span> <span class="Delimiter">{</span> +<span id="L145" class="LineNr">145 </span> compare n, <span class="Constant">3</span> +<span id="L146" class="LineNr">146 </span> <span class="PreProc">break-if-!=</span> +<span id="L147" class="LineNr">147 </span> <a href='life.mu.html#L38'>set-state</a> new-grid, x, y, <span class="Constant">1</span>/live +<span id="L148" class="LineNr">148 </span> <span class="Delimiter">}</span> +<span id="L149" class="LineNr">149 </span> x <span class="SpecialChar"><-</span> increment +<span id="L150" class="LineNr">150 </span> <span class="PreProc">loop</span> +<span id="L151" class="LineNr">151 </span> <span class="Delimiter">}</span> +<span id="L152" class="LineNr">152 </span> y <span class="SpecialChar"><-</span> increment +<span id="L153" class="LineNr">153 </span> <span class="PreProc">loop</span> +<span id="L154" class="LineNr">154 </span> <span class="Delimiter">}</span> +<span id="L155" class="LineNr">155 </span><span class="Delimiter">}</span> +<span id="L156" class="LineNr">156 </span> +<span id="L157" class="LineNr">157 </span><span class="muComment"># color a square of size 'side' starting at x*side, y*side</span> +<span id="L158" class="LineNr">158 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='life.mu.html#L158'>render-square</a></span> _x: int, _y: int, color: int <span class="Delimiter">{</span> +<span id="L159" class="LineNr">159 </span> <span class="PreProc">var</span> y/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy _y +<span id="L160" class="LineNr">160 </span> y <span class="SpecialChar"><-</span> shift-left <span class="Constant">2</span>/log2side +<span id="L161" class="LineNr">161 </span> <span class="PreProc">var</span> side/<span class="Constant">ebx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">1</span> +<span id="L162" class="LineNr">162 </span> side <span class="SpecialChar"><-</span> shift-left <span class="Constant">2</span>/log2side +<span id="L163" class="LineNr">163 </span> <span class="PreProc">var</span> ymax/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy y +<span id="L164" class="LineNr">164 </span> ymax <span class="SpecialChar"><-</span> add side +<span id="L165" class="LineNr">165 </span> <span class="Delimiter">{</span> +<span id="L166" class="LineNr">166 </span> compare y, ymax +<span id="L167" class="LineNr">167 </span> <span class="PreProc">break-if->=</span> +<span id="L168" class="LineNr">168 </span> <span class="Delimiter">{</span> +<span id="L169" class="LineNr">169 </span> <span class="PreProc">var</span> x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy _x +<span id="L170" class="LineNr">170 </span> x <span class="SpecialChar"><-</span> shift-left <span class="Constant">2</span>/log2side +<span id="L171" class="LineNr">171 </span> <span class="PreProc">var</span> xmax/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy x +<span id="L172" class="LineNr">172 </span> xmax <span class="SpecialChar"><-</span> add side +<span id="L173" class="LineNr">173 </span> <span class="Delimiter">{</span> +<span id="L174" class="LineNr">174 </span> compare x, xmax +<span id="L175" class="LineNr">175 </span> <span class="PreProc">break-if->=</span> +<span id="L176" class="LineNr">176 </span> <a href='101screen.subx.html#L8'>pixel-on-real-screen</a> x, y, color +<span id="L177" class="LineNr">177 </span> x <span class="SpecialChar"><-</span> increment +<span id="L178" class="LineNr">178 </span> <span class="PreProc">loop</span> +<span id="L179" class="LineNr">179 </span> <span class="Delimiter">}</span> +<span id="L180" class="LineNr">180 </span> <span class="Delimiter">}</span> +<span id="L181" class="LineNr">181 </span> y <span class="SpecialChar"><-</span> increment +<span id="L182" class="LineNr">182 </span> <span class="PreProc">loop</span> +<span id="L183" class="LineNr">183 </span> <span class="Delimiter">}</span> +<span id="L184" class="LineNr">184 </span><span class="Delimiter">}</span> +<span id="L185" class="LineNr">185 </span> +<span id="L186" class="LineNr">186 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='life.mu.html#L186'>render</a></span> grid: (addr array boolean) <span class="Delimiter">{</span> +<span id="L187" class="LineNr">187 </span> <span class="PreProc">var</span> y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L188" class="LineNr">188 </span> <span class="Delimiter">{</span> +<span id="L189" class="LineNr">189 </span> compare y, <span class="Constant">0xc0</span>/height +<span id="L190" class="LineNr">190 </span> <span class="PreProc">break-if->=</span> +<span id="L191" class="LineNr">191 </span> <span class="PreProc">var</span> x/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> +<span id="L192" class="LineNr">192 </span> <span class="Delimiter">{</span> +<span id="L193" class="LineNr">193 </span> compare x, <span class="Constant">0x100</span>/width +<span id="L194" class="LineNr">194 </span> <span class="PreProc">break-if->=</span> +<span id="L195" class="LineNr">195 </span> <span class="PreProc">var</span> <a href='life.mu.html#L8'>state</a>/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='life.mu.html#L8'>state</a> grid, x, y +<span id="L196" class="LineNr">196 </span> compare <a href='life.mu.html#L8'>state</a>, <span class="Constant">0</span>/false +<span id="L197" class="LineNr">197 </span> <span class="Delimiter">{</span> +<span id="L198" class="LineNr">198 </span> <span class="PreProc">break-if-=</span> +<span id="L199" class="LineNr">199 </span> <a href='life.mu.html#L158'>render-square</a> x, y, <span class="Constant">3</span>/cyan +<span id="L200" class="LineNr">200 </span> <span class="Delimiter">}</span> +<span id="L201" class="LineNr">201 </span> compare <a href='life.mu.html#L8'>state</a>, <span class="Constant">0</span>/false +<span id="L202" class="LineNr">202 </span> <span class="Delimiter">{</span> +<span id="L203" class="LineNr">203 </span> <span class="PreProc">break-if-!=</span> +<span id="L204" class="LineNr">204 </span> <a href='life.mu.html#L158'>render-square</a> x, y, <span class="Constant">0</span>/black +<span id="L205" class="LineNr">205 </span> <span class="Delimiter">}</span> +<span id="L206" class="LineNr">206 </span> x <span class="SpecialChar"><-</span> increment +<span id="L207" class="LineNr">207 </span> <span class="PreProc">loop</span> +<span id="L208" class="LineNr">208 </span> <span class="Delimiter">}</span> +<span id="L209" class="LineNr">209 </span> y <span class="SpecialChar"><-</span> increment +<span id="L210" class="LineNr">210 </span> <span class="PreProc">loop</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='life.mu.html#L214'>main</a></span> <span class="Delimiter">{</span> +<span id="L215" class="LineNr">215 </span><span class="CommentedCode">#? # allocate on the stack</span> +<span id="L216" class="LineNr">216 </span><span class="CommentedCode">#? var grid1-storage: (array boolean 0xc000) # width * height</span> +<span id="L217" class="LineNr">217 </span><span class="CommentedCode">#? var grid1/esi: (addr array boolean) <- address grid1-storage</span> +<span id="L218" class="LineNr">218 </span><span class="CommentedCode">#? var grid2-storage: (array boolean 0xc000) # width * height</span> +<span id="L219" class="LineNr">219 </span><span class="CommentedCode">#? var grid2/edi: (addr array boolean) <- address grid2-storage</span> +<span id="L220" class="LineNr">220 </span> <span class="muComment"># allocate on the heap</span> +<span id="L221" class="LineNr">221 </span> <span class="PreProc">var</span> grid1-storage: (handle array boolean) +<span id="L222" class="LineNr">222 </span> <span class="PreProc">var</span> grid1-ah/<span class="Constant">eax</span>: (addr handle array boolean) <span class="SpecialChar"><-</span> address grid1-storage +<span id="L223" class="LineNr">223 </span> populate grid1-ah, <span class="Constant">0xc000</span> <span class="muComment"># width * height</span> +<span id="L224" class="LineNr">224 </span> <span class="PreProc">var</span> _grid1/<span class="Constant">eax</span>: (addr array boolean) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *grid1-ah +<span id="L225" class="LineNr">225 </span> <span class="PreProc">var</span> grid1/<span class="Constant">esi</span>: (addr array boolean) <span class="SpecialChar"><-</span> copy _grid1 +<span id="L226" class="LineNr">226 </span> <span class="PreProc">var</span> grid2-storage: (handle array boolean) +<span id="L227" class="LineNr">227 </span> <span class="PreProc">var</span> grid2-ah/<span class="Constant">eax</span>: (addr handle array boolean) <span class="SpecialChar"><-</span> address grid2-storage +<span id="L228" class="LineNr">228 </span> populate grid2-ah, <span class="Constant">0xc000</span> <span class="muComment"># width * height</span> +<span id="L229" class="LineNr">229 </span> <span class="PreProc">var</span> _grid2/<span class="Constant">eax</span>: (addr array boolean) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *grid2-ah +<span id="L230" class="LineNr">230 </span> <span class="PreProc">var</span> grid2/<span class="Constant">edi</span>: (addr array boolean) <span class="SpecialChar"><-</span> copy _grid2 +<span id="L231" class="LineNr">231 </span> <span class="muComment"># initialize grid1</span> +<span id="L232" class="LineNr">232 </span> <a href='life.mu.html#L38'>set-state</a> grid1, <span class="Constant">0x80</span>, <span class="Constant">0x5f</span>, <span class="Constant">1</span>/live +<span id="L233" class="LineNr">233 </span> <a href='life.mu.html#L38'>set-state</a> grid1, <span class="Constant">0x81</span>, <span class="Constant">0x5f</span>, <span class="Constant">1</span>/live +<span id="L234" class="LineNr">234 </span> <a href='life.mu.html#L38'>set-state</a> grid1, <span class="Constant">0x7f</span>, <span class="Constant">0x60</span>, <span class="Constant">1</span>/live +<span id="L235" class="LineNr">235 </span> <a href='life.mu.html#L38'>set-state</a> grid1, <span class="Constant">0x80</span>, <span class="Constant">0x60</span>, <span class="Constant">1</span>/live +<span id="L236" class="LineNr">236 </span> <a href='life.mu.html#L38'>set-state</a> grid1, <span class="Constant">0x80</span>, <span class="Constant">0x61</span>, <span class="Constant">1</span>/live +<span id="L237" class="LineNr">237 </span> <span class="muComment"># render grid1</span> +<span id="L238" class="LineNr">238 </span> <a href='life.mu.html#L186'>render</a> grid1 +<span id="L239" class="LineNr">239 </span> <span class="Delimiter">{</span> +<span id="L240" class="LineNr">240 </span> <span class="PreProc">var</span> key/<span class="Constant">eax</span>: byte <span class="SpecialChar"><-</span> <a href='102keyboard.subx.html#L9'>read-key</a> <span class="Constant">0</span>/keyboard +<span id="L241" class="LineNr">241 </span><span class="CommentedCode">#? # press key to step</span> +<span id="L242" class="LineNr">242 </span><span class="CommentedCode">#? compare key, 0</span> +<span id="L243" class="LineNr">243 </span><span class="CommentedCode">#? loop-if-=</span> +<span id="L244" class="LineNr">244 </span> <span class="muComment"># press key to quit</span> +<span id="L245" class="LineNr">245 </span> compare key, <span class="Constant">0</span> +<span id="L246" class="LineNr">246 </span> <span class="PreProc">break-if-!=</span> +<span id="L247" class="LineNr">247 </span> <span class="muComment"># iter: grid1 -> grid2</span> +<span id="L248" class="LineNr">248 </span> <a href='life.mu.html#L114'>step</a> grid1, grid2 +<span id="L249" class="LineNr">249 </span> <a href='life.mu.html#L186'>render</a> grid2 +<span id="L250" class="LineNr">250 </span> <span class="muComment"># iter: grid2 -> grid1</span> +<span id="L251" class="LineNr">251 </span> <a href='life.mu.html#L114'>step</a> grid2, grid1 +<span id="L252" class="LineNr">252 </span> <a href='life.mu.html#L186'>render</a> grid1 +<span id="L253" class="LineNr">253 </span> <span class="PreProc">loop</span> +<span id="L254" class="LineNr">254 </span> <span class="Delimiter">}</span> +<span id="L255" class="LineNr">255 </span><span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/baremetal/mu-init.subx.html b/html/baremetal/mu-init.subx.html index 9886ded4..440aab67 100644 --- a/html/baremetal/mu-init.subx.html +++ b/html/baremetal/mu-init.subx.html @@ -70,9 +70,9 @@ if ('onhashchange' in window) { <span id="L15" class="LineNr">15 </span>{ <span id="L16" class="LineNr">16 </span> 3d/compare-eax-and 0/imm32 <span id="L17" class="LineNr">17 </span> 75/jump-if-!= <span class="Constant">break</span>/disp8 -<span id="L18" class="LineNr">18 </span> (<a href='500text-screen.mu.html#L209'>clear-real-screen</a>) -<span id="L19" class="LineNr">19 </span> c7 0/subop/copy *<span class="SpecialChar"><a href='103grapheme.subx.html#L167'>Real-screen-cursor-x</a></span> 0/imm32 -<span id="L20" class="LineNr">20 </span> c7 0/subop/copy *<span class="SpecialChar"><a href='103grapheme.subx.html#L169'>Real-screen-cursor-y</a></span> 0/imm32 +<span id="L18" class="LineNr">18 </span> (<a href='500text-screen.mu.html#L226'>clear-real-screen</a>) +<span id="L19" class="LineNr">19 </span> c7 0/subop/copy *<span class="SpecialChar"><a href='103grapheme.subx.html#L170'>Real-screen-cursor-x</a></span> 0/imm32 +<span id="L20" class="LineNr">20 </span> c7 0/subop/copy *<span class="SpecialChar"><a href='103grapheme.subx.html#L172'>Real-screen-cursor-y</a></span> 0/imm32 <span id="L21" class="LineNr">21 </span> (main) <span id="L22" class="LineNr">22 </span>} <span id="L23" class="LineNr">23 </span> diff --git a/html/baremetal/rpn.mu.html b/html/baremetal/rpn.mu.html index 1ce25cca..1fd836f0 100644 --- a/html/baremetal/rpn.mu.html +++ b/html/baremetal/rpn.mu.html @@ -16,9 +16,9 @@ a { color:inherit; } * { font-size:12pt; font-size: 1em; } .PreProc { color: #c000c0; } .LineNr { } -.Delimiter { color: #c000c0; } -.SpecialChar { color: #d70000; } .Constant { color: #008787; } +.SpecialChar { color: #d70000; } +.Delimiter { color: #c000c0; } .muFunction { color: #af5f00; text-decoration: underline; } .muComment { color: #005faf; } --> @@ -73,7 +73,7 @@ if ('onhashchange' in window) { <span id="L15" class="LineNr"> 15 </span><span class="muComment">#</span> <span id="L16" class="LineNr"> 16 </span><span class="muComment"># Error handling is non-existent. This is just a prototype.</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='rpn.mu.html#L18'>main</a></span><span class="PreProc"> -> </span>_/<span class="Constant">ebx</span>: int <span class="Delimiter">{</span> +<span id="L18" class="LineNr"> 18 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='rpn.mu.html#L18'>main</a></span> <span class="Delimiter">{</span> <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="Constant">esi</span>: (addr stream byte) <span class="SpecialChar"><-</span> address in-storage <span id="L21" class="LineNr"> 21 </span> <span class="PreProc">var</span> y/<span class="Constant">ecx</span>: int <span class="SpecialChar"><-</span> copy <span class="Constant">0</span> @@ -81,134 +81,133 @@ if ('onhashchange' in window) { <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/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L73'>draw-text-rightward</a> <span class="Constant">0</span>, <span class="Constant">"> "</span>, <span class="Constant">0</span>, <span class="Constant">0x80</span>, y, <span class="Constant">3</span> -<span id="L27" class="LineNr"> 27 </span> <a href='500text-screen.mu.html#L115'>set-cursor-position</a> <span class="Constant">0</span>, x, y +<span id="L26" class="LineNr"> 26 </span> <span class="PreProc">var</span> x/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L81'>draw-text-rightward</a> <span class="Constant">0</span>/screen, <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> <a href='500text-screen.mu.html#L133'>set-cursor-position</a> <span class="Constant">0</span>/screen, x, y <span id="L28" class="LineNr"> 28 </span> <span class="muComment"># read line from keyboard</span> <span id="L29" class="LineNr"> 29 </span> <a href='106stream.subx.html#L20'>clear-stream</a> in <span id="L30" class="LineNr"> 30 </span> <span class="Delimiter">{</span> -<span id="L31" class="LineNr"> 31 </span> <a href='500text-screen.mu.html#L162'>show-cursor</a> <span class="Constant">0</span>, space -<span id="L32" class="LineNr"> 32 </span> <span class="PreProc">var</span> key/<span class="Constant">eax</span>: byte <span class="SpecialChar"><-</span> <a href='102keyboard.subx.html#L9'>read-key</a> <span class="Constant">0</span> -<span id="L33" class="LineNr"> 33 </span> compare key, <span class="Constant">0xa</span> <span class="muComment"># newline</span> +<span id="L31" class="LineNr"> 31 </span> <a href='500text-screen.mu.html#L180'>show-cursor</a> <span class="Constant">0</span>/screen, space +<span id="L32" class="LineNr"> 32 </span> <span class="PreProc">var</span> key/<span class="Constant">eax</span>: byte <span class="SpecialChar"><-</span> <a href='102keyboard.subx.html#L9'>read-key</a> <span class="Constant">0</span>/keyboard +<span id="L33" class="LineNr"> 33 </span> compare key, <span class="Constant">0xa</span>/newline <span id="L34" class="LineNr"> 34 </span> <span class="PreProc">break-if-=</span> <span id="L35" class="LineNr"> 35 </span> compare key, <span class="Constant">0</span> <span id="L36" class="LineNr"> 36 </span> <span class="PreProc">loop-if-=</span> <span id="L37" class="LineNr"> 37 </span> <span class="PreProc">var</span> key2/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy key <span id="L38" class="LineNr"> 38 </span> <a href='115write-byte.subx.html#L12'>append-byte</a> in, key2 <span id="L39" class="LineNr"> 39 </span> <span class="PreProc">var</span> g/<span class="Constant">eax</span>: grapheme <span class="SpecialChar"><-</span> copy key2 -<span id="L40" class="LineNr"> 40 </span> <a href='501draw-text.mu.html#L63'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>, g, <span class="Constant">0xf</span> -<span id="L41" class="LineNr"> 41 </span> <a href='501draw-text.mu.html#L16'>cursor-right</a> <span class="Constant">0</span> +<span id="L40" class="LineNr"> 40 </span> <a href='501draw-text.mu.html#L65'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>/screen, g, <span class="Constant">0xf</span>/fg, <span class="Constant">0</span>/bg +<span id="L41" class="LineNr"> 41 </span> <a href='501draw-text.mu.html#L16'>move-cursor-right</a> <span class="Constant">0</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="muComment"># clear cursor</span> -<span id="L45" class="LineNr"> 45 </span> <a href='501draw-text.mu.html#L63'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>, space, <span class="Constant">3</span> <span class="muComment"># 3=foreground color, which is never used</span> +<span id="L45" class="LineNr"> 45 </span> <a href='501draw-text.mu.html#L65'>draw-grapheme-at-cursor</a> <span class="Constant">0</span>/screen, space, <span class="Constant">3</span>/fg/never-used, <span class="Constant">0</span>/bg <span id="L46" class="LineNr"> 46 </span> <span class="muComment"># parse and eval</span> -<span id="L47" class="LineNr"> 47 </span> <span class="PreProc">var</span> out/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L64'>simplify</a> in +<span id="L47" class="LineNr"> 47 </span> <span class="PreProc">var</span> out/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L63'>simplify</a> in <span id="L48" class="LineNr"> 48 </span> <span class="muComment"># print</span> <span id="L49" class="LineNr"> 49 </span> y <span class="SpecialChar"><-</span> increment -<span id="L50" class="LineNr"> 50 </span> out, y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L292'>draw-int32-decimal-wrapping-right-then-down</a> <span class="Constant">0</span>, out, <span class="Constant">0</span>, y, <span class="Constant">0x80</span>, <span class="Constant">0x30</span>, <span class="Constant">0</span>, y, <span class="Constant">7</span> +<span id="L50" class="LineNr"> 50 </span> out, y <span class="SpecialChar"><-</span> <a href='501draw-text.mu.html#L308'>draw-int32-decimal-wrapping-right-then-down</a> <span class="Constant">0</span>/screen, 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="L51" class="LineNr"> 51 </span> <span class="muComment"># newline</span> <span id="L52" class="LineNr"> 52 </span> y <span class="SpecialChar"><-</span> increment <span id="L53" class="LineNr"> 53 </span> <span class="muComment">#</span> <span id="L54" class="LineNr"> 54 </span> <span class="PreProc">loop</span> <span id="L55" class="LineNr"> 55 </span> <span class="Delimiter">}</span> -<span id="L56" class="LineNr"> 56 </span> <span class="PreProc">return</span> <span class="Constant">0</span> -<span id="L57" class="LineNr"> 57 </span><span class="Delimiter">}</span> -<span id="L58" class="LineNr"> 58 </span> -<span id="L59" class="LineNr"> 59 </span><span class="PreProc">type</span> <a href='rpn.mu.html#L59'>int-stack</a> <span class="Delimiter">{</span> -<span id="L60" class="LineNr"> 60 </span> data: (handle array int) -<span id="L61" class="LineNr"> 61 </span> top: int -<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='rpn.mu.html#L64'>simplify</a></span> in: (addr stream byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> -<span id="L65" class="LineNr"> 65 </span> <span class="PreProc">var</span> word-storage: slice -<span id="L66" class="LineNr"> 66 </span> <span class="PreProc">var</span> word/<span class="Constant">ecx</span>: (addr slice) <span class="SpecialChar"><-</span> address word-storage -<span id="L67" class="LineNr"> 67 </span> <span class="PreProc">var</span> stack-storage: <a href='rpn.mu.html#L59'>int-stack</a> -<span id="L68" class="LineNr"> 68 </span> <span class="PreProc">var</span> stack/<span class="Constant">esi</span>: (addr <a href='rpn.mu.html#L59'>int-stack</a>) <span class="SpecialChar"><-</span> address stack-storage -<span id="L69" class="LineNr"> 69 </span> <a href='rpn.mu.html#L118'>initialize-int-stack</a> stack, <span class="Constant">0x10</span> -<span id="L70" class="LineNr"> 70 </span> $simplify:word-loop: <span class="Delimiter">{</span> -<span id="L71" class="LineNr"> 71 </span> <a href='127next-word.subx.html#L11'>next-word</a> in, word -<span id="L72" class="LineNr"> 72 </span> <span class="PreProc">var</span> done?/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='123slice.subx.html#L9'>slice-empty?</a> word -<span id="L73" class="LineNr"> 73 </span> compare done?, <span class="Constant">0</span> -<span id="L74" class="LineNr"> 74 </span> <span class="PreProc">break-if-!=</span> -<span id="L75" class="LineNr"> 75 </span> <span class="muComment"># if word is an operator, perform it</span> -<span id="L76" class="LineNr"> 76 </span> <span class="Delimiter">{</span> -<span id="L77" class="LineNr"> 77 </span> <span class="PreProc">var</span> is-add?/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='123slice.subx.html#L120'>slice-equal?</a> word, <span class="Constant">"+"</span> -<span id="L78" class="LineNr"> 78 </span> compare is-add?, <span class="Constant">0</span> -<span id="L79" class="LineNr"> 79 </span> <span class="PreProc">break-if-=</span> -<span id="L80" class="LineNr"> 80 </span> <span class="PreProc">var</span> _b/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L138'>pop-int-stack</a> stack -<span id="L81" class="LineNr"> 81 </span> <span class="PreProc">var</span> b/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy _b -<span id="L82" class="LineNr"> 82 </span> <span class="PreProc">var</span> a/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L138'>pop-int-stack</a> stack -<span id="L83" class="LineNr"> 83 </span> a <span class="SpecialChar"><-</span> add b -<span id="L84" class="LineNr"> 84 </span> <a href='rpn.mu.html#L126'>push-int-stack</a> stack, a -<span id="L85" class="LineNr"> 85 </span> <span class="PreProc">loop</span> $simplify:word-loop -<span id="L86" class="LineNr"> 86 </span> <span class="Delimiter">}</span> -<span id="L87" class="LineNr"> 87 </span> <span class="Delimiter">{</span> -<span id="L88" class="LineNr"> 88 </span> <span class="PreProc">var</span> is-sub?/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='123slice.subx.html#L120'>slice-equal?</a> word, <span class="Constant">"-"</span> -<span id="L89" class="LineNr"> 89 </span> compare is-sub?, <span class="Constant">0</span> -<span id="L90" class="LineNr"> 90 </span> <span class="PreProc">break-if-=</span> -<span id="L91" class="LineNr"> 91 </span> <span class="PreProc">var</span> _b/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L138'>pop-int-stack</a> stack -<span id="L92" class="LineNr"> 92 </span> <span class="PreProc">var</span> b/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy _b -<span id="L93" class="LineNr"> 93 </span> <span class="PreProc">var</span> a/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L138'>pop-int-stack</a> stack -<span id="L94" class="LineNr"> 94 </span> a <span class="SpecialChar"><-</span> subtract b -<span id="L95" class="LineNr"> 95 </span> <a href='rpn.mu.html#L126'>push-int-stack</a> stack, a -<span id="L96" class="LineNr"> 96 </span> <span class="PreProc">loop</span> $simplify:word-loop -<span id="L97" class="LineNr"> 97 </span> <span class="Delimiter">}</span> -<span id="L98" class="LineNr"> 98 </span> <span class="Delimiter">{</span> -<span id="L99" class="LineNr"> 99 </span> <span class="PreProc">var</span> is-mul?/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='123slice.subx.html#L120'>slice-equal?</a> word, <span class="Constant">"*"</span> -<span id="L100" class="LineNr">100 </span> compare is-mul?, <span class="Constant">0</span> -<span id="L101" class="LineNr">101 </span> <span class="PreProc">break-if-=</span> -<span id="L102" class="LineNr">102 </span> <span class="PreProc">var</span> _b/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L138'>pop-int-stack</a> stack -<span id="L103" class="LineNr">103 </span> <span class="PreProc">var</span> b/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy _b -<span id="L104" class="LineNr">104 </span> <span class="PreProc">var</span> a/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L138'>pop-int-stack</a> stack -<span id="L105" class="LineNr">105 </span> a <span class="SpecialChar"><-</span> multiply b -<span id="L106" class="LineNr">106 </span> <a href='rpn.mu.html#L126'>push-int-stack</a> stack, a -<span id="L107" class="LineNr">107 </span> <span class="PreProc">loop</span> $simplify:word-loop -<span id="L108" class="LineNr">108 </span> <span class="Delimiter">}</span> -<span id="L109" class="LineNr">109 </span> <span class="muComment"># otherwise it's an int</span> -<span id="L110" class="LineNr">110 </span> <span class="PreProc">var</span> n/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='311decimal-int.subx.html#L4'>parse-decimal-int-from-slice</a> word -<span id="L111" class="LineNr">111 </span> <a href='rpn.mu.html#L126'>push-int-stack</a> stack, n -<span id="L112" class="LineNr">112 </span> <span class="PreProc">loop</span> -<span id="L113" class="LineNr">113 </span> <span class="Delimiter">}</span> -<span id="L114" class="LineNr">114 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L138'>pop-int-stack</a> stack -<span id="L115" class="LineNr">115 </span> <span class="PreProc">return</span> result -<span id="L116" class="LineNr">116 </span><span class="Delimiter">}</span> -<span id="L117" class="LineNr">117 </span> -<span id="L118" class="LineNr">118 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='rpn.mu.html#L118'>initialize-int-stack</a></span> _self: (addr <a href='rpn.mu.html#L59'>int-stack</a>), n: int <span class="Delimiter">{</span> -<span id="L119" class="LineNr">119 </span> <span class="PreProc">var</span> self/<span class="Constant">esi</span>: (addr <a href='rpn.mu.html#L59'>int-stack</a>) <span class="SpecialChar"><-</span> copy _self -<span id="L120" class="LineNr">120 </span> <span class="PreProc">var</span> d/<span class="Constant">edi</span>: (addr handle array int) <span class="SpecialChar"><-</span> get self, data -<span id="L121" class="LineNr">121 </span> populate d, n -<span id="L122" class="LineNr">122 </span> <span class="PreProc">var</span> top/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> get self, top -<span id="L123" class="LineNr">123 </span> copy-to *top, <span class="Constant">0</span> -<span id="L124" class="LineNr">124 </span><span class="Delimiter">}</span> -<span id="L125" class="LineNr">125 </span> -<span id="L126" class="LineNr">126 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='rpn.mu.html#L126'>push-int-stack</a></span> _self: (addr <a href='rpn.mu.html#L59'>int-stack</a>), _val: int <span class="Delimiter">{</span> -<span id="L127" class="LineNr">127 </span> <span class="PreProc">var</span> self/<span class="Constant">esi</span>: (addr <a href='rpn.mu.html#L59'>int-stack</a>) <span class="SpecialChar"><-</span> copy _self -<span id="L128" class="LineNr">128 </span> <span class="PreProc">var</span> top-addr/<span class="Constant">ecx</span>: (addr int) <span class="SpecialChar"><-</span> get self, top -<span id="L129" class="LineNr">129 </span> <span class="PreProc">var</span> data-ah/<span class="Constant">edx</span>: (addr handle array int) <span class="SpecialChar"><-</span> get self, data -<span id="L130" class="LineNr">130 </span> <span class="PreProc">var</span> data/<span class="Constant">eax</span>: (addr array int) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *data-ah -<span id="L131" class="LineNr">131 </span> <span class="PreProc">var</span> top/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy *top-addr -<span id="L132" class="LineNr">132 </span> <span class="PreProc">var</span> dest-addr/<span class="Constant">edx</span>: (addr int) <span class="SpecialChar"><-</span> index data, top -<span id="L133" class="LineNr">133 </span> <span class="PreProc">var</span> val/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy _val -<span id="L134" class="LineNr">134 </span> copy-to *dest-addr, val -<span id="L135" class="LineNr">135 </span> add-to *top-addr, <span class="Constant">1</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='rpn.mu.html#L138'>pop-int-stack</a></span> _self: (addr <a href='rpn.mu.html#L59'>int-stack</a>)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> -<span id="L139" class="LineNr">139 </span> <span class="PreProc">var</span> self/<span class="Constant">esi</span>: (addr <a href='rpn.mu.html#L59'>int-stack</a>) <span class="SpecialChar"><-</span> copy _self -<span id="L140" class="LineNr">140 </span> <span class="PreProc">var</span> top-addr/<span class="Constant">ecx</span>: (addr int) <span class="SpecialChar"><-</span> get self, top -<span id="L141" class="LineNr">141 </span> <span class="Delimiter">{</span> -<span id="L142" class="LineNr">142 </span> compare *top-addr, <span class="Constant">0</span> -<span id="L143" class="LineNr">143 </span> <span class="PreProc">break-if-></span> -<span id="L144" class="LineNr">144 </span> <span class="PreProc">return</span> <span class="Constant">0</span> -<span id="L145" class="LineNr">145 </span> <span class="Delimiter">}</span> -<span id="L146" class="LineNr">146 </span> subtract-from *top-addr, <span class="Constant">1</span> -<span id="L147" class="LineNr">147 </span> <span class="PreProc">var</span> data-ah/<span class="Constant">edx</span>: (addr handle array int) <span class="SpecialChar"><-</span> get self, data -<span id="L148" class="LineNr">148 </span> <span class="PreProc">var</span> data/<span class="Constant">eax</span>: (addr array int) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *data-ah -<span id="L149" class="LineNr">149 </span> <span class="PreProc">var</span> top/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy *top-addr -<span id="L150" class="LineNr">150 </span> <span class="PreProc">var</span> result-addr/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> index data, top -<span id="L151" class="LineNr">151 </span> <span class="PreProc">var</span> val/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy *result-addr -<span id="L152" class="LineNr">152 </span> <span class="PreProc">return</span> val -<span id="L153" class="LineNr">153 </span><span class="Delimiter">}</span> +<span id="L56" class="LineNr"> 56 </span><span class="Delimiter">}</span> +<span id="L57" class="LineNr"> 57 </span> +<span id="L58" class="LineNr"> 58 </span><span class="PreProc">type</span> <a href='rpn.mu.html#L58'>int-stack</a> <span class="Delimiter">{</span> +<span id="L59" class="LineNr"> 59 </span> data: (handle array int) +<span id="L60" class="LineNr"> 60 </span> top: int +<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="PreProc">fn</span> <span class="muFunction"><a href='rpn.mu.html#L63'>simplify</a></span> in: (addr stream byte)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L64" class="LineNr"> 64 </span> <span class="PreProc">var</span> word-storage: slice +<span id="L65" class="LineNr"> 65 </span> <span class="PreProc">var</span> word/<span class="Constant">ecx</span>: (addr slice) <span class="SpecialChar"><-</span> address word-storage +<span id="L66" class="LineNr"> 66 </span> <span class="PreProc">var</span> stack-storage: <a href='rpn.mu.html#L58'>int-stack</a> +<span id="L67" class="LineNr"> 67 </span> <span class="PreProc">var</span> stack/<span class="Constant">esi</span>: (addr <a href='rpn.mu.html#L58'>int-stack</a>) <span class="SpecialChar"><-</span> address stack-storage +<span id="L68" class="LineNr"> 68 </span> <a href='rpn.mu.html#L117'>initialize-int-stack</a> stack, <span class="Constant">0x10</span> +<span id="L69" class="LineNr"> 69 </span> $simplify:word-loop: <span class="Delimiter">{</span> +<span id="L70" class="LineNr"> 70 </span> <a href='127next-word.subx.html#L11'>next-word</a> in, word +<span id="L71" class="LineNr"> 71 </span> <span class="PreProc">var</span> done?/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='123slice.subx.html#L9'>slice-empty?</a> word +<span id="L72" class="LineNr"> 72 </span> compare done?, <span class="Constant">0</span> +<span id="L73" class="LineNr"> 73 </span> <span class="PreProc">break-if-!=</span> +<span id="L74" class="LineNr"> 74 </span> <span class="muComment"># if word is an operator, perform it</span> +<span id="L75" class="LineNr"> 75 </span> <span class="Delimiter">{</span> +<span id="L76" class="LineNr"> 76 </span> <span class="PreProc">var</span> is-add?/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='123slice.subx.html#L120'>slice-equal?</a> word, <span class="Constant">"+"</span> +<span id="L77" class="LineNr"> 77 </span> compare is-add?, <span class="Constant">0</span> +<span id="L78" class="LineNr"> 78 </span> <span class="PreProc">break-if-=</span> +<span id="L79" class="LineNr"> 79 </span> <span class="PreProc">var</span> _b/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L137'>pop-int-stack</a> stack +<span id="L80" class="LineNr"> 80 </span> <span class="PreProc">var</span> b/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy _b +<span id="L81" class="LineNr"> 81 </span> <span class="PreProc">var</span> a/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L137'>pop-int-stack</a> stack +<span id="L82" class="LineNr"> 82 </span> a <span class="SpecialChar"><-</span> add b +<span id="L83" class="LineNr"> 83 </span> <a href='rpn.mu.html#L125'>push-int-stack</a> stack, a +<span id="L84" class="LineNr"> 84 </span> <span class="PreProc">loop</span> $simplify:word-loop +<span id="L85" class="LineNr"> 85 </span> <span class="Delimiter">}</span> +<span id="L86" class="LineNr"> 86 </span> <span class="Delimiter">{</span> +<span id="L87" class="LineNr"> 87 </span> <span class="PreProc">var</span> is-sub?/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='123slice.subx.html#L120'>slice-equal?</a> word, <span class="Constant">"-"</span> +<span id="L88" class="LineNr"> 88 </span> compare is-sub?, <span class="Constant">0</span> +<span id="L89" class="LineNr"> 89 </span> <span class="PreProc">break-if-=</span> +<span id="L90" class="LineNr"> 90 </span> <span class="PreProc">var</span> _b/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L137'>pop-int-stack</a> stack +<span id="L91" class="LineNr"> 91 </span> <span class="PreProc">var</span> b/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy _b +<span id="L92" class="LineNr"> 92 </span> <span class="PreProc">var</span> a/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L137'>pop-int-stack</a> stack +<span id="L93" class="LineNr"> 93 </span> a <span class="SpecialChar"><-</span> subtract b +<span id="L94" class="LineNr"> 94 </span> <a href='rpn.mu.html#L125'>push-int-stack</a> stack, a +<span id="L95" class="LineNr"> 95 </span> <span class="PreProc">loop</span> $simplify:word-loop +<span id="L96" class="LineNr"> 96 </span> <span class="Delimiter">}</span> +<span id="L97" class="LineNr"> 97 </span> <span class="Delimiter">{</span> +<span id="L98" class="LineNr"> 98 </span> <span class="PreProc">var</span> is-mul?/<span class="Constant">eax</span>: boolean <span class="SpecialChar"><-</span> <a href='123slice.subx.html#L120'>slice-equal?</a> word, <span class="Constant">"*"</span> +<span id="L99" class="LineNr"> 99 </span> compare is-mul?, <span class="Constant">0</span> +<span id="L100" class="LineNr">100 </span> <span class="PreProc">break-if-=</span> +<span id="L101" class="LineNr">101 </span> <span class="PreProc">var</span> _b/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L137'>pop-int-stack</a> stack +<span id="L102" class="LineNr">102 </span> <span class="PreProc">var</span> b/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy _b +<span id="L103" class="LineNr">103 </span> <span class="PreProc">var</span> a/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L137'>pop-int-stack</a> stack +<span id="L104" class="LineNr">104 </span> a <span class="SpecialChar"><-</span> multiply b +<span id="L105" class="LineNr">105 </span> <a href='rpn.mu.html#L125'>push-int-stack</a> stack, a +<span id="L106" class="LineNr">106 </span> <span class="PreProc">loop</span> $simplify:word-loop +<span id="L107" class="LineNr">107 </span> <span class="Delimiter">}</span> +<span id="L108" class="LineNr">108 </span> <span class="muComment"># otherwise it's an int</span> +<span id="L109" class="LineNr">109 </span> <span class="PreProc">var</span> n/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='311decimal-int.subx.html#L4'>parse-decimal-int-from-slice</a> word +<span id="L110" class="LineNr">110 </span> <a href='rpn.mu.html#L125'>push-int-stack</a> stack, n +<span id="L111" class="LineNr">111 </span> <span class="PreProc">loop</span> +<span id="L112" class="LineNr">112 </span> <span class="Delimiter">}</span> +<span id="L113" class="LineNr">113 </span> <span class="PreProc">var</span> result/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> <a href='rpn.mu.html#L137'>pop-int-stack</a> stack +<span id="L114" class="LineNr">114 </span> <span class="PreProc">return</span> result +<span id="L115" class="LineNr">115 </span><span class="Delimiter">}</span> +<span id="L116" class="LineNr">116 </span> +<span id="L117" class="LineNr">117 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='rpn.mu.html#L117'>initialize-int-stack</a></span> _self: (addr <a href='rpn.mu.html#L58'>int-stack</a>), n: int <span class="Delimiter">{</span> +<span id="L118" class="LineNr">118 </span> <span class="PreProc">var</span> self/<span class="Constant">esi</span>: (addr <a href='rpn.mu.html#L58'>int-stack</a>) <span class="SpecialChar"><-</span> copy _self +<span id="L119" class="LineNr">119 </span> <span class="PreProc">var</span> d/<span class="Constant">edi</span>: (addr handle array int) <span class="SpecialChar"><-</span> get self, data +<span id="L120" class="LineNr">120 </span> populate d, n +<span id="L121" class="LineNr">121 </span> <span class="PreProc">var</span> top/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> get self, top +<span id="L122" class="LineNr">122 </span> copy-to *top, <span class="Constant">0</span> +<span id="L123" class="LineNr">123 </span><span class="Delimiter">}</span> +<span id="L124" class="LineNr">124 </span> +<span id="L125" class="LineNr">125 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='rpn.mu.html#L125'>push-int-stack</a></span> _self: (addr <a href='rpn.mu.html#L58'>int-stack</a>), _val: int <span class="Delimiter">{</span> +<span id="L126" class="LineNr">126 </span> <span class="PreProc">var</span> self/<span class="Constant">esi</span>: (addr <a href='rpn.mu.html#L58'>int-stack</a>) <span class="SpecialChar"><-</span> copy _self +<span id="L127" class="LineNr">127 </span> <span class="PreProc">var</span> top-addr/<span class="Constant">ecx</span>: (addr int) <span class="SpecialChar"><-</span> get self, top +<span id="L128" class="LineNr">128 </span> <span class="PreProc">var</span> data-ah/<span class="Constant">edx</span>: (addr handle array int) <span class="SpecialChar"><-</span> get self, data +<span id="L129" class="LineNr">129 </span> <span class="PreProc">var</span> data/<span class="Constant">eax</span>: (addr array int) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *data-ah +<span id="L130" class="LineNr">130 </span> <span class="PreProc">var</span> top/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy *top-addr +<span id="L131" class="LineNr">131 </span> <span class="PreProc">var</span> dest-addr/<span class="Constant">edx</span>: (addr int) <span class="SpecialChar"><-</span> index data, top +<span id="L132" class="LineNr">132 </span> <span class="PreProc">var</span> val/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy _val +<span id="L133" class="LineNr">133 </span> copy-to *dest-addr, val +<span id="L134" class="LineNr">134 </span> add-to *top-addr, <span class="Constant">1</span> +<span id="L135" class="LineNr">135 </span><span class="Delimiter">}</span> +<span id="L136" class="LineNr">136 </span> +<span id="L137" class="LineNr">137 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='rpn.mu.html#L137'>pop-int-stack</a></span> _self: (addr <a href='rpn.mu.html#L58'>int-stack</a>)<span class="PreProc"> -> </span>_/<span class="Constant">eax</span>: int <span class="Delimiter">{</span> +<span id="L138" class="LineNr">138 </span> <span class="PreProc">var</span> self/<span class="Constant">esi</span>: (addr <a href='rpn.mu.html#L58'>int-stack</a>) <span class="SpecialChar"><-</span> copy _self +<span id="L139" class="LineNr">139 </span> <span class="PreProc">var</span> top-addr/<span class="Constant">ecx</span>: (addr int) <span class="SpecialChar"><-</span> get self, top +<span id="L140" class="LineNr">140 </span> <span class="Delimiter">{</span> +<span id="L141" class="LineNr">141 </span> compare *top-addr, <span class="Constant">0</span> +<span id="L142" class="LineNr">142 </span> <span class="PreProc">break-if-></span> +<span id="L143" class="LineNr">143 </span> <span class="PreProc">return</span> <span class="Constant">0</span> +<span id="L144" class="LineNr">144 </span> <span class="Delimiter">}</span> +<span id="L145" class="LineNr">145 </span> subtract-from *top-addr, <span class="Constant">1</span> +<span id="L146" class="LineNr">146 </span> <span class="PreProc">var</span> data-ah/<span class="Constant">edx</span>: (addr handle array int) <span class="SpecialChar"><-</span> get self, data +<span id="L147" class="LineNr">147 </span> <span class="PreProc">var</span> data/<span class="Constant">eax</span>: (addr array int) <span class="SpecialChar"><-</span> <a href='120allocate.subx.html#L226'>lookup</a> *data-ah +<span id="L148" class="LineNr">148 </span> <span class="PreProc">var</span> top/<span class="Constant">edx</span>: int <span class="SpecialChar"><-</span> copy *top-addr +<span id="L149" class="LineNr">149 </span> <span class="PreProc">var</span> result-addr/<span class="Constant">eax</span>: (addr int) <span class="SpecialChar"><-</span> index data, top +<span id="L150" class="LineNr">150 </span> <span class="PreProc">var</span> val/<span class="Constant">eax</span>: int <span class="SpecialChar"><-</span> copy *result-addr +<span id="L151" class="LineNr">151 </span> <span class="PreProc">return</span> val +<span id="L152" class="LineNr">152 </span><span class="Delimiter">}</span> </pre> </body> </html> |