Skip to content

Commit

Permalink
Added the xor_using_assembly function to the AOT
Browse files Browse the repository at this point in the history
  • Loading branch information
FlatAssembler committed Nov 30, 2023
1 parent 4585c90 commit 99c169e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
11 changes: 11 additions & 0 deletions arithmeticOperatorsTest/arithmeticOperatorsTest.aec
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ Function xor(Integer32 first,
Return (first and invertBits(second)) or (invertBits(first) and second);
EndFunction

Function xor_using_assembly(Integer32 first,
Integer32 second)
Which Returns Integer32 Does
Return asm_i32(R"assembly(
(i32.xor
(i32.load %first)
(i32.load %second)
)
)assembly");
EndFunction

Function emptyFunction() Which Returns Nothing Does
Nothing; //The compiler should no longer crash when compiling the
//no-operation statement ("Nothing").
Expand Down
23 changes: 15 additions & 8 deletions arithmeticOperatorsTest/arithmeticOperatorsTest.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<title>AEC-to-WebAssembly compiler - Arithmetic Operators Test</title>
Expand Down Expand Up @@ -46,7 +46,10 @@ <h1>Arithmetic Operators Test</h1>
minimum(first,second)=<span id="minimum"></span><br />
signum(first)=<span id="signumOfTheFirst"></span><br />
signum(second)=<span id="signumOfTheSecond"></span><br />
xor(first,second)=<span id="xor"></span><br /></span
xor(first,second)=<span id="xor"></span><br />
xor_using_assembly(first,second)=<span
id="xor_using_assembly"
></span> </span
><br />
You can see the source code of the AEC program
<a
Expand All @@ -60,7 +63,7 @@ <h1>Arithmetic Operators Test</h1>
*/
const stack_pointer = new WebAssembly.Global(
{ value: "i32", mutable: true },
0
0,
);
let memory = new WebAssembly.Memory({ initial: 1 }); //Initially allocates
//1 page=64KB of RAM.
Expand All @@ -77,7 +80,8 @@ <h1>Arithmetic Operators Test</h1>
minimum,
signum,
modulo,
xor;
xor,
xor_using_assembly;
fetch("arithmeticOperatorsTest.wasm")
.then((response) => response.arrayBuffer())
.then((bytes) => WebAssembly.instantiate(bytes, importObject))
Expand All @@ -95,33 +99,36 @@ <h1>Arithmetic Operators Test</h1>
signum = exports.signum;
modulo = exports.modulo;
xor = exports.xor;
xor_using_assembly = exports.xor_using_assembly;
});
function invokeAECfunctions() {
let first = parseInt(document.getElementById("firstNumber").value);
let second = parseInt(document.getElementById("secondNumber").value);
document.getElementById("addition").innerText = add(first, second);
document.getElementById("subtraction").innerText = subtract(
first,
second
second,
);
document.getElementById("multiplication").innerText = multiply(
first,
second
second,
);
document.getElementById("integerDivision").innerText = integerDivision(
first,
second
second,
);
document.getElementById("decimalDivision").innerText = decimalDivision(
first,
second
second,
);
document.getElementById("maximum").innerText = maximum(first, second);
document.getElementById("minimum").innerText = minimum(first, second);
document.getElementById("signumOfTheFirst").innerText = signum(first);
document.getElementById("signumOfTheSecond").innerText = signum(second);
document.getElementById("modulo").innerText = modulo(first, second);
document.getElementById("xor").innerText = xor(first, second);
document.getElementById("xor_using_assembly").innerText =
xor_using_assembly(first, second);
}
</script>
</body>
Expand Down

0 comments on commit 99c169e

Please sign in to comment.