Introduction
Welcome to the TI CC-40 Compact Computer emulation on the Emulator.ca BBS. The CC-40 was a remarkable portable computer released by Texas Instruments in March 1983---a battery-powered BASIC computer you could carry in your briefcase.
The CC-40 represented Texas Instruments' vision of portable productivity. With its 31-character LCD display, typewriter keyboard, and HEX-BUS expansion port, it offered computing power in a package that weighed just over a pound. Scientists, engineers, and businesspeople used it for field calculations, data collection, and programming on the go.
This browser implementation recreates CC-40 BASIC and its display with a Rust interpreter. It does not execute the original processor or ROM, and compatibility differs from the original hardware in the areas listed below.
Press ESC at any time to interrupt a running program. Type NEW to clear the current program and start fresh.
Want to see the hardware first? The CC-40 visual demo lets you interact with the LCD display and keyboard directly in your browser, without dialling in.
What is CC-40 BASIC?
CC-40 BASIC is a dialect of the BASIC programming language designed specifically for the CC-40's hardware. It's similar to TI Extended BASIC from the TI-99/4A but adapted for the portable computer's unique characteristics:
- 31-character LCD display with 80-character internal buffer
- Line-numbered programs stored in battery-backed RAM
- Immediate mode execution for calculations and testing
- CALL statements for hardware control (display, sound, keyboard)
If you've used other BASIC dialects---Commodore BASIC, Applesoft BASIC, or Microsoft BASIC---you'll find CC-40 BASIC familiar. The core concepts are the same: line numbers, variables, loops, and subroutines.
Quick Start
Connect to the CC-40 emulator and try these examples:
+------------------------------------------------------------------+
| QUICK START SESSION |
+------------------------------------------------------------------+
| ATDT555-0040 |
| CONNECT 1200 |
| |
| TI CC-40 COMPACT COMPUTER |
| 6144 BYTES FREE |
| READY |
| |
| PRINT "HELLO WORLD" |
| HELLO WORLD |
| READY |
| |
| 10 PRINT "COUNT:" |
| 20 FOR I = 1 TO 5 |
| 30 PRINT I |
| 40 NEXT I |
| RUN |
| COUNT: |
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| READY |
+------------------------------------------------------------------+
Key concepts:
- Commands without line numbers execute immediately
- Lines with numbers are stored in the program
RUNexecutes the stored programLISTdisplays the programNEWclears the program
Getting Connected
To access the CC-40 emulator, configure your modem and dial:
ATDT555-0040
Upon successful connection, you'll see the CC-40 banner:
ATDT555-0040
CONNECT 1200
TI CC-40 COMPACT COMPUTER
6144 BYTES FREE
READY
The READY prompt indicates the CC-40 is waiting for your input. You can enter immediate mode commands or type program lines.
Immediate Mode
Any command typed without a line number executes immediately. Use immediate mode for:
- Calculations: Use the CC-40 as a powerful calculator
- Testing: Try commands before adding them to programs
- Debugging: Check variable values during development
PRINT 125 * 37
4625
READY
PRINT SQR(144)
12
READY
PRINT 2^10
1024
READY
Program Mode
Add line numbers to store commands in memory. Programs remain in memory until you clear them with NEW or power off.
Entering Programs
Type each line with a number:
10 REM TEMPERATURE CONVERTER
20 INPUT "FAHRENHEIT? ":F
30 C = (F - 32) * 5 / 9
40 PRINT "CELSIUS:";C
50 GOTO 20
Program Commands
| Command | Description |
|---|---|
RUN |
Execute program from first line |
RUN 50 |
Execute program starting at line 50 |
LIST |
Display entire program |
LIST 20-40 |
Display lines 20 through 40 |
NEW |
Clear program and variables |
CONT |
Continue after STOP or ESC |
Editing Programs
- Replace a line: Type the line number with new content
- Delete a line: Type just the line number and press ENTER
- Insert lines: Use intermediate numbers (e.g., 15 between 10 and 20)
BASIC Commands Reference
Input/Output
Display text and values. Use semicolons for tight spacing, commas for tab zones.
PRINT "HELLO"
PRINT A; B; C
PRINT "VALUE:"; X
PRINT A, B, C
INPUT
Get data from the user. Optional prompt string precedes the colon.
INPUT A
INPUT "NAME? ":N$
INPUT "X,Y? ":X,Y
This implementation processes one INPUT variable at a time for simplicity.
Variables
LET
Assign values to variables. The keyword LET is optional.
LET A = 10
A = 10
NAME$ = "ALICE"
DIM
Declare array dimensions. Arrays can be multi-dimensional.
DIM A(100)
DIM MATRIX(10,10)
DIM NAMES$(50)
Program Control
IF/THEN/ELSE
Conditional execution. Line numbers can follow THEN for branching.
IF A > 10 THEN PRINT "BIG"
IF X = 0 THEN 100
IF A > B THEN PRINT "A WINS" ELSE PRINT "B WINS"
GOTO
Unconditional jump to a line number.
GOTO 100
GO TO 100
GOSUB/RETURN
Call a subroutine and return.
100 GOSUB 500
110 PRINT "BACK"
120 END
500 REM SUBROUTINE
510 PRINT "IN SUB"
520 RETURN
FOR/NEXT
Counted loop with optional STEP.
FOR I = 1 TO 10
PRINT I
NEXT I
FOR X = 10 TO 1 STEP -1
PRINT X
NEXT X
ON GOTO/GOSUB
Computed branch based on variable value.
ON N GOTO 100, 200, 300
ON CHOICE GOSUB 1000, 2000, 3000
END/STOP
Terminate program execution.
END
STOP
STOP allows continuation with CONT; END does not.
Data Statements
DATA/READ/RESTORE
Store and retrieve data within the program.
10 DATA 10, 20, 30, "HELLO"
20 READ A, B, C, D$
30 PRINT A; B; C; D$
40 RESTORE
50 READ X
Comments
REM
Add comments to document your code.
10 REM THIS IS A COMMENT
20 REM CALCULATE AVERAGE
30 TOTAL = A + B + C
Built-in Functions
Mathematical Functions
| Function | Description | Example |
|---|---|---|
ABS(X) |
Absolute value | ABS(-5) = 5 |
INT(X) |
Integer part (floor) | INT(7.9) = 7 |
SGN(X) |
Sign (-1, 0, or 1) | SGN(-5) = -1 |
SQR(X) |
Square root | SQR(16) = 4 |
EXP(X) |
e raised to power X | EXP(1) = 2.718... |
LOG(X) |
Natural logarithm | LOG(10) = 2.302... |
SIN(X) |
Sine (radians) | SIN(0) = 0 |
COS(X) |
Cosine (radians) | COS(0) = 1 |
TAN(X) |
Tangent (radians) | TAN(0) = 0 |
ATN(X) |
Arc tangent | ATN(1) = 0.785... |
PI |
Pi constant | PI = 3.14159... |
RND(X) |
Random number 0-1 | RND(1) = 0.xxx |
To generate random integers from 1 to N:
R = INT(RND(1) * N) + 1
String Functions
| Function | Description | Example |
|---|---|---|
LEN(A$) |
String length | LEN("HELLO") = 5 |
LEFT$(A$,N) |
Left N characters | LEFT$("HELLO",2) = "HE" |
RIGHT$(A$,N) |
Right N characters | RIGHT$("HELLO",2) = "LO" |
MID$(A$,P,N) |
Substring from position P | MID$("HELLO",2,3) = "ELL" |
ASC(A$) |
ASCII code of first char | ASC("A") = 65 |
CHR$(N) |
Character from ASCII code | CHR$(65) = "A" |
VAL(A$) |
Convert string to number | VAL("123") = 123 |
STR$(N) |
Convert number to string | STR$(123) = "123" |
Operators
Arithmetic Operators
| Operator | Description | Example |
|---|---|---|
+ |
Addition | 5 + 3 = 8 |
- |
Subtraction | 5 - 3 = 2 |
* |
Multiplication | 5 * 3 = 15 |
/ |
Division | 15 / 3 = 5 |
^ |
Exponentiation | 2 ^ 3 = 8 |
\ |
Integer division | 17 \ 5 = 3 |
MOD |
Modulo (remainder) | 17 MOD 5 = 2 |
Comparison Operators
Comparisons return -1 for true, 0 for false.
| Operator | Description |
|---|---|
= |
Equal |
<> |
Not equal |
< |
Less than |
> |
Greater than |
<= |
Less than or equal |
>= |
Greater than or equal |
Logical Operators
| Operator | Description |
|---|---|
AND |
Logical/bitwise AND |
OR |
Logical/bitwise OR |
NOT |
Logical/bitwise NOT |
CALL Statements
The CC-40 provides CALL statements for hardware control. These are unique to TI computers and provide access to display, sound, and keyboard features.
CALL CLEAR
Clear the display.
CALL CLEAR
CALL CHAR
Define a custom character pattern.
CALL CHAR(0, "1F1111111111111F")
The first parameter selects one of seven programmable characters, codes 0–6. Each character has a 5×8 dot pattern, described by two hexadecimal digits per row, top to bottom; only the low five bits of each row illuminate dots. Short patterns are zero-padded. Additional 16-digit patterns define following characters, stopping at code 6. Definitions are cleared when the computer is switched off.
CALL KEY
Check for a keypress without waiting. This enables real-time games and interactive programs.
CALL KEY(K, S)
- K = key code, or 255 if no key
- S = status (0 = no key, 1 = different key from the previous input scan, −1 = same key)
The browser implementation accepts the original two-argument form and retains CALL KEY(0,K,S) as a compatibility extension. It uses a bounded queue of browser key events rather than the original keyboard matrix. The return values follow TI's none/different/same convention; exact scanning and timing still differ from the firmware.
Use S <> 0 to distinguish a key from no input in portable CC-40 examples. Exact ROM keyboard scanning and the physical keyboard matrix are not reproduced here.
10 REM WAIT FOR ANY KEY
20 CALL KEY(K, S)
30 IF S = 0 THEN 20
40 PRINT "KEY CODE:"; K
50 PRINT "CHARACTER: "; CHR$(K)
CALL SOUND
Generate a tone.
CALL SOUND(500, 440, 5)
- Duration in milliseconds
- Frequency in Hz
- Volume (0-15, lower is louder)
CALL HCHAR / CALL VCHAR
Place character codes into the LCD buffer. The CC-40 has a single visible LCD row backed by an 80-character DDRAM buffer, so horizontal writes can fill the buffer and vertical writes clip after row 1.
CALL HCHAR(1, 1, 42, 10)
CALL VCHAR(1, 1, 42, 5)
- Row, Column, Character code, Count
- Rows and columns are 1-based; the current emulation accepts row 1 and columns 1-80.
CALL INDIC
Control LCD indicator segments.
CALL INDIC(2, 1)
Sets one of 18 indicators. An omitted state or any nonzero state turns it on; zero turns it off.
| Number | Indicator |
|---|---|
| 0 | ERROR |
| 1–6 | User downward arrows |
| 7 | LOW battery |
| 8 | Left overflow |
| 9–11 | SHIFT, CTL, FN |
| 12–14 | DEG, RAD, GRAD |
| 15 | I/O |
| 16 | UCL |
| 17 | Right overflow |
File I/O Commands
The CC-40 supports sequential file access for data storage.
OPEN
Open a file for reading or writing.
OPEN #channel:"filename" FOR mode
- channel: Number 1-255 identifying the file
- filename: Name of the file (in quotes)
- mode: INPUT (read), OUTPUT (write/create), or APPEND (add to existing)
OPEN #1:"SCORES" FOR OUTPUT
OPEN #2:"CONFIG" FOR INPUT
OPEN #3:"LOG" FOR APPEND
CLOSE
Close an open file channel.
CLOSE #channel
Always close files when done to ensure data is saved properly.
Write data to an open file.
PRINT #channel:expression
10 OPEN #1:"DATA" FOR OUTPUT
20 FOR I = 1 TO 10
30 PRINT #1:I * 2
40 NEXT I
50 CLOSE #1
INPUT
Read data from an open file.
INPUT #channel:variable
10 OPEN #1:"DATA" FOR INPUT
20 FOR I = 1 TO 10
30 INPUT #1:X
40 PRINT X
50 NEXT I
60 CLOSE #1
File I/O uses in-memory storage that does not persist across sessions. For permanent storage, use the SAVE and LOAD commands which store programs to the BBS disk system.
Example Programs
Temperature Converter
10 REM FAHRENHEIT TO CELSIUS
20 PRINT "TEMPERATURE CONVERTER"
30 INPUT "FAHRENHEIT? ":F
40 C = (F - 32) * 5 / 9
50 PRINT F;"F =";C;"C"
60 GOTO 30
Number Guessing Game
10 REM GUESS THE NUMBER
20 PRINT "I'M THINKING OF"
30 PRINT "A NUMBER 1-100"
40 N = INT(RND(1) * 100) + 1
50 G = 0
60 INPUT "YOUR GUESS? ":A
70 G = G + 1
80 IF A = N THEN 120
90 IF A < N THEN PRINT "TOO LOW"
100 IF A > N THEN PRINT "TOO HIGH"
110 GOTO 60
120 PRINT "CORRECT IN";G;"TRIES!"
130 INPUT "AGAIN (Y/N)? ":A$
140 IF A$ = "Y" THEN 40
150 END
Multiplication Quiz
10 REM MULTIPLICATION QUIZ
20 SCORE = 0
30 FOR Q = 1 TO 10
40 A = INT(RND(1) * 12) + 1
50 B = INT(RND(1) * 12) + 1
60 PRINT A;"X";B;"= ";
70 INPUT "":ANS
80 IF ANS = A * B THEN PRINT "RIGHT!": SCORE = SCORE + 1
90 IF ANS <> A * B THEN PRINT "NO,";A*B
100 NEXT Q
110 PRINT "SCORE:";SCORE;"/10"
Fibonacci Sequence
10 REM FIBONACCI NUMBERS
20 INPUT "HOW MANY? ":N
30 A = 0
40 B = 1
50 FOR I = 1 TO N
60 PRINT A
70 C = A + B
80 A = B
90 B = C
100 NEXT I
Data Logger (File I/O)
10 REM SAVE HIGH SCORES
20 DIM SCORES(5)
30 FOR I = 1 TO 5
40 INPUT "SCORE? ":SCORES(I)
50 NEXT I
60 OPEN #1:"HISCORES" FOR OUTPUT
70 FOR I = 1 TO 5
80 PRINT #1:SCORES(I)
90 NEXT I
100 CLOSE #1
110 PRINT "SCORES SAVED!"
Reaction Time Game
10 REM REACTION TIME TEST
20 PRINT "PRESS ANY KEY"
30 PRINT "WHEN YOU SEE GO!"
40 FOR D = 1 TO INT(RND(1)*50)+20
50 CALL KEY(0, K, S)
60 IF S > 0 THEN PRINT "TOO SOON!": GOTO 40
70 NEXT D
80 PRINT "GO!"
90 T = 0
100 CALL KEY(0, K, S)
110 IF S = 0 THEN T = T + 1: GOTO 100
120 PRINT "TIME:"; T
130 INPUT "AGAIN (Y/N)? ":A$
140 IF A$ = "Y" THEN 40
Simple Snake Movement
10 REM ARROW KEY DEMO
20 X = 40: Y = 12
30 PRINT "USE WASD TO MOVE"
40 PRINT "Q TO QUIT"
50 CALL KEY(0, K, S)
60 IF S = 0 THEN 50
70 IF K = 87 THEN Y = Y - 1
80 IF K = 83 THEN Y = Y + 1
90 IF K = 65 THEN X = X - 1
100 IF K = 68 THEN X = X + 1
110 IF K = 81 THEN END
120 PRINT "X:";X;" Y:";Y
130 GOTO 50
Error Messages
When BASIC encounters a problem, it displays an error message:
| Error | Meaning |
|---|---|
?SYNTAX ERROR |
Command not recognized or malformed |
?UNDEFINED LINE |
GOTO/GOSUB to non-existent line |
?UNDEFINED VARIABLE |
Variable used before assignment |
?BAD SUBSCRIPT |
Array index out of bounds |
?DIVISION BY ZERO |
Attempted to divide by zero |
?OVERFLOW |
Number too large |
?OUT OF MEMORY |
Program or data exceeds available RAM |
?TYPE MISMATCH |
String/number confusion |
?RETURN WITHOUT GOSUB |
RETURN without matching GOSUB |
?NEXT WITHOUT FOR |
NEXT without matching FOR |
Technical Notes
Memory
The emulation models the stock 6KB RAM configuration for BASIC programs and variables. The original CC-40 had 6KB of battery-backed RAM, expandable to 18KB with cartridges.
Display
The original CC-40 featured a 31-character single-line LCD display with an 80-character internal buffer. The display could scroll left and right to view the full buffer. In this terminal emulation, output appears as standard text.
Keyboard
The CC-40 has a staggered typewriter keyboard beside a separate numeric keypad, with SHIFT, CTL, FN, arrow keys, and BREAK/RUN/ON/OFF controls. The visual demo follows that arrangement; the dial-up terminal remains a text interface. In the terminal, use your standard keyboard:
- Ctrl+C or ESC - Interrupt programs (equivalent to BREAK)
- Shift - Uppercase letters, activates SHIFT indicator
- Ctrl - Activates CTL indicator
- Alt - Activates FN indicator
When you interrupt a running program, the CC-40 displays the line number where execution stopped:
* BREAK IN 50
READY
You can resume execution with the CONT command.
FRE Function
The FRE(0) function returns the amount of free memory available:
PRINT FRE(0)
32456
Memory is consumed by:
- Program lines (source code)
- Variables (numeric and string)
- Arrays (based on dimensions)
HEX-BUS
The CC-40's HEX-BUS port allowed connection to peripherals like disk drives, printers, and the Wafertape digital tape drive. Peripheral support is not available in this emulation.
Historical Context
The TI CC-40 was Texas Instruments' entry into the portable computer market of the early 1980s. Released in March 1983 at a price of $249.95, it competed with devices like the Radio Shack TRS-80 Model 100 and the Epson HX-20.
The CC-40 used the TMS70C20 processor, a member of TI's TMS7000 family optimized for low power consumption. Its HEX-BUS interface was designed for a ecosystem of peripherals that never fully materialized due to TI's exit from the home computer market later in 1983.
Despite its short commercial life, the CC-40 found dedicated users among scientists and engineers who appreciated its programmability and portability. Today it remains a collectible piece of computing history.
Emulation Fidelity & Differences from Original Hardware
This emulation does not run the original TMS70C20/TMS7000 CPU or load the original CC-40 ROM image. The BASIC interpreter is a Rust reimplementation that targets functional compatibility with CC-40 BASIC programs.
The visual layout and interaction reference is the original TI CC-40 User Guide, chapters 1–3, especially the keyboard figure on page 1-8 and display diagram on page 1-18. Programmable character behavior is described in chapter 5, pages 5-15–5-17. No original ROM image is distributed with this implementation.
What Is Emulated
- CC-40 BASIC language: Commands, functions, CALL statements, and line-numbered programs
- HD44780 LCD display: 80-character DDRAM, 31-character visible window, display scrolling, custom characters (CGRAM)
- LCD status indicators: SHIFT, CTL, FN, DEG/RAD/GRAD, I/O, UCL, ERROR, six user arrows, LOW, and two overflow arrows
- CALL SOUND: Audio tones via Web Audio API (square wave)
- CALL KEY: Non-blocking keyboard polling with FIFO buffer
- File I/O: In-memory channels with OPEN/CLOSE/PRINT/INPUT
- SAVE/LOAD: Persistent program storage across sessions
What Is Not Emulated
| Gap | Detail |
|---|---|
| CPU / ROM | No TMS70C20 cycle-accurate emulation; original ROM is not executed |
| BASIC dialect fidelity | High coverage, but not guaranteed to be bit-for-bit identical to the original ROM interpreter |
| Keyboard matrix | No key-up events, no multi-key rollover; modifier states approximated from browser events |
| Keyboard scanning | CALL KEY uses browser events in a bounded queue rather than the original physical matrix and input-scan timing |
| HEX-BUS / peripherals | Device types and error messages stubbed; no disk, printer, or Wafertape emulation |
| LCD controller bus | Display, cursor and power state are recreated behaviorally; original CPU-to-controller bus timing and instruction execution are not reproduced |
| Hardware timing | No cycle-accurate CPU timing; CALL SOUND scheduling is approximate |
| Idle powerdown | Original automatic powerdown after roughly ten idle minutes is not implemented; use OFF/ON explicitly |
A standalone visual demo of the CC-40 hardware — with the physical keyboard and LCD display — is available at /cc40/demo/. You can also view the assembled unit at /cc40/.
Quick Reference Card
System Commands
| Command | Description |
|---|---|
NEW |
Clear program and variables |
RUN |
Execute program |
LIST |
Display program |
CONT |
Continue after STOP or BREAK |
SAVE "name" |
Save program to disk |
LOAD "name" |
Load program from disk |
Keyboard Shortcuts
| Key | Action |
|---|---|
Ctrl+C or ESC |
Interrupt running program |
Shift |
SHIFT indicator, uppercase |
Ctrl |
CTL indicator |
Alt |
FN indicator |
Common Statements
| Statement | Example |
|---|---|
PRINT |
PRINT "HELLO"; A |
INPUT |
INPUT "NAME? ":N$ |
LET |
LET A = 10 or A = 10 |
IF/THEN |
IF A > 10 THEN PRINT "BIG" |
FOR/NEXT |
FOR I = 1 TO 10: PRINT I: NEXT I |
GOTO |
GOTO 100 |
GOSUB/RETURN |
GOSUB 500 |
REM |
REM This is a comment |
File I/O
| Statement | Example |
|---|---|
OPEN |
OPEN #1:"DATA" FOR OUTPUT |
CLOSE |
CLOSE #1 |
PRINT # |
PRINT #1:X |
INPUT # |
INPUT #1:Y |
CALL Commands
| Command | Example |
|---|---|
CALL KEY |
CALL KEY(K, S) |
CALL SOUND |
CALL SOUND(500, 440, 5) |
CALL CHAR |
CALL CHAR(0, "1F1111111111111F") |
CALL INDIC |
CALL INDIC(1, 1) |
Function Categories
- Math: ABS, INT, SGN, SQR, EXP, LOG, SIN, COS, TAN, ATN, PI, RND, FRE
- String: LEN, LEFT$, RIGHT$, MID$, ASC, CHR$, VAL, STR$
- Logic: AND, OR, NOT
TI CC-40 COMPACT COMPUTER EMULATION Emulator.ca Systems Dial 555-0040 to connect