5-1 chapter 5 - languages and the machine principles of computer architecture by m. murdocca and v....
TRANSCRIPT
5-1 Chapter 5 - Languages and the Machine
Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring
Assembly Example• We explore how the assembly process proceeds by “hand
assembling” a simple ARC assembly language program.
5-2 Chapter 5 - Languages and the Machine
Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring
Memory Map for the ARC
• Memory locations are arranged linearly in consecutive order. Each numbered locations corresponds to an ARC word. The unique number that identifies each word is referred to as its address.
5-3 Chapter 5 - Languages and the Machine
Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring
Forward Referencing
• An example of forward referencing:
5-4 Chapter 5 - Languages and the Machine
Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring
Macro Definition
• A macro definition for push:
5-5 Chapter 5 - Languages and the Machine
Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring
ARC User-Visible Registers
5-6 Chapter 5 - Languages and the Machine
Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring
Subroutine Linkage – Registers
• Subroutine linkage with registers passes parameters in registers.
5-7 Chapter 5 - Languages and the Machine
Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring
Subroutine Linkage – Data Link Area• Subroutine linkage with a data link area passes parameters in a
separate area in memory. The address of the memory area is passed in a register (%r5 here).
5-8 Chapter 5 - Languages and the Machine
Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring
Subroutine Linkage – Stack• Subroutine linkage with a stack passes parameters on a stack.
5-9 Chapter 5 - Languages and the Machine
Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring
Stack Linkage Example
• A C program illustrates nested function calls.
5-10 Chapter 5 - Languages and the Machine
Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring
StackLinkageExample (cont’)
• (a-f) Stack behavior during execution of the program shown in previous slide.
5-11 Chapter 5 - Languages and the Machine
Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring
Stack Linkage Example (cont’)
• (g-k) Stack behavior during execution of the C program shown previously.
5-12 Chapter 5 - Languages and the Machine
Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring
Exercise
• Pg. 148 4.7