You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It has to do with the fact that the assembler doesn't look into if-branchings, it simply jumps over them while assembling, because mnemonics must not be put inside the if-branchings. Given the way the assembler is structured, there doesn't seem to be a simple solution.
The text was updated successfully, but these errors were encountered:
An obvious solution might be to make the assembler, when it encounters an if-statement, check whether the condition of the if-statement is true, and then, if it's true, invoke the preprocessor again with the if's second child (the body) as an argument. Putting something like this in assembler.js:
if(/^if$/i.test(node_of_depth_1.text)||/^while$/i.test(node_of_depth_1.text))if(node_of_depth_1.children[0].interpretAsArithmeticExpression(output_of_preprocessor.constants))makeCompilationContext(node_of_depth_1.children[1]);//Notice that we are not modifying the output_of_preprocessor
However, that would just replace this problem with another problem. Consider this code:
address 0
constant i, 1if i>1
base_decimal
endif
constant i, 2
inst 10
The problem here is that when the preprocessor sees if i>1, the i>1 will evaluate to false. But when the assembler sees that, it will evaluate to true.
So, once again, there is no obvious solution given the way the assembler is structured.
This program (you can see it live here):
assembles into:
I'd expect it to assemble into:
It has to do with the fact that the assembler doesn't look into if-branchings, it simply jumps over them while assembling, because mnemonics must not be put inside the if-branchings. Given the way the assembler is structured, there doesn't seem to be a simple solution.
The text was updated successfully, but these errors were encountered: