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: December 11, 2024, 5:21 pm

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A weird bug in the preprocessor of PicoBlaze Simulator in JavaScript
#1
A weird bug in the preprocessor of PicoBlaze Simulator in JavaScript
A few weeks ago, I added the FlatAssembler-like `display` command to the preprocessor of my PicoBlaze Simulator in JavaScript, for printing strings and calculated constants to the terminal during assembly. However, there is a weird bug in it. The preprocessor ignores the `display a` (for writing the new-line character, whose ASCII code is 0xA) command if the UART simulation is disabled during assembly.
For example, if you assemble the "Preprocessor Test" example (the 8th example from the left in the flexbox with the example programs) while UART simulation is disabled, the preprocessor outputs this:
[Image: 260815935-4be68410-9cc8-4e96-87cb-17b7b5d6a20b.png]
But if you assemble it while UART simulation is enabled, it outputs this:
[Image: 260816137-ad6da82c-54b7-4955-b2bd-ea54e9cd4dcc.png]
At first, I thought that perhaps setting the innerHTML of a hidden (display:none) <pre> element in JavaScript deletes the new-line characters for some reason. But I've tested that hypothesis (by making a short HTML5 program that sets the innerHTML of a hidden <pre> element and then shows it) and it has proven wrong. I have no idea how that's possible. How can the preprocessor even know whether the UART simulation is enabled? How would I go about diagnozing the problem more precisely?
I have opened a GitHub issue about this:
https://github.com/FlatAssembler/PicoBla...S/issues/8
The code with which the `display` command is implemented is here:
Code:
   if (/^display$/i.test(node.text) &&
       (
           typeof PicoBlaze !==
           "object" // Because UART_OUTPUT is not declared in PicoBlaze
                    // Simulator for Android, which we detect by `PicoBlaze`
                    // being declared.
           )) {
     if (node.children[0].text[0] == '"')
       document.getElementById("UART_OUTPUT").innerText +=
           node.children[0].text.substr(1, node.children[0].text.length - 2);
     else {
       const ASCIIValue =
           node.children[0].interpretAsArithmeticExpression(context.constants);
       if (ASCIIValue != '\n'.charCodeAt(0))
         document.getElementById("UART_OUTPUT")
             .appendChild(
                 document.createTextNode(String.fromCharCode(ASCIIValue)));
       else
         document.getElementById("UART_OUTPUT")
             .appendChild(document.createElement(
                 "br")); // This doesn't appear to work in Firefox if UART is
                         // disabled while assembling, and I have opened a
                         // GitHub issue about that:
                         // https://github.com/FlatAssembler/PicoBlaze_Simulator_in_JS/issues/8
     }
   } else if (/^display$/i.test(node.text)) {
     if (node.children[0].text[0] == '"') {
       for (let i = 0; i < node.children[0].text.length; i++)
         if (node.children[0].text[i] != '"')
           PicoBlaze.displayCharacterOnTerminal(
               node.children[0].text.charCodeAt(
                   i)); // Right now, `displayCharacterOnTerminal` is a
                        // no-operation in PicoBlaze_Simulator_for_Android.
     } else {
       PicoBlaze.displayCharacterOnTerminal(
           node.children[0].interpretAsArithmeticExpression(
               context.constants));
     }
   }
Reply
#2
RE: A weird bug in the preprocessor of PicoBlaze Simulator in JavaScript
Have you tried unplugging it and plugging it back in?
[Image: extraordinarywoo-sig.jpg]
Reply
#3
RE: A weird bug in the preprocessor of PicoBlaze Simulator in JavaScript
What does that mean?

(Figured I would go first.)
[Image: MmQV79M.png]  
                                      
Reply
#4
RE: A weird bug in the preprocessor of PicoBlaze Simulator in JavaScript
(August 17, 2023 at 9:05 am)Angrboda Wrote: Have you tried unplugging it and plugging it back in?

