Commits

Pierre Surply committed 81d3bc9

Added ref asm, mcall and tern

Comments (0)

Files changed (14)

compiler/backend/gen.ml

 			Instr ("ldi", RegInt (24, 1));
 			Instr ("rjmp", String "2f");
 			Label "1";
-			Instr ("clr", RegInt 24);
+			Instr ("clr", Reg 24);
 			Label "2";
                         Instr ("clr", Reg 25);
 		       ]
 begin setup
         PORTB.set_pin_out(7)
-        PORTB.pin_high(7)
+        PORTB.pin_low(7)
 end
 
 begin loop

website/cgi-bin/url.ml

 **    along with OCaml-WebFramework.  If not, see <http://www.gnu.org/licenses/>.
 **
 ** Started on  Sun Sep 16 11:31:15 2012 Pierre Surply
-** Last update Tue Feb 12 09:34:29 2013 Pierre Surply
+** Last update Tue Feb 12 20:11:27 2013 Pierre Surply
 *)
 
 let get_page_from_url () =
           | "boolop"    -> "boolop.html"
           | "bitop"     -> "bitop.html"
           | "malloc"    -> "malloc.html"
+          | "asm"       -> "asm.html"
+          | "tern"      -> "tern.html"
+          | "mcall"     -> "mcall.html"
           | _           -> "summary.html"
         end
     | "faq"             -> "faq.html"

website/templates/faq.html

 
 [begin body]
 <h1>FAQ</h1>
