Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

TI-BASIC programming patterns

TI-BASIC performance depends on parser work, floating-point transfers, VAT lookups, and display calls. This page collects the source-level decisions. The full programs, traces, and BASIC/ASM fixtures are in TI-BASIC examples and ASM interop.

Choose work with fewer interpreter crossings

The statement loop at 38:59C5 dispatches every source statement. Structured loops also maintain FPS and OPS records, and each variable access crosses the VAT/value boundary. [confirmed]

Source-level choiceInterpreter costExample
Keep loop bodies shortFewer statement dispatches and parser scans per iterationText animation
Prefer list or matrix primitivesOne parsed command can run an internal ROM loopTrace-backed list fixture
Cache repeated list elements in scalarsAvoid repeated VAT lookup and list-element address calculationDFS list stack
Keep graph drawing in the graph bufferAvoid repeated home-screen formatting and LCD updatesGraph-buffer visualization
Use structured loops instead of hot Goto pathsAvoid repeated label rescans through 38:7600Loop behavior
Include the optional For( closing parenthesisAvoid the documented implicit-close parser trapFor( parenthesis trap

These are interpreter-cost rules, not cycle counts. Exact timing depends on the program, data, display mode, and calculator speed.

Preserve the BASIC caller for callbacks

TI-BASIC subprograms share variables and Ans, but preserve parser control in a private frame. Use a small input/output convention and let BASIC perform the prgmNAME call. [confirmed]

BoundarySupported pattern
BASIC → BASICStore inputs, call prgmNAME, then read shared variables or Ans.
BASIC → ASMCall Asm(prgmNAME) and require the payload to return normally.
ASM → BASIC callbackStore a result or signal in Ans, return to BASIC, and let the wrapper call prgmNAME.

The compiled launcher, negative public-bcall probes, and private-frame comparison are documented under BASIC and ASM interop.