M2 Instruction Set Architecture

Size: px
Start display at page:

Download "M2 Instruction Set Architecture"

Transcription

1 M2 Instruction Set Architecture

2 Module Outline Addressing modes. Instruction classes. MIPS-I ISA. Translating and starting a program. High level languages, Assembly languages and object code. Subroutine and subroutine call. Use of stack for handling subroutine call and return.

3 hello.c Steps in gcc

4 Steps in gcc hello.c cpp

5 Steps in gcc hello.c hello.i cpp

6 Steps in gcc hello.c hello.i cpp cc1

7 Steps in gcc hello.c hello.i hello.s cpp cc1

8 Steps in gcc hello.c hello.i hello.s cpp cc1 as

9 Steps in gcc hello.c hello.i hello.s cpp cc1 as hello.o

10 Steps in gcc hello.c hello.i hello.s cpp cc1 Libraries (eg. Math) as hello.o ld

11 Steps in gcc hello.c hello.i hello.s cpp cc1 Libraries (eg. Math) as a.out hello.o ld

12 Steps in gcc Step Output FileType Remarks C Preprocessor hello.i C source text #include, #define,... C Compiler hello.s Assembler source text Individual modules. Labels. Assembler hello.o Object code Undefined global references. Linkage Editor a.out Executable Global references resolved

13 Memory Layout of a Program in Execution DATA a b c INSTRUCTIONS i1 i1 i2 i2 i3 i3

14 Memory Layout of a Program in Execution

15 Program to Memory Layout hello.s Libraries (eg. Math) as a.out ld hello.o

16 Object File Format (hello.o)

17 What does the Assembler do?

18 What does the Assembler do?

19 What does the Assembler do? Encodes easily!

20 What does the Assembler do?

21 What does the Assembler do? Assembler Directives

22 What does the Assembler do? Text Text segment begins here. here. Align Align at at word word boundary. main main is is a global label. Can Can be be referred from from other other modules. Assembler Directives

23 What does the Assembler do? Text Text segment begins here. here. Align Align at at word word boundary. main main is is a global label. Can Can be be referred from from other other modules. Assembler Directives Data Data segment begins here. here. Align Align at at byte byte boundary.

24 What does the Assembler do?

25 What does the Assembler do? Labels

26 What does the Assembler do? Labels

27 Assembler Actions How to encode? What information is required?

28 Assembler Actions How to encode? Information required: Where to branch? Where is loop? Where is str?

29 Assembler Actions Labels main, loop, str are names for memory locations.

30 Assembler Actions Labels main, loop, str are names for memory locations. main: first instruction in the text segment loop: 6 th instruction in the text segment str: starts from the first byte in the data segment printf: undefined

31 Assembler Actions Labels main, loop, str are names for memory locations. main: first instruction in the text segment loop: 6 th instruction in the text segment str: starts from the first byte in the data segment printf: undefined main main 0 loop loop str str printf printf????

32 Assembler Actions Labels main, loop, str are names for memory locations. main: first instruction in the text segment loop: 6 th instruction in the text segment str: starts from the first byte in the data segment printf: undefined Symbol Table main main 0 loop loop str str printf printf????

33 What does the Assembler do?

34 What does the Assembler do? Library Function Call Call

35 Unresolved references Defined in other object files Library functions, external calls to other modules

36 Unresolved references Defined in other object files Library functions, external calls to other modules Will exist in the symbol table entries of those obj files

37 Unresolved references Defined in other object files Library functions, external calls to other modules Will exist in the symbol table entries of those obj files Make a list of unresolved references in the present object file Relocation information

38 Unresolved references Defined in other object files Library functions, external calls to other modules Will exist in the symbol table entries of those obj files Make a list of unresolved references in the present object file Relocation information call call printf printf????

39 Object File Format (hello.o)

40 Object File Format (hello.o) Machine code code size size Initialized data data size size 0 Size Size of of uninitialized data data size size Size Size of of the the Symbol Table Table Size Size of of the the Relocation Info Info

41 Object File Format (hello.o) Machine code code size size Initialized data data size size 0 Size Size of of uninitialized data data size size Size Size of of the the Symbol Table Table Size Size of of the the Relocation Info Info

42 Object File Format (hello.o)

43 Object File Format (hello.o) main main 0 loop loop str str

44 Object File Format (hello.o) main main 0 loop loop str str call call printf printf????

45 Assembler

46 Assembler Pass 1: Finds instructions with labels. Records their memory locations and labels so that the relationship between symbolic names and addresses is known when instructions are translated.

47 Assembler Pass 1: Finds instructions with labels. Records their memory locations and labels so that the relationship between symbolic names and addresses is known when instructions are translated. Pass 2: Translate each assembly statement by combining the numeric equivalents of opcodes, register specifiers, and labels into a legal instruction.

