Thread: Converting MINI-BASIC in MASM over to C++?

  1. #361
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    To allow the console to be selected at runtime, I have un-singleton'd it.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  2. #362
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I've submitted a few updates.

    Some small bug-fixes, such as entering just a line-number should REMOVE that line, not end up with a line with just a number on it.

    Loading a text file with an empty line in it would end the loading, whcih I don't think is what it should do.

    There is a bug when loading text BASIC files by the way. Since the same scanner object is used for both reading the load command, and for inputting the text from the file, when we get back to the command loop, it fails the "scanner.empty()" check by an assert in the STL implementation (In VS 2008 Express Edition at least). I think it is because the string that is used for the input to scanner is "gone".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #363
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I'm pushing another refactoring, splitting out the functionality to run, list, load, save etc into separate functions. I will make it table-driven in a bit.

    I have found a difference between the original minibasic and our implementation:
    doing "list 1000" will list line 1000 only in our implementation. In the original code, it lists FROM line 1000.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #364
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I just took a few minutes to look through the changes and make a few notes.

    1): Is the intent of `string awkward_save_helper()' to save with any file extension? If not, the `string awkward_save_helper()' implementation really should use something like `bool ends_with(string const&, string const&);' because most file systems and operating systems in use these days support internal '.' characters. If so, `void load(string name)' should probably drop the implied ".MBI" extension. (If both "test.123" and "text.123.mbi" is in the same directory "LOAD test.123" can't be interpreted as a potentially mistyped "text.123" with the implied extension.)

    2): What is "direct.h" used for?! O_o

    3): After finally realizing the problem I had with extending the virtual character codes, do you think it is time to make a couple of conversion tables so we can get the bigger bang for our precious bits?

    4): Did you ever do anymore work with variable names?

    Soma

  5. #365
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    How are things going?

    Paul

  6. #366
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Paul Panks View Post
    How are things going?

    Paul
    I think we have something that is generally functional (and in my experiments, about 3x faster than the original code - albeit probably 10x bigger too... Can't win them all).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #367
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by phantomotap View Post
    I just took a few minutes to look through the changes and make a few notes.

    1): Is the intent of `string awkward_save_helper()' to save with any file extension? If not, the `string awkward_save_helper()' implementation really should use something like `bool ends_with(string const&, string const&);' because most file systems and operating systems in use these days support internal '.' characters. If so, `void load(string name)' should probably drop the implied ".MBI" extension. (If both "test.123" and "text.123.mbi" is in the same directory "LOAD test.123" can't be interpreted as a potentially mistyped "text.123" with the implied extension.)
    Indeed, I was just doing some more work on that bit of code, and I was thinking exactly the same thing. And I think we should have different defaults for different types of files - e.g. TSAVE should save as test.bas, where SAVE saves as MBI - not quite sure what BSAVE should use.
    2): What is "direct.h" used for?! O_o
    Apparently not needed - I just commented it out and it still compiles just fine. I will remove it.
    3): After finally realizing the problem I had with extending the virtual character codes, do you think it is time to make a couple of conversion tables so we can get the bigger bang for our precious bits?
    I'm quite a fan of table-driven programming, so yes.

    4): Did you ever do anymore work with variable names?
    Not really - I decided to do some more refactoring first, and haven't got back onto it.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #368
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    "not quite sure what BSAVE should use"

    ".MBB"?

    "I'm quite a fan of table-driven programming, so yes."

    O_o

    "I decided to do some more refactoring first, and haven't got back onto it."

    I was thinking around hooking that implementation to virtual character codes. (So that a non-windows implementation wouldn't have to stick with whatever extended keys may be used.)

    Soma

  9. #369
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by phantomotap View Post
    "not quite sure what BSAVE should use"

    ".MBB"?
    Sounds good to me. I will work on that on the way home tonight. Should be doable if I don't get too sleepy on the train! [The advantage of sitting on a train for about 90 minutes each day is that small projects like this gets done pretty neatly].

    On the way here, I moved the long "if token == RUN ... else if token == LIST ... " into a table with function pointers.

    "I decided to do some more refactoring first, and haven't got back onto it."

    I was thinking around hooking that implementation to virtual character codes. (So that a non-windows implementation wouldn't have to stick with whatever extended keys may be used.)

    Soma
    Not quite sure how those things are related... Maybe what you were asking had nothing to do with what I was replying to - my reply was referring to making long variable names and allowing multiple arrays. Which makes little sense to your follow on point. So perhaps we can clear up what the original question was meant to be...

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #370
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    "So perhaps we can clear up what the original question was meant to be..."

    You answered the question I asked. ^_^

    In other words, instead of checking against `17942' in the "MBI" source, you'd check against `CC_APPLE' without ever implying that this was syntactic magic for `17942'. (The same as, say, loading the value 13 into `@(2000)' by default and having users check against that instead of 13.)

    Soma

  11. #371
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I've submitted code to fix up the extension - at least in the basic cases. We probably need a better method, really. But at least we get appropriate names for the respective files.

    Also submitted the table-driven parser of run, list, save etc.

    And I FINALLY fixed the "load test.bas" causes an error!! I had to make a stack of the scanner, which isn't very good solution, but it's better than an error.

    I also fixed the BSAVE command - it was broken if you just load a file and save again, because there was no compiled code. I just added a recompile.

    I also shuffled a bit of code around, as per usual

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  12. #372
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Paul Panks View Post
    How are things going?

    Paul
    Paul,

    Can you get the latest code from
    matsp / minibasic / downloads — bitbucket.org
    and give it a whirl. If something isn't working right, please let us know. If it IS working, please let us know that too.

    If you know someone else who wishes to try it out as well, please feel free to point them towards the link above.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #373
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Would anyone object to putting #ifdef _DEBUG around debugging code? A quick hack in interpreter.cpp shows that it's saving about 8KB there alone.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  14. #374
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I made another bit of code-clean-up - got about 30KB less code by re-arranging a bunch of things. [That's gcc-code, which I feel is quite bulky - mostly to handle exceptions].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  15. #375
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Sounds good. Looks good, too.

    Paul

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting textBox1->Text into a basic string.
    By azjherben in forum C++ Programming
    Replies: 5
    Last Post: 06-07-2009, 08:27 PM
  2. [ANN] New script engine (Basic sintax)
    By MKTMK in forum C++ Programming
    Replies: 1
    Last Post: 11-01-2005, 10:28 AM
  3. what are your thoughts on visual basic?
    By orion- in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 09-22-2005, 04:28 AM
  4. VC++ 6 & MASM (eek)
    By cboard_member in forum C++ Programming
    Replies: 2
    Last Post: 07-16-2005, 10:00 AM