TI BASIC (TI 99/4A)

Last updated
TI BASIC
TI BASIC HELLO WORLD.png
Paradigm Procedural
First appeared1979;45 years ago (1979)
Typing discipline Static, strong
License Proprietary

TI BASIC is an ANSI-compliant interpreter for the BASIC programming language built into the 1979 Texas Instruments TI-99/4 home computer and its improved 1981 version, the TI-99/4A.

Contents

In contrast to most BASICs found on contemporary microcomputers, TI BASIC does not trace its history to Microsoft BASIC, but was instead a TI-developed interpreter following the emerging Minimal BASIC standard being created by ANSI and ECMA. This was, in turn, based on the original Dartmouth BASIC from the 1960s. There are a number of differences, sometimes subtle, between TI BASIC and the more common MS varieties.

Minimal BASIC lacks a number of features that are commonly found on contemporary BASICs, and Texas Instruments later introduced the TI Extended BASIC cartridge that enhanced the functionality accessible to BASIC users. This included a wide variety of features found in other BASICs, as well as new system functions for sprite handling, sound, and other features of the platform.

As was common on home computers, TI BASIC was used not only for programming but also as a thin operating system. On top of Minimal BASIC, TI added commands for text, graphics, and basic file operations like recording to tape or any other file system. Due to the specifics of the TI-99 platform, TI BASIC was most notable for its extremely slow performance, roughly half that of common machines, but conversely sported high numerical accuracy.

Performance

The TI-99 was based on the TMS9900 microprocessor, a 16-bit design that was originally built to provide a single-chip central processing unit (CPU) in low-end models of their TI-990 minicomputer lineup. The TMS9900 was also suitable for use in a microcomputer, but at that time the rest of the support chips required to build a complete computer were invariably 8-bit, and this included TI's wide catalog of such chips. In a minicomputer, 16-bit support systems were built up of many individual chips, but this was not suitable for a low-cost product. TI thus adopted the solution of making the machine mostly 8-bit and connecting the various support chips to this 8-bit bus, with the TMS9900 reading the bus twice to produce a 16-bit value. [1]

The TMS9900's instruction set architecture was based on 16-bit opcodes, meaning that programs would generally be twice as large as they would be on an 8-bit machine. In the era of expensive memory, this presented a significant cost. To address this, TI created an 8-bit virtual machine with its own language or intermediate representation known as the "Graphic Programming Language", or GPL, that allowed programs to be written in a more compact format. The downside to this approach is that every GPL instruction had to be converted on the fly into one or more underlying TMS9900 instructions. [2] The GPL code itself was stored on the 8-bit side of the machine, further slowing its performance. [3]

For all of these reasons, the machine ran far slower than it was theoretically capable of. This was particularly noticeable in BASIC. Every instruction in the user's program had to be read from 8-bit memory, interpreted using code written in GPL, and then output back over the 8-bit bus again. As a result, TI BASIC had poor performance; on common benchmarks of the era, the TI-99 generally ran half as fast as 8-bit machines like the Commodore PET or Apple II. [4] For instance, running the Byte Sieve in BASIC took 3960 seconds in TI BASIC, while the same test in Applesoft BASIC on the Apple II, ostensibly a much slower machine, took 2806 seconds, about 30% faster that the TI. [5]

Elements of TI BASIC

Editing and running

Unlike most BASICs of the era, TI BASIC did not provide a full-screen editor. Instead, a line editor was provided, which allowed the user to add or edit one line at a time. Explicit line numbers were used to order each statement. It used a > prompt to indicate the current new line in immediate mode, as opposed to the more common READY. [6] Line numbers ranged from 1 to 32767, inclusive, and entering a line outside that range resulted in the "BAD LINE NUMBER" error. [7] Line entry was aided by the NUMBER command, available only in immediate mode, which entered ascending line numbers, [8] and RESEQUENCE, which renumbered an existing program. [9]

TI BASIC also included a number of debugging commands. BREAK worked something like STOP, stopping execution on certain lines. Unlike STOP, the exit to immediate mode did not occur on the line where BREAK appeared, but on the lines BREAK referred to. For instance, BREAK 130 would cause the program to exit to immediate mode whenever it moved to line 130. This could be used, for example, by inserting a single BREAK at the top of the program to control execution, rather than having to insert it in the middle of the code. UNBREAK turned off existing breakpoints. [10] Additionally, TRACE printed out the line number of the currently executing line in angle-brackets: <100><110> etc, and UNTRACE turned it off. [11]

