BASICODE
From Wikipedia, the free encyclopedia
BASICODE was a computer project intended to create a unified standard for the BASIC programming language. BASIC was available on many popular home computers, but there were countless variants that were mostly incompatible with each other. The project was initiated in 1980 by the Netherlands broadcasting organisation Nederlandse Omroep Stichting (NOS).
The basic implementation were architecture-specific utility applications that executed calls of subroutines for text, audio and sound defined in the BASICODE language standard according to the abilities of the computer in question. These applications, called Bascoders, also enabled the sharing of data and programs across diffent computer platforms by defining a data format for the compact audio cassettes that were regularly used as storage media in the 1980s. A BASICODE program stored on cassette could be loaded and run on any computer supporting the language. BASICODE was often called "Esperanto for computers" for that reason.
It must be stated that BASICODE was, by design, unable to use the capabilities of the host computers to their full extent. The language standard defined by BASICODE was the lowest common denominator of all relevant computer systems. This concept was partially abandoned only with BASICODE3/3C, as some computers or computer variants were not capable of graphics and color and the new sections of BASICODE using these capabilities were not usable on them. Especially for applications that relied on timing and graphics or sound, for example computer games, BASICODE was clearly inferior to programs written in "native" BASIC or machine code. The strengths of BASICODE were in the areas of application design, education software and data sharing. The BASICODE format was also used for Pascal programs. Pascal was a much more consistent language across systems, but was available only for very few types of home computers.
The installed base of BASICODE is hard to estimate, because both the Bascoders and the programs written in BASICODE were freely available. There was a Bascoder for nearly every home computer sold during this era. Commercially, BASICODE was of no importance because it was always shared for free.
Contents |
[edit] BASICODE
[edit] The situation at the beginning of the 80s
From the late 1970s to the late 1980s home computers based on 8 bit processors were very popular. Among the most well-known models were the TRS-80 by Tandy, the PET 2001, VIC-20, C64, C128 and the Plus/4 by Commodore, the Atari 400 / 800 (XL /XE), the Sinclair Research computers (ZX80, ZX81, ZX Spectrum) and the KC85 family popular in the German Democratic Republic. All these computers had a CPU of the MOS Technology 6502 or Zilog Z80 type, 16 to 64 KByte RAM, connectors for a cassette drive or a built-in one for data storage, and finally a BASIC interpreter that was generally stored in ROM. The flat learning curve of BASIC, which had been designed with newcomers to programming in mind, and the instant availability of the language on all these computers led to many users writing and sharing their own programs.
A problem was that sharing programs and data across computers by different manufacturers was difficult because the various BASIC dialects were totally incompatible in some areas. They used different BASIC commands to make the same action (like clearing the screen, drawing a pixel or playing a sound), so that a BASIC program written for the C64 did not work on an Atari XL without modification and vice versa. Another difficulty was the fact that while these computers were similar, they still differed in key hardware aspects like screen resolution, available color palette or audio abilities. Finally, the data formats used for storing data on cassette were incompatible as well.
[edit] The first standard
Around 1980 the Netherlands broadcaster NOS began transmitting computer programs by radio. Because programs and data were stored as audio on compact cassettes, it was possible to record such a broadcast on tape and load it into the computer later. However, because of the problems mentioned earlier, the program had to be adapted for nearly all popular types of computers and broadcasted multiple times as well. Because the compact cassette has a very low data density compared to todays storage media, the recording of the programs took quite a long time, and only a limited number of programs could be broadcast per show. So, the additional broadcasting of different versions of the same programs was a great inconvenience.
In 1982 the executives at NOS decided to develop a unified data format. An application that was specific for each computer model, called Bascoder, managed the recall and storage of programs and data in this unified format from tape. The Bascoders were broadcast by NOS as well, but could also be bought from NOS on cassette and shared among friends and acquaintances. The format, which was very well-protected against interference, could be read and written by all popular home computer hardware. The robustness of the format also made broadcasting via mediumwave radio possible, which increased the range and in turn the number of potential users. For example, data broadcast by the Netherlands station TROS (Televisie en Radio Omroep Stichting, also known as Radio Hilversum) could be received in large parts of the German Democratic Republic.
[edit] BASICODE 2
The standard solved one of the aforementioned problems, the incompatible data formats. However, programs still had to be adapted to each computer's BASIC dialect and hardware capabilities. Limiting the programs to only use instructions common across all dialects meant big limitations in terms of functionality, for example completely refraining from using graphics and sound and only uncomfortable methods to input data using the keyboard and to control character output on the screen. For this reasons, in 1984 the enhanced standard BASICODE 2 was created. Bascoders using this standard did not only contain routines for input and output of data to tape. In addition to a set of about 50 BASIC commands, functions and operators that were common across all BASIC dialects, the language standard of BASCODE 2 defined a library of subroutines that emulated the same capabilities across all supported computers.
To achieve this, all program lines below 1000 were reserved for the Bascoder, and BASICODE programs could only start at line number 1000. The subroutines of the Bascoder in the lines below 1000 were called with a GOSUB command. Necessary arguments were passed to the Bascoder by using special predefined variables that were reseved for use by the Bascoder. The standard contained a number of additional rules that were made necessary by the limitations of some computer models. For example, on the ZX-81 a line of code could only contain a single BASIC command, a behaviour that almost no other computer shared. On a KC series computer, a line of code could not be longer than 60 characters. These limitations had to be enforced for all BASICODE programs to guarantee platform independence, because the Bascoder was interpreted by the same computer specific BASIC interpreter as the BASICODE program itself.
So, the Bascoders were loaded on the various computers like normal programs and provided the additional routines for the common standard and cassette I/O afterwards. Programs written in BASICODE were only usable after the Bascoder had been loaded and started. However, on some computers the BASICODE programs could be merged with the routines of the Bascoders and saved in the native data format. The resulting program was not platform independent any longer, but due to the higher data density of most native formats it could be loaded much faster than the same program in BASICODE format. Also, because it was not necessary to load the complete Bascoder to run the program, more RAM remained available at run time.
There were BASICODE 2 Bascoders for the Exidy Sorcerer, Colour Genie, Commodore PET, VIC-20, C64, Amiga, Sinclair ZX81, ZX Spectrum, QL, Acorn Atom, Micro, Electron, Tandy TRS-80, MSX, Oric Atmos, Grundy NewBrain, Amstrad CPC, IBM PC, Apple II, Texas Instruments TI-99/4A, Mattel Aquarius and others. Additionally, advanced users were able to write their own Bascoder for their system of choice, since the language standard and data format was open and well-documented. The BASICODE 2 standard made the development of platform independent programs with advanced capabilities (for the time) possible. In addition, BASICODE was used to transmit and share information like computer scene news via radio in the form of so-called "journals". A BASICODE coding tutorial and other documentation was transmitted this way as well.
[edit] BASICODE 3 / 3C
In 1986, the new BASICODE 3 standard was developed. The most important additions were routines for simple monochrome graphics, reading and writing data from within programs and sound output. BASICODE 3 made BASICODE popular in the computer scene of the GDR, and from 1989 onward BASICODE programs were transmitted via radio throughout the GDR. Also, a book was published which included a vinyl record with Bascoders for all computers common in the GDR. The last revision of BASICODE, which featured color graphics, was released as BASICODE 3C in 1991.
[edit] The end of BASICODE
From about 1990 onward the popularity of BASICODE declined rapidly due to the rise of 16- and 32-bit computers, especially IBM-PC variants and compatible systems. Even though there were Bascoders for these machines, BASICODE was too limited to make use of the resources that that generation of computers provided. Additionally, because of the much fewer common architectures in the 16- and 32-bit era, the main reason for the development and use of BASICODE became moot. As the hardware and software of the new systems became more and more complex, most users became unable or disinclined to write programs. The rise of graphical user interfaces contributed to the decline in popularity of 8-bit computers and consequently BASICODE as well.
The successor of the GDR's state broadcaster, the Deutschlandsender Kultur (which later became part of the new Deutschlandradio), continued to broadcast BASICODE programs until about 1992. A planned standard called BASICODE 4 never became reality, because NOS stopped supporting the project shortly after BASICODE 3C was released. BASICODE is still used by enthusiasts, in particular 8-bit computer fans, for nostalgic value, but isn't of any practical relevance.
[edit] The BASICODE data format
In the BASICODE format, the recording of programs is analogous to the recording of data. So, when recording programs, the commands are not read and written in the form of single byte units (tokens), but character by character.
Each byte is transmitted in the sequence "1 start bit - 8 data bits - 2 stop bits". The resulting redundancy is mainly intended for safe transmission. Bit 7 is always flipped, which is especially useful when transmitting ASCII characters, because these always have the 7th bit set to 0, resulting in three stop bits for ASCII data. The beginning of transmission is signalled with the character 02 (STX, start of text), the end with the character 03 (ETX, end of text). After ETX, a check byte made up of the previous bytes including STX and ETX by binary addition (XOR), is transmitted. A 0D character (decimal 13) marks the end of a line during transmission. Data files created by programs are able to use all characters as data and contain no control characters. They are read and written in blocks of 1024 bytes.
For the audio signals, square waves in the form of a 1200 hertz wave for a "0" bit and two 2400 Hz waves for a "1" bit are used, resulting in a time of 1/1200 seconds for each bit. A pause longer than 1/1800 seconds between waves marks the beginning of a byte, making the following wave the start bit. After the start bit and before the eight data bits is another pause of at least 1/1800 seconds. A 2400 Hz signal with a length of five seconds marks the beginning of a transmission and is used for synchronization of the reading program. At the end of the transmission, a 2400 Hz signal with a length of one second is sent.
The theoretical data rate of this format is 1200 bits per second. Considering the transmission of three additional bits per data byte and the pauses before and after the start bit, this results in a usable data rate of 102 bytes per second, and about 6 Kbytes per minute.
[edit] The BASICODE language standard
[edit] BASICODE 2
Commands, functions and operators allowed in BASICODE 2
The following elements of the BASIC programming language are available in the BASIC dialects of all supported computer models with identical functionality. So, they are part of the BASICODE language standard as well.
- Commands:
DATA DIM END FOR GOSUB GOTO IF INPUT NEXT ON PRINT READ REM RESTORE RETURN RUN STEP STOP THEN TAB TO
- Functions:
ABS ASC ATN COS EXP INT LEN LOG SGN SIN SQR TAN VAL CHR$ LEFT$ MID$ RIGHT$ AND OR NOT
- Mathematical operators:
^ Exponential function * Multiplication / Division + Addition and concatenation of string variables - Subtraction
- Comparison operators:
= <> < > <= >=
Routines implemented in the Bascoder of BASICODE 2
The following routines are implemented in the various BASIC dialects with differing and syntax-incompatible commands and have to be provided by the Bascoder. By calling them via GOSUB, they are available in the same form across all supported computers.
GOSUB 100 Clear screen GOSUB 110 Set the cursor to the specified position The position is passed in the variables HO and VE GOSUB 120 Get the position of the cursor The values are returned in the variables HO and VE GOSUB 200 Read a character from the keyboard The character is returned in the variable IN$ IN$ is returned empty if no key is pressed GOSUB 210 Wait for a keypress The character is returned in the variable IN$ GOSUB 250 Play a short tone ("beep") GOSUB 260 Create a random number between 0 and 1 The random number is returned in the variable RV GOSUB 270 Count the available system memory The available system memory is returned in the variable FR GOSUB 300 Convert a numerical variable to a string The number is passed in the variable SR The string is returned in the variable SR$ GOSUB 310 Like GOSUB 300, additional arguments: A fixed string length is passed in the variable CT The position of the decimal point is passed in the variable CN GOSUB 350 Output a string on the printer The string to print is passed in the variable SR$ GOSUB 360 Send a line break to the printer
Further general rules and definitions
A line of BASICODE code may only have a length of 60 characters, including line number and whitespace, and it may only contain one command. The argument for angular functions must be given in radians. In BASICODE, the AND and OR logical operators may not be used for bitwise combination of numbers. When using string functions, possible differences in the character set of different computer types have to be considered. Variable names may be no longer than two characters (one or two capital letters or a capital letter and a digit). Each variable has to be given a value before it is used for the first time with commands or functions, because implicit initialisation does not work on all computer types. Numerical variables are of single precision (six allowed digits). String variables have a maximum length of 255 characters. Each BASICODE programs starts a line number 1000. The lines above 30000 are used for comments, and lines above 32000 for metadata like the name of the author or version information.
[edit] BASICODE 3 / 3C
Commands, functions and operators allowed in BASICODE 3 / 3C
In regard to the allowed BASIC commands, BASICODE 3 / 3C and BASICODE 2 differ only slightly. The biggest change is the addition of DEF FN for the definition of new functions.
- Commands:
DATA DEF FN DIM FOR GOSUB GOTO IF INPUT LET NEXT ON PRINT READ REM RESTORE RETURN STEP TAB THEN TO Differences to BASICODE 2: New : DEF FN LET Removed : END RUN STOP
- Functions:
ABS ASC ATN COS EXP INT LEN LOG SGN SIN SQR TAN VAL CHR$ LEFT$ MID$ RIGHT$ AND OR NOT
- Mathematical operators:
^ Exponential function * Multiplication / Division + Addition and concatenation of string variables - Subtraction
- Comparison operators:
= <> < > <= >=
Routines implemented in the Bascoder of BASICODE 3 / 3C
Compared to its predecessor, the Bascoder subroutines of BASICODE 3/3C were greatly expanded. Especially the new functions for sound output (400), accessing external files (500-580) and graphics display (600-650) considerably increased the capabilities of BASICODE.
GOTO 20 Start program, reset system, delete all variables GOSUB 100 Initialize text mode, clear screen GOSUB 110 Set the cursor to the specified position The position is passed in the variables HO and VE GOSUB 120 Get the position of the cursor The values are returned in the variables HO and VE GOSUB 150 Obvious display of a string on the display (Three spaces to the left and to the right) The string is passed in the variable SR$ GOSUB 200 Read a character from the keyboard The character is returned in the variable IN$ IN$ is returned empty if no key is pressed GOSUB 210 Wait for a keypress The character is returned in the variable IN$ GOSUB 220 Read a character from the screen The position is passed in the variables HO and VE The character is returned as a numerical value in the variable IN GOSUB 250 Play a short tone ("beep") GOSUB 260 Create a random number between 0 and 1 The random number is returned in the variable RV GOSUB 270 Count the available system memory The available system memory is returned in the variable FR GOSUB 280 Toggle the STOP/BREAK key between on and off The status is returned in the variable FR (FR=0 or FR=1) GOSUB 300 Convert a numerical variable to a string The number is passed in the variable SR The string is returned in the variable SR$ GOSUB 310 Like GOSUB 300, additional arguments: A fixed string length is passed in the variable CT The position of the decimal point is passed in the variable CN GOSUB 330 Convert all lowercase characters in a string to uppercase The string is passed and returned in the variable SR$ GOSUB 350 Output a string on the printer The string to print is passed in the variable SR$ GOSUB 360 Send a line break to the printer GOSUB 400 Play a tone The volume, length and pitch are passed in the variables SV, SD and SP GOSUB 450 Wait for a keypress for a predefined amount of time The time is passed in the variable SD (in units of 100 milliseconds) GOSUB 500 Open a file The file name is passed in the variable NF$ A file indentifier is defined in the variable NF GOSUB 540 Read a string from a file The identifier is passed in the variable NF The string is returned in the variable IN$ GOSUB 560 Write a string to a file The identifier is passed in the variable NF The string is passed in the variable SR$ GOSUB 580 Close a file The identifier is passed in the variable NF GOSUB 600 Initialize graphics mode, clear screen GOSUB 620 Paint a pixel The position is passed in the variables HO and VE The color is passed in the variable CN GOSUB 630 Print a line starting from the current graphics position The end position is passed in the variables HO and VE The color is passed in the variable CN The graphics position is defined by painting a pixel earlier GOSUB 650 Display a string in graphics mode The position is passed in the variables HO and VE The string is passed in the variable SR$ GOTO 950 End the BASICODE program Differences to BASICODE 2: New : 20, 150, 220, 280, 330, 400-450, 500-580, 600-650, 950 Changed : 100
The position arguments and return values in text mode are absolute values. However, in graphics mode the values of the variables HO and VE are relative. That means that the values for painting a pixel in the middle of the screen are HO=0.5 and VE=0.5, for the upper left corner HO=0 and VE=0 and for the lower right corner HO=1 and VE=1. This is to ensure a comparable graphics output regardless of available screen resolution.
Further general rules and definitions (in addition to the BASICODE 2 standard)
The names of new functions may only be two characters long, just like variable names. Defining new string functions is not possible in BASICODE. The program ends with "GOTO 950", because the commands RUN, END and STOP are no longer allowed.
The following variable names are not available to programs in BASICODE:
- all variables starting with the letter "O" - AS, AT, DI, DI$, DS, DS$, EI, EI$, EL, ER, FN, GO, GR, IF, LN, SQ, SQ$, ST, TI, TI$, TO - PI
The following variables are used by the Bascoder, for example for passing values from the program to the Bascoder or for returning them from the Bascoder to the program:
- A, CN, CT, FR, HG, HO, IN, IN$, NF, NF$, RV, SD, SP, SR, SR$, SV, VE, VG
[edit] See also
[edit] References
- This article is based on a translation of an article from the German Wikipedia.
[edit] Literature
- (German) Michael Wiegand, Manfred Fillinger: BASICODE. Mit Programmkassette. Ravensburger Buchverlag, Ravensburg 1986, ISBN 3-473-44010-8
- (Dutch) Hermine Bakker, Jaques Haubrich (authors), Stichting BASICODE (publisher): Het BASICODE-3 boek. 3. Auflage. Kluwer Technische Boeken B.V., Deventer/ Antwerpen 1988, ISBN 90-201-2111-1
- (German) Horst Völz: Basicode mit Programmen auf Schallplatte für Heimcomputer. Verlag Technik, Berlin 1990, ISBN 3-341-00895-0
[edit] External links
- BASICODE: an example of Dutch computer folklore - Historical information
- (German) BasiCode – Software für alle - Information about history and programming