0% found this document useful (0 votes)
490 views7 pages

Digital Design and Computer Architecture, 2: Edition

This chapter discusses the process of compiling and running a program from high-level code to executable code in memory. It explains the roles of the compiler, assembler, linker, loader, and memory in this process. The chapter provides an example MIPS assembly program to demonstrate how the code is compiled and linked to create an executable that can run in memory.

Uploaded by

moacyranicio6360
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
490 views7 pages

Digital Design and Computer Architecture, 2: Edition

This chapter discusses the process of compiling and running a program from high-level code to executable code in memory. It explains the roles of the compiler, assembler, linker, loader, and memory in this process. The chapter provides an example MIPS assembly program to demonstrate how the code is compiled and linked to create an executable that can run in memory.

Uploaded by

moacyranicio6360
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Chapter 6

Digital Design and Computer Architecture, 2nd Edition


David Money Harris and Sarah L. Harris

Chapter 6 <1>
How to Compile & Run a Program
High Level Code

Compiler

Assembly Code

Assembler

Object Files
Object File
Library Files

Linker

Executable

Loader

Memory
David Money Harris and Sarah L. Harris, Digital Design and Computer Architecture, Second Edition, 2012
Chapter 6 <2>
Example Program: MIPS Assembly
.data High Level Code
int f, g, y; // global
f:
Compiler
g:
y: Assembly Code
int main(void)
.text
{ Assembler
main:
addi $sp, $sp, -4 # stack frame Object File
Object Files
Library Files
sw $ra, 0($sp) # store $ra
f = 2; addi $a0, $0, 2 # $a0 = 2 Linker

g = 3; sw $a0, f # f = 2 Executable
addi $a1, $0, 3 # $a1 = 3
y = sum(f, g); sw $a1, g # g = 3 Loader

return y; jal sum # call sum Memory


} sw $v0, y # y = sum()
lw $ra, 0($sp) # restore $ra
int sum(int a, int b) { addi $sp, $sp, 4 # restore $sp
return (a + b); jr $ra # return to OS
} sum:
add $v0, $a0, $a1 # $v0 = a + b
jr $ra # return
David Money Harris and Sarah L. Harris, Digital Design and Computer Architecture, Second Edition, 2012
Chapter 6 <3>
Example Program: Symbol Table
High Level Code

Compiler

Assembly Code

Assembler

Object Files
Object File
Library Files

Linker

Executable

Loader

Memory

David Money Harris and Sarah L. Harris, Digital Design and Computer Architecture, Second Edition, 2012
Chapter 6 <4>
Example Program: Executable
High Level Code

Compiler

Assembly Code

Assembler

Object Files
Object File
Library Files

Linker

Executable

Loader

Memory

David Money Harris and Sarah L. Harris, Digital Design and Computer Architecture, Second Edition, 2012
Chapter 6 <5>
Example Program: In Memory
High Level Code

Compiler

Assembly Code

Assembler

Object Files
Object File
Library Files

Linker

Executable

Loader

Memory

David Money Harris and Sarah L. Harris, Digital Design and Computer Architecture, Second Edition, 2012
Chapter 6 <6>
What is Stored in Memory?
• Instructions (also called text)
• Data
– Global/static: allocated before program begins
– Dynamic: allocated within program

• How big is memory?


– At most 232 = 4 gigabytes (4 GB)
– From address 0x00000000 to 0xFFFFFFFF

David Money Harris and Sarah L. Harris, Digital Design and Computer Architecture, Second Edition, 2012
Chapter 6 <7>

You might also like