@@ -162,7 +162,7 @@ structure of your project `src` directory should be as follows:
...
@@ -162,7 +162,7 @@ structure of your project `src` directory should be as follows:
└── Module.scala
└── Module.scala
## Deliverables
## Deliverables
Deadline: **Friday December 9 at 11pm**.
You are given **TBD weeks** for this assignment.
Submission: push the solved lab 5 to the branch `clplab5` that was created on your Gitlab repo. Do not push the changes to other branches! It may interfere with your previous submissions.
You may want to copy the files you changed directly to the new branch, since the two branches don't share a history in git.
<li>WASM has types. We will use exclusively i32.</li>
<li>Instructions can push or pop values from the stack.
<ul>
<li>i32.const x : push x to the stack.</li>
<li>i32.add : pop 2 values, add them and push the result.</li>
<li>drop : pop a value and ignore it.</li>
</ul></li>
<li>Locals can store values inside a function. Useful for val definitions among others.
<ul>
<li>local.get x : get xth local</li>
<li>local.set x : set xth local</li>
</ul></li>
<li>Globals store program wide values.
<ul>
<li>global.get x : get xth global</li>
<li>global.set x : set xth global</li>
</ul></li>
<li>Control flow.
<ul>
<li>if : pop value from stack, if 0 goto else otherwise continue.</li>
<li>call : pop arguments from the stack, jump to function.</li>
</ul></li>
</ul>
<h2id="function-calls">Function calls</h2>
<p>How to call a function: - Push the required number of arguments on the stack. - Call the function. The call instruction will pop the arguments and place them in the locals. - The result will be placed on top of the stack.</p>