Skip to content

Commit

Permalink
Merge pull request #17 from ith8/master
Browse files Browse the repository at this point in the history
Typo in lec 03
  • Loading branch information
ranjitjhala authored Jun 8, 2020
2 parents 28013dc + e0081e9 commit ebce2a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
13 changes: 7 additions & 6 deletions docs/lectures/03-adder.html
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ <h3 id="brief-digression-typeclasses">Brief digression: Typeclasses</h3>
<a class="sourceLine" id="cb17-6" data-line-number="6"></a>
<a class="sourceLine" id="cb17-7" data-line-number="7"><span class="kw">instance</span> <span class="dt">ToX86</span> <span class="dt">Arg</span> <span class="kw">where</span></a>
<a class="sourceLine" id="cb17-8" data-line-number="8"> asm (<span class="dt">Const</span> n) <span class="fu">=</span> printf <span class="st">&quot;%d&quot;</span> n</a>
<a class="sourceLine" id="cb17-9" data-line-number="9"> arg (<span class="dt">Reg</span> r) <span class="fu">=</span> asm r</a>
<a class="sourceLine" id="cb17-9" data-line-number="9"> asm (<span class="dt">Reg</span> r) <span class="fu">=</span> asm r</a>
<a class="sourceLine" id="cb17-10" data-line-number="10"></a>
<a class="sourceLine" id="cb17-11" data-line-number="11"><span class="kw">instance</span> <span class="dt">ToX86</span> <span class="dt">Register</span> <span class="kw">where</span></a>
<a class="sourceLine" id="cb17-12" data-line-number="12"> asm <span class="dt">EAX</span> <span class="fu">=</span> <span class="st">&quot;eax&quot;</span></a></code></pre></div>
Expand Down Expand Up @@ -515,16 +515,17 @@ <h3 id="examples-revisited">Examples Revisited</h3>
<a class="sourceLine" id="cb24-2" data-line-number="2"></a>
<a class="sourceLine" id="cb24-3" data-line-number="3">exp1 <span class="fu">=</span> <span class="dt">Add1</span> (<span class="dt">Number</span> <span class="dv">7</span>)</a>
<a class="sourceLine" id="cb24-4" data-line-number="4"></a>
<a class="sourceLine" id="cb24-5" data-line-number="5">asm1 <span class="fu">=</span> [ <span class="dt">IMov</span> (<span class="dt">EAX</span>) (<span class="dt">Const</span> <span class="dv">7</span>)</a>
<a class="sourceLine" id="cb24-6" data-line-number="6"> , <span class="dt">IAdd</span> (<span class="dt">EAX</span>) (<span class="dt">Const</span> <span class="dv">1</span>)</a>
<a class="sourceLine" id="cb24-5" data-line-number="5">asm1 <span class="fu">=</span> [ <span class="dt">IMov</span> (<span class="dt">Reg</span> <span class="dt">EAX</span>) (<span class="dt">Const</span> <span class="dv">7</span>)</a>
<a class="sourceLine" id="cb24-6" data-line-number="6"> , <span class="dt">IAdd</span> (<span class="dt">Reg</span> <span class="dt">EAX</span>) (<span class="dt">Const</span> <span class="dv">1</span>)</a>
<a class="sourceLine" id="cb24-7" data-line-number="7"> ]</a></code></pre></div>
<div class="sourceCode" id="cb25"><pre class="sourceCode haskell"><code class="sourceCode haskell"><a class="sourceLine" id="cb25-1" data-line-number="1">src2 <span class="fu">=</span> <span class="st">&quot;add1(add1(12))&quot;</span></a>
<a class="sourceLine" id="cb25-2" data-line-number="2"></a>
<a class="sourceLine" id="cb25-3" data-line-number="3">exp2 <span class="fu">=</span> <span class="dt">Add1</span> (<span class="dt">Add1</span> (<span class="dt">Number</span> <span class="dv">12</span>))</a>
<a class="sourceLine" id="cb25-4" data-line-number="4"></a>
<a class="sourceLine" id="cb25-5" data-line-number="5">asm2 <span class="fu">=</span> [ <span class="dt">IMov</span> (<span class="dt">EAX</span>) (<span class="dt">Const</span> <span class="dv">7</span>)</a>
<a class="sourceLine" id="cb25-6" data-line-number="6"> , <span class="dt">IAdd</span> (<span class="dt">EAX</span>) (<span class="dt">Const</span> <span class="dv">1</span>)</a>
<a class="sourceLine" id="cb25-7" data-line-number="7"> ]</a></code></pre></div>
<a class="sourceLine" id="cb25-5" data-line-number="5">asm2 <span class="fu">=</span> [ <span class="dt">IMov</span> (<span class="dt">Reg</span> <span class="dt">EAX</span>) (<span class="dt">Const</span> <span class="dv">12</span>)</a>
<a class="sourceLine" id="cb25-6" data-line-number="6"> , <span class="dt">IAdd</span> (<span class="dt">Reg</span> <span class="dt">EAX</span>) (<span class="dt">Const</span> <span class="dv">1</span>)</a>
<a class="sourceLine" id="cb25-7" data-line-number="7"> , <span class="dt">IAdd</span> (<span class="dt">Reg</span> <span class="dt">EAX</span>) (<span class="dt">Const</span> <span class="dv">1</span>)</a>
<a class="sourceLine" id="cb25-8" data-line-number="8"> ]</a></code></pre></div>
<h2 id="transforms">3. Transforms</h2>
<p>Now lets go back and suitably extend the transforms:</p>
<div class="sourceCode" id="cb26"><pre class="sourceCode haskell"><code class="sourceCode haskell"><a class="sourceLine" id="cb26-1" data-line-number="1"><span class="ot">parse ::</span> <span class="dt">Text</span> <span class="ot">-&gt;</span> <span class="dt">Expr</span> <span class="co">-- 1. Transform source-string into AST</span></a>
Expand Down
11 changes: 6 additions & 5 deletions lectures/03-adder.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ instance ToX86 Instruction where
instance ToX86 Arg where
asm (Const n) = printf "%d" n
arg (Reg r) = asm r
asm (Reg r) = asm r
instance ToX86 Register where
asm EAX = "eax"
Expand Down Expand Up @@ -414,8 +414,8 @@ src1 = "add1(7)"

exp1 = Add1 (Number 7)

asm1 = [ IMov (EAX) (Const 7)
, IAdd (EAX) (Const 1)
asm1 = [ IMov (Reg EAX) (Const 7)
, IAdd (Reg EAX) (Const 1)
]
```

Expand All @@ -424,8 +424,9 @@ src2 = "add1(add1(12))"

exp2 = Add1 (Add1 (Number 12))

asm2 = [ IMov (EAX) (Const 7)
, IAdd (EAX) (Const 1)
asm2 = [ IMov (Reg EAX) (Const 12)
, IAdd (Reg EAX) (Const 1)
, IAdd (Reg EAX) (Const 1)
]
```

Expand Down

0 comments on commit ebce2a5

Please sign in to comment.