Statements

The ANSI-compatible statements of TI BASIC are DATA, DEF, DIM, END, FOR..TO..STEP..NEXT, GOSUB, GOTO, IF..THEN..ELSE, INPUT, LET, NEXT, ON..GOSUB, ON..GOTO, OPTION BASE, PRINT, RANDOMIZE, READ, REM, RESTORE, RETURN, STOP. Most of these operate in the same fashion as their MS counterparts with two additions; RANDOMIZE restarts the random number generator at a given "seed" value, and OPTION BASE sets the first entry in arrays to either 0 or 1, whereas MS is always zero-based. To this standard set it added CALL, CLOSE, DISPLAY and OPEN. [12]

In keeping with the Minimal BASIC standard, [13] IF statements could only perform branches, they could not perform arbitrary statements as was common in almost every other BASIC of the era. For instance, code such as:

100IFX>5THENPRINT"IT IS LARGE"

is not valid in TI BASIC. Instead, this would have to be performed using multiple lines:

100IFX<=5THEN300200PRINT"IT IS LARGE"

This can easily lead to off-by-one errors if the conversion is not careful about changing the sense of the boolean comparison. TI BASIC did, however, support the ELSE clause: [14]

100IFX>5THEN200ELSE300

The PRINT statement used colons to separate items on different lines, in addition to the more common comma or semicolon. This precluded its use as a statement separator, a concept that TI BASIC did not have. [15] This means a line can have only a single statement. Due to the way BASIC interpreters work, GOTO-based loops can be sped up significantly by combining code onto a single line, which avoids having to search through the program for line numbers. This seemingly minor missing feature may result in much slower code, and adding this feature was part of Extended BASIC.

Extensions to the Minimal BASIC system were often not represented directly in BASIC, but were instead accessed via the CALL command and a series of named GPL-based subroutines. For instance, CALL CLEAR clears the screen, and CALL KEY returns the keycode of the currently pressed key on the keyboard. The language lacked PEEK and POKE so there was no official way [16] to create new CALLable code within BASIC, to do this one would require the TI Editor/Assembler, the TI Mini Memory cartridge which included a small assembler, [17] or by using Extended BASIC.

Functions

Unlike Microsoft BASICs, which used LEFT$, MID$, RIGHT$, and INSTR for manipulating strings, TI BASIC used the ANSI-compliant SEG$ and POS.

ABS
Absolute value
ASC
ASCII numeric value of the first character of a string
ATN
Arctangent
CHR$
Convert a number into a string with an ASCII character
COS
Cosine
EOF
Test whether the end of a file has been reached
EXP
Exponentiation
INT
greatest integer less than or equal to the parameter
LEN
Length of a string
LOG
Natural logarithm
POS
First occurrence of a string in another string
RND
Pseudorandom number generator
SEG$
Return a substring of a string
SGN
Sign function
SIN
Sine
SQR
Square root
STR$
Convert a number to a string
TAN
Tangent
VAL
Convert a string to a number

Subprograms

Subprograms are called with CALL statement (e.g. CALL CLEAR).

Extended BASIC

TI Extended BASIC cartridge. TIextendedbasic.JPG
TI Extended BASIC cartridge.

TI BASIC was located in the system's internal ROMs. In 1981, TI released a plug-in ROM cartridge that added additional functions to the existing code, improving the language in a number of ways. [18] Known as Extended BASIC, it was a highly anticipated addition to the platform. [19]

Among the changes was the addition of the ability to have multiple statements on a line. Using multiple statements may improve performance; loops that are implemented in a single line run much faster. Additionally, statements could now span several lines. As the underlying dialect already used the colon for string separators, Extended BASIC used the double-colon for this purpose. Confusingly, as a statement with two colons was also possible in TI BASIC, for instance, PRINT "A"::"B", which would output "A", a blank line and then "B", so these statements required a space to be added in Extended BASIC, PRINT "A": :"B". [18]

