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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Global variables are necessary, I think. I know they are hard to keep track of, but that is how programming can be sometimes. I don't know much C, so someone else would have to translate it to C.

    Paul

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Paul Panks View Post
    Global variables are necessary, I think. I know they are hard to keep track of, but that is how programming can be sometimes. I don't know much C, so someone else would have to translate it to C.

    Paul
    Global variables are SOMETIMES necessary, but often used as a lazy excuse for not passing variables from one function to another.

    Why do you want this translated to C?

    --
    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. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Because I think it would run better, with fewer Windows API errors. In C or C++, there would be a standard library which could use the Windows API for handling the keyboard, display and file I/O.

    As it is now, MINI-BASIC is a fragile piece of software. It crashes on occasion with Windows API errors. It is a mystery to me why this occurs.

    Paul

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Paul Panks View Post
    Because I think it would run better, with fewer Windows API errors. In C or C++, there would be a standard library which could use the Windows API for handling the keyboard, display and file I/O.

    As it is now, MINI-BASIC is a fragile piece of software. It crashes on occasion with Windows API errors. It is a mystery to me why this occurs.

    Paul
    Right, I've done some work, and I can probably say that I wouldn't be surprised if the API errors you get are caused by global variables being changed when some other bit of code expects it to remain the same.

    As to wheter C or C++ or Assembler is "more safe", I'd say all three languages are capable of doing the wrong thing, and badly written code in either of them will not work reliably.

    --
    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.

  5. #5
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Yeah. That's true. I don't know how badly written MINI-BASIC is, but it does crash occasionally with Windows API errors. Which is unfortunate. Translating it to C or C++ shouldn't be impossible. It has a very limited subset of the traditional BASIC language. It has 26 scalar variables and 1 array -- denoted by @(I).

    Paul

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Sure. But it's not the easiest way to "translate" it.

    I'm still working my way through it, and I'm just about to implement the begginnings of the parser.

    Most of the code so far is following very closely the original code, but I will use C style strings in the parser, to make life a bit more C-friendly.

    --
    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. #7
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Ok, thanks for the update. Sounds good so far.

    Paul

  8. #8
    Registered User
    Join Date
    Apr 2004
    Location
    Ohio
    Posts
    147
    It probably comes down to shoddy programming -- that is usually the case with so-called fragile software. Fragile = badly written. Being written in ASM only compounds these problems when somebody is using the language without a complete and thorough understanding of internal machine code.

    If you were to convert or 'port' it, I would suggest that you just rewrite it from scratch. ASM - C++ is, if you ask me, a waste of time.

    Note, though, that C++ is only based on C... it is not C. (I know that's going to start an argument but I'm quoting Bjorn Stroustrup himself). You would need to choose one or the other. C++ is a lot easier when it comes to dealing with errors and the STL names it almost trivial to write an interpretter.

    I would say, however, that if you're not familiar with C/C++ you should probably start with a project a little smaller than that.

  9. #9
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    So is it possible to convert to C++?

    Paul

  10. #10
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Quote Originally Posted by leeor_net View Post
    It probably comes down to shoddy programming -- that is usually the case with so-called fragile software. Fragile = badly written. Being written in ASM only compounds these problems when somebody is using the language without a complete and thorough understanding of internal machine code.

    If you were to convert or 'port' it, I would suggest that you just rewrite it from scratch. ASM - C++ is, if you ask me, a waste of time.

    Note, though, that C++ is only based on C... it is not C. (I know that's going to start an argument but I'm quoting Bjorn Stroustrup himself). You would need to choose one or the other. C++ is a lot easier when it comes to dealing with errors and the STL names it almost trivial to write an interpretter.

    I would say, however, that if you're not familiar with C/C++ you should probably start with a project a little smaller than that.
    Assembly language is a different animal altogether, true...but I think porting it to C/C++ would benefit the C/C++ community. It is a useful language modeled after Palo Alto Tiny BASIC from 1976.

    Paul

  11. #11
    The larch
    Join Date
    May 2006
    Posts
    3,573
    It is possible to implement it from scratch (write a program that does the same thing functionally). I don't think there is any direct way to convert asm to C++ or C, since it is lacking all the higher level constructs. Assembly just contains less human readable information than the equivalent C or C++ code.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  12. #12
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Writing it from scratch in C would require examining how the program works first.. I believe anyway.

    Paul

  13. #13
    Registered User
    Join Date
    Apr 2004
    Location
    Ohio
    Posts
    147
    Quote Originally Posted by Paul Panks View Post
    Writing it from scratch in C would require examining how the program works first.. I believe anyway.

    Paul
    True... or you could take a BASIC standard approach and write a new interpretter using BASIC syntax.

    I think you're best bet is to just write a new basic interpretter or use an existing open-source interpretter.

    It looks like you're getting a bit of help with it though so good luck!

  14. #14
    The larch
    Join Date
    May 2006
    Posts
    3,573
    And converting Assembly to C would require you to study how the program works (what is input, what is output) as well as the implementation details of the assembly version. The latter you wouldn't have to do, since you'd just design that yourself any way you like.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  15. #15
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Yeah, I think it would work that way. Hopefully it can work.

    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