Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
TI BASIC (TI 99/4A)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Programming language for TI-99 home computers}} {{about|TI-99/4A programming language|the calculator language|TI-BASIC}} {{Infobox programming language | name = TI BASIC | logo = TI BASIC HELLO WORLD.png| | file_ext = | paradigm = [[Imperative programming|Imperative]] | year = {{Start date and age|1979}} | designer = | developer = | latest_release_version = | latest_release_date = | latest_test_version = | latest_test_date = | typing = [[Static type|Static]], [[Strong and weak typing|strong]] | implementations = | dialects = | influenced_by = | influenced = | platform = [[TI-99/4A|TI-99/4, TI-99/4A]] | operating_system = | license = Proprietary | website = | wikibooks = }} '''TI BASIC''' is an [[American National Standards Institute|ANSI]]-compliant [[interpreter (computing)|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]]. In contrast to most BASICs found on contemporary [[microcomputer]]s, TI BASIC does not trace its history to [[Microsoft BASIC]], but was instead developed in-house following the emerging [[Minimal BASIC]] standard being created by ANSI and [[Ecma International|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 (computer graphics)|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 [[Cassette tape|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 (computing)|bus]], with the TMS9900 reading the bus twice to produce a 16-bit value.<ref name=arch>{{cite web |url=https://www.unige.ch/medecine/nouspikel/ti99/architec.htm |title= The TI-99/4A internal architecture |date=16 August 2000}}</ref> The TMS9900's [[instruction set architecture]] was based on 16-bit [[opcode]]s, 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.<ref>{{cite web|last1=Nouspikel|first1=Thierry|title=GPL: Graphic Programming Language|url=http://www.unige.ch/medecine/nouspikel/ti99/gpl.htm|accessdate=2 August 2020}}</ref> The GPL code itself was stored on the 8-bit side of the machine, further slowing its performance.<ref>{{cite web|publisher=Hacker News|title=I grew up and learned basic on a TI-99/4a. It was a wonderful and simple time......|url=https://news.ycombinator.com/item?id=13521531|accessdate=2 August 2020}}</ref> 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]].<ref>{{cite web |title= How Fast Were Those Late 1970s Home Computers? |url=https://lowendmac.com/2016/how-fast-were-those-late-1970s-home-computers/ |first= Daniel |last=Knight |date=10 January 2016 |website=Low End Mac}}</ref> 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.<ref>{{cite magazine |title=Eratosthenes Revisited: Once More through the Sieve |first1=Jim |last1=Gilbreath |first2=Gary |last2=Gilbreath |magazine=Byte |date=January 1983 |pages=283β325 |url=https://archive.org/details/byte-magazine-1983-01/page/n291 }}</ref> == Elements of TI BASIC == ===Editing and running=== Unlike most BASICs of the era, TI BASIC did not provide a [[Full-screen writing program|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 {{code|>}} prompt to indicate the current new line in [[direct mode|immediate mode]], as opposed to the more common {{code|READY}}.{{sfn|Guide1981|p=II-5}} Line numbers ranged from 1 to 32767, inclusive, and entering a line outside that range resulted in the "BAD LINE NUMBER" error.{{sfn|Guide1981|p=II-8}} Line entry was aided by the {{code|NUMBER}} command, available only in immediate mode, which entered ascending line numbers,{{sfn|Guide1981|p=II-26}} and {{code|RESEQUENCE}}, which renumbered an existing program.{{sfn|Guide1981|p=II-27}} TI BASIC also included a number of [[debugging]] commands. {{code|BREAK}} worked something like {{code|STOP}}, stopping execution on certain lines. Unlike {{code|STOP}}, the exit to immediate mode did not occur on the line where {{code|BREAK}} appeared, but on the lines {{code|BREAK}} referred to. For instance, {{code|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 {{code|BREAK}} at the top of the program to control execution, rather than having to insert a {{code|STOP}} in the middle of the code. {{code|UNBREAK}} turned off existing breakpoints.{{sfn|Guide1981|p=II-33}} Additionally, {{code|TRACE}} printed out the line number of the currently executing line in angle-brackets: {{code|<100><110>}} etc, and {{code|UNTRACE}} turned it off.{{sfn|Guide1981|p=II-36}} === Statements === The ANSI-compatible [[Statement (computer science)|statements]] of TI BASIC are <code>{{mono|DATA, DEF, DIM, END, [[For loop|FOR..TO..STEP..NEXT]], [[GOSUB]], [[GOTO]], [[Conditional (programming)|IF..THEN..ELSE]], INPUT, LET, NEXT, ON..GOSUB, ON..GOTO, OPTION BASE, PRINT, [[Random number generation|RANDOMIZE]], READ, [[Comment (computer programming)|REM]], RESTORE, [[Return statement|RETURN]], STOP}}</code>. Most of these operate in the same fashion as their MS counterparts with two additions; {{code|RANDOMIZE}} restarts the [[random number generator]] at a given "seed" value, and {{code|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 [[Subroutine|<code>CALL</code>]], [[File descriptor#Operations on the file descriptor table|<code>CLOSE</code>]], <code>DISPLAY</code> and [[Computer file#Operations|<code>OPEN</code>]].{{sfn|Guide1981|p=i}} In keeping with the Minimal BASIC standard,<ref>{{cite tech report |url=https://www.ecma-international.org/wp-content/uploads/ECMA-55_1st_edition_january_1978.pdf |title=Minimal BASIC |date=January 1978 |publisher=ECMA}}</ref> {{code|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: {{sxhl|2=basic| 100 IF X>5 THEN PRINT "IT IS LARGE" }} is not valid in TI BASIC. Instead, this would have to be performed using multiple lines: {{sxhl|2=basic|1= 100 IF X<=5 THEN 300 200 PRINT "IT IS LARGE" }} This can easily lead to [[off-by-one error]]s if the conversion is not careful about changing the sense of the boolean comparison. TI BASIC did, however, support the {{code|ELSE}} clause:{{sfn|Guide1981|p=II-51}} {{sxhl|2=basic| 100 IF X>5 THEN 200 ELSE 300 }} The {{code|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.{{sfn|Guide1981|p=II-65}} This means a line can have only a single statement. Due to the way BASIC interpreters work, {{code|GOTO}}-based loops can be sped up significantly by combining code onto a single line, which reduces the number of lines in the program and the corresponding amount of time needed to find a particular line number. This seemingly minor missing feature may result in much slower code, and adding this feature was part of TI Extended BASIC. Extensions to the Minimal BASIC system were often not represented directly in BASIC, but were instead accessed via the {{code|CALL}} command and a series of named GPL-based subroutines. For instance, {{code|CALL CLEAR}} clears the screen, and {{code|CALL KEY}} returns the keycode of the currently pressed key on the keyboard. The language lacked [[PEEK and POKE|<code>PEEK</code> and <code>POKE</code>]] so there was no official way<ref>[https://forums.atariage.com/topic/162941-assembly-on-the-994a/page/11/?tab=comments#comment-2849894 Exploit by James Abbatiello]</ref> 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 [[assembly language|assembler]],<ref>{{cite web |url=https://www.ninerpedia.org/wiki/Mini_Memory |title=Mini Memory}}</ref> or by using Extended BASIC. === Functions === Unlike Microsoft BASICs, which used <code>{{mono|LEFT$}}</code>, <code>{{mono|MID$}}</code>, <code>{{mono|RIGHT$}}</code>, and <code>{{mono|INSTR}}</code> for manipulating strings, TI BASIC used the ANSI-compliant <code>{{mono|SEG$}}</code> and <code>{{mono|POS}}</code>. ; {{mono|ABS}} : [[Absolute value]] ; {{mono|ASC}} : [[ASCII]] numeric value of the first character of a [[String (computer science)|string]] ; {{mono|ATN}} : [[Trigonometric function|Arctangent]] ; {{mono|CHR$}} : Convert a number into a [[String (computer science)|string]] with an ASCII character ; {{mono|COS}} : [[Trigonometric function|Cosine]] ; {{mono|EOF}} : Test whether the [[End-of-file|end of a file]] has been reached ; {{mono|EXP}} : [[Exponentiation]] ; {{mono|INT}} : greatest integer less than or equal to the parameter ; {{mono|LEN}} : Length of a [[String (computer science)|string]] ; {{mono|LOG}} : [[Natural logarithm]] ; {{mono|POS}} : First occurrence of a string in another string ; {{mono|RND}} : [[Pseudorandom number generator]] ; {{mono|SEG$}} : Return a substring of a string ; {{mono|SGN}} : [[Sign function]] ; {{mono|SIN}} : [[Trigonometric function|Sine]] ; {{mono|SQR}} : [[Square root]] ; {{mono|STR$}} : Convert a number to a [[String (computer science)|string]] ; {{mono|TAN}} : [[Trigonometric function|Tangent]] ; {{mono|VAL}} : Convert a string to a number === Subprograms === Subprograms are called with <code>CALL</code> statement (e.g. <code>CALL CLEAR</code>). * <code>CHAR</code> Definition of graphical characters * <code>CLEAR</code> Clears the [[Computer monitor|screen]] * <code>COLOR</code> Defines foreground- and background color for 8 characters * <code>GCHAR</code> Reads one character at a specified position from the screen * <code>HCHAR</code> Writes a character to a screen position and repeats it horizontally * <code>JOYST</code> Returns the position of the [[joystick]] * <code>KEY</code> Reads from the keyboard without echo on the screen * <code>SCREEN</code> Changes the color of the screen * <code>SOUND</code> Creates sounds (using a [[frequency]]) and noise * <code>VCHAR</code> Writes a character to a screen position and repeats it vertically ==Extended BASIC== [[File:TIextendedbasic.JPG|thumb|TI Extended BASIC cartridge.]] TI BASIC was located in the system's internal [[read-only memory|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.{{sfn|Shaw|1983}} Known as Extended BASIC, it was a highly anticipated addition to the platform.<ref name=kaplan>{{cite magazine |first=Gary |last=Kaplan |magazine=TI 99er |date=June 1981 |title=Extended BASIC Review |url=http://www.mainbyte.com/ti99/software/s_carts/ext_basic.html}}</ref> 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, {{code|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, {{code|PRINT "A": :"B"}}.{{sfn|Shaw|1983}} Another overdue addition was that {{code|IF}} statements could now perform arbitrary statements, rather than only a {{code|GOTO}}. In Extended BASIC one could write a simple statement like {{code|IF X>10 THEN X{{=}}X-1|basic}}. This also worked in the {{code|ELSE}} clause, allowing statements like {{code|IF A{{=}}4 AND B{{=}}6 THEN R{{=}}10 ELSE PRINT "OOPS"|basic}}.{{sfn|Shaw|1983}} Other additions include a small selection of new statements, including {{code|ACCEPT}}, {{code|IMAGE}}, {{code|LINPUT}}, {{code|ON BREAK}}, {{code|ON ERROR}}, {{code|ON WARNING}}, {{code|SUB}}, {{code|SUBEND}} and {{code|SUBEXIT}}. The last three statements are used for [[structured programming]], allowing the creation of named [[subroutine]]s. 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.{{sfn|Shaw|1983}} ===Speech synthesis=== When equipped with the TI Speech Synthesizer, TI Extended BASIC users could also [[Speech synthesis|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:{{sfn|Shaw|1983}} CALL SAY("HELLO I AM A #TEXAS INSTRUMENTS# T I NINETY NINE FOUR A HOME COMPUTER") Multi-word phrases are [[delimiter|delimited]] with the # symbol, as <code>#TEXAS INSTRUMENTS#</code> 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.{{sfn|Shaw|1983}} ==References== ===Citations=== {{Reflist}} ===Bibliography=== * {{cite book |title= Getting Started With the Texas Instruments TI99/4A |first= Stephen |last=Shaw |date= 1983 |url=https://stephen.shawweb.co.uk/book.html |publisher=Phoenix Publishing | isbn = 978-0-946576-04-3 | chapter = Extended Basic | chapter-url = https://stephen.shawweb.co.uk/book7.html}} * {{cite book |title= User's Reference Guide |publisher=Texas Instruments |url= http://www.classiccmp.org/dunfield/ti/usrguide.pdf |date=1981 |ref=CITEREFGuide1981}} == External links == * [http://www.classiccmp.org/dunfield/ti/beginbas.pdf Beginner's BASIC] at ClassicCmp.org * [https://web.archive.org/web/20200301021952/http://www.classiccmp.org/dunfield/ti/basicref.pdf TI-99/4A BASIC Reference Card] at ClassicCmp.org {{BASIC}} {{DEFAULTSORT:Ti Basic (Ti 99 4a)}} [[Category:TI-99/4A]] [[Category:BASIC interpreters]] [[Category:Discontinued BASICs]] [[Category:BASIC programming language family]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:About
(
edit
)
Template:BASIC
(
edit
)
Template:Cite book
(
edit
)
Template:Cite magazine
(
edit
)
Template:Cite tech report
(
edit
)
Template:Cite web
(
edit
)
Template:Code
(
edit
)
Template:Infobox programming language
(
edit
)
Template:Mono
(
edit
)
Template:Reflist
(
edit
)
Template:Sfn
(
edit
)
Template:Short description
(
edit
)
Template:Sxhl
(
edit
)