Our server costs ~$56 per month to run. Please consider donating or becoming a Patron to help keep the site running. Help us gain new members by following us on Twitter and liking our page on Facebook!
Current time: November 24, 2024, 2:42 pm

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PicoBlaze Simulator in JavaScript
#61
RE: PicoBlaze Simulator in JavaScript
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
#62
RE: PicoBlaze Simulator in JavaScript
(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
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;
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.
#63
RE: PicoBlaze Simulator in JavaScript
(August 21, 2022 at 10:10 am)bennyboy Wrote:
(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
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;
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.
Well, @HappySkeptic , if I correctly understand him, says that the measurements show that JavaScript execution is not the bottleneck in my simulator.
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.
#64
RE: PicoBlaze Simulator in JavaScript
(August 21, 2022 at 11:05 am)FlatAssembler Wrote: Well, @HappySkeptic , if I correctly understand him, says that the measurements show that JavaScript execution is not the bottleneck in my simulator.
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.

Personally, I like and enjoy Blazor-- a C#-based WASM SPA framework by Microsoft.  It's quite robust now, and I like the Visual Studio IDE.  It depends on .NET, which can be deployed almost anywhere.  .NET also has a native cross-platform framework called (Maui).

But if you are comfortable with Javascript, I know there are backend frameworks that use it.  I suspect you might find Node.js interesting.

Keep in mind you don't have to put all your eggs in one basket. These days, integrating microservices written in multiple languages / frameworks is totally fine. If you get 1/2 through a project and find a new framework you like better, you can use APIs to communicate between them.
#65
RE: PicoBlaze Simulator in JavaScript
(August 21, 2022 at 11:05 am)FlatAssembler Wrote: By the way, what do you think about the user interface of the PicoBlaze Simulator?
I like the animation of it, and it looks like a sincerely interesting project.

You have a lot going on-- IMO you should assume the client will be on a PC, and use the full width of the media, with multiple large columns, 1 for each section: 1 for the assembler example selection and lines display, another for the input terminal, etc.

If you have time, it may be worth learning a CSS framework, like Boostrap. Seeing the example pages may inspire you in how to lay out the page more productively.
#66
RE: PicoBlaze Simulator in JavaScript
bennyboy Wrote:Personally, I like and enjoy Blazor-- a C#-based WASM SPA framework by Microsoft.
I also like WebAssembly. I don't like C# though, the university has made me hate it (I failed my Object Oriented Development class, where we used C#, three times). I have made a few things on my website using WebAssembly, mostly to showcase my compiler that targets WebAssembly: my Analog Clock and my N Queens Puzzle solver, for example.
bennyboy Wrote:I like the Visual Studio IDE.
I also like it. It is one of the reasons I switched from Linux to Windows.
bennyboy Wrote:It depends on .NET, which can be deployed almost anywhere.
As far as I know, it is the PHP that can be deployed almost anywhere as a back-end language, not .NET. Am I missing something?
bennyboy Wrote:.NET also has a native cross-platform framework called (Maui).
Never heard of Maui.
bennyboy Wrote:But if you are comfortable with Javascript, I know there are backend frameworks that use it. I suspect you might find Node.js interesting.
I thought I would be using PHP to develop the back-end and deploy it on SourceForge, like I did with the highscore of my SVG PacMan. SourceForge allows me to run PHP for free on their servers.
bennyboy Wrote:These days, integrating microservices written in multiple languages / frameworks is totally fine.
I thought the vast majority of back-ends these days were written in PHP.
bennyboy Wrote:IMO you should assume the client will be on a PC, and use the full width of the media, with multiple large columns, 1 for each section: 1 for the assembler example selection and lines display, another for the input terminal, etc.
Sounds like something a lot more difficult to program than what I already have, doesn't it?
bennyboy Wrote:Seeing the example pages may inspire you in how to lay out the page more productively.
What example pages do you have in mind?
#67
RE: PicoBlaze Simulator in JavaScript
(August 22, 2022 at 9:07 am)FlatAssembler Wrote: As far as I know, it is the PHP that can be deployed almost anywhere as a back-end language, not .NET. Am I missing something?
Yes. The old .NET framework was Windows-dependent. The new .net can be run on any modern platform, including Linux, Kubernetes, IIS, and Apple. Maui is a cross-platform app system related to Blazor-- it runs as an app on any popular OS, and uses native controls instead of a web interface.

Quote:I thought the vast majority of back-ends these days were written in PHP.
That only matters if you already know PHP and prefer it. You can use almost any of the most popular languages as a back-end for a website now.
#68
RE: PicoBlaze Simulator in JavaScript
bennyboy Wrote:You can use almost any of the most popular languages as a back-end for a website now.
But then I cannot host it for free, right? To work in a language I want to work for back-end development, I need to buy an expensive VPS, right?
#69
RE: PicoBlaze Simulator in JavaScript
(August 22, 2022 at 11:49 am)FlatAssembler Wrote:
bennyboy Wrote:You can use almost any of the most popular languages as a back-end for a website now.
But then I cannot host it for free, right? To work in a language I want to work for back-end development, I need to buy an expensive VPS, right?

Free hosting is bullshit.  I hate it.  However, some of the big hosting sites have free tiers: GitHub, Firebase, AWS, etc.

Blazor WASM is pre-compiled and runs on client even without an internet connection (once it's been downloaded).  I think ANY kind of WASM solution can probably be served from a CDN or a static-files host.

Here's an example of someone using just GitHub and Firebase (google free static-files host) to successfully run a free app:




And a similar (hard accent to understand though) example for Node.js




Of course, any free system will have limitations over corporate paid services. But I think for what you are doing, they will be fine.

You can google "___ free hosting" for whatever framework you are interested in, and you will likely find some kind of video about how to do it.
#70
RE: PicoBlaze Simulator in JavaScript
bennyboy Wrote:Free hosting is bullshit. I hate it.
What makes you say so? I am, thus far, only using free hosting. PicoBlaze Simulator, along with my entire website, is hosted on GitHub Pages, which is a free service.
What do you think about the zero-investment rule? That is, that you should not invest any money into trying out your new software ideas? I have no idea if people are going to like my website for sharing PicoBlaze programs, so why should I invest money if I have no good reasons to think I will get a return on investment?
bennyboy Wrote:Blazor WASM is pre-compiled and runs on client even without an internet connection (once it's been downloaded). I think ANY kind of WASM solution can probably be served from a CDN or a static-files host.
I know that, I made a compiler targetting WebAssembly. But that does not help me to create a back-end I can run for free, right? I mean, I cannot run WebAssembly on a back-end that supports only PHP (like most free hostings do), nor would it be easy to make a back-end in my own programming language that compiles to WebAssembly (as it is a fairly low-level language).
bennyboy Wrote:Firebase (google free static-files host)
So, how is Firebase different from GitHub Pages? I watched the video and I failed to understand what does one gain by using FireBase instead of GitHub pages for WebAssembly.
bennyboy Wrote:And a similar (hard accent to understand though) example for Node.js
I must admit I completely failed to understand that video. Where is his NodeJS code that is running on FireBase? I already have a static-file hosting service, that is GitHub Pages, I want to build and deploy a back-end, so that people can share and comment on their own PicoBlaze programs.



Possibly Related Threads...
Thread Author Replies Views Last Post
  A weird bug in the preprocessor of PicoBlaze Simulator in JavaScript FlatAssembler 81 9212 December 19, 2023 at 4:46 pm
Last Post: BrianSoddingBoru4
  Reformatting tools for JavaScript FlatAssembler 0 449 June 14, 2020 at 10:13 am
Last Post: FlatAssembler
  Anatomy of religion in RELIGION SIMULATOR game gravitysoftware 12 3370 February 8, 2015 at 12:52 pm
Last Post: c172
  Analysis of a Facebook social engineering/Javascript "hack" Autumnlicious 4 3492 March 2, 2011 at 9:29 am
Last Post: fr0d0



Users browsing this thread: 1 Guest(s)