ITEC 352 Lecture 17 Functions in Assembly. Functions + Assembly Review Questions? Branching Call / Jump Reminder exam on Friday, project due next Friday.

Slides:



Advertisements
Similar presentations
Cosc 2150: Computer Organization
Advertisements

Target Code Generation
ITEC 352 Lecture 13 ISA(4).
1 Lecture 3: MIPS Instruction Set Today’s topic:  More MIPS instructions  Procedure call/return Reminder: Assignment 1 is on the class web-page (due.
Lecture 5: MIPS Instruction Set
Lecture 20: 11/12/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
ITEC 352 Lecture 14 ISA(5). Review Questions? Exam 1 next Friday Assembly –Assembler –Basic structure –Registers –Memory.
Chapter 10- Instruction set architectures
1 Procedure Calls, Linking & Launching Applications Lecture 15 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
Chapter 2 — Instructions: Language of the Computer — 1 Branching Far Away If branch target is too far to encode with 16-bit offset, assembler rewrites.
ECE 232 L6.Assemb.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 6 MIPS Assembly.
1 Lecture 4: Procedure Calls Today’s topics:  Procedure calls  Large constants  The compilation process Reminder: Assignment 1 is due on Thursday.
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
Lecture 8: MIPS Instruction Set
Functions Functions and Parameters. History A function call needs to save the registers in use The called function will use the registers The registers.
Microprocessors General Features To be Examined For Each Chip Jan 24 th, 2002.
Linkage Editors Difference between a linkage editor and a linking loader: Linking loader performs all linking and relocation operations, including automatic.
3. Loaders & Linkers1 Chapter III: Loaders and Linkers Chapter goal: r To realize how a source program be loaded into memory m Loading m Relocation m Linking.
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.
1 Lecture 2: MIPS Instruction Set Today’s topic:  MIPS instructions Reminder: sign up for the mailing list cs3810 Reminder: set up your CADE accounts.
An introduction to systems programming
Choice for the rest of the semester New Plan –assembler and machine language –Operating systems Process scheduling Memory management File system Optimization.
ITEC 352 Lecture 11 ISA - CPU. ISA (2) Review Questions? HW 2 due on Friday ISA –Machine language –Buses –Memory.
4-1 Chapter 4 - The Instruction Set Architecture Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring.
MIPS coding. SPIM Some links can be found such as:
JIT in webkit. What’s JIT See time_compilation for more info. time_compilation.
1 A Simple but Realistic Assembly Language for a Course in Computer Organization Eric Larson Moon Ok Kim Seattle University October 25, 2008.
4-1 Chapter 4 - The Instruction Set Architecture Department of Information Technology, Radford University ITEC 352 Computer Organization Principles of.
ITEC 352 Lecture 20 JVM Intro. Functions + Assembly Review Questions? Project due today Activation record –How is it used?
Chapter 5: Programming Languages and Constructs by Ravi Sethi Activation Records Dolores Zage.
ITEC 352 Lecture 12 ISA(3). Review Buses Memory ALU Registers Process of compiling.
ITEC 352 Lecture 18 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Exam –Average 76 Methods for functions in assembly.
5-1 Chapter 5 - Languages and the Machine Department of Information Technology, Radford University ITEC 352 Computer Organization Principles of Computer.
4-1 Chapter 4 - The Instruction Set Architecture Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
6-1 Chapter 6 - Languages and the Machine Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer.
Computer architecture Lecture 11: Reduced Instruction Set Computers Piotr Bilski.
Chapter 1 Computer architecture Languages: machine, assembly, high
Languages and the Machine Chapter 5 CS221. Topics The Compilation Process The Assembly Process Linking and Loading Macros We will skip –Case Study: Extensions.
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
Richard P. Paul, SPARC Architecture, Assembly Language Programming, and C Chapter 7 – Subroutines These are lecture notes to accompany the book SPARC Architecture,
ITEC 352 Lecture 14 ISA(6). Review Questions? Beginning / End Memory locations Variable / Memory syntax PSR Loops / Branches.
1 Branches and Procedure Calls Lecture 14 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
5-1 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
5-1 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
4-1 Chapter 4 - The Instruction Set Architecture Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
Blackfin Array Handling Part 1 Making an array of Zeros void MakeZeroASM(int foo[ ], int N);
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson Slides4-2.ppt Modification date: March 23, Procedures Essential ingredient of high level.
by Richard P. Paul, 2nd edition, 2000.
M. Mateen Yaqoob The University of Lahore Spring 2014.
ITEC 352 Lecture 19 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Stacks Function activation / deactivation.
Assembly Language Co-Routines
ITEC 352 Lecture 16 ISA(7). Review Exam / Questions? Conditional codes, how important are they? How important are comments in assembly? What are the benefits.
First Foray into Programming (the hard way). A reminder from last lesson: A machine code instruction has two parts:  Op-code  Operand An instruction.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
7-Nov Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct lecture23-24-hll-interrupts 1 High Level Language vs. Assembly.
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
Lecture 6: Assembly Programs
System Programming and administration
Computer Architecture and Organization Miles Murdocca and Vincent Heuring Chapter 4 – The Instruction Set Architecture.
Conditional Branches What distinguishes a computer from a simple calculator is its ability to make decisions Decisions are made using the if statement,
Loaders and Linkers.
by Richard P. Paul, 2nd edition, 2000.
Programming Languages
Lecture 6: Assembly Programs
Lecture 11 Z80 Instruction Hong DGU.
MIPS assembly.
An introduction to systems programming
Lecture 3 - Instruction Set - Al
MIPS instructions.
Procedures and Macros.
Presentation transcript:

ITEC 352 Lecture 17 Functions in Assembly

Functions + Assembly Review Questions? Branching Call / Jump Reminder exam on Friday, project due next Friday

Functions + Assembly Outline Beyond the basics

Functions + Assembly Points to ponder So far you have seen the instructions available for the ARC machine Mapping between high level languages and assembly –Variables –Operations –Assignment –Conditionals –Loops –Arrays –Functions –Objects

Functions + Assembly Process How to take simple tools and build something complex Bootstrapping 101

Functions + Assembly A little buildup Addressing modes –How to get to memory –Why more than one?

Functions + Assembly ARC Methods Using the call instruction.begin.org 2048 f: ld %r1, %r2 ….org 0 main: … call f ! call routine at function f. ld [x], %r1  instruction that must be executed after f finishes. halt.end

Functions + Assembly Writing methods in ARC (2).begin.org 2048 f: ld %r1, %r2 … jmpl %r15+4, %r0.org 0 main: … call f ld [x], %r1 <- This is at memory address %r halt.end

Functions + Assembly Jumping Have ability to jump back / forth to blocks of code What capabilities are not made possible with this approach?

Functions + Assembly Registers Subroutine linkage with registers passes parameters in registers. High level language equivalent?

Functions + Assembly Memory 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).

