A series of BASIC compilers have been produced by Basmark Corporation and by Microsoft Corporation for the IBM PC. Since all these are based on the original Microsoft compiler, BASICA, this compiler is the basis for comparison. While Microsoft’s QuickBASIC 2.0 is intended to be a superset of BASICA, conflicts exist but the importance of BASICA implies that these conflicts be regarded as inadequacies in QuickBASIC. Still the new features of QuickBASIC are useful. The current Basmark compiler is intended to be compatible with the Microsoft compiler defined as BASICA augmented with the harmonious features of QuickBASIC.
This discussion focuses on the differences between Microsoft BASIC and Basmark QuickBASIC. By necessity there are differences: due to the difference in underlying operating systems, due to differences between multi-user and single-user systems, and due to differences in hardware configurations.
The Microsoft BASIC compiler runs on the IBM Personal Computer under the MS-DOS operating system. It generates code for an Intel 8088 processor with an optional Intel 8087 numeric coprocessor. The system supports one user and does not support multi-tasking. The architecture is segmented into 64 Kbyte chunks; this segmentation scheme is directly supported by the Microsoft compiler. Addresses, like integer numbers, are 16 bits in size. A modified ASCII character set is used.
The Basmark QuickBASIC Compiler runs under several versions of the UNIX Operating System on a variety of processors and architectures. These systems generally support multiple simultaneous users as well as multi-tasking. Memory management schemes vary with the architecture. Addresses are usually either 16 or 32 bits in size. The standard ASCII character set is used.
In most cases, the lexical and syntactic differences between Basmark QuickBASIC and Microsoft BASIC are the result of limitations in the Microsoft compiler being either eased or applied slightly differently in Basmark QuickBASIC. The major exception to this has to do with the number of significant characters in variable names. In Microsoft BASIC, variable names are significant to 40 characters. The Basmark QuickBASIC Compiler also recognizes 40 significant characters; however on many UNIX systems the native assembler and link editor recognize only 8 significant characters. On such a system, the assembler or link editor may fail if presented with two or more variables which are identical in the first 8 characters. Although this is actually a problem with the native assembler or link editor, it is important to note when using the Basmark QuickBASIC Compiler. The remaining lexical and syntactic differences follow.
In Microsoft BASIC, each line of a source file may be up to 253 characters long and is terminated by a carriage return character followed by a line feed character. In Basmark QuickBASIC, each line is terminated by a line feed character; no line length limit exists.
In statements and functions which make references to files, Basmark QuickBASIC uses UNIX path names rather than MS-DOS file specifications. No default extensions are assumed since file extensions are not enforced in UNIX as they are in MS-DOS.
Microsoft BASIC expects all lines to be numbered unless the /N option is given to the compiler; even in this case, line numbers that appear must be in ascending order. In Basmark QuickBASIC, line numbers are entirely optional and may appear in any order.
In Microsoft BASIC, the maximum number of arguments to call and def fn is 60. In Basmark QuickBASIC, this limit is 1022.
In Microsoft BASIC, no array may have more than 60 dimensions. In Basmark QuickBASIC, the limit is 1023.
The differences in the run-time environments for Microsoft BASIC and Basmark QuickBASIC fall into several categories.
Microsoft BASIC has special language features for accessing IBM PC hardware such as joysticks, light pens, screen memory, serial ports, etc. Since Basmark QuickBASIC makes no assumption about the hardware on which it is running, it does not support these language features. If custom hardware must be accessed by a BASIC program without customizing the compiler, an external subroutine or function can be written to perform the access.
Several statements and functions are not implemented or are implemented slightly differently in Basmark QuickBASIC since they are hardware dependent. In particular, circle, draw, get, line, paint, palette, pcopy, pmap, point, preset, pset, put, screen, view and window are not implemented since they all depend on graphics capabilities of the IBM PC. Color is implemented in a limited form.
Stick, on com, com, on key, key, on pen, pen, on strig, strig, on play, and on timer are not implemented since they depend on IBM PC-specific hardware. Likewise, inp, out, open "com..., and wait are not implemented since they depend on the existence of the IBM PC serial ports. Play and sound are not implemented because they depend on the sound-generating ability of the IBM PC. Cls, inkey$ and locate are implemented but dependent upon a terminal capability database. Beep simply sends an ASCII bell character to the terminal.
Erdev, erdev$, ioctl and ioctl$ are not implemented since they depend on the MS-DOS device driver system.
Lprint and lpos are dependent upon a dedicated printer port in Microsoft BASIC; UNIX has no dedicated devices although the notion of a printer is strong. This statement and function are implemented in a modified form which uses the environment variable ‘LPR’ wherein the command to access the printer is stored.
In Microsoft BASIC, the floating-point format of the 8087 numeric coprocessor is used. In Basmark QuickBASIC, the floating-point format of the actual floating-point processor in use is adopted. This may result in some floating-point operations differing slightly; however, most systems now follow the ANSI/IEEE Standard 754-1985 and this can be used with some confidence.
Both compilers expect file specifications to occur as string variables or constants and generate code to pass them unaltered to the run-time routines. Naturally, the Microsoft BASIC run-time routines expect these file names to adhere to MS-DOS naming conventions while Basmark QuickBASIC expects UNIX file naming conventions to be used. Similarly for files, the available file name matching metacharacters follow operating system conventions.
Microsoft BASIC allows up to 128 files to be open simultaneously. Basmark QuickBASIC allows 15 files to be open simultaneously. This restriction is a direct result of a UNIX limitation on the number of simultaneously open files. File numbers may not exceed 100.
Basmark QuickBASIC presents to the programmer a view of memory that is compatible with Microsoft BASIC. Addresses are 16 bits. A 16-bit segmentation register is maintained and is always used to supply the high-order 16 bits in all memory accesses via peek and poke.
Microsoft BASIC allows external functions to be called via absolute numeric addresses. In Basmark QuickBASIC, absolute addresses are avoided in favor of symbolic names; for example, call absolute is not implemented. Usr functions are implemented in Basmark QuickBASIC in a form similar to Microsoft BASIC, but are referenced symbolically rather than via numeric memory addresses. Arguments are passed by reference. It is expected that most user-defined external subroutines and functions would be written in the C language, but they may be written in any high-level language or in assembly language.
The layout of memory at run-time is system dependent since it relies on the native link editor. No attempt is made to adhere to the memory layout used by the Microsoft compiler. As a result, clear and the memory clearing behavior of run is not implemented in Basmark QuickBASIC.
When run-time errors are reported in Microsoft BASIC, the memory address of the offending instruction is supplied. In Basmark QuickBASIC, the line number of the instruction is given.
If more than one run-time error can be detected in one function or statement, only one is reported. The error that Microsoft BASIC detects may differ from the error that Basmark QuickBASIC detects. This can affect the use of err in error handling.
An attempt is made to map UNIX error codes into Microsoft error codes when operating system dependent errors occur. The following table describes this mapping.
|UNIX to Basmark QuickBASIC Error Mapping|
|UNIX Error||Basmark QuickBASIC Error|
|0||Not Used||51||Internal error|
|1||Not owner||5||Illegal function call|
|2||No such file or directory||53||File not found|
|3||No such process||51||Internal error|
|4||Interrupted system call||51||Internal error|
|5||I/O error||72||Disk media error|
|6||No such device or address||71||Disk not ready|
|7||Arg list too long||51||Internal error|
|8||Exec format error||51||Internal error|
|9||Bad file number||51||Internal error|
|10||No children||51||Internal error|
|11||No more processes||51||Internal error|
|12||Not enough core||7||Out of memory|
|13||Permission denied||5||Illegal function call|
|14||Bad address||51||Internal error|
|15||Block device required||51||Internal error|
|16||Mount device busy||51||Internal error|
|17||File exists||58||File already exists|
|18||Cross-device link||51||Internal error|
|19||No such device||51||Internal error|
|20||Not a directory||51||Internal error|
|21||Is a directory||64||Bad file name|
|22||Invalid argument||51||Internal error|
|23||File table overflow||51||Internal error|
|24||Too many open files||51||Internal error|
|25||Not a typewriter||51||Internal error|
|26||Text file busy||51||Internal error|
|27||File too large||51||Internal error|
|28||No space left on device||61||Disk full|
|29||Illegal seek||51||Internal error|
|30||Read-only file system||70||Disk write protect|
|31||Too many links||51||Internal error|
|32||Broken pipe||51||Internal error|
|33||Math argument||11||Division by zero|
|34||Result too large||6||Overflow|
The message “Internal Error” is used to indicate an inconsistency or corruption within the compiler. In such a case, the compiler is assumed to be at fault, although some of the more esoteric operations, such as chain, may produce this message when the operating system is corrupt or the user code is at fault.
In Microsoft BASIC, the /E, /X, and /O options may need to be specified to the compiler. Basmark QuickBASIC assumes these options and allows them to be disabled selectively.
The metacommands in Microsoft BASIC used to format output listings are not available in Basmark QuickBASIC. Listing files are not produced and the /A option is not available.
The /4 and /T options are not available.
In this appendix, all Microsoft BASIC statements, functions, and variables are cataloged with a brief description of all known differences in Basmark QuickBASIC. Refer to the main text of this paper or to the QuickBASIC Programmer’s Manual for further elucidation.
from The Basmark QuickBASIC Programmer’s Manual by Lawrence Leinweber