instructions aligned is little-endian

Similar documents
Kernel Registers 0 1. Global Data Pointer. Stack Pointer. Frame Pointer. Return Address.

Course Administration

MIPS Reference Guide

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

MIPS Architecture and Assembly Language Overview

MIPS Coding Snippets. Prof. James L. Frankel Harvard University. Version of 9:32 PM 14-Feb-2016 Copyright 2016 James L. Frankel. All rights reserved.

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

Course Administration

Chapter 2A Instructions: Language of the Computer

Introduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

CS3350B Computer Architecture

QtSPIM and MARS : MIPS Simulators

CSCI 402: Computer Architectures. Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI.

Compiling Techniques

ECE232: Hardware Organization and Design

We will study the MIPS assembly language as an exemplar of the concept.

Lecture 5: Procedure Calls

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 3 2/8/2018

ECE260: Fundamentals of Computer Engineering

ECE260: Fundamentals of Computer Engineering

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes

Chapter 2. Instruction Set. The MIPS Instruction Set. Arithmetic Operations. Instructions: Language of the Computer

CS3350B Computer Architecture MIPS Introduction

Lecture 7: Examples, MARS, Arithmetic

ELEC / Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2)

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Thomas Polzer Institut für Technische Informatik

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

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

Levels of Programming. Registers

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 5 2/22/2018

Instructions: Language of the Computer

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Assembly labs start this week. Don t forget to submit your code at the end of your lab section. Download MARS4_5.jar to your lab PC or laptop.

ECE 473 Computer Architecture and Organization Lab 4: MIPS Assembly Programming Due: Wednesday, Oct. 19, 2011 (30 points)

Computer Architecture. MIPS Instruction Set Architecture

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

LAB C Translating Utility Classes

A crash course in MIPS assembly programming

Adventures in Assembly Land

MIPS Assembly Language. Today s Lecture

Instructions: Language of the Computer

Today s Lecture. MIPS Assembly Language. Review: What Must be Specified? Review: A Program. Review: MIPS Instruction Formats

Lecture 5: Procedure Calls

SPIM S20: A MIPS R2000 Simulator

Instructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1

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

Control Instructions

COMP2421 COMPUTER ORGANZATION. Lab 3

CENG3420 Lab 1-1: MIPS assembly language programing

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

SPIM Instruction Set

CSSE 232 Computer Architecture I. I/O and Addressing

Announcements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls

Reduced Instruction Set Computer (RISC)

ECE 15B Computer Organization Spring 2010

Computer Systems and Architecture

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

ECE331: Hardware Organization and Design

CENG3420 Lecture 03 Review

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

SPIM & MIPS Programming

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont )

MIPS function continued

2.1 DOWNLOAD AND INSTALL MARS

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook)

Chapter 2: Instructions:

Computer Architecture. The Language of the Machine

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

MIPS Instruction Set

Character Is a byte quantity (00~FF or 0~255) ASCII (American Standard Code for Information Interchange) Page 91, Fig. 2.21

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

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

ICS DEPARTMENT ICS 233 COMPUTER ARCHITECTURE & ASSEMBLY LANGUAGE. Midterm Exam. First Semester (141) Time: 1:00-3:30 PM. Student Name : _KEY

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

EEC 581 Computer Architecture Lecture 1 Review MIPS

Architecture II. Computer Systems Laboratory Sungkyunkwan University

Lecture 6: Assembly Programs

COMPUTER ORGANIZATION AND DESIGN

Chapter 2. Instructions: Language of the Computer. HW#1: 1.3 all, 1.4 all, 1.6.1, , , , , and Due date: one week.

MIPS Hello World. MIPS Assembly 1. # PROGRAM: Hello, World! # Data declaration section. out_string:.asciiz "\nhello, World!\n"

Computer Organization Lab #3.

CS 61C: Great Ideas in Computer Architecture More RISC-V Instructions and How to Implement Functions

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

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

Introduction to MIPS Processor

Reduced Instruction Set Computer (RISC)

Computer Architecture. Chapter 2-2. Instructions: Language of the Computer

Shift and Rotate Instructions

ECE331: Hardware Organization and Design

MIPS (SPIM) Assembler Syntax

MIPS Processor Overview

MIPS and QTSPIM Recap. MIPS Architecture. Cptr280. Dr Curtis Nelson. Cptr280, Autumn

CPSC 330 Computer Organization

2.7 Supporting Procedures in hardware. Why procedures or functions? Procedure calls

ECE 30 Introduction to Computer Engineering

Computer Architecture

CA Compiler Construction

ECE 154A Introduction to. Fall 2012

CS/COE1541: Introduction to Computer Architecture

Transcription:

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 (sh) Store byte (sb) The MIPS architecture as simulated in QtSpim is little-endian. This means that the Least Significant Byte (LSB) is stored in the lowest memory address. The Most Significant Byte (MSB) is stored in the highest memory location. X: LSB X+1: MSB

Data Types These instructions load and store unaligned data: Load word left (lwl) Load word right (lwr) Store word left (swl) Store word right (swr) Unaligned load word (ulw) Unaligned load halfword (ulh) Unaligned load halfword unsigned (ulhu) Unaligned store word (usw) Unaligned store halfword (ush) The MIPS architecture as simulated in QtSpim is little-endian. This means that the Least Significant Byte (LSB) is stored in the lowest memory address. The Most Significant Byte (MSB) is stored in the highest memory location. X: LSB X+1: MSB

UP num2: 5.000.000 in decimal 0x004C4B40 in Hexa num1: 42 in decimal 0x0000002A in Hexa