48 Linking Multiple Modules

49 Linking Multiple Modules

50 Linking Multiple Modules

51 Linking Multiple Modules Header Info main(){... jal printf()... } Data Linker Symbol Table Reloc. Info hello.o Header Info print library printf() {... } Data Symbol Table Reloc. Info

52 Linking Multiple Modules Header Info main(){... jal printf()... } Data Symbol Table Reloc. Info hello.o print library Header Info printf() {... } Data Symbol Table Reloc. Info Linker hello + library Header main(){... jal printf()... } printf() {... } hello.o Data library Data Combined Symbol Table Combined Relocation Info. a.out

53 Memory Layout of a.out hello + library Header main(){... jal printf()... } printf() {... } during execution hello.o Data library Data Combined Symbol Table Combined Relocation Info. a.out

54 Linking Example Link modules procedurea and procedureb procedurea: la la $gp, $gp, X lw lw $a0, $a0, 0($gp) jal jal B data.data.word X procedureb: la la $gp, $gp, Y sw sw $a0, $a0, 0($gp) jal jal A data.data.word Y

55 Linking Example Procedure A

56 Linking Example Procedure A

57 Linking Example Procedure A

58 Linking Example Procedure A

59 Linking Example Procedure A

60 Linking Example Procedure B

61 Linking Example Procedure B

62 Linking Example Procedure B

63 Linking Example Address of Procedure A? Address of Procedure B? B() A() 200B 100B

64 Linking Example Procedure A starts at 0x Procedure B starts at 0x B() A() 200B 100B

65 Value of $gp? Addresses of X & Y? Linking Example Y X 30B 20B

66 Value of $gp? Addresses of X & Y? Linking Example Y X 30B 20B

67 Linking Example Value of $gp = 0x X = 0x Y = 0x Y X 30B 20B

68 Linking Example a.out

69 Module Outline Addressing modes. Instruction classes. MIPS-I ISA. Translating and starting a program. High level languages, Assembly languages and object code. Subroutine and subroutine call. Use of stack for handling subroutine call and return.

70 Backup

71 Linking Multiple Modules Header Info main(){... jal printf()... } Data Symbol Table Reloc. Info hello.o print library Header Info printf() {... } Data Symbol Table Reloc. Info Linker a.out hello + library Header main(){... jal printf()... } printf() {... } hello + library Data hello + library Symbol Table hello + library Reloc. Info

72 The a.out executable What does the a.out file contain? Program code (machine instructions) Data values (values, size of arrays) Other information that is needed for execution debugging Debugging: The stage in program development where mistakes ( bugs ) in the program are identified

73 Stack Frame Recall Stack Frame $fp Return Addr Old FP Saved Registers $t0 $ra func1 Frame Local Variables $fp func2 Frame $sp $sp

74 Saved Registers Registers are saved across function calls

75 Saved Registers Registers are saved across function calls Save registers $s0 - $s7 if used by the callee Example: $s0, $s1 are saved

76 Stack Frame Local variables are allocated on the stack after the saved registers... $fp $sp $t1 $t0 $ra $fp $s0 $s1 func1_x func1_y......

77 Stack Frame

Lecture 3: Instruction Set Architecture

Lecture 3: Instruction Set Architecture Lecture 3: Instruction Set Architecture CSE 30: Computer Organization and Systems Programming Summer 2014 Diba Mirza Dept. of Computer Science and Engineering University of California, San Diego 1. Steps

More information

M2 Instruction Set Architecture. Translating and Starting a Program Linkage Editor

M2 Instruction Set Architecture. Translating and Starting a Program Linkage Editor M2 Instruction Set Architecture Translating and Starting a Program Linkage Editor Module Outline Addressing modes. Instruction classes. RISC-V ISA. Translating and starting a program. High level languages,

More information

M2 Instruction Set Architecture

M2 Instruction Set Architecture M2 Instruction Set Architecture Module Outline Addressing modes. Instruction classes. MIPS-I ISA. Translating and starting a program. High level languages, Assembly languages and object code. Subroutine

More information

High Performance Computing Lecture 1. Matthew Jacob Indian Institute of Science

High Performance Computing Lecture 1. Matthew Jacob Indian Institute of Science High Performance Computing Lecture 1 Matthew Jacob Indian Institute of Science Agenda 1. Program execution: Compilation, Object files, Function call and return, Address space, Data & its representation

More information

Compilation, Disassembly, and Profiling (in Linux)

Compilation, Disassembly, and Profiling (in Linux) Compilation, Disassembly, and Profiling (in Linux) CS 485: Systems Programming Spring 2016 Instructor: Neil Moore 1 Turning C into Object Code Code in files p1.c p2.c Compile with command: gcc O1 p1.c

