The <default.h> Header File

Default header file which is always included

default.h is always included at the top of every other header file.

In addition to defining the following macros, this header file handles basic symbols such as USE_TI89 and related ones, or MIN_AMS. See the info section How to make a TIGCC program.

Functions

_rom_call_addr_concat
Returns a void pointer to a TIOS ROM call (internal).
_rom_call_addr_hack_concat
Returns a void pointer for a TIOS ROM call, using an address hack if needed (internal).
_rom_call_addr_hack
Returns a void pointer for a TIOS ROM call, using an address hack if needed.
_rom_call_addr
Returns a void pointer to a TIOS ROM call.
_rom_call_attr
Constructs a function definition with attributes for a TIOS ROM call.
_rom_call_concat
Constructs a function definition for a TIOS ROM call (internal).
_rom_call_hack_attr_concat
Constructs a function definition with an address hack and attributes for a TIOS ROM call (internal).
_rom_call_hack_attr
Constructs a function definition with an address hack and attributes for a TIOS ROM call.
_rom_call_hack
Constructs a function definition with an address hack for a TIOS ROM call.
_rom_call
Constructs a function definition for a TIOS ROM call.
import_binary
Imports a binary file as an arbitrary symbol.

Global Variables

__jmp_tbl
A variable which points to the TIOS jump table of ROM calls.

Constants

MIN_AMS_MAJOR
The major part of MIN_AMS.
MIN_AMS_MINOR
The minor part of MIN_AMS.

See also: nostub.h, doors.h


_rom_call_addr_concat

#define _rom_call_addr_concat(intindex,romindex) (__jmp_tbl [intindex])

Returns a void pointer to a TIOS ROM call (internal).

_rom_call_addr_concat is an internal macro which is used by _rom_call_addr and _rom_call.

intindex contains the index of the ROM call as a numeric constant. It is used in this definition, as an array subscript for __jmp_tbl, a pointer to the table of ROM calls. romindex contains a symbol in the form _ROM_CALL_xxx, where xxx is the index in hexadecimal form without the '0x' prefix.

Other header files override this definition to use romind instead. In particular, doors.h includes a romsymb.h header file which defines a list of external variables for all ROM call symbols which may appear in romindex, and changes the definition to:

#define _rom_call_addr_concat(intindex,romindex) (&romindex)

You probably wonder why _rom_call_addr_concat exists at all, since other header files might as well override _rom_call_addr, which could be used directly by _rom_call. The reason is that all arguments which are not concatenated are scanned for macros that have to be expanded. If _rom_call was using _rom_call_addr, passing index to it, then the index parameter would be scanned. This turns out to be fatal if the user defines a macro such as A1, and uses the ROM call with the index 0xA1.

Therefore, both _rom_call_addr and _rom_call have to use concatenation on their index parameter. Then they pass the resulting symbols to _rom_call_addr_concat.


_rom_call_addr_hack_concat

#define _rom_call_addr_hack_concat(intindex,romindex,addr,minams,minindex) (MIN_AMS >= (minams) || TIOS_entries >
(minindex) ? _rom_call_addr_concat (intindex, romindex) : ({
asm (".xdef __ref_all___reject_unofficial_os");
(void *) (addr);
}))

Returns a void pointer for a TIOS ROM call, using an address hack if needed (internal).

_rom_call_addr_hack_concat is a macro used internally by _rom_call_addr_hack. Its only purpose is to prevent prescan of the ROM call index (see _rom_call_addr_concat for more information).

See also: _rom_call_addr_hack


_rom_call_addr_hack

#define _rom_call_addr_hack(index,addr,minams) (_rom_call_addr_hack_concat (0x##index, _ROM_CALL_##index, (addr), (minams), 0x##index))

Returns a void pointer for a TIOS ROM call, using an address hack if needed.

_rom_call_addr_hack works exactly like _rom_call_addr, except that it takes an additional parameter addr specifying an alternative way to get the address of the ROM call. If the TIOS jump table contains the ROM call specified by index, the address from the jump table is used. Otherwise _rom_call_addr_hack computes the address specified by addr (which can be any pointer type), and returns it.

minams specifies the AMS version which first exports the ROM call identified by index. If the value of MIN_AMS is greater or equal to the value of minams, the ROM call is used unconditionally. When using this macro directly, you need to make sure that this value is correct; otherwise you will get crashes only if a specific value for MIN_AMS has been chosen and an unsupported AMS version is used.

See also: _rom_call_addr, _rom_call_hack, Manually Obtaining the Address of a ROM Function


_rom_call_addr

#define _rom_call_addr(index) (_rom_call_addr_concat (0x##index, _ROM_CALL_##index))

Returns a void pointer to a TIOS ROM call.

_rom_call_addr returns a void pointer to a TIOS ROM call, which you can cast to any other pointer type. After this cast, you can dereference it and handle it like any other variable.

Note that index is the index of the ROM Call in hexadecimal form, but without the '0x' prefix. The reason for this unusual convention is that kernel programs use ROM calls by referring to _ROM_CALL_xxx, where xxx is the hexadecimal index of the ROM call.

See _rom_call_addr_concat for info about the reason why _rom_call_addr_concat is used.


_rom_call_attr

#define _rom_call_attr(type,args,attr,index) (*({
typedef __ATTR_TIOS__ attr type (*__temp__type__) args;
(__temp__type__) (__rom_call_addr_concat (0x##index, _ROM_CALL_##index));
}))

Constructs a function definition with attributes for a TIOS ROM call.

