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

This is a discussion on Converting MINI-BASIC in MASM over to C++? within the Projects and Job Recruitment forums, part of the Community Boards category; Global variables are necessary, I think. I know they are hard to keep track of, but that is how programming ...

  1. #16
    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. #17
    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. #18
    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. #19
    Professional Chef leeor_net's Avatar
    Join Date
    Apr 2004
    Location
    Charles Town, WV
    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.
    - Leeor

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

    Paul

  6. #21
    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).

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

  8. #23
    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).

  9. #24
    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.

  10. #25
    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

  11. #26
    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.

  12. #27
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Ok, thanks for the update. Sounds good so far.

    Paul

  13. #28
    Professional Chef leeor_net's Avatar
    Join Date
    Apr 2004
    Location
    Charles Town, WV
    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!
    - Leeor

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

    Paul

  15. #30
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Well, I'm just about ready to try the "list" command. Currently it doesn't quite work (says Syntax error), but I should have that fixed in minutes.

    I completely changed the way the actual program is stored - I'm using a linked list rather than a fixed area of memory for the program store.

    It's still a LONG way off working, but it's getting in the right direction.

    Next, I think will be save and load, so that I can start using some saved code to try things out, rather than having to type it all in.

    Edit: changed wording and added a bit of what I'm doing next.

    --
    Mats
    Last edited by matsp; 03-16-2009 at 02:14 PM.
    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.

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, 09: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, 05:28 AM
  4. VC++ 6 & MASM (eek)
    By cboard_member in forum C++ Programming
    Replies: 2
    Last Post: 07-16-2005, 11:00 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21