Creating Variables

z80 » Variables

The TI86 has several routines that can set up space for variables. For all these routines you must:

  1. Put the name in Variable Name Format into OP1 and
  2. load hl with the desired size of the variable data area.
Some of these routines have fixed sizes (_CreatREAL, _CreateCPLX, etc.) so you don't have to load hl with the desired size. These such routines have a '*' after their names.

The only other special inputs needed for these variables are that _CreateRMAT and _CreateCMAT need the number of rows in h and the number of columns in l; _CreateRVECT and _CreateCVECT need the number of elements in l.

CallType Created
_CreateREAL*Real Number
_CreateCPLX*Complex Number
_CreateRCONST*Real Constant
_CreateCCONST*Complex Constant
_CreateRVECTReal Vector
_CreateCVECTComplex Vector
_CreateRLISTReal List
_CreateCLISTComplex List
_CreateRMATReal Matrix
_CreateCMATComplex Matrix
_CreateSTRNGString
_CreateEQUEquation
_CreatePICT*Picture
_CreatePROGProgram

The output of these calls:

  1. bde will be an absolute pointer to the data area for the variable created
  2. OP4 will hold the name of the variable
  3. hl will point to where in the Variable Allocation Table (VAT) this variable is
  4. RAM page 7 will be loaded (meaning hl is a valid pointer to the VAT entry).
Let's make an optimized routine to create a string named "Stupid".
	ld hl,name-1		;load name address in to hl
				;we can put a trash byte in
				; for the type byte because
				; it doesn't matter so we
				; include the byte before the
				; name
	rst 20h			;same as 'call _Mov10ToOP1'
	jp _CreateSTRNG		;create the string and return

For variables that have varying sizes (programs, strings, equations), the first two bytes in the variable's data will be the Length Word. This is a word (2 bytes) that tells the length of the variable. This means that we can't have a variable with a length of over 65535 ($ffff) bytes.

More examples on this can be found in the Messing With Variable Data section.


More from z80 » Variables
Absolute Addressing // Binary Coded Decimal // Creating Variables // External Levels // _FindSym // Messing with Variable Data // OP Math // TI-OS Variable Manipulation // Variable Name Format // VAT Searches