TI CC-40 COMPACT COMPUTER

Texas Instruments Portable BASIC Computer

Phone: 555-0040

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, membrane keyboard, and HEX-BUS expansion port, it offered genuine 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 emulation brings the CC-40 experience to your terminal. You'll find a faithful implementation of CC-40 BASIC, complete with the original's distinctive features and quirks.

Press ESC at any time to interrupt a running program. Type NEW to clear the current program and start fresh.

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:

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                                       |
|  34K 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:

  1. Commands without line numbers execute immediately
  2. Lines with numbers are stored in the program
  3. RUN executes the stored program
  4. LIST displays the program
  5. NEW clears 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:

CODE_FENCE_0

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:

CODE_FENCE_0

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

BASIC Commands Reference

Input/Output

PRINT

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: CODE_FENCE_0

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(128, "FF818181818181FF")

The first parameter is the character code (128-135 for user-defined). The second is a 16-character hex string defining the 8x8 pixel pattern.

CALL KEY

Check for a keypress without waiting. This enables real-time games and interactive programs.

CALL KEY(0, K, S)

CODE_FENCE_0

CALL SOUND

Generate a tone.

CALL SOUND(500, 440, 5)

CALL HCHAR / CALL VCHAR

Place characters horizontally or vertically.

CALL HCHAR(1, 1, 42, 10)
CALL VCHAR(1, 1, 42, 5)

CALL INDIC

Control LCD indicator segments.

CALL INDIC(2, 1)

Sets indicator number (1-5) on (1) or off (0).

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

CODE_FENCE_0

CLOSE

Close an open file channel.

CLOSE #channel

Always close files when done to ensure data is saved properly.

PRINT

Write data to an open file.

PRINT #channel:expression

CODE_FENCE_0

INPUT

Read data from an open file.

INPUT #channel:variable

CODE_FENCE_0

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 provides approximately 34KB 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 had a membrane keyboard with 50 keys including function keys, arrow keys, and a BREAK key. In this emulation, use your standard keyboard:

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:

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.

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 SHFT 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(0, K, S)
CALL SOUND CALL SOUND(500, 440, 5)
CALL CHAR CALL CHAR(128, "FF818181...")
CALL INDIC CALL INDIC(1, 1)

Function Categories


TI CC-40 COMPACT COMPUTER EMULATION Emulator.ca Systems Dial 555-0040 to connect