5-1 chapter 5 - languages and the machine principles of computer architecture by m. murdocca and v....

12
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.

Upload: clement-merritt

Post on 18-Dec-2015

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 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

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.

Page 2: 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

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.

Page 3: 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

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:

Page 4: 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

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:

Page 5: 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

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

Page 6: 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

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.

Page 7: 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

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).

Page 8: 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

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.

Page 9: 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

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.

Page 10: 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

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.

Page 11: 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

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.

Page 12: 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

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