top of page

T LANGUAGE

OVERVIEW

Programming a TI 59 calculator is rather long and painful. The AOS Language is pretty simple but it doesn't provide advanced facilities for structured programming: it has very basic control structures, no variable identifiers/scope, and even less argument passing mechanisms to subroutines.

 

To overcome these weaknesses, I created the T Language which is a subset of the C Language (T stands for Ti). A program written in T Language can be easily compiled with any C Compiler. Once validated on a computer, the T Compiler allows to generate corresponding AOS instructions for your TI 59 calculator.

 

As an output, the T Compiler also provides information about the memory consumption, the number of steps required, and a mapping table between variable names and calculator registers.

OUTLINE OF A PROGRAM

 

A typical program looks like this:

 

variable declarations;        // Set of global variables

 

double function(parameters)   // A function and its parameters

{

    variable declarations;    // Set of local variables

 

    instructions;

    return value;

}

 

void procedure(parameters)    // A procedure and its parameters

{

    variable declarations;

 

    Instructions;

}

 

void main()                   // The main module

{

    variable declarations;

 

    instructions;

}

 

 

VARIABLES

 

Like the C Language, the T Language is using an identifier for each variable. Anyway, the variable type is restricted to double which is the only type that can be handled by the calculator.

 

A variable can be a simple value or an array of values (one dimension only):

 

double value;

double values[5];

 

A variable can also contain the address of another variable (actually its associated register number in the calculator):

 

double *pointer;

double *pointers[10];

 

To reference a variable address, the & character is used:

 

pointer=&value;

pointers[5]=&values[1];

 

The T Language also manages the scope of a variable which means the portion(s) of code in which it is known and addressable. Very often, the variable is known within the function/procedure where it has been defined. Anyway, it is possible to define it out of any subroutines and make it global to the whole program.

 

double g;        // g is a global variable

 

void main()

{

    double l;    // l is a local variable

 

    l=g;         // g is known within main

}

 

 

FUNCTIONS AND PROCEDURES

 

The T Language defines two types of reusable code:

  • Functions which accept input parameters passed by value and return a value.

  • Procedures which accept input parameters passed by value or by reference but don't return any value.

 

Let's consider the following program:

 

double myFunction(double var)

{

    var=var+1;

    return var;

}

 

void myProcedure(double *var)

{

    *var=*var+1;

}

 

void main()

{

    double a;

    double b;

 

    a=1;

    b=myFunction(a);

    display(a);        // Will display 1

    display(b);        // Will display 2

 

    myProcedure(&a);

    display(a);        // Will display 2

}

 

The main difference between myFunction and myProcedure is the way the input parameter is handled:

  • myFunction input parameter is passed by value which means variable a is copied locally to a new variable named var. Therefore, computations on var change the value of a.

  • myProcedure input parameter is passed by reference which means variable a is directly used. As a consequence, computations on var change the value of a.

 

Variables passed as input parameters are local to the function or procedure. Thus, there is no possible mix between var declared in myFunction and var declared in myProcedure.

 

 

CONTROL STRUCTURES

 

The T Language offers two types of control: the if-else statement and the while statement. Both are used in conjunction with tests.

 

Natively, the calculator only supports four tests out of six:

  • Lower than,

  • Equal to,

  • Not equal to,

  • Greater or equal to.

 

The T Language adds the two missing tests:

  • Lower or equal to,

  • Greather than.

 

 The T Language doesn't allow test combinations with and/or logic operators but it can be easily implemented by using nested tests.

 

 

INPUT/OUTPUT FUNCTIONS

 

The T Language defines several I/Ofunctions to interact with the User:

 

  • input(identifier, stop)          Assign a value to a variable identifierStop tells whether we wait for a next input after this one.                                     In case we don't, the program starts running.

  • inputKey(identifier, key, stop)  Assign a value to a variable identifier by pressing a User key on the calculator (labeled from A to E').

 

  • display(expression)              Display an expression - variable or a numeric value - without stopping the program.

  • pause(expression)                Display an expression while stopping the program for a short time.

 

  • printText(string, justification) Print on a PC 100-C a string with the specified justification (LEFT, CENTER, RIGHT).

                                    Caesura is managed.

  • printValue(expression, string)   Print on a PC 100-C an expression followed by a string.

  • advance()                        Trigger a line feed.

FUNCTION

myFunction accepts an input parameter passed by value and returns a value thanks to the keyword return.

 

PROCEDURE

myProcedure accepts an input parameter passed by reference but doesn't return any value (keyword void)

 

WANT TO KNOW MORE?
WANT TO KNOW MORE?
WANT TO KNOW MORE?
INPUT_OUTPUT_FUNCTIONS
WANT TO SEE MORE?
bottom of page