CS334: MIPS language _Mars simulator Lab 2_1

Slides:



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

2.3) Example of program execution 1. instruction  B25 8 Op-code B means to change the value of the program counter if the contents of the indicated register.
CS 61C L06 MIPS Intro (1) A Carle, Summer 2005 © UCB inst.eecs.berkeley.edu/~cs61c/su05 CS61C : Machine Structures Lecture #6: Intro to MIPS
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) Lecturer: Hui Wu Session.
Normal C Memory Management °A program’s address space contains 4 regions: stack: local variables, grows downward heap: space requested for pointers via.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 4: Arithmetic / Data Transfer Instructions Partially adapted from Computer Organization.
CIS 314: Introduction to MIPS Assembly Language: Arithmetic Fall 2005 I´ve been getting this a lot lately So, what are you teaching this term? Computer.
Instruction Representation II (1) Fall 2007 Lecture 10: Instruction Representation II.
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.
Chapter 7 Low-Level Programming Languages. 2 Chapter Goals List the operations that a computer can perform Discuss the relationship between levels of.
CS 61C L08 Introduction to MIPS Assembly Language: Arithmetic (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
Lecture 7: Instruction Set Architecture CSE 30: Computer Organization and Systems Programming Winter 2014 Diba Mirza Dept. of Computer Science and Engineering.
MIPS assembly. Computer What’s in a computer? Processor, memory, I/O devices (keyboard, mouse, LCD, video camera, speaker), disk, CD drive, …
Lecture 15 Today’s lecture MARIE programming Assembler
Assembly Language A Brief Introduction. Unit Learning Goals CPU architecture. Basic Assembler Commands High level Programming  Assembler  Machine Language.
Lecture 4: MIPS Instruction Set Reminders: –Homework #1 posted: due next Wed. –Midterm #1 scheduled Friday September 26 th, 2014 Location: TODD 430 –Midterm.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
Chapter 2-2 Assembly Instructions Number Systems Number Systems Assembly Instructions Assembly Instructions Branch Branch Next Lecture Next Lecture  Addressing.
1 Instruction Set Architecture (ISA) Alexander Titov 10/20/2012.
Module : Algorithmic state machines. Machine language Machine language is built up from discrete statements or instructions. On the processing architecture,
Chapter 2 Instructions: Language of the Computer Part I.
CMSC 150 PROGRAM EXECUTION CS 150: Wed 1 Feb 2012.
Computer Organization 1 Instruction Fetch and Execute.
An Example Architecture. A Paper Computer - Woody Woody's characteristics Word size – 8 bits One word.
Computer Systems – Machine & Assembly code. Objectives Machine Code Assembly Language Op-code Operand Instruction Set.
Computer Organization Instructions Language of The Computer (MIPS) 2.
CS334: Number Systems&& Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%
MIPS assembly. Computer  What’s in a computer?  Processor, memory, I/O devices (keyboard, mouse, LCD, video camera, speaker), disk, CD drive, …
Lecture 16: 10/29/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
CS 125 Lecture 3 Martin van Bommel. Overflow In 16-bit two’s complement, what happens if we add =
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
Writing an Assembly-language program MIPS assembly language using MARS: MIPS Assembler and Runtime Simulator CS-2710 Dr. Mark L. Hornick 1.
Assembly Language Basic job of a CPU: execute lots of instructions. Instructions are the primitive operations that the CPU may execute. Different CPUs.
Computer Architecture & Operations I
Computer Architecture & Operations I
MIPS Assembly.
Why to use the assembly and why we need this course at all?
Morgan Kaufmann Publishers
ACOE301: Computer Architecture II Labs
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Conditional Branches What distinguishes a computer from a simple calculator is its ability to make decisions Decisions are made using the if statement,
Computer Organization and Assembly Language (COAL)
Data Representation – Instructions
Lecturer PSOE Dan Garcia
The Processor and Machine Language
MIPS Assembly.
Introduction to Assembly Language
Number Representations and Basic Processor Architecture
Lecture 4: MIPS Instruction Set
CS170 Computer Organization and Architecture I
CSCI206 - Computer Organization & Programming
MIPS assembly.
CSCE Fall 2013 Prof. Jennifer L. Welch.
MIPS Instructions.
MARIE: An Introduction to a Simple Computer
Chapter 9 Instruction Sets: Characteristics and Functions
CS334: Memory _ Mars simulator Lab 4(part2-2)
MARIE: An Introduction to a Simple Computer
CSCE Fall 2012 Prof. Jennifer L. Welch.
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2018
Introduction to Microprocessor Programming
Instructions in Machine Language
CS334: Number Systems Lab 1.
Review In last lecture, done with unsigned and signed number representation. Introduced how to represent real numbers in float format.
CPU Structure CPU must:
Part I Data Representation and 8086 Microprocessors
CS 111 – Sept. 16 Machine language examples Instruction execution
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

CS334: MIPS language _Mars simulator Lab 2_1

Part1:MIPS assembly language. Questions. Contents: introduction. Part1:MIPS assembly language. Questions. Ins.Ebtesam AL-Etowi

Assembly Language Instructions are the primitive operations that the CPU may execute. Different CPUs implement different sets of instructions. The set of instructions a particular CPU implements is an Instruction Set Architecture (ISA). Examples: Intel 80x86 (Pentium 4), IBM/Motorola PowerPC (Macintosh), MIPS, Intel IA64, ... Ins.Ebtesam AL-Etowi

MIPS Architecture MIPS – semiconductor company that built one of the first commercial RISC architectures MIPS is simple, elegant. Assembly Operands are registers Groups of 32 bits called a word in MIPS The Text segment shows you: Address -- where this instruction is stored in memory Code -- the machine code of the instruction Basic -- [not too helpful at this point] Source -- the original instruction you typed in Ins.Ebtesam AL-Etowi

List of Instructions Ins.Ebtesam AL-Etowi

Part 1: MIPS .text $t1 = 3 + 5 + 9 addi $t1, $zero, 3 Start the program with: .text This says that the following are program instructions (and not, e.g.,data). Let's do the following: $t1 = 3 + 5 + 9 First, let's put 3 in $t1: addi $t1, $zero, 3 Ins.Ebtesam AL-Etowi

Part 1: MIPS (cont…) addi $t1, $t1, 5 addi $t1, $t1, 9 This says to take what is stored in register $zero, add 3 to it, and put the result in register $t1. $zero ALWAYS contains 0, so this puts 0 + 3 into register $t1 Now we want to add 5 to our running sum: addi $t1, $t1, 5 And then we want to add 9: addi $t1, $t1, 9 Save and Assemble the program (run it). You will see that $t1 contains 0x00000011 The 0x just means that the number following it is in hex. Ins.Ebtesam AL-Etowi

Performing the program Pc : Special register keeping the address of next instruction . Read the code from memory by pc . $at : assembler temporary as handle for save value . Ins.Ebtesam AL-Etowi

Questions Answer: 17 program counter = 0x00400000 Question 1: What decimal number is 0x00000011? Answer: 17 Question 2: before the first instruction is executed (the program counter is the register labeled "pc") program counter = __________ program counter = 0x00400000 Ins.Ebtesam AL-Etowi

Cont..)) Questions program counter = 0x00400004 $t1 = 0x00000003 Question 3: after the first instruction is executed: program counter = $t1 = program counter = 0x00400004 $t1 = 0x00000003 Question 4: after the second instruction is executed: program counter = $t1 = ____________ program counter = 0x00400008 $t1 = 0x00000008 Ins.Ebtesam AL-Etowi

