I just want to be sure I'm being precise in my definitions. Is a program label just another term for a symbolic address or is it something different and more specific?
-
Yes, a label associates a name with a memory address. Machine code uses the memory address, which ultimately is a number (encoded as needed, for use in machine instructions or data), whereas assembly code uses the names of labels (usually). – Erik Eidt Oct 04 '19 at 20:04
1 Answers
Pretty much yes; see also MIPS labels storage location for more about symbols being ways to refer to memory addresses. They're very useful to avoid having to recalculate by hand the numeric address of the top of every loop (or actually the distance away from the relative branch).
They're also useful for cases where assemble-time calculation wouldn't be possible, and has to be deferred to link time.
Terminology: A label defines a symbol. Symbols can also be defined other ways, but usually by labels.
foo:
on a line by itself (or at the start of a line) is a label.
foo
is the symbol which you can refer to from other places, like jal foo
or bne foo
. Or put the address of into a register with la $t0, foo
You can even refer to a symbol from other source files for symbols that are exported so they end up in the symbol table of an object file (.o
) that your assembler creates from your asm source. (e.g. you use .global foo
to export foo
instead of leaving it as just a file-local symbol.)
In GAS syntax (which MARS mostly uses), other ways to define symbols are with things like the .set
directive, or .weakref
to define a label that's an alias of another label. Or .comm
to reserve some space in the BSS and point a symbol name at it. (But without using a .bss
directive to actually make .bss
the current section, so this is not a label.)

- 328,167
- 45
- 605
- 847