Skip to content
KhiCASPublic

Repository files navigation

KhiCAS CE

An XCAS port for the TI-84 Plus CE / TI-83 Premium CE calculators.

KhiCAS Screenshots

Recent changes

  • Native 2D expression and matrix editing, with fractions, powers, roots, integrals, sums, limits and series templates. The editor uses the FlowCE layout and structural editing code adapted by Bernard Parisse.
  • F5 evaluates the selected subexpression, or the whole expression in caret mode. Series templates default to polynomial output without a remainder term.
  • Console history displays expressions and results in 2D by default. Use MODE → 2D history to switch to compact text history. Copying and recalling an entry keeps its Giac source text; strings, programs and expressions that do not fit use text display.
  • Results that fit in 2D history appear there directly, without an extra confirmation in the expression editor. Larger results can still use the editor.
  • Leaving a graph adds a monochrome thumbnail to 2D history. Recall or copy the entry to recover its plot command, or open it again to redisplay the graph. Saved sessions retain the command and a “Graphic object” placeholder rather than the thumbnail bitmap.
  • Improved interruption and low-memory handling, plus fixes for catalog completion, console menus and cursor placement, reciprocal printing, and graph redraw after cancelling a menu.

Using the 2D editor

With 2D history enabled, typing on an empty command line opens the editor automatically (except in Python mode). Recent history stays visible above the editing area. Press ENTER to return the expression to the command line, then ENTER again to evaluate it. Disable MODE → 2D history to keep plain command-line entry.

You can also open the editor with the fraction template key on a TI-83 Premium CE, or 2nd, X,T,theta,n on a TI-84 Plus CE. The current expression starts selected. On the TI-83 Premium CE, 2nd, fraction starts with the caret at the end instead.

Key Action in the editor
MODE Switch between caret and subexpression selection modes
Arrows Move the caret; in selection mode, left/right select siblings and up/down select the parent/child
F5 (rightmost key under the screen) Evaluate the selection, or the whole expression in caret mode
ENTER Accept the edited expression into the console
CLEAR / annul Undo the last edit; cancel when there is nothing left to undo
2nd, MODE (QUIT) Cancel and discard edits immediately
2nd, CLEAR Empty the editor

F1/F2 menus and MATH provide command templates. For example, series(sin(x),x,0,5,polynom) displays a series template; empty point and order fields default to 0 and 5 when accepted. In a matrix cell, comma adds a column and 2nd, ENTER adds a row. The text line below the 2D display shows the underlying Giac expression.

An 8 KiB emergency reserve and a preallocated error value help interrupted calculations unwind under memory pressure. Recovery is best effort; some allocation failures still terminate the application.

Compilation:

Prerequisites

Clone with git clone --recurse-submodules https://github.com/KhiCAS/ti-ce.git. In an existing checkout, run git submodule update --init --recursive after pulling so that the Giac sources match the referenced revision.

KhiCAS build

Run the ./mkappen (English build) or ./mkappfr (French build) script.

It will create, in the bin/ folder, many appvars (.8xv files) and an installer (.8xp).
A bundle file (.b83/.b84), only usable on TI Connect CE for Windows, will also be created with those files.

make -j8 builds the English app and installer segments without publishing to shared/ti. The linked ELF is bin/KhiCAS.obj; convbin converts it to bin/KhiCAS.8ek, then app_tools/relocate_app.py produces bin/_KhiCAS.bin with its Flash relocations applied and removed. bin/_KhiCAS.8ek and the AppIns*.8xv files contain this smaller app. The distribution scripts copy the pre-relocated 8ek to shared/ti/KhiCAS.8ek.

The default LTO_TUNING=AUTO selects a measured size/speed balance when the compiler supports the required eZ80 controls: function merging, inline threshold 0, an 11-byte machine-outliner minimum sequence, and register arguments for eligible internal functions in merged IR. Older compilers keep the original function-merging / inline-threshold -10 policy. LTO_TUNING=YES requires the new controls; LTO_TUNING=NO reproduces the original policy.

LTO_INLINE_THRESHOLD and LTO_OUTLINE_MIN_BYTES adjust these defaults; LTOFLAGS replaces the complete LTO flag list. The former is an LLVM cost threshold; the latter counts native instruction bytes. INLINE_THRESHOLDS accepts source/threshold pairs for experiments, for example INLINE_THRESHOLDS='src/giac/kmodpoly.cc=0'. The balanced default leaves that list empty: the earlier console.cc=25 kgen.cc=0 example increased size, while the later -20 / kmodpoly=0 kmoyal=0 policy slowed the calculation suite by 6.4%. Per-source settings use LLVM attributes that survive the bitcode merge; see the tuning notes for their scope. Changing the settings rebuilds the app automatically.

Clean builds with the tested ez80 Clang 22.1.8 (opts branch) binary on 2026-11-04 produced:

Build Original bytes Balanced bytes Saved bytes Installer AppVars, old → new
English, normal 2,481,035 2,299,572 181,463 39 → 36
French, normal 2,482,915 2,301,439 181,476 39 → 36
English, L2 2,477,329 2,297,347 179,982 38 → 36
French, L2 2,478,925 2,298,930 179,995 39 → 36

In CEmu, 12 CAS workloads (three measured repetitions after a warmup) had a 2.7% aggregate evaluation slowdown; including parsing and result formatting, the total was 3.0%. The largest individual evaluation slowdown was 4.3% (6.9 ms on a polynomial integral). Every result matched the original build, and 32 exact-zero factoring/integration identities passed. These are emulator measurements, not physical-calculator timings. The balanced policy was selected from 46 runtime-tested configurations, following a 76-candidate size-only sweep. Generated measurements and emulator artifacts are local outputs under the ignored tests/results/ directory; the commands below reproduce the comparisons. Broader inlining, IR outlining and more aggressive native outlining did not offer a better balance on this suite. No math or UI feature was removed.

Reproduce the benchmarks with BENCHMARK=YES; return to BENCHMARK=NO for a normal app. This optional mode retains the normal UI code during LTO, times parsing/evaluation/formatting on the calculator's 32,768 Hz clock and emits results through CEmu's software console. The runner prepares a disposable copy of the supplied ROM with existing apps (including language packs) removed, ensuring the required first-app placement. The original ROM is left untouched.

The balanced policy requires the eZ80 backend extensions from codex/ez80-opts. Stock toolchain v15.0's Clang 19 lacks these controls; a newer compiler or nightly must contain those patches to enable them. AUTO checks the options rather than the compiler version.

CI prints the compiler version, pre-relocated app size and installer AppVar count. CI follows the nightly toolchain release; CEdev v15.0 ships Clang 19.

This pre-relocation assumes KhiCAS is the first installed app: delete all apps before installing it with INST, as described in the installation instructions. See app_tools/readme.md for the address calculation, and tests/README.md for tests.

Installation on calculator:

See install_en.txt or install_fr.txt.

Build customization:

Some compile flags control the inclusion of parts of the code.

The total app size ranges from 2.2MB to 2.8MB, approximately.

  • math:
    • -DWITH_LAPLACE Laplace/inverse Laplace transform ≈ 20K
    • -DWITH_DESOLVE desolve command ≈ 60K (including Laplace)
  • science:
    • -DWITH_PERIODIC periodic table ≈ 10K
    • -DWITH_UNITS physical units ≈ 40K

Note that 2 apps do never share a flash page, as a consequence you can add space up to a multiple of 65.536, e.g. 2260 KB and 2280 KB will leave free the same amount of flash.

Releases

Used by

Contributors

Languages