Asm & Basic Fun : BASIC | |||||||||||||||||||||||||||||||||||||
This page is a First Draft. | |||||||||||||||||||||||||||||||||||||
OTHER | OPTIMZ | ASM | BAS/PAS | HOME | FILES | LINKS | |||||||||||||||||||||||||||||||
Basic & Pascal: | |||||||||||||||||||||||||||||||||||||
On this page are: UPDATE ON MOVING FORWARD: This decision comes after looking at some of my older source code, as well as code from others, all well commented and well structured. The source in 68K / PDP-11 / ARM Assembly Language was easy to follow and understand, that in BASIC V and Pascal was still understanable, the source in other Programming Langauges was quite more difficult to follow. This means that at least for me Assembly Language is the most maintainable, with ARM Assembly being the best, and ARM BASIC V and Pascal are the most usable High Level Languages. Everyone has there view of a good usable Programming Language. BASIC today is a well structured modern programming language, this is not the line numbered BASIC of the past. Structured BASIC began at Dartmouth in the late 1970's in SBASIC, meant to negate the need of line numbers. There is no single standard followed by BASIC, though there are two generally followed defacto standards, those of BBC BASIC and MS Structured BASIC. There is not even any reason to use GOTO or GOSUB in any modern structured BASIC. The BASIC implementation we are using is structured, this is BBC BASIC V on RISC OS. This is a more capable than people seem to think, BASIC is a very capable language if used well. ARM BASIC V represents one of the Defacto standards for Modern Structured BASIC. We also look at Pascal, as it is a similar level of lanugage with similar abilities and structure to modern BASIC. There is no question that Pascal is just as simple to use and learn as BASIC, as well as being just as universally usable as BASIC. BASIC V is a well structured language, with named procedures and user functions that contain code blocks, and other structured elements of control flow. Unfortunately there is the EVAL statement in BBC BASIC, making some programs difficult to compile. Though BASIC V does include simple means to call OS functions directly, with the SYS statement. There is the helpful Assembler in BASIC V (in RISC OS) that can be used to enhance BASIC programs, or it can be used to write full standalone machine language programs, or even modules. In sum RISC OS and BASIC V are a perfect fit for each other. NOTE: It will be a while before any Pascal is seen here. May possibly do some C just to see if I can get myself to do better at following C source code. Regardless of High Level Language there will always be a lot of assembly in any project. |
|||||||||||||||||||||||||||||||||||||
BBC BASIC V on RISC OS: | |||||||||||||||||||||||||||||||||||||
Without any question BBC BASIC V on RISC OS is my favorite basic, bar none. The structure of BBC BASIC makes programming a true joy. Then there is the choice of indirection operators, with a BCPL like feel, that make many things very easy, and is an improvement over explicit structured types. Add to this the ability to directly call SWI's as well as directly call machine code by address. Then there is the built in ARM assembler, allowing easily writing assembly language routines, or even full programs or modules. All of this makes BBC BASIC on RISC OS the best single BASIC in my view. BBC BASIC V is a part of the RISC OS ROM or ROM Image. This makes the interpreter always available, and usable on all RISC OS running computers. BBC BASIC V is one of the fastest purely interpreted languages, as it is implemented in RISC OS. To the core of the OS BBC BASIC V is usable, with some included applications written in this language, some which are widely used. BBC BASIC V is a well structured language, line numbers are only needed for reference on errors (or if typing in directly to the interpreter). The native support for user defined block oriented Functions and Procedures help to better sub-divide your code in a logical manner. Do to the extreme structure of BBC BASIC V there is never any need to use GOTO or GOSUB, these are relics of an earlier era of BASIC and FORTRAN. Beyond this there is the ability to use multiple source modules in the form of what BASIC V calls Libraries, these are just multiple source modules with some reasonable limits. BASIC V is a very language to use, even for more advanced tasks. Programs may be written in a text editor, that supports tokenizing the language, like the in ROM !Edit application, without ever having to directly enter the program direct to the interpreter. A program once written can be ran by double clicking on it, without needing to explicitly invoke BASIC. The graphics commands that are built into BASIC V are very capable, and can do more than most think. There are also builtin sound commands that are capable of using installed voices to good effect. This is truly an all around language without any real limit on what can be done. BASIC V provides very good operators to manage Indirection, like what pointers do in C. There are operators for offset indirection of Bytes, Words, and Floats, making different kinds of access very simple to achieve. This level of indirection more than makes up for the lack of formal structured data types in BASIC V. Once you learn the indirection operators it is likely you will like them better than even those known as pointers in C like languages. BASIC V even has means of directly calling the Operating System, using the SYS command, which takes parameters for register values, returns register values, and even returns the flags if requested. There is also support for directly calling machine language code directly from within BASIC V. This allows us to write full blown WIMP programs in BASIC, and a lot more, pretty much lifting all restrictions on usage. BASIC V includes a builtin ARM Assembler, that is very well written. This may be used for code blocks that can be used within BASIC V programs. It is also possible to create standalone Programs or modules, making BASIC V a good tool for writing programs in Assembly Language. Do to the nature of the assembler, and the ability to use BASIC to produce macros, BASIC V is a very capable ARM assembler. Some of the features of BBC BASIC V are difficult to compile, like the EVAL statement. As such we focus on the subset of the language that is reasonable to compile, this still includes 99.7% of the defined language. At the same time we make sure to continue to do well in the interpreter, not sacrificing anything that aids in the interpreted programs in BASIC V. Pages linked from this section are to be:
All the sub sections to be linked in will take time to come, one at a time as I relearn details. There is the goal to keep everything as simple as possible in every case. The compiler will be very slow to come, being a simple Recursive Decent one pass compiler, only minimal register usage tracking for speed optimization, and only selective linking for size optimization. |
|||||||||||||||||||||||||||||||||||||
A Pascal Subset on RISC OS: | |||||||||||||||||||||||||||||||||||||
We will look at an integer only subset of the Pascal language for RISC OS on the ARM CPU. This is a language that correctly targets ARM CPU's from the ARMv2 through the ARMv6, and versions of RISC OS from RISC OS 2.00 through the newest RISC OS 5.xx. The language implementation supports modular compilation by the unit modules (using the unit, interface, implementation, and uses keywords to define a unit), compound user types, strings, most array types, the structure rules of Pascal, and most of the core language (excluding things like sets). This makes for a Pascal that can almost keep up with ARM BASIC V in usability, almost. This will also detail how to interact with RISC OS, which requires some Assembly Language. This is much the same as with most other compiled High Level Languages (such as C, C++, etc). |
|||||||||||||||||||||||||||||||||||||
This site created on RISC OS using !Zap. |
|||||||||||||||||||||||||||||||||||||
It turns out to be easier to write and maintain a site with tables than one without tables. |