EasyManuals Logo
Home>Texas Instruments>Calculator>TI-89

Texas Instruments TI-89 Software Guide

Texas Instruments TI-89
334 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #92 background imageLoading...
Page #92 background image
80
Section 2: Compiler
TI
-
89 / TI
-
92 Plus Sierra C Assembler Reference Manual
Not for Distribution
Beta Version February 2, 2001
The structure return mechanism can be further clarified using a pair of examples.
Example A shows a function returning a structure, and Example B uses structure
pointers to demonstrate (at the C level) what the compiler generates internally
when a function returns a structure. These examples generate essentially
identical code.
Example A Example B
struct s { struct s {
int a; int a;
int b; int b;
}; };
struct s f(); struct s *f();
struct s x; struct s x;
main() main()
{{
x = f(1,2); struct s tmp;
}
x = *f(&tmp,1,2);
struct s f(int i,int j) }
{
struct z; struct *f(strct_ptr,i,j)
z.a = i; struct s *strct_ptr;
z.b = j; {
return z; struct z;
}
z.a = i;
z.b = j;
*strct_ptr = z;
return strct_ptr;
}
Warning:
A function that returns anything other than an integer
must
be declared in a file
before it is called. Failure to do so could result in unexpected behavior. Without a
declaration in scope, a called function is assumed to return an integer; therefore, its
return value is expected to be in
d0
. However, if the function actually returned a
pointer, the return value would be found in
a0
. Similarly, if the function returned
floating-point data, the return value would be in
fp0
. Even if the function returned an
object of type
char
or
short int
, the upper portion of
d0
might contain invalid data
that would result in a corrupted integer value.
Warning:
A function that returns a structure
must
be declared in a file before it is called, even
when the return value is not used. Without a declaration in scope, the pointer to the
structure return area is not pushed onto the stack. The called function, which
assumes that the memory pointer has been pushed, cannot access its parameters
correctly and may corrupt memory when it attempts to return a structure.

Table of Contents

Other manuals for Texas Instruments TI-89

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments TI-89 and is the answer not in the manual?

Texas Instruments TI-89 Specifications

General IconGeneral
Display size (HxV)100 x 160 mm
Memory type639K FLASH ROM, 188K bytes RAM
Compatible operating systemsOperating System 2.09
Battery typeAAA

Related product manuals