Another overdue addition was that IF statements could now perform arbitrary statements, rather than only a GOTO. In Extended BASIC one could write a simple statement like IFX>10THENX=X-1. This also worked in the ELSE clause, allowing statements like IFA=4ANDB=6THENR=10ELSEPRINT"OOPS". [18]

Other additions include a small selection of new statements, including ACCEPT, IMAGE, LINPUT, ON BREAK, ON ERROR, ON WARNING, SUB, SUBEND and SUBEXIT. The last three statements are used for structured programming, allowing the creation of named subroutines. Extended BASIC also included a number of new functions and especially CALLable routines. Among the latter was a library of sprite commands, including ones that created motion that continued automatically. [18]

Speech synthesis

When equipped with the TI Speech Synthesizer, TI Extended BASIC users could also generate speech from a predefined vocabulary as easily as writing text on-screen. For example, the following line of text would cause the speech synthesizer to identify the computer: [18]

 CALL SAY("HELLO I AM A #TEXAS INSTRUMENTS# T I NINETY NINE FOUR A HOME COMPUTER") 

Multi-word phrases are delimited with the # symbol, as #TEXAS INSTRUMENTS# in this example. Using a word not included in the speech synthesizer's built-in vocabulary of 338 words and phrases would cause it to slowly spell out the word. TI's Terminal Emulator II cartridge provided text-to-speech functionality. [18]

Related Research Articles

Applesoft BASIC is a dialect of Microsoft BASIC, developed by Marc McDonald and Ric Weiland, supplied with Apple II computers. It supersedes Integer BASIC and is the BASIC in ROM in all Apple II series computers after the original Apple II model. It is also referred to as FP BASIC because of the Apple DOS command FP used to invoke it, instead of INT for Integer BASIC.

<span class="mw-page-title-main">BASIC</span> Family of programming languages

BASIC is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College in 1963. They wanted to enable students in non-scientific fields to use computers. At the time, nearly all computers required writing custom software, which only scientists and mathematicians tended to learn.

Tiny BASIC is a family of dialects of the BASIC programming language that can fit into 4 or fewer KBs of memory. Tiny BASIC was designed by Dennis Allison and the People's Computer Company (PCC) in response to the open letter published by Bill Gates complaining about users pirating Altair BASIC, which sold for $150. Tiny BASIC was intended to be a completely free version of BASIC that would run on the same early microcomputers.

<span class="mw-page-title-main">Atari BASIC</span> Dialect of the BASIC programming language

Atari BASIC is an interpreter for the BASIC programming language that shipped with Atari 8-bit computers. Unlike most American BASICs of the home computer era, Atari BASIC is not a derivative of Microsoft BASIC and differs in significant ways. It includes keywords for Atari-specific features and lacks support for string arrays.

Microsoft BASIC is the foundation software product of the Microsoft company and evolved into a line of BASIC interpreters and compiler(s) adapted for many different microcomputers. It first appeared in 1975 as Altair BASIC, which was the first version of BASIC published by Microsoft as well as the first high-level programming language available for the Altair 8800 microcomputer.

<span class="mw-page-title-main">TI-99/4A</span> Home computer by Texas Instruments

The TI-99/4 and TI-99/4A are home computers released by Texas Instruments in 1979 and 1981, respectively. Based on Texas Instruments's own TMS9900 microprocessor originally used in minicomputers, the TI-99/4 was the first 16-bit home computer. The associated TMS9918 video display controller provides color graphics and sprite support which were only comparable with those of the Atari 400 and 800 released a month after the TI-99/4. The TI-99 series also initially competed with the Apple II and TRS-80.

Integer BASIC is a BASIC interpreter written by Steve Wozniak for the Apple I and Apple II computers. Originally available on cassette for the Apple I in 1976, then included in ROM on the Apple II from its release in 1977, it was the first version of BASIC used by many early home computer owners.

Commodore BASIC, also known as PET BASIC or CBM-BASIC, is the dialect of the BASIC programming language used in Commodore International's 8-bit home computer line, stretching from the PET (1977) to the Commodore 128 (1985).

Sinclair BASIC is a dialect of the programming language BASIC used in the 8-bit home computers from Sinclair Research, Timex Sinclair and Amstrad. The Sinclair BASIC interpreter was written by Nine Tiles Networks Ltd.