_rom_call_attr works exactly like _rom_call, except that it takes an additional parameter attr to specify attributes for the function.

See also: _rom_call


_rom_call_concat

#define _rom_call_concat(type,args,intindex,romindex) (*((type (* __ATTR_TIOS__) args) (__rom_call_addr_concat (intindex, romindex))))

Constructs a function definition for a TIOS ROM call (internal).

_rom_call_concat is a macro used internally by _rom_call and other macros. Its only purpose is to prevent prescan of the ROM call index (see _rom_call_addr_concat for more information).

See also: _rom_call


_rom_call_hack_attr_concat

#define _rom_call_hack_attr_concat(type,args,attr,intindex,romindex,addr,minams,minindex) (*({
typedef __ATTR_TIOS__ attr type (*__temp__type__hack__) args;
(__temp__type__hack__) (MIN_AMS >= (minams) || TIOS_entries >
(minindex) ? (const void *) (&(_rom_call_concat (void, (void), (intindex), (romindex)))) : ({
asm (".xdef __ref_all___reject_unofficial_os");
(const void *) (addr);
}));
}))

Constructs a function definition with an address hack and attributes for a TIOS ROM call (internal).

_rom_call_hack_attr_concat is a macro used internally by _rom_call_hack and _rom_call_hack_attr. Its only purpose is to prevent prescan of the ROM call index (see _rom_call_addr_concat for more information).

See also: _rom_call_hack_attr, _rom_call_hack, _rom_call


_rom_call_hack_attr

#define _rom_call_hack_attr(type,args,attr,index,addr,minams) (_rom_call_hack_attr_concat (type, args, attr, 0x##index, _ROM_CALL_##index, (addr), (minams), 0x##index))

Constructs a function definition with an address hack and attributes for a TIOS ROM call.

_rom_call_hack_attr works exactly like _rom_call_hack, except that it takes an additional parameter attr to specify attributes for the function.

See also: _rom_call_hack, _rom_call_addr_hack, _rom_call_attr, _rom_call


_rom_call_hack

#define _rom_call_hack(type,args,index,addr,minams) (_rom_call_hack_attr_concat (type, args, , 0x##index, _ROM_CALL_##index, (addr), (minams), 0x##index))

Constructs a function definition with an address hack for a TIOS ROM call.

_rom_call_hack works exactly like _rom_call, except that it takes an additional parameter addr specifying an alternative way to get the address of the ROM call. If the TIOS jump table contains the ROM call specified by index, the address from the jump table is used. Otherwise _rom_call_hack computes the address specified by addr (which can be any pointer type), and uses it as the address of the ROM call.

minams specifies the AMS version which first exports the ROM call identified by index. If the value of MIN_AMS is greater or equal to the value of minams, the ROM call is used unconditionally. When using this macro directly, you need to make sure that this value is correct; otherwise you will get crashes only if a specific value for MIN_AMS has been chosen and an unsupported AMS version is used.

See also: _rom_call, _rom_call_hack_attr, _rom_call_addr_hack, Manually Obtaining the Address of a ROM Function


_rom_call

#define _rom_call(type,args,index) (_rom_call_concat (type, args, 0x##index, _ROM_CALL_##index))

Constructs a function definition for a TIOS ROM call.

_rom_call uses _rom_call_addr to get a void pointer to the location in memory where the function is stored, and then casts this pointer to a temporarily defined "pointer to function" type.

To avoid argument prescan of index, _rom_call_addr cannot be used directly, but instead another macro has to be used, which has been called _rom_call_addr_concat.

See also: _rom_call_attr, _rom_call_hack, _rom_call_addr


import_binary

#define import_binary(filename,symname) asm(".globl "#symname"\n"#symname":\n\t.incbin \""filename"\"")

Imports a binary file as an arbitrary symbol.

import_binary imports a binary file at the current position using the .incbin assembler directive. The parameter filename specifies the file name in quotes; symname specifies the symbol name to assign to the contents. You can give the symbol any type using an external definition; for example:

extern unsigned char myarray[];
import_binary ("myfile.bin", myarray);

It is not recommended to use import_binary at any place other than the top level, as binary contents placed inside functions will generally be interpreted as code.


__jmp_tbl

#define __jmp_tbl (*(void***)0xC8)

A variable which points to the TIOS jump table of ROM calls.

__jmp_tbl is a global variable, which is implemented here as a macro. Defining OPTIMIZE_ROM_CALLS causes this definition to be overridden; in this case, __jmp_tbl will be a real variable stored in the register a5.

__jmp_tbl is always a pointer to a void pointer, so you can treat it as an array of void pointers. Its size can be determined using the TIOS_entries pseudo-constant.

Most of the entries in the jump table point to functions, but some of them actually point to global variables of the operating system.

Usually, it is not desirable to use __jmp_tbl directly. The code may be optimized a little better if you use the _rom_call and _rom_call_addr macros instead.


MIN_AMS_MAJOR

#define MIN_AMS_MAJOR (MIN_AMS / 100)

The major part of MIN_AMS.

MIN_AMS_MAJOR contains the major version number of the defined minimum AMS version. It may be used in header files which are supplied to a lot of users to test the availability of certain features, in addition to MIN_AMS itself.


MIN_AMS_MINOR

#define MIN_AMS_MINOR (MIN_AMS % 100)

The minor part of MIN_AMS.

MIN_AMS_MINOR contains the minor version number of the defined minimum AMS version. It may be used in header files which are supplied to a lot of users to test the availability of certain features, in addition to MIN_AMS itself.


Return to the main index