Announcement

Collapse
No announcement yet.

ROM BASIC, yes you can !

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • ROM BASIC, yes you can !

    Flexibility was always the key with BASIC as a language, for any who are old enough, the way the world was in 1980.
    Code:
    000: FUNCTION PBMAIN AS LONG
    001: ? "HOW TO WRITE ROM-BASIC USING POWERBASIC"
    002: INPUT "ENTER A LOOP COUNT NUMBER > ",A$
    003: X& = VAL(A$)
    004: L& = 1
    005: ? STR$(L&)+" ";
    006: L& = L& + 1
    007: IF L& <= X& THEN GOTO 005
    008: ? "PRESS ANY KEY TO EXIT ...."
    009: WAITKEY$
    010: END FUNCTION
    I confess I have not written this stuff since about 1990 when a lady I knew had a twin floppy IBM PC to use MultiMate. If you have not written this style for a long time, its more work than you think but it makes the point that PowerBASIC supports a very wide range of programming styles.
    hutch at movsd dot com
    The MASM Forum

    www.masm32.com

  • #2
    I confess that I am still changing from a basic Basic programmer to a real PB programmer after 15 years!
    [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
    Kerry Farmer

    Comment


    • #3
      This is version two (2), emulating QBASIC/QB45 code circa 1990.
      Code:
      FUNCTION PBmain as LONG
      
      ? "Emulating QBASIC/QB45"+$CRLF
      ? $CRLF
      
      INPUT "Enter the loop count you require > ",A$
      
      XX& = VAL(A$)
      
      LC& = 1
      
      DO
      ? STR$(LC&);
      LC& = LC& + 1
      LOOP WHILE LC& <= XX&
      
      ? $CRLF
      ? "Urrrrgh, that's all folks, press any key . . . ."
      
      WAITKEY$
      
      End FUNCTION
      There is madness in the method of travelling down memory (not mammary) lane but I will come to that later.
      hutch at movsd dot com
      The MASM Forum

      www.masm32.com

      Comment


      • #4
        Originally posted by Steve Hutchesson View Post
        Flexibility was always the key with BASIC as a language, for any who are old enough, the way the world was in 1980.
        Thanks for your posting, Hutch! BASIC has gone a long way indeed. This topic brings back old memories to me. See my contribution in Café Vivian over here.
        Last edited by Albert Richheimer; 16 May 2018, 08:18 AM. Reason: Moved in order not to disturb PBCC dialect variations.
        „Let the machine do the dirty work.“
        The Elements of Programming Style, Brian W. Kernighan, P. J. Plauger 1978

        Comment


        • #5
          If you still want to run the BASIC from yester-year on a modern Windows OS, take note of the following;

          PC-BASIC has many settings and options http://robhagemans.github.io/pcbasic/doc/

          PC-BASIC is available from http://robhagemans.github.io/pcbasic/

          Joe

          Comment


          • #6
            Joe,

            The drift of this posting is not the nostalgia of running old basic versions but what styles you can write in the latest PBCC version and so far the simple examples are line numbered basic and early quick basic. There will be more to come that highlights the further progression of what PBCC can emulate so that people of many different styles of programming can make use of PBCC without the burden of political correctness.
            hutch at movsd dot com
            The MASM Forum

            www.masm32.com

            Comment


            • #7
              This is version three (3), the style of code available in early PBCC.
              Code:
              ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              
                  DECLARE FUNCTION atoi CDECL LIB "MSVCRT.DLL" ALIAS "atoi"(ByVal pstr as DWORD) as DWORD
              
              ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              
              FUNCTION PBmain as LONG
              
                  LOCAL lcnt as DWORD                 ' loop count total
                  LOCAL icnt as DWORD                 ' iteration counter
              
                  StdOut "Early PBCC with API and external function support"+$CRLF
              
                  Input "Enter the loop count you require > ", UserInput$
              
                  lcnt = atoi(StrPtr(UserInput$))     ' you get it for nothing and it works OK
                  icnt = 1
              
                  Do
                    StdOut format$(icnt)+" ";
                    icnt = icnt + 1
                  Loop While icnt <= lcnt
              
                  StdOut $CRLF+"Press any key . . . ."
              
                  Waitkey$
              
              End FUNCTION
              
              ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              hutch at movsd dot com
              The MASM Forum

              www.masm32.com

              Comment


              • #8
                The reason for writing these three (3) simple examples was to make the point that there are many different ways to write code and the three examples all build at the same size, 14,336 bytes. The final measure of a binary file is what ends up in it and whether it does what its author intended. Once that criterion is achieved the rest does not matter, it does not have to be politically correct, it does not have to conform to the current group consensus and the only criterion that matters is that of the author.

                You can cobble it together in hex, write it as mnemonics, stick to ancient basic, OOP(S) it if you can suffer it, craft it in modern basic intrinsics, perform pure API code, use as much as you can be bothered of the MSVCRT and similar C runtime DLLs, whatever floats your boat because in the final analysis, you just don't have to listen to anyone telling you what to do or how to do it. As you have a collective here of people who have different experience in different areas, it is a worthwhile approach to ask for their assistance if you don't know how to do something or perhaps want to try and make something faster but the final evaluation must be yours, not the dictates of others or conformity to someone elses ideas.

                In the gap between Bob passing away and Adam becoming the new owner of PowerBASIC, a lot of patronising nonsense occurred and while I was appalled at the way Vivian Zale was treated and the fall off of older members who were less than enchanted with the moronic behaviour, this is coming to an end as I have read the new rules of the forum and this style of nonsense will not be tolerated any longer.
                hutch at movsd dot com
                The MASM Forum

                www.masm32.com

                Comment


                • #9
                  Originally posted by Steve Hutchesson View Post
                  The reason for writing these three (3) simple examples was to make the point that there are many different ways to write code and the three examples all build at the same size, 14,336 bytes. The final measure of a binary file is what ends up in it and whether it does what its author intended. Once that criterion is achieved the rest does not matter, it does not have to be politically correct, it does not have to conform to the current group consensus and the only criterion that matters is that of the author.

                  You can cobble it together in hex, write it as mnemonics, stick to ancient basic, OOP(S) it if you can suffer it, craft it in modern basic intrinsics, perform pure API code, use as much as you can be bothered of the MSVCRT and similar C runtime DLLs, whatever floats your boat because in the final analysis, you just don't have to listen to anyone telling you what to do or how to do it. As you have a collective here of people who have different experience in different areas, it is a worthwhile approach to ask for their assistance if you don't know how to do something or perhaps want to try and make something faster but the final evaluation must be yours, not the dictates of others or conformity to someone elses ideas.

                  In the gap between Bob passing away and Adam becoming the new owner of PowerBASIC, a lot of patronising nonsense occurred and while I was appalled at the way Vivian Zale was treated and the fall off of older members who were less than enchanted with the moronic behaviour, this is coming to an end as I have read the new rules of the forum and this style of nonsense will not be tolerated any longer.
                  I have to agree. There is an old saying "If it works don't mock it". The only problem is that when applying for a job, many employers expect their staff to carry umpteen years experience with the latest programming fads. But for individuals creating their own software then it doesn't matter what programming language or methodology is used. All that matters is that the programmer had fun developing it.

                  Comment


                  • #10
                    Originally posted by Raymond Couzens View Post

                    I have to agree. There is an old saying "If it works don't mock it". The only problem is that when applying for a job, many employers expect their staff to carry umpteen years experience with the latest programming fads. But for individuals creating their own software then it doesn't matter what programming language or methodology is used. All that matters is that the programmer had fun developing it.
                    Agreed. I've even stumbled across old QuickBasic programs I wrote a zillion years ago, and recompiled them as 32-bit applications in QB64 so they'd run under 64-bit Windows. (Easier than converting them to PB.)
                    Michael Burns

                    Comment


                    • #11
                      In post #1, line 9 your code is
                      Code:
                      009:  WAITKEY$
                      I am not aware of any ROM-based or other interpreted BASIC (e.g., GW-Basic, QBasic) which supported a 'WAITKEY$' statement... especially with the variable type specifier '$' suffixed.

                      MCM

                      Comment


                      • #12
                        Originally posted by Michael Mattias View Post
                        In post #1, line 9 your code is
                        Code:
                        009: WAITKEY$
                        I am not aware of any ROM-based or other interpreted BASIC (e.g., GW-Basic, QBasic) which supported a 'WAITKEY$' statement... especially with the variable type specifier '$' suffixed.

                        MCM
                        Yep, it was a long time before there was anything other than INPUT or an INKEY$ loop to pause a program.

                        Comment


                        • #13
                          but what styles you can write in the latest PBCC version
                          Hmm, if your code is intended to be PB/CC code... there are no "mysteries" and WAITKEY$ is perfectly valid.

                          (Although your post did manage to confuse me!)

                          Otherwise.... another issue might be the use of a variable with a "&" type suffix. IIRC LONG integers were never supported by ROM or other Interpreted 16-bit BASICs; you had your choice of integer (%), single precision (!) and string ($)... and no more.

                          MCM

                          Comment


                          • #14
                            As the three examples are written in PowerBASIC's PBCC, the punch line is "emulation". If you wanted the real thing[tm] you would warm up your 1980 IBM PC or your MS-DOS 5.0 box to run the earlier forms of BASIC. There was madness in the method, the three examples do much the same thing, build at much the same size yet are 3 entirely different styles of writing BASIC code.

                            The topic addresses a simple problem for many older BASIC programmers, there is no "politically correct" technique to write PB, you can produce the binary any way you like if you can get it to work and if it does the job you want. None of the example may be your style or mine but free form programming is one of the hallmarks of PowerBASIC and there is no "One True Way", there are many ways to write code, these have just been a few simple older ones.
                            hutch at movsd dot com
                            The MASM Forum

                            www.masm32.com

                            Comment


                            • #15
                              This is purely for those with a sense of humour. I downloaded QB64 and built a simple program with it.
                              Code:
                              PRINT "Arrrrgh, G'day !"
                              var& = 1
                              DO
                                  PRINT STR$(var&) + " ";
                                  var& = var& + 1
                              LOOP WHILE var& <= 100
                              PRINT "Thats all folks"
                              Build was as slow as a wet week and it built at 1,460,736 bytes and ran as slow as a wet week. I will probably stick to using PBCC.
                              hutch at movsd dot com
                              The MASM Forum

                              www.masm32.com

                              Comment


                              • #16
                                !!!!
                                The topic addresses a simple problem for many older BASIC programmers, there is no "politically correct" technique to write PB, you can produce the binary any way you like if you can get it to work and if it does the job you want.
                                {gasp} You don't mean, ahem, "It's not the paintbrush, it's the artist," do you? I'm flattered!

                                MCM

                                Comment


                                • #17
                                  Originally posted by Kerry Farmer View Post
                                  I confess that I am still changing from a basic Basic programmer to a real PB programmer after 15 years!
                                  +1 for that. Someday I'll understand and master sub- and super-classing controls.
                                  Real programmers use a magnetized needle and a steady hand

                                  Comment


                                  • #18
                                    Agreed, there is no "politically correct" technique.

                                    However, there is both
                                    a. "clear maintainable source code" and
                                    b. "obscure, complex, convoluted, difficult to maintain source code".

                                    Writing the former has nothing to do with political correctness.

                                    PB provides many features including a broad range of intrinsic functions and statements, built in equates etc,etc to achieve the former and it is a good idea to learn and use as many of them as possible.
                                    Eschewing whole categories of them in favour of more complex constructs is seldom the optimal solution to a programming problem.


                                    (Using those capabilities also does not have any connection to an old kids' TV program that a certain poster seems obsessed with.)

                                    Comment


                                    • #19
                                      Hi Stuart,

                                      > a. "clear maintainable source code"

                                      Problem is its just a statement of "somebodies" politically correct. If you are a GOTO line numbered person you have an entirely different view on the former statement. Now it is the notion of range of capacity that we differ on, I have no problem with PB instrinsics and use many of them but I would hate to have to be restricted to that range when you can do so much more. Pirate your way through the MSVCRT functions and while they are nothing exciting, you get them for nothing. Then there is the ever expanding Windows API that is the base for the entire interaction with the OS as there is no other way.

                                      When you have a basic compiler written by an expert in assembler programming, you have capacities that appear to be the method by which a future PB will be written in and this includes an Intel notation inline assembler, then you have the FASTPROC procedures that have no overhead at all which you write your own code in then there is the block escapes for asm "PREFIX "!" which makes it even easier to directly port inline VC, asm dumps and of course MASM code directly into PB.

                                      I am not willing to give up that range for "political correctness" and would not advocate anyone else doing it either. The "if it works, do it" approach is one tuned back into the eye of the beholder, write it, let her rip and if it does the job, who cares what the "politically correct" think.

                                      Michael,

                                      > "It's not the paintbrush, it's the artist,"

                                      I have never had any problem with this view, even though its not exactly how I approach the subject. I am very much out at the forge making an even harder axe and when you have it up and going you master how to sharpen it. To the programmer it translates to write the correct algorithm, make sure its robust and economical then kick the guts out of it to make it faster. On a one off level its often a waste of time but for re-usable code its the "one true way" as it may get use between billions to trillions of times.

                                      Its a theory of cost based on usage. If it only gets used a few times, write it in a visual garbage generator, if it gets use a few thousand times, write it with the normal intrinsics you have available, if it gets used some millions of times, start to look for highly efficient code but if it gets battered billions of times, the unit cost gets so low that you can afford to spend some extra time to extract those extra few pico seconds out of it.
                                      hutch at movsd dot com
                                      The MASM Forum

                                      www.masm32.com

                                      Comment


                                      • #20
                                        Originally posted by Steve Hutchesson View Post
                                        Build was as slow as a wet week and it built at 1,460,736 bytes and ran as slow as a wet week. I will probably stick to using PBCC.
                                        QB64 used to be a halfway-decent product, but several years back it ran afoul of the Open Source Gestapo and some radical changes (not for the better) had to be made to comply with the draconian closed nature of open source.

                                        I am legally blind. Please forgive any typos. I do try and catch as many as I can.

                                        Comment

                                        Working...
                                        X