MIPS Assembly Language Programming

Slides:



Advertisements
Similar presentations
MIPS Assembly Tutorial
Advertisements

Lecture 5: MIPS Instruction Set
MIPS assembly. Review  Lat lecture, we learnt  addi,  and, andi, or, ori, xor, xori, nor,  beq, j, bne  An array is stored sequentially in the memory.
CS/COE0447 Computer Organization & Assembly Language
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /15/2013 Lecture 11: MIPS-Conditional Instructions Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER.
1 ECE369 ECE369 Chapter 2. 2 ECE369 Instruction Set Architecture A very important abstraction –interface between hardware and low-level software –standardizes.
10/9: Lecture Topics Starting a Program Exercise 3.2 from H+P Review of Assembly Language RISC vs. CISC.
Chapter 2 Instructions: Language of the Computer
The University of Adelaide, School of Computer Science
Datorteknik DatapathControl bild 1 Designing a Single Cycle Datapath & Datapath Control.
CS2100 Computer Organisation MIPS Part III: Instruction Formats (AY2014/2015) Semester 2.
Comp Sci instruction encoding 1 Instruction Encoding MIPS machine language Binary encoding of instructions MIPS instruction = 32 bits Three instruction.
ENEE350 Spring07 1 Ankur Srivastava University of Maryland, College Park Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005.”
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
CS 300 – Lecture 6 Intro to Computer Architecture / Assembly Language Instructions.
MIPS Instruction Set Advantages
Lecture 8. MIPS Instructions #3 – Branch Instructions #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System Education.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Computer Organization & Programming Chapter 6 Single Datapath CPU Architecture.
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
Computer Organization Rabie A. Ramadan Lecture 3.
EET 4250 Instruction Representation & Formats Acknowledgements: Some slides and lecture notes for this course adapted from Prof. Mary Jane Penn.
Chapter 2 — Instructions: Language of the Computer — 1 Memory Operands Main memory used for composite data – Arrays, structures, dynamic data To apply.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 9 Binary Representation and Logical Operations.
Branch Addressing op rs rt address address beq $s1, $s2, Label if ($s1 = =$s2) go to Label 6 bits 5 bits 5 bits 16 bits effective 32 bit address.
Computer Organization Instructions Language of The Computer (MIPS) 2.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 11 Conditional Operations.
CS Computer Organization Numbers and Instructions Dr. Stephen P. Carl.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Yaohang Li.
Computer Architecture & Operations I
MIPS Assembly.
Prof. Hsien-Hsin Sean Lee
MIPS Instruction Set Advantages
COMPUTER ARCHITECTURE & OPERATIONS I
MIPS Coding Continued.
Lecture 4: MIPS Instruction Set
ELEN 468 Advanced Logic Design
Computer Architecture & Operations I
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 Architecture & Operations I
Instructions for Making Decisions
Computer Organization and Design Instruction Sets
CS170 Computer Organization and Architecture I
The University of Adelaide, School of Computer Science
MIPS processor continued
MIPS coding.
Han Wang CS3410, Spring 2012 Computer Science Cornell University
How to represent signed integers
Computer Architecture & Operations I
MIPS Instruction Encoding
Datapath & Control MIPS
The University of Adelaide, School of Computer Science
MIPS processor continued
MIPS Instruction Encoding
MIPS coding.
Review.
The University of Adelaide, School of Computer Science
The University of Adelaide, School of Computer Science
MIPS Coding.
COMP541 Datapaths I Montek Singh Mar 18, 2010.
COMS 361 Computer Organization
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2018
ECE 463/563 Fall `18 RISC-V instruction formats
Review Fig 4.15 page 320 / Fig page 322
MIPS Instruction Set Architecture
MIPS Coding Continued.
MIPS coding.
MIPS assembly.
MIPS instructions.
Presentation transcript:

MIPS Assembly Language Programming CDA 3101 Fall 2010 Discussion Session 07 MIPS Assembly Language Programming 1 1

Instruction Register add $t0, $t1, $t2 ## RF[Rd] =RF[Rs] +RF[Rt] Register – Format (add Rd, Rs, Rt)‏ Op-code Rs Rt Rd Shamt Function-code 6 5 5 5 5 6 add $t0, $t1, $t2 ## RF[Rd] =RF[Rs] +RF[Rt] 2 2 2

Instruction Register addi $t0, $t1, 100 ## RF[Rt] =RF[Rs] + se Imm Immediate – Format (addi Rt, Rs, Imm)‏ Op-code Rs Rt Immediate 6 5 5 16 2’s Complement ? addi $t0, $t1, 100 ## RF[Rt] =RF[Rs] + se Imm se Imm = {16 {immediate[15]}, immediate} beq Rs, Rt, Label ##if(RF[Rs] == Rf[Rt]) PC = PC +4 + BranchAddr* *BranchAddr = {14{immediate[15]}, immediate, 2’b0} 3 3 3

Instruction Register j Label ## PC = JumpAddr Jump– Format (j addr)‏ Op-code Address 6 26 j Label ## PC = JumpAddr JumpAddr = { PC[31:28], address, 2’b0} 4 4 4

Problem Assume the address start from 0x00400024, translate the following MIPS code into the corresponding machine code. lable1: addi $t0, $0, 1 0x00400024 sll $t0, $t0, 2 0x00400028 bgez $t0, lable1 0x0040002C and $s0, $s0, $t0 0x00400030 lable2: bne $s0, $0, lable3 0x00400034 lb $t4, 8($s4) 0x00400038 sb $t4, -8($s4) 0x0040003C lable3: j lable1 0x00400040 5 5 5

Problem [0x00400024] 001000 00000 01000 0000000000000001 ;addi $8, $0, 1 [0x00400028] 000000 00000 01000 01000 00010 000000 ;sll $8, $8, 2 [0x0040002c] 000001 01000 00001 1111111111111101 ;bgez $8 -12 [lable1-0x0040002c - 4] [0x00400030] 000000 10000 01000 10000 00000 100100 ;and $16, $16, $8 [0x00400034] 000101 10000 00000 00000000 0000 0010 ;bne $16, $0, 8 [lable3-0x00400034- 4] [0x00400038] 100000 10100 01100 0000000000001000 ;lb $12, 8($20) [0x0040003c] 101000 10100 01100 1111111111111000 ;sb $12, -8($20) [0x00400040] 000010 00 00010000 00000000 00001001 ;j 0x00400024 [lable1] 6 6 6