A Comparison of Basmark QuickBASIC and Microsoft BASIC

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. 

1. Environmental Differences

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. 

2. Lexical and Syntactic Differences

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. 

3. Differences in Run-Time Environment

The differences in the run-time environments for Microsoft BASIC and Basmark QuickBASIC fall into several categories. 

3.1 Hardware-specific Language Features

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. 

3.2 Devices

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. 

3.3 Floating-Point Considerations

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. 

3.4 File Naming

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. 

3.5 Files

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. 

3.6 Memory Addressing

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. 

3.7 Memory Layout

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. 

3.8 Dynamic Memory Allocation

In Microsoft BASIC, string space is deallocated intermittently with a garbage collection system implemented by fre.  In Basmark QuickBASIC, a continuous system is employed so this function is not implemented. 

3.9 Run-time errors

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 ErrorBasmark QuickBASIC Error
0Not Used51Internal error
1Not owner5Illegal function call
2No such file or directory53File not found
3No such process51Internal error
4Interrupted system call51Internal error
5I/O error72Disk media error
6No such device or address71Disk not ready
7Arg list too long51Internal error
8Exec format error51Internal error
9Bad file number51Internal error
10No children51Internal error
11No more processes51Internal error
12Not enough core7Out of memory
13Permission denied5Illegal function call
14Bad address51Internal error
15Block device required51Internal error
16Mount device busy51Internal error
17File exists58File already exists
18Cross-device link51Internal error
19No such device51Internal error
20Not a directory51Internal error
21Is a directory64Bad file name
22Invalid argument51Internal error
23File table overflow51Internal error
24Too many open files51Internal error
25Not a typewriter51Internal error
26Text file busy51Internal error
27File too large51Internal error
28No space left on device61Disk full
29Illegal seek51Internal error
30Read-only file system70Disk write protect
31Too many links51Internal error
32Broken pipe51Internal error
33Math argument11Division by zero
34Result too large6Overflow

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. 

4. Options and Listings

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. 

5. Appendix A: A Compendium of Differences

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. 

abs
No differences. 

asc
No differences. 

atn
No differences. 

beep
An ASCII bell character is sent to the terminal.  What happens after that is terminal dependent. 

bload
No differences. 

bsave
No differences. 

call
Call absolute is not implemented.  Parameter passing may differ slightly.  See the call manual page for details. 

calls
Not implemented — segmented architecture dependent. 

cdbl
No differences. 

chain
The values of common variables are passed serially to the chained program.  In cases where the common declarations differ between two programs sharing the common data, performance may differ.  This difference is visible only in programs that incorrectly declare common blocks. 

chdir
No differences. 

chr$
No differences. 

cint
No differences. 

circle
Not implemented — hardware dependent. 

clear
Not implemented — memory layout dependent. 

close
No differences. 

cls
The termcap or terminfo database is used to determine how to clear the screen.  Graphics options are not supported. 

color
You can have any color you want, as long as it’s black or white. 

com(n)
Not implemented — hardware dependent. 

command$
The value is subject to expansion by the UNIX shell.  White space between adjacent command line arguments is represented by a single blank. 

common
The values of common variables are passed serially to the chained program.  In cases where the common declarations differ between two programs sharing the common data, performance may differ.  This difference is visible only in programs that incorrectly declare common blocks. 

cos
No differences. 

csng
No differences. 

csrlin
No differences. 

cvd
No differences. 

cvdmbf
No differences. 

cvi
No differences. 

cvs
No differences. 

cvsmbf
No differences. 

data
No differences. 

date$
Ordinarily UNIX does not permit setting the date, so this is a read-only variable. 

def fn
No differences. 

def seg
No differences. 

def usr
Not implemented — A symbolic system is used.  See the manual page on usr functions for details. 

defdbl
No differences. 

defint
No differences. 

defsng
No differences. 

defstr
No differences. 

dim
No differences. 

do...loop
No differences. 

draw
Not implemented — hardware dependent. 

$dynamic
No differences. 

end
No differences. 

environ
No differences. 

environ$
No differences. 

eof
No differences. 

erase
No differences. 

erdev
Not implemented — operating system dependent. 

erdev$
Not implemented — operating system dependent. 

erl
No differences. 

err
No differences. 

error
No differences. 

exp
No differences. 

field
No differences. 

files
The file name matching metacharacters are those of the UNIX shell. 

fix
No differences. 

for...next
No differences. 

fre
Not implemented — memory allocation system dependent. 

get(files)
No differences. 

get(graphics)
Not implemented — hardware dependent. 

gosub
No differences. 

goto
No differences. 

