Skip to content

Commit

Permalink
Replaced (local.get 0) with variable names in inline assembly...
Browse files Browse the repository at this point in the history
  • Loading branch information
FlatAssembler committed Feb 16, 2023
1 parent b914a35 commit 1254c50
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions analogClock/analogClock.aec
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,13 @@ Function sin(Decimal32 degrees) Which Returns Decimal32 Does {
EndIf;
If degrees > 90 Then { Return cos(degrees - 90); }
EndIf;
If not(sineMemoisation[asm_f32("(f32.nearest (local.get 0))")] = 0)
Then { //"(local.get 0)" means, in WebAssembly, "Get the first argument
// of
// this function.", and the first argument of this function is
//"degrees". I've used inline assembly here because nothing else
// I
If not(sineMemoisation[asm_f32("(f32.nearest (f32.load %degrees))")] = 0)
Then { // I've used inline assembly here because nothing else I
// write will output "f32.nearest" (called "round" in most
// programming languages) WebAssembly directive, and it's way
// more convenient to insert some inline assembly than to modify
// and recompile the compiler.
Return sineMemoisation[asm_f32("(f32.nearest (local.get 0))")];
Return sineMemoisation[asm_f32("(f32.nearest (f32.load %degrees))")];
}
EndIf;
/*
Expand All @@ -210,7 +206,8 @@ Function sin(Decimal32 degrees) Which Returns Decimal32 Does {
i += epsilon;
}
EndWhile;
Return sineMemoisation[asm_f32("(f32.nearest (local.get 0))")] : = tmpsin;
Return sineMemoisation[asm_f32("(f32.nearest (f32.load %degrees))")]
: = tmpsin;
}
EndFunction;

Expand Down

0 comments on commit 1254c50

Please sign in to comment.