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

  1. #31
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Sounds good! Thanks for the update.

    Paul

  2. #32
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Just done a load and save function, and VERY basic (pun intended!) testing.

    Picture for proof (check the URL for "proof" [it's either that, or I'm spending a lot of time doing photoshopping! ]).

    Note that the program is absolutely not valid basic, but just something I typed in before doing save.

    Edit: I just loaded pitman.mbi as well - it seems to work so far as I can tell. Just paused it a bit into the listing.

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

  3. #33
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Hey, that's pretty cool, matsp. Would you mind sharing what you have so far? I'd be interested to see what approach you've taken with this. Maybe some of us could pitch in on whatever else needs to be done, to make things a little easier? Just a thought.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #34
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I'd be happy to share it, but bear in mind that I'm following the original format/functions and it's a bit messy and hacky.

    Once I've got something roughly working (at least a small section of the functionality of the language, such as assigning variables, goto's, gosub's and for-loops working), I'm thinking that I should do a bit of a refactoring, and use more C++ style approach, rather than "Assembler written in C", as it is now.

    I don't think that will happen for a few weeks yet.

    And I'd rather share something that I'm reasonably proud of, than a "quick hack".

    --
    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. #35
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Well, I figured it would be pretty hackish, given what you have to work with. But I'm game. I don't really have a lot of (practical) assembly experience, but there are other areas I could be of some use. And I don't mind working in straight C, either - it doesn't have to be very fancy, it just has to work, right? Either way, keep us posted on the progress. It looks like an interesting project.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  6. #36
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I may put something up tonight - I'm not doing any of this at work, you know... ;-)

    --
    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. #37
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    No rush - I don't expect this to become your second job, either!
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  8. #38
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Looks nice. I think it would work well in C++. I don't know about speed-wise, if it would be faster, but hopefully those Windows API errors would be less frequent.

    Paul

  9. #39
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Paul Panks View Post
    Looks nice. I think it would work well in C++. I don't know about speed-wise, if it would be faster, but hopefully those Windows API errors would be less frequent.

    Paul
    It will almost certainly be slower (although some of the assembler tricks makes short code rather than fast code, it's still VERY unlikely that the code will run faster in C++).

    I haven't had any Windows API errors yet.

    --
    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. #40
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Yeah, Windows API errors were frequent in the assembled version.

    Paul

  11. #41
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Just thought I'd share that "run" now works too - it only supports ONE command within the code (PRINT, and only with quoted strings as argument), but it's a move in the right direction.

    --
    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. #42
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Quote Originally Posted by matsp View Post
    Just done a load and save function, and VERY basic (pun intended!) testing.

    Picture for proof (check the URL for "proof" [it's either that, or I'm spending a lot of time doing photoshopping! ]).

    Note that the program is absolutely not valid basic, but just something I typed in before doing save.

    Edit: I just loaded pitman.mbi as well - it seems to work so far as I can tell. Just paused it a bit into the listing.

    --
    Mats
    Quote Originally Posted by matsp View Post
    Just thought I'd share that "run" now works too - it only supports ONE command within the code (PRINT, and only with quoted strings as argument), but it's a move in the right direction.

    --
    Mats
    That's definitely a great start. It's looking good!

    Paul

  13. #43
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Quote Originally Posted by matsp View Post
    Just done a load and save function, and VERY basic (pun intended!) testing.

    Picture for proof (check the URL for "proof" [it's either that, or I'm spending a lot of time doing photoshopping! ]).

    Note that the program is absolutely not valid basic, but just something I typed in before doing save.

    Edit: I just loaded pitman.mbi as well - it seems to work so far as I can tell. Just paused it a bit into the listing.

    --
    Mats
    Looking good.

    Paul

  14. #44
    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

  15. #45
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Quote Originally Posted by matsp View Post
    Just done a load and save function, and VERY basic (pun intended!) testing.

    Picture for proof (check the URL for "proof" [it's either that, or I'm spending a lot of time doing photoshopping! ]).

    Note that the program is absolutely not valid basic, but just something I typed in before doing save.

    Edit: I just loaded pitman.mbi as well - it seems to work so far as I can tell. Just paused it a bit into the listing.

    --
    Mats
    Does the list function list the whole program?

    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