+<h2>Can I edit Mara code with Emacs ?</h2>
+<p>
+Yes, you can install the mara-mode by copying the file <samp>utils/mara-mode.el</samp> in your <samp>~/.emacs.d/</samp> directory.<br/>
+Then, add the following lines to your <samp>~/.emacs</samp> file :
+</p>
+
+<pre>
+<code>
+  (autoload 'mara-mode "~/.emacs.d/mara-mode.el" "" t)
+  (setq auto-mode-alist (cons '("\\.mr\\w?" . mara-mode) auto-mode-alist))
+</code>
+</pre>
 [end]

website/templates/gettingstarted.html

 
 [begin body]
 <h1>Getting started</h1>
-<h2>Edit Mara code with Emacs</h2>
-<p>
-First, copy the file <samp>utils/mara-mode.el</samp> in your <samp>~/.emacs.d/</samp> directory.<br/>
-Then, add the following lines to your <samp>~/.emacs</samp> file :
-</p>
 
-<pre>
-<code>
-  (autoload 'mara-mode "~/.emacs.d/mara-mode.el" "" t)
-  (setq auto-mode-alist (cons '("\\.mr\\w?" . mara-mode) auto-mode-alist))
-</code>
-</pre>
 [end]

website/templates/ref/arith.html

     <tr><th><code>%</code></th><th>modulo</th></tr>
   </tbody>
 </table>
-<h2>Example</h2>
+<h3>Example</h3>b
 <pre>
 <code>
   begin setup
   end
 </code>
 </pre>
-<h2>Assembler equivalent</h2>
-<h3>Addition</h3>
+<h3>Assembler equivalent</h3>
+<h4>Addition</h4>
 <pre>
   <code>
     add         r24, r18
     adc         r25, r18
   </code>
 </pre>
-<h3>Substraction</h3>
+<h4>Substraction</h4>
 <pre>
   <code>
     sub         r24, r18
     sbc         r25, r18
   </code>
 </pre>
-<h3>Multiplication</h3>
+<h4>Multiplication</h4>
 <pre>
   <code>
     movw        r20, r24
     clr         r1
   </code>
 </pre>
-<h3>Division</h3>
+<h4>Division</h4>
 <pre>
   <code>
     movw        r22, r18
     movw        r24, r22
   </code>
 </pre>
-<h3>Modulo</h3>
+<h4>Modulo</h4>
 <pre>
   <code>
     movw        r22, r18

website/templates/ref/asm.html

+{@ ref/ref.html @}
+
+[begin tref]Inline Assembler[end]
+
+[begin ref]
+<h3>Syntax</h3>
+<pre>
+  <code>
+    asm<<em>expression</em>> "<em>assembler instructions</em>"
+  </code>
+</pre>
+<h3>Description</h3>
+<p>
+  The <code>asm</code> statement can be used to include assembler instructions into mara programs. This may be used to manually optimized time critical parts or to use a specific AVR features. The result of the given expression is placed in <code>r24</code> and <code>r25</code> before executing the given assembler instructions.
+</p>
+<ul>
+  <li></li>
+</ul>
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+        var a &#60;- 40
+        var b &#60;- asm&#60;a+1&#62; "inc r24" # b = 42
+  end
+
+  begin loop
+  end
+  </code>
+</pre>
+[end]

website/templates/ref/bitop.html

     <tr><th><code>&#62;&#62;</code></th><th>bitshift right</th></tr>
   </tbody>
 </table>
-<h2>Example</h2>
+<h3>Example</h3>
 <pre>
 <code>
   begin setup
 
         c <- a & b      # c = 0b00001010
         c <- a | b      # c = 0b00101111
-        c <- ~b         # c = 0b11110000
+        c <- ~b         # c = 0xFFF0
         c <- a >> 1     # c = 0b00010101
         c <- a << 2     # c = 0b10101000
   end
   end
 </code>
 </pre>
-<h2>Assembler equivalent</h2>
-<h3>Bitwise AND</h3>
+<h3>Assembler equivalent</h3>
+<h4>Bitwise AND</h4>
 <pre>
   <code>
     and         r24, r18
     and         r25, r18
   </code>
 </pre>
-<h3>Bitwise OR</h3>
+<h4>Bitwise OR</h4>
 <pre>
   <code>
     or          r24, r18
     or          r25, r18
   </code>
 </pre>
-<h3>Bitwise NOT</h3>
+<h4>Bitwise NOT</h4>
 <pre>
   <code>
     com          r24
     com          r25
   </code>
 </pre>
-<h3>Bitshift left</h3>
+<h4>Bitshift left</h4>
 <pre>
   <code>
     mov         r0, r18
     brpl        1b
   </code>
 </pre>
-<h3>Bitshift right</h3>
+<h4>Bitshift right</h4>
 <pre>
   <code>
     mov         r0, r18

website/templates/ref/boolop.html

     <tr><th><code>not</code></th><th>logical NOT</th></tr>
   </tbody>
 </table>
-<h2>Example</h2>
+<h3>Example</h3>
 <pre>
 <code>
   begin setup
   end
 </code>
 </pre>
-<h2>Assembler equivalent</h2>
-<h3>Logical AND</h3>
+<h3>Assembler equivalent</h3>
+<h4>Logical AND</h4>
 <pre>
   <code>
     cp          r24, r1
 2:  clr         r25
   </code>
 </pre>
-<h3>Logical OR</h3>
+<h4>Logical OR</h4>
 <pre>
   <code>
     cp          r24, r1
 2:  clr         r25
   </code>
 </pre>
-<h3>Logical NOT</h3>
+<h4>Logical NOT</h4>
 <pre>
   <code>
     sbiw        r24, 0

website/templates/ref/comp.html

     <tr><th><code>&#62;=</code></th><th>greater than or equal to</th></tr>
   </tbody>
 </table>
-<h2>Example</h2>
+<h3>Example</h3>
 <pre>
 <code>
   begin setup
   end
 </code>
 </pre>
-<h2>Assembler equivalent</h2>
-<h3>Equal to</h3>
+<h3>Assembler equivalent</h3>
+<h4>Equal to</h4>
 <pre>
   <code>
     cp          r24, r18
 2:  clr         r25
   </code>
 </pre>
-<h3>Not equal to</h3>
+<h4>Not equal to</h4>
 <pre>
   <code>
     cp          r24, r18
 2:  clr         r25
   </code>
 </pre>
-<h3>Greater than</h3>
+<h4>Greater than</h4>
 <pre>
   <code>
     cp          r24, r18
 2:  clr         r25
   </code>
 </pre>
-<h3>Less than or equal to</h3>
+<h4>Less than or equal to</h4>
 <pre>
   <code>
     cp          r24, r18
 2:  clr         r25
   </code>
 </pre>
-<h3>Greater than or equal to</h3>
+<h4>Greater than or equal to</h4>
 <pre>
   <code>
     cp          r24, r18

website/templates/ref/malloc.html

 [begin tref]Object creation/destruction[end]
 
 [begin ref]
+<h2>Syntax</h2>
 <table>
   <thead>
     <tr>
-      <th>Keyword</th>
+      <th>Syntax</th>
       <th>Operation</th>
     </tr>
   </thead>
   <tbody>
-    <tr><th><code>new</code></th><th>Create a new object</th></tr>
-    <tr><th><code>del</code></th><th>Delete an object</th></tr>
+    <tr>
+      <th><code>new <em>class_name</em>(<em>arguments</em>)</code></th>
+      <th>Create a new object from the class <em>class_name</em></th>
+    </tr>
+    <tr>
+      <th><code>del <em>object_name</em></code></th>
+      <th>Delete the object <em>object_name</em></th>
+    </tr>
   </tbody>
 </table>
+<h2>Decription</h2>
+<p>
+  The <code>new</code> operator must be used in an expression to allocate memory and initialize a new object from the given class.
+  If the class is not loaded yet, the compiler try to load the file which name match with the class name suffixed with <code>.mr</code> in its search directory (Example : <code>point.mr</code> for the class <code>point</code>).
+  When an object is created, the memory is allocated with the <a href="http://www.nongnu.org/avr-libc/user-manual/malloc.html"><code>malloc</code></a> C-function provided by <a href="http://www.nongnu.org/avr-libc/">avr-libc</a>. Then, the method <code>init</code> bound with the object is called with the given arguments.
+</p>
+<p>
+  The <code>del</code> operator is one full instruction (unlike <code>new</code>) and cannot be used in an expression.
+  When an object is deleted, the method <code>destr</code> bound with the object is called without argument. Then, the memory used by the object is free using the C-function <a href="http://www.nongnu.org/avr-libc/user-manual/malloc.html"><code>free</code></a> provided by <a href="http://www.nongnu.org/avr-libc/">avr-libc</a>.
+</p>
 <h2>Example</h2>
 <pre>
 <code>

website/templates/ref/mcall.html

+{@ ref/ref.html @}
+
+[begin tref]Method call[end]
+
+[begin ref]
+<h3>Syntax</h3>
+<pre>
+  <code>
+    <em>object_name</em>.<em>method_name</em>(<em>arg1</em>, <em>arg2</em>, ...)
+  </code>
+</pre>
+<h3>Description</h3>
+<p>
+</p>
+<ul>
+  <li></li>
+</ul>
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+  end
+
+  begin loop
+  end
+  </code>
+</pre>
+[end]

website/templates/ref/summary.html

         <h3>Advanced operators</h3>
         <ul>
           <li><a href="?ref/malloc/">Object creation/destruction</a></li>
-          <li>Method call</li>
-          <li>Ternary operation</li>
-          <li>Inline Assembler</li>
+          <li><a href="?ref/mcall/">Method call</a></li>
+          <li><a href="?ref/tern/">Ternary operation</a></li>
+          <li><a href="?ref/asm/">Inline Assembler</a></li>
         </ul>
       </li>
     </ul>

website/templates/ref/tern.html

+{@ ref/ref.html @}
+
+[begin tref]Ternary[end]
+
+[begin ref]
+<h3>Syntax</h3>
+<pre>
+  <code>
+    <em>expression1</em> ? <em>expression2</em> : <em>expression3</em>
+  </code>
+</pre>
+<h3>Description</h3>
+<p>
+  If the result of <em>expression1</em> is greater than 0, the result of the whole expression is equal to the result of <em>expression2</em>. Else, it's equal to the result of <em>expression3</em>.
+</p>
+<ul>
+  <li></li>
+</ul>
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+        var a &#60;- 2
+        var b &#60;- a = 2 ? 42 : 1337 # b= 42
+  end
+
+  begin loop
+  end
+  </code>
+</pre>
+[end]