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

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    76

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

    Is this an easy conversion? Converting MINI-BASIC, written in MASM, over to C++? The Yahoo group for MINI-BASIC is here:

    http://tech.groups.yahoo.com/group/minibasic/

    Paul

  2. #2
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    I should also note that MINI-BASIC uses the Windows API for display, keyboard and file I/O. This should be easy to convert to C or C++ using the stdlib.h

    Paul

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    The original Palo Alto Tiny BASIC appeared in 1976 in the pages of Dr. Dobbs Journal. MINI-BASIC is a modern variant of Palo Alto Tiny BASIC using Windows API calls for screen, keyboard and file I/O. It has 26 variables, A-Z, and 1 array, @(I).

    Despite these limitations, MINI-BASIC is a robust programming language written in ASM. More commands can be added with ease.

    Paul

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Not having looked at it, I'd say that rewriting it in C++ is an "intermediate" difficultly - far from impossible, but not a "5 minutes whilst browsing the web" either.

    --
    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
    What should a person focus on when converting from one language to another?

    Paul

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    First, you need to understand BOTH languages well. Next you need to have some way of testing the new code, to ensure that it still does the same thing as the old one.

    I have looked a bit at the Mini-Basic code now, and it's using an awful lot of global variables and various naughty assembler tricks (like calls to the middle of a function), which makes the task a bit difficult.

    --
    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
    Calls to the middle of a function? Could that be causing the occasional (and strange) Windows API error?

    Paul

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Paul Panks View Post
    Calls to the middle of a function? Could that be causing the occasional (and strange) Windows API error?

    Paul
    Possibly, but I think that may be other problems. I have currently got it displaying the console window with a title. See attached picture.

    Edit: That's with 278 lines of code.

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

  9. #9
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Looks good. Is that a mock screen, or the real thing?

    Paul

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Paul Panks View Post
    Looks good. Is that a mock screen, or the real thing?

    Paul
    It's real in the sense that I copied the MASM code into C++ - although it is more "assembler written in C" than C++, if you see what I mean.

    I'm currently trying to get the input going - it's a bit long-winded to try to translate back from assembler, but I'm getting there. Once I have basic input working, I'll go to bed for today. Don't know when I will continue (and I don't know if I'll EVER finish it).

    I've got over 600 lines, but that includes a bit of "comments of work to be done with untranslated assembler code".

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

  11. #11
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Looks good. Keep up the good work.

    Paul

  12. #12
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Quote Originally Posted by matsp View Post
    Not having looked at it, I'd say that rewriting it in C++ is an "intermediate" difficultly - far from impossible, but not a "5 minutes whilst browsing the web" either.

    --
    Mats
    I think the easiest way to convert it is to study the assembly code and write a C++ program to interpret it in C.

    Paul

  13. #13
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Quote Originally Posted by matsp View Post
    Not having looked at it, I'd say that rewriting it in C++ is an "intermediate" difficultly - far from impossible, but not a "5 minutes whilst browsing the web" either.

    --
    Mats
    True. It does require some patience to re-write in C/C++.

    Paul

  14. #14
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Quote Originally Posted by matsp View Post
    First, you need to understand BOTH languages well. Next you need to have some way of testing the new code, to ensure that it still does the same thing as the old one.

    I have looked a bit at the Mini-Basic code now, and it's using an awful lot of global variables and various naughty assembler tricks (like calls to the middle of a function), which makes the task a bit difficult.

    --
    Mats
    Global variables are fine, right? Aren't they useful in such a large program?

    Paul

  15. #15
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Paul Panks View Post
    Global variables are fine, right? Aren't they useful in such a large program?

    Paul
    Global variables are hard to keep track of, since it's hard to follow where such variables are being changed. I currently keep some global variables, but a lot of variables are passed around between functions.

    And it's only 120KB of source code, so I wouldn't call it a "large" program.

    How is your translation work going? Or are you waiting for me to do it for you?

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

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