1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Goal: Write Programs in Assembly
Lecture 5: MIPS Instruction Set
1 Procedure Calls, Linking & Launching Applications Lecture 15 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
SPIM and MIPS programming
Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Computer Organization Lecture 4 Assembly language programming ALU and.
MIPS Assembly Language Programming
1 Computer Architecture MIPS Simulator and Assembly language.
IT253: Computer Organization Lecture 6: Assembly Language and MIPS: Programming Tonga Institute of Higher Education.
Assembly Language Working with the CPU.
Assembly Process. Machine Code Generation Assembling a program entails translating the assembly language into binary machine code This requires more than.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
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.
MIPS Instruction Set Advantages
Computer Science 210 Computer Organization The Instruction Execution Cycle.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Computer Architecture Instruction Set Architecture Lynn Choi Korea University.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Lecture 4: MIPS Instruction Set
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.
Computer Architecture CSE 3322 Lecture 2 NO CLASS MON Sept 1 Course WEB SITE crystal.uta.edu/~jpatters.
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.
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
Microarchitecture. Outline Architecture vs. Microarchitecture Components MIPS Datapath 1.
MIPS coding. slt, slti slt $t3, $t1, $t2 – set $t3 to be 1 if $t1 < $t2 ; else clear $t3 to be 0. – “Set Less Than.” slti $t3, $t1, 100 – set $t3 to be.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Addressing Modes. Register Addressing Immediate Addressing Base Addressing Indexed Addressing PC-Relative Addressing.
The Assembly Process Computer Organization and Assembly Language: Module 10.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Lecture 16: 10/29/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Addressing Modes in Microprocessors
Computer Architecture Instruction Set Architecture
MIPS Instruction Set Advantages
Control Unit Lecture 6.
MIPS Coding Continued.
Lecture 4: MIPS Instruction Set
ACOE301: Computer Architecture II Labs
MIPS assembly syntax Comments
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Instruction Format MIPS Instruction Set.
Design of the Control Unit for Single-Cycle Instruction Execution
The fetch-execute cycle
MIPS coding.
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Single-Cycle CPU DataPath.
Lecture 4: MIPS Instruction Set
CSCI206 - Computer Organization & Programming
Design of the Control Unit for One-cycle Instruction Execution
CSCE Fall 2013 Prof. Jennifer L. Welch.
MIPS Instruction Encoding
MIPS coding.
Topic 5: Processor Architecture Implementation Methodology
MIPS Instruction Encoding
Topic 5: Processor Architecture
COMS 361 Computer Organization
MARIE: An Introduction to a Simple Computer
Instruction encoding The ISA defines Format = Encoding
COMS 361 Computer Organization
COMS 361 Computer Organization
COMS 361 Computer Organization
Instruction Format MIPS Instruction Set.
Instruction encoding The ISA defines Format = Encoding
Instruction encoding The ISA defines Format = Encoding
MIPS Coding Continued.
MIPS coding.
Program Assembly.
COMS 361 Computer Organization
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
MIPS Processor.
Presentation transcript:

1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10

2 Announcements Homework 4 –Due 10/05/04

3 Review Instructions –unconditional branch –J-Type instruction format MIPS history SPIM –MIPS simulator

4 Outline SPIM –MIPS simulator

5 SPIM Program Show me the code! MIPS/SPIM program files usually end in.s File is loaded into SPIM –Assembled into MIPS machine code –Executed and debugged in SPIM

6 SPIM Program ## exit.s - program simply makes a system call to exit ## ## text segment ##.text main:addi $v0, $zero, 10 # exit call code syscall # terminate program execution ## ## data segment ## ## end exit.s

7 SPIM Program ## exit.s - program simply makes a system call to exit ## ## text segment ##.text main:addi $v0, $zero, 10 # exit call code syscall # terminate program execution ## ## data segment ## ## end exit.s Comments in MIPS assembly code are denoted by the sharp (#) sign Similar to the C++ (//) comment. Starts at instance and goes to the end of the line Assembly code in NOT self- documenting. Use comments liberally, like associated with each instruction

