Jump to content

TI BASIC (TI 99/4A)

From Wikipedia, the free encyclopedia
(Redirected fromTI Extended BASIC)
TI BASIC
ParadigmProcedural
First appeared1979;45 years ago(1979)
Typing disciplineStatic,strong
LicenseProprietary

TI BASICis anANSI-compliant interpreter for theBASICprogramming language built into the 1979 Texas Instruments TI-99/4home computerand its improved 1981 version, theTI-99/4A.

In contrast to most BASICs found on contemporarymicrocomputers,TI BASIC does not trace its history toMicrosoft BASIC,but was instead a TI-developedinterpreterfollowing the emerging Minimal BASIC standard being created by ANSI andECMA.This was, in turn, based on the originalDartmouth BASICfrom 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 theTI Extended BASICcartridge 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 forspritehandling, 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 thinoperating system.On top of Minimal BASIC, TI added commands for text, graphics, and basic file operations like recording totapeor 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

[edit]

The TI-99 was based on theTMS9900microprocessor,a 16-bit design that was originally built to provide a single-chipcentral processing unit(CPU) in low-end models of theirTI-990minicomputerlineup. 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'sinstruction set architecturewas based on 16-bitopcodes,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-bitvirtual machinewith its own language orintermediate representationknown 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 theCommodore PETorApple II.[4]For instance, running theByte Sievein BASIC took 3960 seconds in TI BASIC, while the same test inApplesoft BASICon the Apple II, ostensibly a much slower machine, took 2806 seconds, about 30% faster that the TI.[5]

Elements of TI BASIC

[edit]

Editing and running

[edit]

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 inimmediate mode,as opposed to the more commonREADY.[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 theNUMBERcommand, available only in immediate mode, which entered ascending line numbers,[8]andRESEQUENCE,which renumbered an existing program.[9]

TI BASIC also included a number of debugging commands.BREAKworked something likeSTOP,stopping execution on certain lines. UnlikeSTOP,the exit to immediate mode did not occur on the line whereBREAKappeared, but on the linesBREAKreferred to. For instance,BREAK 130would cause the program to exit to immediate mode whenever it moved to line 130. This could be used, for example, by inserting a singleBREAKat the top of the program to control execution, rather than having to insert it in the middle of the code.UNBREAKturned off existing breakpoints.[10]Additionally,TRACEprinted out the line number of the currently executing line in angle-brackets:<100><110>etc, andUNTRACEturned it off.[11]

Statements

[edit]

The ANSI-compatiblestatementsof TI BASIC areDATA, 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;RANDOMIZErestarts therandom number generatorat a given "seed" value, andOPTION BASEsets the first entry in arrays to either 0 or 1, whereas MS is always zero-based. To this standard set it addedCALL,CLOSE,DISPLAY andOPEN.[12]

In keeping with the Minimal BASIC standard,[13]IFstatements 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<=5THEN300
200PRINT"IT IS LARGE"

This can easily lead tooff-by-one errorsif the conversion is not careful about changing the sense of the boolean comparison. TI BASIC did, however, support theELSEclause:[14]

100IFX>5THEN200ELSE300

ThePRINTstatement 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 theCALLcommand and a series of named GPL-based subroutines. For instance,CALL CLEARclears the screen, andCALL KEYreturns the keycode of the currently pressed key on the keyboard. The language lackedPEEK and POKEso 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 smallassembler,[17]or by using Extended BASIC.

Functions

[edit]

Unlike Microsoft BASICs, which usedLEFT$,MID$,RIGHT$,andINSTRfor manipulating strings, TI BASIC used the ANSI-compliantSEG$andPOS.

ABS
Absolute value
ASC
ASCIInumeric value of the first character of astring
ATN
Arctangent
CHR$
Convert a number into astringwith an ASCII character
COS
Cosine
EOF
Test whether theend of a filehas been reached
EXP
Exponentiation
INT
greatest integer less than or equal to the parameter
LEN
Length of astring
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 astring
TAN
Tangent
VAL
Convert a string to a number

Subprograms

[edit]

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

  • CHAR Definition of graphical characters
  • CLEAR Clears thescreen
  • COLOR Defines foreground- and background color for 8 characters
  • GCHAR Reads one character at a specified position from the screen
  • HCHAR Writes a character to a screen position and repeats it horizontally
  • JOYST Returns the position of thejoystick
  • KEY Reads from the keyboard without echo on the screen
  • SCREEN Changes the color of the screen
  • SOUND Creates sounds (using afrequency) and noise
  • VCHAR Writes a character to a screen position and repeats it vertically

Extended BASIC

[edit]
TI Extended BASIC cartridge.

TI BASIC was located in the system's internal ROMs. In 1981, TI released a plug-inROM cartridgethat 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 thatIFstatements could now perform arbitrary statements, rather than only aGOTO.In Extended BASIC one could write a simple statement likeIFX>10THENX=X-1.This also worked in theELSEclause, allowing statements likeIFA=4ANDB=6THENR=10ELSEPRINT"OOPS".[18]

Other additions include a small selection of new statements, includingACCEPT,IMAGE,LINPUT,ON BREAK,ON ERROR,ON WARNING,SUB,SUBENDandSUBEXIT.The last three statements are used forstructured programming,allowing the creation of namedsubroutines.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

[edit]

When equipped with the TI Speech Synthesizer, TI Extended BASIC users could alsogenerate speechfrom 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]

References

[edit]

Citations

[edit]
  1. ^"The TI-99/4A internal architecture".16 August 2000.
  2. ^Nouspikel, Thierry."GPL: Graphic Programming Language".Retrieved2 August2020.
  3. ^"I grew up and learned basic on a TI-99/4a. It was a wonderful and simple time..."Hacker News.Retrieved2 August2020.
  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. ^abcdefShaw 1983.
  19. ^Kaplan, Gary (June 1981)."Extended BASIC Review".TI 99er.

Bibliography

[edit]
[edit]