Cont..)) Questions program counter = 0x0040000C $t1 = 0x00000011 Question 5: after the third instruction is executed: program counter = ___________ $t1 = _____________ program counter = 0x0040000C $t1 = 0x00000011 Question 6: Complete this sentence: After each instruction, the PC is incremented so that it contains: 1) A bit which is a 0 or 1. 2) A byte which is 8 bits. 3) A word which is 4 bytes. Ins.Ebtesam AL-Etowi

Cont..)) Questions Hint : In a MIPS architecture, each byte has its own address (the byte is the "addressable unit").   Question 7: How big are instructions in MIPS? Number of bits = Number of bytes = Number of words = 32 4 1 Ins.Ebtesam AL-Etowi

conclusion This shows a good way to learn assembly language. Enter and assemble instructions; this will show you the machine code that is produced. Then, step through execution so you can see the effects of the individual instructions. Ins.Ebtesam AL-Etowi

exercise to perform the calculation: f = (g + h) - (i + j) g= 5 h= -20 Ins.Ebtesam AL-Etowi

Ins.Ebtesam AL-Etowi

H.W for absent You are given the following two numbers in two’s complement representation. Perform the binary addition and subtraction. Did signed overflow occur? determined whether or not overflow occurred. 00101100 - 00101100 00101100 Ins.Ebtesam AL-Etowi