Dartmouth BASIC is the original version of the BASIC programming language. It was designed by two professors at Dartmouth College, John G. Kemeny and Thomas E. Kurtz. With the underlying Dartmouth Time Sharing System (DTSS), it offered an interactive programming environment to all undergraduates as well as the larger university community.

The Atari Microsoft BASIC and Atari Microsoft BASIC II variants of the 6502-version of Microsoft BASIC ported to the Atari 8-bit computers. The first version, released 1981, required 32 KB of RAM and was supplied on floppy disk. The second version, released the next year, had most of the code on a ROM cartridge with additional functions on an optional floppy.

The TMS9900 was one of the first commercially available, single-chip 16-bit microprocessors. Introduced in June 1976, it implemented Texas Instruments' TI-990 minicomputer architecture in a single-chip format, and was initially used for low-end models of that lineup.

HP Time-Shared BASIC is a BASIC programming language interpreter for Hewlett-Packard's HP 2000 line of minicomputer-based time-sharing computer systems. TSB is historically notable as the platform that released the first public versions of the game Star Trek.

<span class="mw-page-title-main">Simons' BASIC</span>

Simons' BASIC is an extension to BASIC 2.0 for the Commodore 64 home computer. Written by British programmer David Simons in 1983, who was 16 years old at the time, it was distributed by Commodore as a cartridge.

The Geneve 9640 is an enhanced TI-99/4A clone. It was sold by the company Myarc as a card to fit into the Texas Instruments TI Peripheral Expansion System. Released in 1987, it is in many ways similar to the earlier TI-99/8, which was in prototype form in early 1983. The Geneve 9640 was designed by Paul Charlton, and the graphical swan on the boot up screen was designed by Mi-Kyung Kim.

There are several notable bulletin board systems (BBS) for the TI-99/4A home computer.

<span class="mw-page-title-main">BASIC interpreter</span> Interpreter that enables users to enter and run programs in the BASIC language

A BASIC interpreter is an interpreter that enables users to enter and run programs in the BASIC language and was, for the first part of the microcomputer era, the default application that computers would launch. Users were expected to use the BASIC interpreter to type in programs or to load programs from storage.

Minimal BASIC is a dialect of the BASIC programming language developed as an international standard. The effort started at ANSI in January 1974, and was joined in September by a parallel group at ECMA. The first draft was released for comments in January 1976 and the final standard, known alternately as ANSI X3.60-1978 or ECMA-55, was published in December 1977. The US Bureau of Standards introduced the NBSIR 77-1420 test suite to ensure implementations met the definition.

Acorn System BASIC and Atom BASIC are two closely related dialects of the BASIC programming language developed by Acorn Computers for their early microcomputers like the Acorn System 3 and Acorn Atom. Developed in-house, they have a number of significant idiosyncrasies compared to most BASIC dialects of the home computer era.

References

Citations

  1. "The TI-99/4A internal architecture". 16 August 2000.
  2. Nouspikel, Thierry. "GPL: Graphic Programming Language" . Retrieved 2 August 2020.
  3. "I grew up and learned basic on a TI-99/4a. It was a wonderful and simple time..." Hacker News. Retrieved 2 August 2020.
  4. Knight, Daniel (10 January 2016). "How Fast Were Those Late 1970s Home Computers?". Low End Mac.
  5. Gilbreath, Jim; Gilbreath, Gary (January 1983). "Eratosthenes Revisited: Once More through the Sieve". Byte. pp. 283–325.
  6. Guide1981, p. II-5.
  7. Guide1981, p. II-8.
  8. Guide1981, p. II-26.
  9. Guide1981, p. II-27.
  10. Guide1981, p. II-33.
  11. Guide1981, p. II-36.
  12. Guide1981, p. i.
  13. Minimal BASIC (PDF) (Technical report). ECMA. January 1978.
  14. Guide1981, p. II-51.
  15. Guide1981, p. II-65.
  16. Exploit by James Abbatiello
  17. "Mini Memory".
  18. 1 2 3 4 5 6 Shaw 1983.
  19. Kaplan, Gary (June 1981). "Extended BASIC Review". TI 99er.

Bibliography