hex$
No differences. 

if...then...else
No differences. 

$include
The complete file specification must be given; no default extension is assumed. 

inkey$
The termcap or terminfo database is used to determine how to interpret special keys. 

inp
Not implemented — hardware dependent. 

input
No differences. 

input #
No differences. 

input$
No differences. 

instr
No differences. 

int
No differences. 

ioctl
Not implemented — operating system dependent. 

ioctl$
Not implemented — operating system dependent. 

key
Not implemented — hardware dependent. 

key(n)
Not implemented — hardware dependent. 

kill
If a file is open when it is killed, no error occurs; instead, the file remains open and usable until it is closed, at which time it is killed. 

lbound
No differences. 

lcase$
No differences. 

left$
No differences. 

len
No differences. 

let
No differences. 

line
Not implemented — hardware dependent. 

line input
No differences. 

line input #
No differences. 

loc
No differences. 

locate
The termcap or terminfo database is used to determine how to address the cursor.  Graphics and color-oriented options are not supported. 

lock
No differences. 

lof
The value is the exact size of a file. 

log
No differences. 

lpos
Uses the environment variable ‘LPR’ to get the command to access the printer. 

lprint
Uses the environment variable ‘LPR’ to get the command to access the printer. 

lprint using
Uses the environment variable ‘LPR’ to get the command to access the printer. 

lset
No differences. 

ltrim$
No differences. 

mid$
No differences. 

mkdir
Requires superuser permission. 

mkd$
No differences. 

mkdmbf$
No differences. 

mki$
No differences. 

mks$
No differences. 

mksmbf$
No differences. 

name
No differences. 

oct$
No differences. 

on com(n)
Not implemented — hardware dependent. 

on error
No differences. 

on gosub
No differences. 

on goto
No differences. 

on key(n)
Not implemented — hardware dependent. 

on pen
Not implemented — hardware dependent. 

on play
Not implemented — hardware dependent. 

on strig(n)
Not implemented — hardware dependent. 

on timer
Not implemented — hardware dependent. 

open
No differences. 

open "com... 
Not implemented — hardware dependent. 

option base
No differences. 

out
Not implemented — hardware dependent. 

paint
Not implemented — hardware dependent. 

palette
Not implemented — hardware dependent. 

pcopy
Not implemented — hardware dependent. 

peek
No differences. 

pen
Not implemented — hardware dependent. 

play
Not implemented — hardware dependent. 

pmap
Not implemented — hardware dependent. 

point
Not implemented — hardware dependent. 

poke
No differences. 

pos
No differences. 

print
No differences. 

print using
No differences. 

print #
No differences. 

print # using
No differences. 

preset
Not implemented — hardware dependent. 

pset
Not implemented — hardware dependent. 

put(files)
No differences. 

put(graphics)
Not implemented — hardware dependent. 

randomize
No differences. 

read
No differences. 

redim
No differences. 

rem
No differences. 

reset
No differences. 

restore
No differences. 

resume
No differences. 

return
No differences. 

right$
No differences. 

rmdir
Requires superuser permission. 

rnd
No differences. 

rset
No differences. 

rtrim$
No differences. 

run
Memory clearing behavior of run [linenum] not implemented — memory layout dependent. 

sadd
No differences. 

screen
Not implemented — hardware dependent. 

select
No differences. 

sgn
No differences. 

shared
No differences. 

shell
No differences. 

sin
No differences. 

sound
Not implemented — hardware dependent. 

space$
No differences. 

spc
No differences. 

sqr
No differences. 

static
No differences. 

$static
No differences. 

stick
Not implemented — hardware dependent. 

stop
No differences. 

str$
No differences. 

strig
Not implemented — hardware dependent. 

strig(n)
Not implemented — hardware dependent. 

string$
No differences. 

sub
No differences. 

swap
No differences. 

system
No differences. 

tab
No differences. 

tan
No differences. 

time$
Ordinarily UNIX does not permit setting the time, so this is a read-only variable. 

timer
No differences. 

tron & troff
No differences. 

ubound
No differences. 

ucase$
NO differences. 

unlock
No differences. 

usr
Parameters may be used to pass data to and from the external function.  The external function may return a value of any given type.  See the manual page on usr for details. 

val
No differences. 

varptr
No differences. 

varptr$
No differences. 

view
Not implemented — hardware dependent. 

wait
Not implemented — hardware dependent. 

while...wend
No differences. 

width
Only width device, size is not implemented. 

window
Not implemented — hardware dependent. 

write
No differences. 

write #
No differences. 

from The Basmark QuickBASIC Programmer’s Manual by Lawrence Leinweber