.text
.globl main
main:
jal pread # read first integer
nop #
move $s0,$v0 # save it in $s0
jal pread # read second integer
nop #
move $s1,$v0 # save it in $s1
jal pread # read third integer
nop #
move $s2,$v0 # save it in $s2
addu $s0,$s0,$s1 # compute the sum
addu $a0,$s0,$s2 # result in $a0
li $v0,1 # print the sum in $a0
syscall
li $v0,10 # exit
syscall
R ecall
that modules (for us, subroutines) should not know about
each other's symbolic addresses.
It would violate the idea of modularity for main
to do something to pread's prompt,
for example.
But some symbolic addresses need to be used between modules.
For example, pread is a symbolic address, and
main must know about it and use it in the jal
instruction.
A symbol that a subroutine makes visible to other subroutines is
a global symbol.
Global symbols often label entry points.
Symbols that are not global are called local symbols.
In MIPS assembly and in SPIM, a symbol is made global by
placing it in a list of symbols following the .globl directive.
Some languages use the word external for what we are
calling global.
.globl main
In the language C, a symbol that is visible to another module is called an external symbol. For example, the names of functions in C are external symbols.
Source programs for SPIM are contained in a single file, which includes all subroutines. However, in professional software development, each subroutine might be placed in a separate source file. Each file must say which of its symbolic addesses are global and might be referenced by other source files.
What global symbols are in the subroutine pread?