More information

Assembler. Lecture 8 CS301

Assembler. Lecture 8 CS301 Assembler Lecture 8 CS301 Discussion Given the following function header, int foo(int a, int b); what will be on the stack before any of the calculations in foo are performed? Assume foo() calls some other

More information

MIPS (SPIM) Assembler Syntax

MIPS (SPIM) Assembler Syntax MIPS (SPIM) Assembler Syntax Comments begin with # Everything from # to the end of the line is ignored Identifiers are a sequence of alphanumeric characters, underbars (_), and dots () that do not begin

More information

Computer Systems Organization

Computer Systems Organization Computer Systems Organization 1 Outline 2 A software view User Interface 3 How it works 4 The gcc compilation system 5 The gcc compilation system hello.c (source code) Pre-processor (cpp) hello.i (modified

More information

Course Administration

Course Administration Fall 2017 EE 3613: Computer Organization Chapter 2: Instruction Set Architecture Introduction 3/4 Avinash Kodi Department of Electrical Engineering & Computer Science Ohio University, Athens, Ohio 45701

More information

Department of Computer Science and Engineering Yonghong Yan

Department of Computer Science and Engineering Yonghong Yan Appendix A and Chapter 2.12: Compiler, Assembler, Linker and Program Execution CSCE 212 Introduction to Computer Architecture, Spring 2019 https://passlab.github.io/csce212/ Department of Computer Science

More information

ENCE Computer Organization and Architecture. Chapter 1. Software Perspective

ENCE Computer Organization and Architecture. Chapter 1. Software Perspective Computer Organization and Architecture Chapter 1 Software Perspective The Lifetime of a Simple Program A Simple Program # include int main() { printf( hello, world\n ); } The goal of this course

More information

From Code to Program: CALL Con'nued (Linking, and Loading)

From Code to Program: CALL Con'nued (Linking, and Loading) ecture 13 Computer Science 61C Spring 2017 February 15th, 2017 From Code to Program: CALL Con'nued (Linking, and Loading) 1 Administrivia We know it still sucks but: Waitlist students: Please be patient.

More information

CS 61C: Great Ideas in Computer Architecture CALL continued ( Linking and Loading)

CS 61C: Great Ideas in Computer Architecture CALL continued ( Linking and Loading) CS 61C: Great Ideas in Computer Architecture CALL continued ( Linking and Loading) Instructors: Nicholas Weaver & Vladimir Stojanovic http://inst.eecs.berkeley.edu/~cs61c/sp16 1 Where Are We Now? 2 Linker

More information

ECE260: Fundamentals of Computer Engineering. Supporting Procedures in Computer Hardware

ECE260: Fundamentals of Computer Engineering. Supporting Procedures in Computer Hardware Supporting Procedures in Computer Hardware James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy

More information

High Performance Computing Lecture 7. Matthew Jacob Indian Institute of Science

High Performance Computing Lecture 7. Matthew Jacob Indian Institute of Science High Performance Computing Lecture 7 Matthew Jacob Indian Institute of Science Recall: C Program to a.out % gcc program.c program.c: File containing program written in the C programming language a.out:

More information

High Performance Computing Lecture 6. Matthew Jacob Indian Institute of Science

High Performance Computing Lecture 6. Matthew Jacob Indian Institute of Science High Performance Computing Lecture 6 Matthew Jacob Indian Institute of Science MULT Instruction Example: MULT R1, R2 32 bits 32 bits R1 R2 The product could be twice as large (i.e., 64b) It may not fit

More information

Compila(on, Disassembly, and Profiling

Compila(on, Disassembly, and Profiling Compila(on, Disassembly, and Profiling (in Linux) CS 485: Systems Programming Fall 2015 Instructor: James Griffioen 1 Recall the compila(on process/steps 2 Turning C into Object Code Code in files p1.c

More information

Machine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine

Machine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine Machine Language Instructions Introduction Instructions Words of a language understood by machine Instruction set Vocabulary of the machine Current goal: to relate a high level language to instruction

More information

Slide Set 4. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Slide Set 4. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 4 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary January 2018 ENCM 369 Winter 2018 Section

More information

Review C program: foo.c Compiler Assembly program: foo.s Assembler Object(mach lang module): foo.o

Review C program: foo.c Compiler Assembly program: foo.s Assembler Object(mach lang module): foo.o CS61C L18 Running a Program I (1) inst.eecs.berkeley.edu/~cs61c UC Berkeley CS61C : Machine Structures Lecture 19 Running a Program II aka Compiling, Assembling, Linking, Loading 2006-10-11 (aka 2006-0xB)

More information

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University. Instructions: ti Language of the Computer Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Computer Hierarchy Levels Language understood

More information

Orange Coast College. Business Division. Computer Science Department CS 116- Computer Architecture. The Instructions

Orange Coast College. Business Division. Computer Science Department CS 116- Computer Architecture. The Instructions Orange Coast College Business Division Computer Science Department CS 116- Computer Architecture The Instructions 1 1 Topics: Assembly language, assemblers MIPS R2000 Assembly language Instruction set

More information

Review (1/2) IEEE 754 Floating Point Standard: Kahan pack as much in as could get away with. CS61C - Machine Structures

Review (1/2) IEEE 754 Floating Point Standard: Kahan pack as much in as could get away with. CS61C - Machine Structures Review (1/2) CS61C - Machine Structures Lecture 11 - Starting a Program October 4, 2000 David Patterson http://www-inst.eecs.berkeley.edu/~cs61c/ IEEE 754 Floating Point Standard: Kahan pack as much in

More information

(Extract from the slides by Terrance E. Boult

(Extract from the slides by Terrance E. Boult What software engineers need to know about linking and a few things about execution (Extract from the slides by Terrance E. Boult http://vast.uccs.edu/~tboult/) A Simplistic Program Translation Scheme

More information

LC-3 Assembly Language

LC-3 Assembly Language Chapter 7 LC-3 Assembly Language CS Reality You ve got to know assembly Chances are, you ll never write program in assembly Compilers are much better & more patient than you are Understanding assembly

More information

CALL (Compiler/Assembler/Linker/ Loader)

CALL (Compiler/Assembler/Linker/ Loader) CALL (Compiler/Assembler/Linker/ Loader) 1 Integer Multiplication (1/3) Paper and pencil example (unsigned): Multiplicand 1000 8 Multiplier x1001 9 1000 0000 0000 +1000 01001000 72 m bits x n bits = m

More information

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#: Computer Science and Engineering 331 Midterm Examination #1 Fall 2000 Name: Solutions S.S.#: 1 41 2 13 3 18 4 28 Total 100 Instructions: This exam contains 4 questions. It is closed book and notes. Calculators

More information

A software view. Computer Systems. The Compilation system. How it works. 1. Preprocesser. 1. Preprocessor (cpp)

A software view. Computer Systems. The Compilation system. How it works. 1. Preprocesser. 1. Preprocessor (cpp) A software view User Interface Computer Systems MTSU CSCI 3240 Spring 2016 Dr. Hyrum D. Carroll Materials from CMU and Dr. Butler How it works hello.c #include int main() { printf( hello, world\n

More information

Review C program: foo.c Compiler Assembly program: foo.s Assembler Object(mach lang module): foo.o

Review C program: foo.c Compiler Assembly program: foo.s Assembler Object(mach lang module): foo.o CS61C L18 Running a Program I (1) inst.eecs.berkeley.edu/~cs61c UC Berkeley CS61C : Machine Structures Lecture 19 Running a Program II aka Compiling, Assembling, Linking, Loading 2007-03-02 Lecturer SOE

More information

Arguments and Return Values. EE 109 Unit 16 Stack Frames. Assembly & HLL s. Arguments and Return Values

Arguments and Return Values. EE 109 Unit 16 Stack Frames. Assembly & HLL s. Arguments and Return Values 1 Arguments and Return Values 2 EE 109 Unit 16 Stack Frames MIPS convention is to use certain registers for this task used to pass up to 4 arguments. If more arguments, use the stack used for return value

More information

Memory Usage 0x7fffffff. stack. dynamic data. static data 0x Code Reserved 0x x A software convention

Memory Usage 0x7fffffff. stack. dynamic data. static data 0x Code Reserved 0x x A software convention Subroutines Why we use subroutines more modular program (small routines, outside data passed in) more readable, easier to debug code reuse i.e. smaller code space Memory Usage A software convention stack

More information

MIPS%Assembly% E155%

MIPS%Assembly% E155% MIPS%Assembly% E155% Outline MIPS Architecture ISA Instruction types Machine codes Procedure call Stack 2 The MIPS Register Set Name Register Number Usage $0 0 the constant value 0 $at 1 assembler temporary

More information

Lecture 10: Program Development versus Execution Environment

Lecture 10: Program Development versus Execution Environment Lecture 10: Program Development versus Execution Environment CSE 30: Computer Organization and Systems Programming Winter 2010 Rajesh Gupta / Ryan Kastner Dept. of Computer Science and Engineering University

More information

CS 61c: Great Ideas in Computer Architecture

CS 61c: Great Ideas in Computer Architecture C.A.L.L. July 7, 2014 Review Three different instruction formats designed to be as similar as possible, while still handling all instructions: R: opcode rs rt rd shamt funct I: opcode rs rt immediate J:

More information

CSE 2021: Computer Organization

CSE 2021: Computer Organization CSE 2021: Computer Organization Lecture-5 Code Translation-3 Heap, Storage options, Addressing modes, Concurrent data access, Linking & loading Shakil M. Khan (adapted from Prof. Roumani) So Far Registers

More information

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization CS/COE0447: Computer Organization and Assembly Language Chapter 2 Sangyeun Cho Dept. of Computer Science Five classic components I am like a control tower I am like a pack of file folders I am like a conveyor

More information

PROGRAM COMPILATION MAKEFILES. Problem Solving with Computers-I

PROGRAM COMPILATION MAKEFILES. Problem Solving with Computers-I PROGRAM COMPILATION MAKEFILES Problem Solving with Computers-I The compilation process Source code Source code: Text file stored on computers hard disk or some secondary storage Compiler Executable hello.cpp

More information

CSE Lecture In Class Example Handout

CSE Lecture In Class Example Handout CSE 30321 Lecture 07-08 In Class Example Handout Part A: J-Type Example: If you look in your book at the syntax for j (an unconditional jump instruction), you see something like: e.g. j addr would seemingly

More information

Machine Instructions - II. Hwansoo Han

Machine Instructions - II. Hwansoo Han Machine Instructions - II Hwansoo Han Conditional Operations Instructions for making decisions Alter the control flow - change the next instruction to be executed Branch to a labeled instruction if a condition

More information

Do-While Example. In C++ In assembly language. do { z--; while (a == b); z = b; loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero

Do-While Example. In C++ In assembly language. do { z--; while (a == b); z = b; loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero Do-While Example In C++ do { z--; while (a == b); z = b; In assembly language loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero 25 Comparisons Set on less than (slt) compares its source registers

More information

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program.

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program. Language Translation Compilation vs. interpretation Compilation diagram Step 1: compile program compiler Compiled program Step 2: run input Compiled program output Language Translation compilation is translation

More information

Architecture II. Computer Systems Laboratory Sungkyunkwan University

Architecture II. Computer Systems Laboratory Sungkyunkwan University MIPS Instruction ti Set Architecture II Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Making Decisions (1) Conditional operations Branch to a

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures #13 Running a Program II aka Compiling, Assembling, Linking, Loading (CALL) 2007-7-17 Scott Beamer, Instructor Green Subscription Based PC Announced

More information

CSCI341. Lecture 22, MIPS Programming: Directives, Linkers, Loaders, Memory

CSCI341. Lecture 22, MIPS Programming: Directives, Linkers, Loaders, Memory CSCI341 Lecture 22, MIPS Programming: Directives, Linkers, Loaders, Memory REVIEW Assemblers understand special commands called directives Assemblers understand macro commands Assembly programs become

More information

CMSC 611: Advanced Computer Architecture

CMSC 611: Advanced Computer Architecture CMSC 611: Advanced Computer Architecture Compilers Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted from Hennessy & Patterson / 2003 Elsevier Science

More information

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei Computer Architecture Instruction Set Architecture part 2 Mehran Rezaei Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a MIPS Interpreter

More information

A Simplistic Program Translation Scheme

A Simplistic Program Translation Scheme A Simplistic Program Translation Scheme m.c ASCII source file Translator p Binary executable object file (memory image on disk) Problems: Efficiency: small change requires complete recompilation Modularity:

More information

ECE260: Fundamentals of Computer Engineering

ECE260: Fundamentals of Computer Engineering ECE260: Fundamentals of Computer Engineering Translation of High-Level Languages James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania ECE260: Fundamentals of Computer Engineering

More information

ECE 15B COMPUTER ORGANIZATION

ECE 15B COMPUTER ORGANIZATION ECE 15B COMPUTER ORGANIZATION Lecture 17 Executing Programs: Compiling, Assembling, Linking and Loading (Part II) Project #3 Due June 10, 5pm Announcements Submit via email Homework #4 Due June 5, 5pm

More information

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015 Branch Addressing Branch instructions specify Opcode, two registers, target address Most branch targets are near branch Forward or backward op rs rt constant or address 6 bits 5 bits 5 bits 16 bits PC-relative

More information

Instruction Set Architectures (4)

Instruction Set Architectures (4) Computer Architecture Week 06 Instruction Set Architectures (4) College of Information Science and Engineering Ritsumeikan University subroutines functions, procedures remember the next instruction s address

More information

Assembler. #13 Running a Program II

Assembler. #13 Running a Program II CS61C L13 Running a Program II (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures #13 Running a Program II aka Compiling, Assembling, Linking, Loading (CALL) 2007-7-17 Scott Beamer, Instructor

More information

MIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions

MIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions Representing Instructions Instructions are encoded in binary Called machine code MIPS instructions Encoded as 32-bit instruction words Small number of formats encoding operation code (opcode), register

More information

Course Administration

Course Administration Fall 2018 EE 3613: Computer Organization Chapter 2: Instruction Set Architecture Introduction 4/4 Avinash Karanth Department of Electrical Engineering & Computer Science Ohio University, Athens, Ohio 45701

More information

Where Are We Now? Linker (1/3) Linker (2/3) Four Types of Addresses we ll discuss. Linker (3/3)

Where Are We Now? Linker (1/3) Linker (2/3) Four Types of Addresses we ll discuss. Linker (3/3) inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Where Are We Now? Lecture 19 Running a Program II (Compiling, Assembling, Linking, Loading) Lecturer SOE Dan Garcia 2008-03-06 20000 15000 10000

More information

CS3350B Computer Architecture MIPS Procedures and Compilation

CS3350B Computer Architecture MIPS Procedures and Compilation CS3350B Computer Architecture MIPS Procedures and Compilation Marc Moreno Maza http://www.csd.uwo.ca/~moreno/cs3350_moreno/index.html Department of Computer Science University of Western Ontario, Canada

More information

CS 110 Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading)

CS 110 Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading) CS 110 Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading) Instructor: Sören Schwertfeger http://shtech.org/courses/ca/ School of Information Science and Technology

More information

Draft. Chapter 1 Program Structure. 1.1 Introduction. 1.2 The 0s and the 1s. 1.3 Bits and Bytes. 1.4 Representation of Numbers in Memory

Draft. Chapter 1 Program Structure. 1.1 Introduction. 1.2 The 0s and the 1s. 1.3 Bits and Bytes. 1.4 Representation of Numbers in Memory Chapter 1 Program Structure In the beginning there were 0s and 1s. GRR 1.1 Introduction In this chapter we will talk about memory: bits, bytes and how data is represented in the computer. We will also

More information

Procedure Calling. Procedure Calling. Register Usage. 25 September CSE2021 Computer Organization

Procedure Calling. Procedure Calling. Register Usage. 25 September CSE2021 Computer Organization CSE2021 Computer Organization Chapter 2: Part 2 Procedure Calling Procedure (function) performs a specific task and return results to caller. Supporting Procedures Procedure Calling Calling program place

More information

Chapter 2A Instructions: Language of the Computer

Chapter 2A Instructions: Language of the Computer Chapter 2A Instructions: Language of the Computer Copyright 2009 Elsevier, Inc. All rights reserved. Instruction Set The repertoire of instructions of a computer Different computers have different instruction

More information

CS 61C: Great Ideas in Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading)

CS 61C: Great Ideas in Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading) CS 61C: Great Ideas in Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading) Instructors: Krste Asanović & Randy H. Katz http://inst.eecs.berkeley.edu/~cs61c/fa17

More information

MIPS Datapath. MIPS Registers (and the conventions associated with them) MIPS Instruction Types

MIPS Datapath. MIPS Registers (and the conventions associated with them) MIPS Instruction Types 1 Lecture 08 Introduction to the MIPS ISA + Procedure Calls in MIPS Longer instructions = more bits to address registers MIPS Datapath 6 bit opcodes... 2 MIPS Instructions are 32 bits More ways to address

More information

Introduction to Computer Systems

Introduction to Computer Systems Introduction to Computer Systems Today: Welcome to EECS 213 Lecture topics and assignments Next time: Bits & bytes and some Boolean algebra Fabián E. Bustamante, Spring 2010 Welcome to Intro. to Computer

More information

Implementing Procedure Calls

Implementing Procedure Calls 1 / 39 Implementing Procedure Calls February 18 22, 2013 2 / 39 Outline Intro to procedure calls Caller vs. callee Procedure call basics Calling conventions The stack Interacting with the stack Structure

More information

Outline. Review: RISC-V Instruction Formats

Outline. Review: RISC-V Instruction Formats CS 61C: Great Ideas in Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading) Instructors: Krste Asanović & Randy H. Katz http://inst.eecs.berkeley.edu/~cs61c/fa17

More information

comp 180 Lecture 10 Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions

comp 180 Lecture 10 Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions Procedure Calls A procedure of a subroutine is like an agent which needs certain information to perform a

More information

Lecture 6: Assembly Programs

Lecture 6: Assembly Programs Lecture 6: Assembly Programs Today s topics: Procedures Examples Large constants The compilation process A full example 1 Procedures Local variables, AR, $fp, $sp Scratchpad and saves/restores, $fp Arguments

More information

Lecture 5: Procedure Calls

Lecture 5: Procedure Calls Lecture 5: Procedure Calls Today s topics: Memory layout, numbers, control instructions Procedure calls 1 Memory Organization The space allocated on stack by a procedure is termed the activation record

More information

More C functions and Big Picture [MIPSc Notes]

More C functions and Big Picture [MIPSc Notes] More C functions and Big Picture [MIPSc Notes] Implementing C functions Passing parameters Local variables Stack frames Big picture Compiling Assembling Passing parameters by value or reference Galen H.

More information

Chapter 3. Instructions:

Chapter 3. Instructions: Chapter 3 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic Instructions We ll be working with

More information

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei Instruction Set Architecture part 1 (Introduction) Mehran Rezaei Overview Last Lecture s Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a

More information

Outline. Unresolved references

Outline. Unresolved references Outline CS 4120 Introduction to Compilers Andrew Myers Cornell University Lecture 36: Linking and Loading 21 Nov 11 Static linking Object files Libraries Shared libraries Relocatable Dynamic linking explicit

More information

CSE2421 Systems1 Introduction to Low-Level Programming and Computer Organization

CSE2421 Systems1 Introduction to Low-Level Programming and Computer Organization Spring 2013 CSE2421 Systems1 Introduction to Low-Level Programming and Computer Organization Kitty Reeves TWRF 8:00-8:55am 1 Compiler Drivers = GCC When you invoke GCC, it normally does preprocessing,

More information

Review Session 1 Fri. Jan 19, 2:15 pm 3:05 pm Thornton 102

Review Session 1 Fri. Jan 19, 2:15 pm 3:05 pm Thornton 102 Review Session 1 Fri. Jan 19, 2:15 pm 3:05 pm Thornton 102 1. Agenda Announcements Homework hints MIPS instruction set Some PA1 thoughts MIPS procedure call convention and example 1 2. Announcements Homework

More information

CS2141 Software Development using C/C++ Libraries

CS2141 Software Development using C/C++ Libraries CS2141 Software Development using C/C++ Compilation and linking /* p1.c */ int x; int z; main() { x=0; z=0; printf("f(3)=%d x=%d z=%d\n",f(3),x,z); } Code for int f(int) not available yet, nor printf()

More information

Assembling Programs. .o les (Unix).obj les (Windows/DOS)

Assembling Programs. .o les (Unix).obj les (Windows/DOS) Assembling Programs What is an assembler? Expands pseudo-operations into machine instructions Translates text assembly language to binary machine code Output: object le.o les (Unix).obj les (Windows/DOS)

More information

CS631 - Advanced Programming in the UNIX Environment. UNIX development tools

CS631 - Advanced Programming in the UNIX Environment. UNIX development tools CS631 - Advanced Programming in the UNIX Environment Slide 1 CS631 - Advanced Programming in the UNIX Environment UNIX development tools Department of Computer Science Stevens Institute of Technology Jan

More information

MIPS Functions and the Runtime Stack

MIPS Functions and the Runtime Stack MIPS Functions and the Runtime Stack COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline

More information

ECE260: Fundamentals of Computer Engineering

ECE260: Fundamentals of Computer Engineering Supporting Nested Procedures James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy Memory Layout

More information

Thomas Polzer Institut für Technische Informatik

Thomas Polzer Institut für Technische Informatik Thomas Polzer tpolzer@ecs.tuwien.ac.at Institut für Technische Informatik Branch to a labeled instruction if a condition is true Otherwise, continue sequentially beq rs, rt, L1 if (rs == rt) branch to

More information

Instruction Set Architecture

Instruction Set Architecture Computer Architecture Instruction Set Architecture Lynn Choi Korea University Machine Language Programming language High-level programming languages Procedural languages: C, PASCAL, FORTRAN Object-oriented

More information

CS 61C: Great Ideas in Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading)

CS 61C: Great Ideas in Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading) CS 61C: Great Ideas in Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading) Instructors: John Wawrzynek & Vladimir Stojanovic http://inst.eecs.berkeley.edu/~cs61c/fa15

More information

Part I: Translating & Starting a Program: Compiler, Linker, Assembler, Loader. Lecture 4

Part I: Translating & Starting a Program: Compiler, Linker, Assembler, Loader. Lecture 4 Part I: a Program: Compiler, Linker, Assembler, Loader Lecture 4 Program Translation Hierarchy C program Com piler Assem bly language program Assem bler Object: Machine language module Object: Library

More information

MIPS Procedure Calls. Lecture 6 CS301

MIPS Procedure Calls. Lecture 6 CS301 MIPS Procedure Calls Lecture 6 CS301 Function Call Steps Place parameters in accessible location Transfer control to function Acquire storage for procedure variables Perform calculations in function Place

More information

Systems Programming. Fatih Kesgin &Yusuf Yaslan Istanbul Technical University Computer Engineering Department 18/10/2005

Systems Programming. Fatih Kesgin &Yusuf Yaslan Istanbul Technical University Computer Engineering Department 18/10/2005 Systems Programming Fatih Kesgin &Yusuf Yaslan Istanbul Technical University Computer Engineering Department 18/10/2005 Outline How to assemble and link nasm ld gcc Debugging Using gdb; breakpoints,registers,

More information

Code Generation. The Main Idea of Today s Lecture. We can emit stack-machine-style code for expressions via recursion. Lecture Outline.

Code Generation. The Main Idea of Today s Lecture. We can emit stack-machine-style code for expressions via recursion. Lecture Outline. The Main Idea of Today s Lecture Code Generation We can emit stack-machine-style code for expressions via recursion (We will use MIPS assembly as our target language) 2 Lecture Outline What are stack machines?

More information

Run-time Environment

Run-time Environment Run-time Environment Prof. James L. Frankel Harvard University Version of 3:08 PM 20-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Storage Organization Automatic objects are

More information

We can emit stack-machine-style code for expressions via recursion

We can emit stack-machine-style code for expressions via recursion Code Generation The Main Idea of Today s Lecture We can emit stack-machine-style code for expressions via recursion (We will use MIPS assembly as our target language) 2 Lecture Outline What are stack machines?

More information

MIPS Instruction Set Architecture (2)

MIPS Instruction Set Architecture (2) MIPS Instruction Set Architecture (2) Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3050: Theory on Computer Architectures, Spring 2017, Jinkyu

More information

CS222: Dr. A. Sahu. Indian Institute of Technology Guwahati

CS222: Dr. A. Sahu. Indian Institute of Technology Guwahati CS222: (a) Activation Record of Merge Sort (b) Architecture Space RISC/CISC Dr. A. Sahu Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati 1 Outline Activation Record in Recursion: Merge

More information

COMPUTER ORGANIZATION AND DESIGN

COMPUTER ORGANIZATION AND DESIGN COMPUTER ORGANIZATION AND DESIGN 5 th The Hardware/Software Interface Edition Chapter 2 Instructions: Language of the Computer 2.1 Introduction Instruction Set The repertoire of instructions of a computer

More information

Introduction to Computer Systems

Introduction to Computer Systems Introduction to Computer Systems Today:! Welcome to EECS 213! Lecture topics and assignments Next time:! Bits & bytes! and some Boolean algebra Fabián E. Bustamante, 2007 Welcome to Intro. to Computer

More information

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary Control Instructions Computer Organization Architectures for Embedded Computing Thursday, 26 September 2013 Many slides adapted from: Computer Organization and Design, Patterson & Hennessy 4th Edition,

More information

Control Instructions

Control Instructions Control Instructions Tuesday 22 September 15 Many slides adapted from: and Design, Patterson & Hennessy 5th Edition, 2014, MK and from Prof. Mary Jane Irwin, PSU Summary Previous Class Instruction Set

More information

instructions aligned is little-endian

instructions aligned is little-endian MEMÓRIA Data Types These instructions load and store aligned data: Load word (lw) Load halfword (lh) Load halfword unsigned (lhu) Load byte (lb) Load byte unsigned (lbu) Store word (sw) Store halfword

More information

Chapter 2. Instructions: Language of the Computer

Chapter 2. Instructions: Language of the Computer Chapter 2 Instructions: Language of the Computer Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many aspects in common Early computers

More information

CSE Lecture In Class Example Handout

CSE Lecture In Class Example Handout CSE 30321 Lecture 07-09 In Class Example Handout Part A: A Simple, MIPS-based Procedure: Swap Procedure Example: Let s write the MIPS code for the following statement (and function call): if (A[i] > A

More information

Computer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology

Computer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology Computer Organization MIPS Architecture Department of Computer Science Missouri University of Science & Technology hurson@mst.edu Computer Organization Note, this unit will be covered in three lectures.

More information

Chris Riesbeck, Fall Introduction to Computer Systems

Chris Riesbeck, Fall Introduction to Computer Systems Chris Riesbeck, Fall 2011 Introduction to Computer Systems Welcome to Intro. to Computer Systems Everything you need to know http://www.cs.northwestern.edu/academics/courses/213/ Instructor: Chris Riesbeck

More information

Link 3. Symbols. Young W. Lim Mon. Young W. Lim Link 3. Symbols Mon 1 / 42

Link 3. Symbols. Young W. Lim Mon. Young W. Lim Link 3. Symbols Mon 1 / 42 Link 3. Symbols Young W. Lim 2017-09-11 Mon Young W. Lim Link 3. Symbols 2017-09-11 Mon 1 / 42 Outline 1 Linking - 3. Symbols Based on Symbols Symbol Tables Symbol Table Examples main.o s symbol table

More information