June 2005Computer Architecture, Instruction-Set ArchitectureSlide 1 Part II Instruction-Set Architecture.

Slides:



Advertisements
Similar presentations
Henk Corporaal TUEindhoven 2011
Advertisements

MIPS ISA-II: Procedure Calls & Program Assembly. (2) Module Outline Review ISA and understand instruction encodings Arithmetic and Logical Instructions.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 2: IT Students.
MIPS ISA-II: Procedure Calls & Program Assembly. (2) Module Outline Review ISA and understand instruction encodings Arithmetic and Logical Instructions.
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.
SPIM and MIPS programming
MIPS Assembly Language Programming
Wannabe Lecturer Alexandre Joly inst.eecs.berkeley.edu/~cs61c-te
1 Computer Architecture MIPS Simulator and Assembly language.
Assembly Language Working with the CPU.
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
8.
Computer Organization CS224 Fall 2012 Lesson 12. Synchronization  Two processors or threads sharing an area of memory l P1 writes, then P2 reads l Data.
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
Lec 9Systems Architecture1 Systems Architecture Lecture 9: Assemblers, Linkers, and Loaders Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
1 Lecture 25 (Assemblers). 2 Assemblers,Linkers,and Debuggers Assembler -Translates assembly to machine code. - Resolves symbolic address. - Extends virtual.
1. Copyright  2005 by Oxford University Press, Inc. Computer Architecture Parhami2 Figure 7.1 Steps in transforming an assembly language program to an.
MIPS Assembly Language I Computer Architecture CPSC 321 Andreas Klappenecker.
Feb 18, 2009 Lecture 4-2 instruction set architecture (Part II of [Parhami]) MIPS encoding of instructions Spim simulator more examples of MIPS programming.
RISC Concepts, MIPS ISA and the Mini–MIPS project
instruction set architecture (Part II of [Parhami])
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 2:
MIPS Instruction Set Advantages
9/29: Lecture Topics Memory –Addressing (naming) –Address space sizing Data transfer instructions –load/store on arrays on arrays with variable indices.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
MIPS coding. SPIM Some links can be found such as:
CSC 3210 Computer Organization and Programming Chapter 1 THE COMPUTER D.M. Rasanjalee Himali.
Computer Architecture, Instruction-Set ArchitectureSlide 1 Part II Instruction-Set Architecture.
1 Compilers Modern Compiler Design Supplementary Note 2 SPIM Overview NCYU C. H. Wang.
In Class Execise. .data A:.word 0,1,2,3,4,5,6,7,8,9.text.globl main main: la $a0,A li $a1,6 li $a2,5 jal onUpStream done: li $v0, 10# exit syscall onUpStream:
CSCI 136 Lab 1: 135 Review.
11/02/2009CA&O Lecture 03 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 2 Part 4.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /29/2013 Lecture 13: Compile-Link-Load Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE.
Ch2b- 2 EE/CS/CPE Computer Organization  Seattle Pacific University Thanks for all the Memory! When 32 registers just won’t do. Many times (almost.
Lecture 10: MIPS Simulator Today’s topic –SPIM Simulator Readings –Appendix B 1.
MIPS coding. Review Shifting – Shift Left Logical (sll) – Shift Right Logical (srl) – Moves all of the bits to the left/right and fills in gap with 0’s.
8.
MIPS Assembly Language Chapter 13 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
MIPS Assembly Language Chapter 15 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer, 2003.
Mar. 2006Computer Architecture, Instruction-Set ArchitectureSlide 1 Part II Instruction-Set Architecture.
Lecture 16: 10/29/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
CS 312 Computer Architecture & Organization
Lecture 3 Translation.
Computer Architecture & Operations I
Assembly language.
Lecture 6: Assembly Programs
MIPS Instruction Set Advantages
The University of Adelaide, School of Computer Science
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Instructions - Type and Format
Lecture 4: MIPS Instruction Set
MPIS Instructions Functionalities of instructions Instruction format
11/24/
Lecture 7: Examples, MARS, Arithmetic
Instruction encoding The ISA defines Format = Encoding
Part II Instruction-Set Architecture
COMS 361 Computer Organization
Generalities for Assembly Language
MIPS Assembly Language Programming Computer Architecture
Program Assembly.
9/27: Lecture Topics Memory Data transfer instructions
CS 286 Computer Architecture & Organization
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Presentation transcript:

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 1 Part II Instruction-Set Architecture

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 2 II Instruction Set Architecture Topics in This Part Chapter 5 Instructions and Addressing Chapter 6 Procedures and Data Chapter 7 Assembly Language Programs Chapter 8 Instruction Set Variations Introduce machine “words” and its “vocabulary,” learning: A simple, yet realistic and useful instruction set Machine language programs; how they are executed RISC vs CISC instruction-set design philosophy

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 3 7 Assembly Language Programs Topics in This Chapter 7.1 Machine and Assembly Languages 7.2 Assembler Directives 7.3 Pseudoinstructions 7.4 Macroinstructions 7.5 Linking and Loading 7.6 Running Assembler Programs Everything else needed to build and run assembly programs: Supply info to assembler about program and its data Non-hardware-supported instructions for convenience

June 2005Computer Architecture, Instruction-Set ArchitectureSlide Machine and Assembly Languages Figure 7.1 Steps in transforming an assembly language program to an executable program residing in memory.

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 5 Symbol Table Figure 7.2 An assembly-language program, its machine-language version, and the symbol table created during the assembly process. byte 0 byte 1 byte 2 byte 3

June 2005Computer Architecture, Instruction-Set ArchitectureSlide Assembler Directives Assembler directives provide the assembler with info on how to translate the program but do not lead to the generation of machine instructions.macro# start macro (see Section 7.4).end_macro# end macro (see Section 7.4).text# start program’s text segment...# program text goes here.data# start program’s data segment tiny:.byte 156,0x7a# name & initialize data byte(s) max:.word 35000# name & initialize data word(s) small:.float 2E-3# name short float (see Chapter 12) big:.double 2E-3# name long float (see Chapter 12).align 2# align next item on word boundary array:.space 600# reserve 600 bytes = 150 words str1:.ascii “a*b”# name & initialize ASCII string str2:.asciiz “xyz”# null-terminated ASCII string.global main# consider “main” a global name (See P&H App. A, §A.10, pp. A-47 to A-49 for more details)

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 7 Composing Simple Assembler Directives Write assembler directive to achieve each of the following objectives: a. Put the error message “Warning: The printer is out of paper!” in memory. b. Set up a constant called “size” with the value 4. c. Set up an integer variable called “width” and initialize it to 4. d. Set up a constant called “mill” with the value 1,000,000 (one million). e. Reserve space for an integer vector “vect” of length 250. Solution: a. noppr:.asciiz “Warning: The printer is out of paper!” b. size:.byte 4# small constant fits in one byte c. width:.word 4# byte could be enough, but... d. mill:.word # constant too large for byte e. vect:.space 1000# 250 words = 1000 bytes Example 7.1

June 2005Computer Architecture, Instruction-Set ArchitectureSlide Pseudoinstructions Example of one-to-one pseudoinstruction: The following not $s0 # complement ($s0) is converted to the real instruction: nor $s0,$s0,$zero # complement ($s0) Example of one-to-several pseudoinstruction: The following abs $t0,$s0 # put |($s0)| into $t0 is converted to the sequence of real instructions: add $t0,$s0,$zero # copy x into $t0 slt $at,$t0,$zero # is x negative? beq $at,$zero,+4 # if not, skip next instr sub $t0,$zero,$s0 # the result is 0 – x

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 9 MiniMIPS Pseudo- instructions PseudoinstructionUsage Move move regd,regs Load address la regd,address Load immediate li regd,anyimm Absolute value abs regd,regs Negate neg regd,regs Multiply (into register) mul regd,reg1,reg2 Divide (into register) div regd,reg1,reg2 Remainder rem regd,reg1,reg2 Set greater than sgt regd,reg1,reg2 Set less or equal sle regd,reg1,reg2 Set greater or equal sge regd,reg1,reg2 Rotate left rol regd,reg1,reg2 Rotate right ror regd,reg1,reg2 NOT not reg Load doubleword ld regd,address Store doubleword sd regd,address Branch less than blt reg1,reg2,L Branch greater than bgt reg1,reg2,L Branch less or equal ble reg1,reg2,L Branch greater or equal bge reg1,reg2,L Copy Control transfer Shift Arithmetic Memory access Table 7.1 Logic

June 2005Computer Architecture, Instruction-Set ArchitectureSlide Macroinstructions A macro is a mechanism to give a name to an oft-used sequence of instructions (shorthand notation).macro name(args)# macro and arguments named...# instr’s defining the macro.end_macro# macro terminator How is a macro different from a pseudoinstruction? Pseudos are predefined, fixed, and look like machine instructions Macros are user-defined and resemble procedures (have arguments) How is a macro different from a procedure? Control is transferred to and returns from a procedure After a macro has been replaced, no trace of it remains

June 2005Computer Architecture, Instruction-Set ArchitectureSlide Linking and Loading The linker has the following responsibilities: Ensuring correct interpretation (resolution) of labels in all modules Determining the placement of text and data segments in memory Evaluating all data addresses and instruction labels Forming an executable program with no unresolved references The loader is in charge of the following: Determining the memory needs of the program from its header Copying text and data from the executable program file into memory Modifying (shifting) addresses, where needed, during copying Placing program parameters onto the stack (as in a procedure call) Initializing all machine registers, including the stack pointer Jumping to a start-up routine that calls the program’s main routine

June 2005Computer Architecture, Instruction-Set ArchitectureSlide Running Assembler Programs Spim is a simulator that can run MiniMIPS programs The name Spim comes from reversing MIPS Three versions of Spim are available for free downloading: PCSpimfor Windows machines xspimfor X-windows spimfor Unix systems You can download SPIM by visiting:

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 13 Input/Output Conventions for MiniMIPS Table 7.2 Input/output and control functions of syscall in PCSpim. ($v0) FunctionArgumentsResult 1 Print integerInteger in $a0 Integer displayed 2 Print floating-pointFloat in $f12 Float displayed 3 Print double-floatDouble-float in $f12, $f13 Double-float displayed 4 Print stringPointer in $a0 Null-terminated string displayed 5 Read integerInteger returned in $v0 6 Read floating-pointFloat returned in $f0 7 Read double-floatDouble-float returned in $f0, $f1 8 Read stringPointer in $a0, length in $a1 String returned in buffer at pointer 9 Allocate memoryNumber of bytes in $a0 Pointer to memory block in $v0 10 Exit from programProgram execution terminated Output Input Cntl

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 14 Figure 7.3 PCSpim User Interface