Functions + Assembly sethi Example: sethi 1, %r1 will load the number “1” in the 11 th position as follows: The value in register %r1 is not 1!, It is 2 10 Hence, to load 1 into the register, we now need to shift the register by 10 bits to the right. srl 10, %r1 10 th position Purpose: set a value in a particular place

Functions + Assembly Shifty Shift right (srl) –Shift a register by a certain # of bits and store the result in another register (0s are padded) –srl 10, %r1 Shift left (sll) –Instead of the right, go left Why is shifting bits important?

Functions + Assembly Back to functions Limitations of each approach –Registers –Data link area Recursion Possible solutions

Functions + Assembly Function calls void f() { printf(“enter f”); g(); printf(“exit f”); } void g() { printf(“enter g”); h(); printf(“exit g”); } void h() { printf(“enter h”); i(); printf(“exit h”); } void i() { printf(“enter i”); i(); printf(“exit i”); } void main() { f(); } Write out what is called? Does this remind you of any particular data structure?

Functions + Assembly Terms Function activation –When its code is being activated –How many times is f activated? Function deactivation –When a function’s code goes from being active to non-active

Functions + Assembly OS / Languages Keeps track of what is active what is not Scheduling algorithms –Multi-tasking Scope of variables –Where do they live, when can they be accessed?

Functions + Assembly Review Functions / Assembly intro Next time –Stacks and the full implementation