SourcePoint AMD Help

Table of Contents

Symbolic References

References to program addresses and variables

Syntax:

label

procedure

variable

variable[array-expr]

composite-variable.member

composite-variable->member

compound-variable

variable-ref=expr

*ptr-variable

&variable

Where:

label

program label

procedure

procedure name

variable

variable name

composite-variable

structure or union name

member

structure or union member name

compound-variable

a combination of other variable types

ptr-variable

pointer variable name

[array-expr]

specifies a number or expression identifying an element in an array

variable-ref

specifies a variable, an array variable, a composite variable or a compound-variable

expr

specifies a number or expression

Discussion

A program symbol table contains the names of all objects in the program, including the type and (for some objects) the length of each object. A symbolic reference identifies an object by name. When you use a symbolic reference in a command or expression, the emulator returns the value corresponding to the object. The value returned depends on the object type. This section reviews the kinds of symbolic references and the value represented. It also discusses special operators used with symbolic references, the address of operator (&) and the indirection operator (*), the direct-selection operator (.) and the indirect selection operator (-> ).

Symbol Table

The load command reads information about the program symbols from the object file named in the command. This information is stored internally in SourcePointโ€™s symbol table. Symbol information is available in the Symbols window. Symbols can be used in place of addresses in the Memory, Code and Breakpoints windows. In addition, symbolic references can be used from within the Command window.

Names

All symbolic references involve the names of objects. Symbol names are case-sensitive. The legal characters in a name are defined by the language used in generating the object file. If a name conflicts with a reserved keyword, an emulator control variable, a debug variable, or a processor register name, then preface the name with the reserved keyword override operator (\). ย If a name exists more than once in a program, see Qualified Symbol Names.

Labels and Procedures

When you specify a label name or procedure name, the address associated with that object is returned. The address of operator (&) is ignored when used with a label or procedure name.

Variables

When you specify a variable name, the value associated with that object is returned.

Command input:

usi ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย // usi is an unsigned short int

Result:

0001H

Command input:

f ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย // f is a float

Result:

1.234500

Command input:

f=14.67

f

Result:

14.670000

Array Variables

An array consists of elements of a given type. To read or write an individual element, specify the index of the element. The address of operator (&) can be used to return the address of an array element.

Command input:

ai ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย // ai is an array of integers

Result:

ai[0]: 0x00000000

ai[1]: 0x00000001

ai[2]: 0x00000002

ai[3]: 0x00000003

ai[4]: 0x00000004

ai[5]: 0x00000005

Command input:

ai[4] = 0

ai[4]

Result:

0x00000000

Composite Variables

A composite variable contains a collection of different objects called members. In "C" these include structures and unions. The direct-selection operator (.) is used to access individual members of a composite variable. If a pointer to a composite variable is specified, then the indirect-selection operator (->) is used to access members. The address of operator (&) can be used to return the address of a member of a composite variable.

Command input:

ints ย ย ย ย ย ย ย ย ย  ย ย ย ย ย ย ย ย ย // ints is a structure with 3 members: a, b and c

Result:

a: 0

b: 0

c: 0

Command input:

ints.b=5 ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย // change one member

ints

Result:

a: 0

b: 5

c: 0

Compound Variables

The program can contain compound forms such as arrays of arrays, arrays of structures, structures of arrays, and structures of structures. The rules for references to these compound forms are a combination of the previously discussed rules for variables.

Command input:

IntsArray ย ย ย ย ย ย  ย ย ย ย ย ย ย // IntsArray is an array of structures

Result:

IntsArray[0]:

a: -1

b: -2

c: -3

ย 

IntsArray[1]:

a: 1

b: 2

c: 3

Command input:

IntsArray[1].b = -5 ย ย ย ย // change one member of one element

IntsArray[1]

Result:

a: 1

b: -5

c: 3

Pointer Variables

Pointer variables contain addresses that reference program variables. When a program variable is defined as a pointer to another program variable that has a specific data type, use the indirection operator (*) to obtain the value of the variable.

Command input:

ints ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย // ints is a structure with members a, b, and c

Result:

a: 0

b: 5

c: 0

Command input:

&ints ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย // display address of ints

Result:

00000C78

Command input:

pInts ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย // pInts points to int

Result:

00000C78

Command input:

*pInts ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย // display ints through the pointer pInts

Result:

a: 0

b: 5

c: 0

Command input:

pInts->b = 0 ย ย ย ย ย ย ย ย ย ย ย // change a member of ints through pInts

Result:

a: 0

b: 0

c: 0

Changing the Value of a Variable

Variables can be assigned new values from within the Command window or the Symbols window. To change the value of a variable, the variable must be active (be in the current or global scope). You cannot change the address corresponding to a procedure or label. The value assigned is converted to the variable type.

ย