about summary refs log tree commit diff stats
path: root/html/apps/factorial.subx.html
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-08-31 22:34:56 -0700
committerKartik Agaram <vc@akkartik.com>2019-08-31 22:34:56 -0700
commit518429b1cbb193d31416e02e660908469b96a459 (patch)
treecd89135d66f07f49f6dbf3670dba214b66517855 /html/apps/factorial.subx.html
parent5008a4ec4e21a73246b354758d6a68bb9b33f78f (diff)
downloadmu-518429b1cbb193d31416e02e660908469b96a459.tar.gz
5598
Diffstat (limited to 'html/apps/factorial.subx.html')
-rw-r--r--html/apps/factorial.subx.html89
1 files changed, 44 insertions, 45 deletions
diff --git a/html/apps/factorial.subx.html b/html/apps/factorial.subx.html
index f8e53ba6..67bfaf84 100644
--- a/html/apps/factorial.subx.html
+++ b/html/apps/factorial.subx.html
@@ -134,52 +134,51 @@ if ('onhashchange' in window) {
 <span id="L73" class="LineNr"> 73 </span>    55/push-ebp
 <span id="L74" class="LineNr"> 74 </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="L75" class="LineNr"> 75 </span>    53/push-ebx
-<span id="L76" class="LineNr"> 76 </span>    <span class="subxComment"># eax = 1 (base case)</span>
+<span id="L76" class="LineNr"> 76 </span>    <span class="subxComment"># if (n &lt;= 1) return 1</span>
 <span id="L77" class="LineNr"> 77 </span>    b8/copy-to-eax  1/imm32
-<span id="L78" class="LineNr"> 78 </span>    <span class="subxComment"># if (n &lt;= 1) return</span>
-<span id="L79" class="LineNr"> 79 </span>    81          7/subop/compare     1/mod/*+disp8   5/rm32/ebp   <span class="Normal"> . </span>         <span class="Normal"> . </span>           <span class="Normal"> . </span>         <span class="Normal"> . </span>          8/disp8         1/imm32           <span class="subxComment"># compare *(ebp+8)</span>
-<span id="L80" class="LineNr"> 80 </span>    7e/jump-if-&lt;=  $factorial:end/disp8
-<span id="L81" class="LineNr"> 81 </span>    <span class="subxComment"># ebx = n-1</span>
-<span id="L82" class="LineNr"> 82 </span>    8b/copy                         1/mod/*+disp8   5/rm32/ebp   <span class="Normal"> . </span>         <span class="Normal"> . </span>                        3/r32/ebx   8/disp8        <span class="Normal"> . </span>                <span class="subxComment"># copy *(ebp+8) to ebx</span>
-<span id="L83" class="LineNr"> 83 </span>    81          5/subop/subtract    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>              1/imm32           <span class="subxComment"># subtract from ebx</span>
-<span id="L84" class="LineNr"> 84 </span>    <span class="subxComment"># eax = factorial(n-1)</span>
-<span id="L85" class="LineNr"> 85 </span>    <span class="subxS2Comment"># . . push args</span>
-<span id="L86" class="LineNr"> 86 </span>    53/push-ebx
-<span id="L87" class="LineNr"> 87 </span>    <span class="subxS2Comment"># . . call</span>
-<span id="L88" class="LineNr"> 88 </span>    e8/call  <a href='factorial.subx.html#L71'>factorial</a>/disp32
-<span id="L89" class="LineNr"> 89 </span>    <span class="subxS2Comment"># . . discard args</span>
-<span id="L90" class="LineNr"> 90 </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="L91" class="LineNr"> 91 </span>    <span class="subxComment"># return n * factorial(n-1)</span>
-<span id="L92" class="LineNr"> 92 </span>    f7          4/subop/multiply    1/mod/*+disp8   5/rm32/ebp   <span class="Normal"> . </span>         <span class="Normal"> . </span>                                    8/disp8        <span class="Normal"> . </span>                <span class="subxComment"># multiply *(ebp+8) into eax</span>
-<span id="L93" class="LineNr"> 93 </span>    <span class="subxComment"># TODO: check for overflow</span>
-<span id="L94" class="LineNr"> 94 </span><span class="Constant">$factorial:end</span>:
-<span id="L95" class="LineNr"> 95 </span>    <span class="subxS1Comment"># . epilog</span>
-<span id="L96" class="LineNr"> 96 </span>    5b/pop-to-ebx
-<span id="L97" class="LineNr"> 97 </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="L98" class="LineNr"> 98 </span>    5d/pop-to-ebp
-<span id="L99" class="LineNr"> 99 </span>    c3/return
-<span id="L100" class="LineNr">100 </span>
-<span id="L101" class="LineNr">101 </span><span class="subxTest">test-factorial</span>:
-<span id="L102" class="LineNr">102 </span>    <span class="subxComment"># factorial(5)</span>
-<span id="L103" class="LineNr">103 </span>    <span class="subxS2Comment"># . . push args</span>
-<span id="L104" class="LineNr">104 </span>    68/push  5/imm32
-<span id="L105" class="LineNr">105 </span>    <span class="subxS2Comment"># . . call</span>
-<span id="L106" class="LineNr">106 </span>    e8/call  <a href='factorial.subx.html#L71'>factorial</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>              4/imm32           <span class="subxComment"># add to esp</span>
-<span id="L109" class="LineNr">109 </span>    <span class="subxComment"># check-ints-equal(eax, 120, msg)</span>
-<span id="L110" class="LineNr">110 </span>    <span class="subxS2Comment"># . . push args</span>
-<span id="L111" class="LineNr">111 </span>    68/push  <span class="Constant">&quot;F - test-factorial&quot;</span>/imm32
-<span id="L112" class="LineNr">112 </span>    68/push  0x78/imm32/expected-120
-<span id="L113" class="LineNr">113 </span>    50/push-eax
-<span id="L114" class="LineNr">114 </span>    <span class="subxS2Comment"># . . call</span>
-<span id="L115" class="LineNr">115 </span>    e8/call  <a href='../051test.subx.html#L24'>check-ints-equal</a>/disp32
-<span id="L116" class="LineNr">116 </span>    <span class="subxS2Comment"># . . discard args</span>
-<span id="L117" class="LineNr">117 </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="L118" class="LineNr">118 </span>    <span class="subxComment"># end</span>
-<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="subxS2Comment"># . . vim&#0058;nowrap:textwidth=0</span>
+<span id="L78" class="LineNr"> 78 </span>    81          7/subop/compare     1/mod/*+disp8   5/rm32/ebp   <span class="Normal"> . </span>         <span class="Normal"> . </span>           <span class="Normal"> . </span>         <span class="Normal"> . </span>          8/disp8         1/imm32           <span class="subxComment"># compare *(ebp+8)</span>
+<span id="L79" class="LineNr"> 79 </span>    7e/jump-if-&lt;=  $factorial:end/disp8
+<span id="L80" class="LineNr"> 80 </span>    <span class="subxComment"># ebx = n-1</span>
+<span id="L81" class="LineNr"> 81 </span>    8b/copy                         1/mod/*+disp8   5/rm32/ebp   <span class="Normal"> . </span>         <span class="Normal"> . </span>                        3/r32/ebx   8/disp8        <span class="Normal"> . </span>                <span class="subxComment"># copy *(ebp+8) to ebx</span>
+<span id="L82" class="LineNr"> 82 </span>    81          5/subop/subtract    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>              1/imm32           <span class="subxComment"># subtract from ebx</span>
+<span id="L83" class="LineNr"> 83 </span>    <span class="subxComment"># eax = factorial(n-1)</span>
+<span id="L84" class="LineNr"> 84 </span>    <span class="subxS2Comment"># . . push args</span>
+<span id="L85" class="LineNr"> 85 </span>    53/push-ebx
+<span id="L86" class="LineNr"> 86 </span>    <span class="subxS2Comment"># . . call</span>
+<span id="L87" class="LineNr"> 87 </span>    e8/call  <a href='factorial.subx.html#L71'>factorial</a>/disp32
+<span id="L88" class="LineNr"> 88 </span>    <span class="subxS2Comment"># . . discard args</span>
+<span id="L89" class="LineNr"> 89 </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="L90" class="LineNr"> 90 </span>    <span class="subxComment"># return n * factorial(n-1)</span>
+<span id="L91" class="LineNr"> 91 </span>    f7          4/subop/multiply    1/mod/*+disp8   5/rm32/ebp   <span class="Normal"> . </span>         <span class="Normal"> . </span>                                    8/disp8        <span class="Normal"> . </span>                <span class="subxComment"># multiply *(ebp+8) into eax</span>
+<span id="L92" class="LineNr"> 92 </span>    <span class="subxComment"># TODO: check for overflow</span>
+<span id="L93" class="LineNr"> 93 </span><span class="Constant">$factorial:end</span>:
+<span id="L94" class="LineNr"> 94 </span>    <span class="subxS1Comment"># . epilog</span>
+<span id="L95" class="LineNr"> 95 </span>    5b/pop-to-ebx
+<span id="L96" class="LineNr"> 96 </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="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="subxTest">test-factorial</span>:
+<span id="L101" class="LineNr">101 </span>    <span class="subxComment"># factorial(5)</span>
+<span id="L102" class="LineNr">102 </span>    <span class="subxS2Comment"># . . push args</span>
+<span id="L103" class="LineNr">103 </span>    68/push  5/imm32
+<span id="L104" class="LineNr">104 </span>    <span class="subxS2Comment"># . . call</span>
+<span id="L105" class="LineNr">105 </span>    e8/call  <a href='factorial.subx.html#L71'>factorial</a>/disp32
+<span id="L106" class="LineNr">106 </span>    <span class="subxS2Comment"># . . discard args</span>
+<span id="L107" class="LineNr">107 </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="L108" class="LineNr">108 </span>    <span class="subxComment"># check-ints-equal(eax, 120, msg)</span>
+<span id="L109" class="LineNr">109 </span>    <span class="subxS2Comment"># . . push args</span>
+<span id="L110" class="LineNr">110 </span>    68/push  <span class="Constant">&quot;F - test-factorial&quot;</span>/imm32
+<span id="L111" class="LineNr">111 </span>    68/push  0x78/imm32/expected-120
+<span id="L112" class="LineNr">112 </span>    50/push-eax
+<span id="L113" class="LineNr">113 </span>    <span class="subxS2Comment"># . . call</span>
+<span id="L114" class="LineNr">114 </span>    e8/call  <a href='../051test.subx.html#L24'>check-ints-equal</a>/disp32
+<span id="L115" class="LineNr">115 </span>    <span class="subxS2Comment"># . . discard args</span>
+<span id="L116" class="LineNr">116 </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="L117" class="LineNr">117 </span>    <span class="subxComment"># end</span>
+<span id="L118" class="LineNr">118 </span>    c3/return
+<span id="L119" class="LineNr">119 </span>
+<span id="L120" class="LineNr">120 </span><span class="subxS2Comment"># . . vim&#0058;nowrap:textwidth=0</span>
 </pre>
 </body>
 </html>