That's not an option. That PicoBlaze Simulator is hosted on GitHub Pages, and I don't have physical access to the server where it is hosted (presumably somewhere in California) to unplug it and plug it back in. In fact, I don't even control the back-end, I can't run custom scripts (PHP...) on that server.
Reply
#5
RE: A weird bug in the preprocessor of PicoBlaze Simulator in JavaScript
(August 17, 2023 at 9:40 am)FlatAssembler Wrote:
(August 17, 2023 at 9:05 am)Angrboda Wrote: Have you tried unplugging it and plugging it back in?

That's not an option. That PicoBlaze Simulator is hosted on GitHub Pages, and I don't have physical access to the server where it is hosted (presumably somewhere in California) to unplug it and plug it back in. In fact, I don't even control the back-end, I can't run custom scripts (PHP...) on that server.

Have you tried translating into Croatian? The p-values should fix it (it’s what Semmelweis would do).

Boru
‘I can’t be having with this.’ - Esmeralda Weatherwax
Reply
#6
RE: A weird bug in the preprocessor of PicoBlaze Simulator in JavaScript
(August 17, 2023 at 12:04 pm)BrianSoddingBoru4 Wrote:
(August 17, 2023 at 9:40 am)FlatAssembler Wrote: That's not an option. That PicoBlaze Simulator is hosted on GitHub Pages, and I don't have physical access to the server where it is hosted (presumably somewhere in California) to unplug it and plug it back in. In fact, I don't even control the back-end, I can't run custom scripts (PHP...) on that server.

Have you tried translating into Croatian? The p-values should fix it (it’s what Semmelweis would do).

Boru

Translating what to Croatian? P-values of what? By the way, Semmelweis didn't calculate p-values, presumably because statistics wasn't developed enough yet to make it possible.
Reply
#7
RE: A weird bug in the preprocessor of PicoBlaze Simulator in JavaScript
(August 17, 2023 at 12:16 pm)FlatAssembler Wrote:
(August 17, 2023 at 12:04 pm)BrianSoddingBoru4 Wrote: Have you tried translating into Croatian? The p-values should fix it (it’s what Semmelweis would do).

Boru

Translating what to Croatian? P-values of what? By the way, Semmelweis didn't calculate p-values, presumably because statistics wasn't developed enough yet to make it possible.

Sorry, I wasn’t thinking. Try the commands

execute[sesame seeds]

execute[heme iron]

execute[river names]

Best of luck.

Boru
‘I can’t be having with this.’ - Esmeralda Weatherwax
Reply
#8
RE: A weird bug in the preprocessor of PicoBlaze Simulator in JavaScript
OP is lost again.
Reply
#9
RE: A weird bug in the preprocessor of PicoBlaze Simulator in JavaScript
(August 17, 2023 at 12:20 pm)BrianSoddingBoru4 Wrote:
(August 17, 2023 at 12:16 pm)FlatAssembler Wrote: Translating what to Croatian? P-values of what? By the way, Semmelweis didn't calculate p-values, presumably because statistics wasn't developed enough yet to make it possible.

Sorry, I wasn’t thinking. Try the commands

execute[sesame seeds]

execute[heme iron]

execute[river names]

Best of luck.

Boru

Which programming language is that? Where should I type those commands?
Reply
#10
RE: A weird bug in the preprocessor of PicoBlaze Simulator in JavaScript
Faints
[Image: MmQV79M.png]  
                                      
Reply



Possibly Related Threads...
Thread Author Replies Views Last Post
  PicoBlaze Simulator in JavaScript FlatAssembler 80 12713 June 23, 2023 at 5:20 pm
Last Post: arewethereyet
  Reformatting tools for JavaScript FlatAssembler 0 452 June 14, 2020 at 10:13 am
Last Post: FlatAssembler
  Android bug fear in 900 million phones account_inactive 0 665 August 8, 2016 at 6:31 am
Last Post: account_inactive
  Anatomy of religion in RELIGION SIMULATOR game gravitysoftware 12 3394 February 8, 2015 at 12:52 pm
Last Post: c172
  Analysis of a Facebook social engineering/Javascript "hack" Autumnlicious 4 3498 March 2, 2011 at 9:29 am
Last Post: fr0d0



Users browsing this thread: 1 Guest(s)