The first part, near the bottom of the address space (starting at address $400000 (hexa), is the text segment, which holds the program s instructions. The second part, above the text segment, is the data segment, which is further divided into two parts. Static data (starting at address $10000000 hex) Immediately above static data is dynamic data. This data, as its name implies, is allocated by the program as it executes. The program stack segment, resides at the top of the virtual address space (starting at address $7FFFFFFF hex)

# Print out "Hello World" # Copyright (c) 2013, James R. Larus. msg:.data.asciiz "Hello World".text.globl main main: li $v0, 4 # syscall 4 (print_str) la $a0, msg # argument: string syscall # print the string END: li $v0, 10 # exits program syscall The first part, near the bottom of the address space (starting at address $400000 (hexa), is the text segment, which holds the program s instructions. The second part, above the text segment, is the data segment, which is further divided into two parts. Static data (starting at address $10000000 hex) Immediately above static data is dynamic data. This data, as its name implies, is allocated by the program as it executes. The program stack segment, resides at the top of the virtual address space (starting at address $7FFFFFFF hex)

REGISTRADORES

The MIPS has 32, 32-bit integer registers ($0 through $31) and The MIPS has 32, 32-bit floating point registers ($f0 through $f31). Some of the integer registers are used for special purposes. The FPU has sixteen floating-point registers. Each register can hold either a single-precision (32 bit) or double-precision (64 bit) value. In case of a double-precision value, $f0 holds the least-significant half, and $f1 holds the most-significant half. All references to these registers use an even register number (e.g., $f4).

MIPS Register File Register Naming Convention $0 : Constant Zero $V0 : Returned values from functions $A0 : Arguments passed to functions $T0 : Temporary registers (functions) $S0 : Saved registers (main program) $SP : Stack Pointer $RA : Return address The MIPS CPU contains 32 general-purpose registers that are numbered 0 31. Register $0 always contains the hardwired value 0. Registers $at (1), $k0 (26), and $k1 (27) are reserved for the assembler and operating system and should not be used by user programs or compilers. Registers $a0 $a3 (4 7) are used to pass the first four arguments to routines (remaining arguments are passed on the stack). Registers $v0 and $v1 (2, 3)are used to return values from functions.

MIPS Register File Register Naming Convention $0 : Constant Zero $V0 : Returned values from functions $A0 : Arguments passed to functions $T0 : Temporary registers (functions) $S0 : Saved registers (main program) $SP : Stack Pointer $RA : Return address Instruções de Desvio: j => Jump Uncondicional jal => Jump and Link Jump com retorno ($RA) b => Branch Unconditional beq => Branch if equal zero bne => Branch if not equal bge => Branch if greater or equal Syscall => System Call (Software Interrupt) Procedure Call Convention: Registers $t0 $t9 (8 15, 24, 25) are caller-saved registers that are used to hold temporary quantities that need not be preserved across calls (see Section 2.7 in Chapter 2 Larus Appendix). Registers $s0 $s7 (16 23) are callee-saved registers that hold long-lived values that should be preserved across calls. Register $gp (28) is a global pointer that points to the middle of a 64K block of memory in the static data segment. Register $sp (29) is the stack pointer, which points to the last location on the stack. Register $fp (30) is the frame pointer. The jal instruction writes register $ra (31), the return address from a procedure call

$PC Program Counter $SP Stack Pointer $RA Return Address $STATUS Flags $GP Global Pointer $FP Frame Pointer $AT Assembler Temporary $K0-$K1 - Kernel $Zero Floating Point $FG0 to $FG31 => Single $FP0 to $FP30 => Double Floating Point Registers: FG0, FG1, FG2,... FG31 => 32 bits FP0, FP2, FP4,... FP30 => 64 bits

MONTADOR File.s SPIM: Assembler and Simulator MARS: MIPS Assembler and Runtime Simulator (Java)

SPIM - DATA DECLARATION (Data Segment) Comments The "#" character represents a comment line. Anything typed after the "#" is considered a comment. Blank lines are accepted.

.data dado1:.word 0x12345678 dado2:.word 0xF1F2F3F4 # 0x => Hexadecimal Values

Details => See: Larus Appendix A

SYSTEM CALLS I/O Functions

Register $V0 Register $A0 (CPU) SPIM SysCalls Details => See: Larus Appendix A

Register $V0 Register $A0 (CPU) SPIM SysCalls

MIPS Instruções e Código li = Load Immediate la = Load Address lw = Load Word (32 bits) syscall = System Call (Software Interrupt Call) # helloworld.s # # Print out "Hello World" # Copyright (c) 2013, James R. Larus. msg:.data.asciiz "Hello World".text.globl main main: li $v0, 4 # syscall 4 (print_str) la $a0, msg # argument: string syscall # print the string END: li $v0, 10 # exits program syscall

REFERÊNCIAS

1. Organização e Projeto de Computadores Patterson, D. & Hennessy J. - 2015. Apêndice A Larus Appendix A Assemblers, Linkers, and the SPIM Simulator 2. MIPS Assembly Language Programming Robert Britton May 2002 3. MIPS - Assembly Language Programming using QtSpim Ed Jorgensen - Version 1.1.7 - July 2015 4. MIPS - Assembly Language Programmer s Guide ASM-01-DOC - Silicon Graphics 1992. 5. SPIM Simulator (Larus) http://pages.cs.wisc.edu/~larus/spim.html http://spimsimulator.sourceforge.net/ http://sourceforge.net/projects/spimsimulator/files/ QtSPIM 6. MARS Simulator (Java Missouri State University) http://courses.missouristate.edu/kenvollmar/mars/ 7. MIPS Resumo : Tutorial http://logos.cs.uic.edu/366/notes/mips%20quick%20tutorial.htm