Odd quirk with BBCSDL WASM build

I'm trying to get this program to load - https://wasm.bbcbasic.co.uk/bbcsdl.html?app=http://www.matrixnetwork.co.uk/NoteQuiz/NoteQuiz.bbc - but it's failing with "Number too big". After RENUMBERing the loader, it's line 880 that is failing loading L% with the first 4 bytes of the program - 12 0A 00 EE - yet at the immediate mode prompt I'm dropped into, if I try to do L%=&EE000A12 it works but doing L%=&12 + &0A*&100 + &EE * &1000000 it fails with "Number too big".

Now it's quite possible my program is somehow corrupt however it loads fine in BBCSDL for Linux and the BB4C console version - and indeed I used BB4C to convert it from plain-text to this file with tokenised BASIC.

Comments

  • Richard_Russell
    edited September 2023
    Soruk wrote: »
    L%=&12 + &0A * &100 + &EE * &1000000
    
    fails with "Number too big".
    Indeed it should - the number is too big to fit in a signed 32-bit signed integer! That's easily demonstrable by loading it into a float:
    L=&12 + &0A * &100 + &EE * &1000000
    PRINT L
    
    That prints 3.99297999E9 and the largest number which can be stored in a signed 32-bit integer is 2.14748365E9.

    So this isn't the reason for your code running in BBCSDL and the Console Mode editions but not in a browser. That is indeed concerning, and if you can create some minimal code which reproduces it I will investigate.
  • Soruk
    edited September 2023
    It is repeatable - visit the link above, when it fails with "Number too big" the program currently visible is your downloader - so if you RENUMBER then RUN it again, it fails with "Number too big at line 880".
    Line 880 has it reading the file in 4 bytes at a time, and populating L% with it. That's part of your loader code, not my program.

    This also fails https://wasm.bbcbasic.co.uk/bbcsdl.html?app=http://www.matrixnetwork.co.uk/NoteQuiz/test.bbc

    The entire code of this is:
    >NEW
    >10 ON ERROR H%=FALSE: GOTO 40
    >20 H%=TRUE
    >40 MODE 7
    >SAVE"test"
    
  • Indeed it should - the number is too big to fit in a signed 32-bit signed integer!
    Just to add, in Matrix Brandy it reports 'Number is out of range'. So nothing at all surprising there.
  • Yep, as I would expect. However that really doesn't explain why I get that same error in exactly the same place, doing the same thing, with that test.bbc program which is doing nothing with numbers. My suspicion is it's choking on the token of ON ERROR.
  • Soruk wrote: »
    That's part of your loader code, not my program.
    It's perfectly true that the code you listed can be found in my loader (specifically, in the ?app= case) but it won't fail in the way you describe because the .bbb file format doesn't allow it to happen. The only circumstance I can think of when it would fail is if the file was corrupted.

    I could avoid the error, even in the case of a corrupted file, by replacing the + with OR:
    L% = BGET#F% OR BGET#F% * &100 OR BGET#F% * &10000 OR BGET#F% * &1000000
    
    but all that would do is result in another error occurring downstream.

    If you have a corrupted .bbb file which provokes the 'Number too big' error please send it to me.
  • Soruk
    edited September 2023
    How do I make a .bbb file? It ran quite happily with an earlier .bbc file where ON ERROR wasn't the first line of the program, though that sounds like it worked due to dumb luck than actually getting it right!

    Edit: Found it, under Utilities -> Compile in SDLIDE.
  • Soruk wrote: »
    It ran quite happily with an earlier .bbc file where ON ERROR wasn't the first line of the program
    You'd need to be remarkably lucky for ?app= to work the same as ?chain=, not least because the first four bytes of the program would be discarded! I would expect that almost always to result in a 'Bad program' error.

    I wonder why you used ?app= rather than ?chain= in the first place. The supported URL parameters are documented here.
  • I didn't know about ?chain= - and that works for the .bbc file straight off. That makes my life a WHOLE lot easier - thank you! My google-fu totally failed me, I had never found that page. I found another example of a program being loaded somewhere and just blindly copied the approach (and missed the fact it was .bbb)
  • Richard_Russell
    edited September 2023
    Soruk wrote: »
    My google-fu totally failed me, I had never found that page.
    Bear in mind that the BBCSDL online help index page contains a custom Google search box, which will prioritise looking in the most likely place. For example if you search there for 'URL parameters' it will find the relevant page (after the sponsored results of course, Google has to make its money somehow!).
Sign In or Register to comment.