CS 2734 Computer Organization II
Lecture 11: Program Layout and Variables - 2/10/97
Answers to Informal Quiz 2: Tracing Instruction Cycle
Program layout (refer to Figure 9.1 on page 229 of Paul).
Text segment - program code (starts at
0x2000
in Sparc).
Data segment - initialized static variables.
bss
- uninitialized static variables are initialized to zero.
Heap - where
malloc
obtains free space.
Stack
Environment
Defining a one-dimensional array in the
data
segment using:
.word
.byte
.ascii
.asciz
Defining data in the
bss
:
.common name,bytes
The
.align
is used to align data.
Addressing of memory by loading the address in a register, e.g. to load the address of the memory at label
MYARRAY
into register
%l1
sethi %hi(MYARRAY), %l1 or %l1, %lo(MYARRAY), %l1
SKILL:
You should understand how static and automatic variables in C are related to the corresponding structures in Sparc assembly language.
Revision Date: 2/10/97