(August 21, 2022 at 10:10 am)bennyboy Wrote:Well, @HappySkeptic , if I correctly understand him, says that the measurements show that JavaScript execution is not the bottleneck in my simulator.(August 21, 2022 at 5:31 am)FlatAssembler Wrote: Anyway, @bennyboy , I have managed to modify the simulator to use switch-case instead of if-else, and the "Decimal to Binary" and "Binary to Decimal" examples work again. Unfortunately, they are not significantly faster. https://github.com/FlatAssembler/PicoBla...mulator.js
Yeah, I wasn't sure that it would. However, as a work of the programming arts, the new file is vastly superior-- I think anyone reading that will take some interest, instead of getting a headache.
If it is issues with the DOM and so on, i.e. if the execution of JavaScript code is not the bottleneck, then I'd recommend separating out highly repeated code. For example, I see a lot of this kind of thing:
Code:case 0x31000:
// RETURN Z ; Return from a function only if the Zero Flag is set.
if (flagZ[regbank]) {
if (callStack.length)
PC = callStack.pop() + 1;
else {
if (playing)
clearInterval(simulationThread);
alert("The program exited!");
}
} else
PC++;
break;
case 0x35000:
// RETURN NZ ; Return from a function only if the Zero Flag is not set.
if (!flagZ[regbank]) {
if (callStack.length)
PC = callStack.pop() + 1;
else {
if (playing)
clearInterval(simulationThread);
alert("The program exited!");
}
} else
PC++;
break;
Could be
The comment and the name of the function (which will do all the cut stuff) will now make it very clear what is going on.Code:case 0x31000:
// RETURN Z ; Return from a function only if the Zero Flag is set.
PopIf (flagZ[regbank]);
break;
case 0x35000:
// RETURN NZ ; Return from a function only if the Zero Flag is not set.
PopIf (!flagZ[regbank]);
break;
By the way, what do you think about the user interface of the PicoBlaze Simulator? Is it better than the rest of the website? Is it better than the user interface of the Arithmetic Expression Compiler?
Also, what do you think, would it be a good idea to develop a back-end so that people can share their PicoBlaze programs and comment on each other's PicoBlaze programs? If so, how should I go about doing that? Would you recommend me some framework that would make it easier to do that? I know nothing about back-end development right now.