8 SPIM Program ## exit.s - program simply makes a system call to exit ## ## text segment ##.text main:addi $v0, $zero, 10 # exit call code syscall # terminate program execution ## ## data segment ## ## end exit.s Comments indicating the start of the code After text segment is converted into its binary representation, it is stored in the text memory segment. indicates an assembler directive.text directs the assembler to treat what follows as instructions

9 Text Segment The source code format is relatively standard –Proper indentation is fundamentally important in assembly language programming –[] indicate optional fields Not all fields appear on a line of code [label:] operation [operand], [operand], [operand] [# comment]

10 SPIM Program ## exit.s - program simply makes a system call to exit ## ## text segment ##.text main:addi $v0, $zero, 10 # exit call code syscall # terminate program execution ## ## data segment ## ## end exit.s main: is a label Just as C++ programs need a main function, MIPS programs need a main label main: labels the first instruction of the program

11 Labels : –Tells the assembler that the proceeding alphanumerics including (_) and (.) constitutes the label –Opcodes are reserved words and are not permitted to be used as labels –Use appropriate names for labels Labels associate a symbol with –The address of an instruction –The address of a variable

12 SPIM Program ## exit.s - program simply makes a system call to exit ## ## text segment ##.text main:addi $v0, $zero, 10 # exit call code syscall # terminate program execution ## ## data segment ## ## end exit.s Program is to simple call the OS with the exit call code In the real world the OS cleans up after the program The call code for exit is the decimal number 10, which needs to be put into the $v0 register (convention) addi with the proper operands can achieve this goal

13 SPIM Program ## exit.s - program simply makes a system call to exit ## ## text segment ##.text main:addi $v0, $zero, 10 # exit call code syscall # terminate program execution ## ## data segment ## ## end exit.s Call the OS with the proper call code in the $v0 register

14 SPIM Program Show me the program execute! –And some things about SPIM City!! exit.s hello.s

15 Datapath Diagram Main functional units –Control unit

16 Datapath Diagram Main functional units –Register file

17 Datapath Diagram Main functional units –Arithmetic and logic unit (ALU)

18 Datapath Diagram Main functional units –Program counter (PC)

19 Datapath Diagram Main functional units –Memory

20 Datapath Diagram Main functional units –Instruction register (IR)

21 Datapath Diagram Other operational units –bus

22 Datapath Diagram Other operational units –Multiplexor (data selector)

23 Fetch and Execute R-type Instruction Fetch Phase –Fetch the word in memory at the address specified by the Program Counter (PC) –Load instruction into the IR –Increment the PC (add 4) Operand Fetch Phase –Decode the Rs and Rt fields within the instruction Decode the Op Code

24 Fetch and Execute Cycle Execute Phase –Perform ALU operation defined by the function code on the source operands Write Back Phase –Result if the ALU is written into the decoded Rd register

25 MIPS Instructions MIPS instruction set architecture –Assembly instructions that convert into machine (binary) instructions Assembly instructions can be converted directly into machine instructions –One-to-one mapping Assembly instructions can be converted into more than one machine instruction –One-to-many mapping –Native machine instructions –Pseudo-, Macro-, Synthetic-machine instructions Consists of more than one native machine instruction

26 MIPS Instructions Assembler converts pseudo-instructions with the corresponding set of actual MIPS instructions –Pseudo-instructions simplify the task of writing assembly code pseudo instruction la $a0 label load address of label into register $a0 actual MIPS instructions lui $at, upper 16 bits of label ori $Rd, $at, Lower 16 bits of label

27 Assembler Directives Used to create data structures that are available at run-time –To allocate a one-dimensional array in C++ int ARRAY[1024]; –Corresponds to the MIPS assemble directive.data ARRAY:.space4096 Allocate space in the data segment of the SPIM memory model Allocates 4096 bytes in the data segment

28 Assembler Directives –Allocate and initialize a one-dimensional array int ARRAY[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 }; –Corresponds to the MIPS assemble directive.data ARRAY:.word1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 la$a0ARRAY# $a0 = &ARRAY[0] lw$s08($a0)# $s0 = MEM[$ao + 8] $a0 contains a pointer to the array

29 Assembler Directives –String literal definition.data helloStr:.ascii“Hello, World!\n” –helloStr is the memory location of the array of characters –The string is not null terminated Can cause problems (hell01.s).data helloStr:.asciiz“Hello, World!\n”