MIPS Instruction Encoding

Slides:



Advertisements
Similar presentations
MIPS Assembly Tutorial
Advertisements

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.
Goal: Write Programs in Assembly
Lecture 5: MIPS Instruction Set
MIPS processor continued. Review Different parts in the processor should be connected appropriately to be able to carry out the functions. Connections.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
ELEN 468 Advanced Logic Design
Chapter 2 Instructions: Language of the Computer
Chapter 2 Instructions: Language of the Computer Part III.
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.
Instructions Set Bo Cheng Instruction Set Design An Instruction Set provides a functional description of a processor. It is the visible.
Computer Architecture CPSC 321 E. J. Kim. Overview Logical Instructions Shifts.
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.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
Instruction Representation I (1) Fall 2005 Lecture 05: INSTRUCTION REPRESENTATION.
CS 300 – Lecture 6 Intro to Computer Architecture / Assembly Language Instructions.
Lecture Objectives: 1)Define the terms least significant bit and most significant bit. 2)Explain how unsigned integer numbers are represented in memory.
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
Computer Architecture CSE 3322 Lecture 2 NO CLASS MON Sept 1 Course WEB SITE crystal.uta.edu/~jpatters.
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
MS108 Computer System I Lecture 3 ISA Prof. Xiaoyao Liang 2015/3/13 1.
Computer Organization Rabie A. Ramadan Lecture 3.
CENG 311 Instruction Representation
Chapter 2 — Instructions: Language of the Computer — 1 Memory Operands Main memory used for composite data – Arrays, structures, dynamic data To apply.
MIPS Assembly Language Programming
Computer Architecture & Operations I
MIPS Assembly.
Computer Architecture Instruction Set Architecture
MIPS Instruction Set Advantages
COMPUTER ARCHITECTURE & OPERATIONS I
Computer Architecture Instruction Set Architecture
Morgan Kaufmann Publishers
MIPS Coding Continued.
Lecture 4: MIPS Instruction Set
ELEN 468 Advanced Logic Design
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 (CS 207 D) Instruction Set Architecture ISA
Computer Architecture & Operations I
Instructions for Making Decisions
CS170 Computer Organization and Architecture I
Control Path Catholic University PUCRS.
MIPS processor continued
MIPS coding.
Instructions - Type and Format
Lecture 4: MIPS Instruction Set
CSCI206 - Computer Organization & Programming
Computer Architecture & Operations I
MIPS Processor.
MIPS Instructions.
The University of Adelaide, School of Computer Science
ECE232: Hardware Organization and Design
September 24 Test 1 review More programming
MIPS processor continued
Topic 5: Processor Architecture Implementation Methodology
MIPS Instruction Encoding
Instruction encoding The ISA defines Format = Encoding
MIPS coding.
Review.
MIPS Coding.
COMS 361 Computer Organization
COMS 361 Computer Organization
COMS 361 Computer Organization
Review Fig 4.15 page 320 / Fig page 322
MIPS Coding Continued.
MIPS coding.
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
MIPS Processor.
Presentation transcript:

MIPS Instruction Encoding

Representing Instructions in Computers 12/1/2018 Representing Instructions in Computers Note that computers only have 0’s and 1’s Before we can load MIPS instructions into memory, they need to be translated into machine instructions, which consist of only 0’s and 1’s In other words, we need to encode or represent instructions The symbolic representation of machine instructions is called assembly language The binary representation of instructions is called machine language A sequence of instructions in binary form is called machine code 12/1/2018 CDA3100 CDA3100

12/1/2018 Example 12/1/2018 CDA3100 CDA3100

MIPS Instruction Encoding Each MIPS instruction is exactly 32 bits R-type (register type) I-type (immediate type) J-type (jump type) op rs rt rd shamt funct op rs rt 16 bit address or constant op 26 bit address 12/1/2018 CDA3100

R-Type Encoding Encoding = 0x00622020 opcode rs rt rd shamt funct 1 31 opcode rs rt rd 26 25 21 20 16 15 11 10 6 5 shamt funct 1 add $4, $3, $2 Encoding = 0x00622020 12/1/2018 CDA3100

I-type Encoding Encoding = 0x8C450BB8 opcode rs rt Immediate Value 31 opcode rs rt Immediate Value 26 25 21 20 16 15 lw $5, 3000($2) Immediate 1 Encoding = 0x8C450BB8 12/1/2018 CDA3100

I-type Encoding Encoding = opcode rs rt Immediate Value rt Immediate 12/1/2018 I-type Encoding 31 26 25 21 20 16 15 opcode rs rt Immediate Value rt Immediate sw $5, 3000($2) rs 31 26 25 21 20 16 15 opcode rs rt Immediate Value Encoding = 12/1/2018 CDA3100 CDA3100

I-type Encoding Encoding = 0xAC450BB8 opcode rs rt Immediate Value 31 opcode rs rt Immediate Value 26 25 21 20 16 15 sw $5, 3000($2) Immediate 1 Encoding = 0xAC450BB8 12/1/2018 CDA3100

I-type Encoding Encoding = opcode rs rt Immediate Value rt Immediate 12/1/2018 I-type Encoding 31 26 25 21 20 16 15 opcode rs rt Immediate Value rt Immediate addi $s0, $s0, 95 rs 31 26 25 21 20 16 15 opcode rs rt Immediate Value Encoding = 12/1/2018 CDA3100 CDA3100

I-type Encoding Encoding = 0x2210005F opcode rs rt Immediate Value rt 12/1/2018 I-type Encoding 31 26 25 21 20 16 15 opcode rs rt Immediate Value rt Immediate addi $s0, $s0, 95 rs 31 26 25 21 20 16 15 1 1 1 1 1 1 1 1 1 opcode rs rt Immediate Value 1 1 1 1 1 1 1 1 1 Encoding = 0x2210005F 12/1/2018 CDA3100 CDA3100

J-type Encoding Encoding = 0x0810001F opcode Jump Address Jump Address 31 26 25 opcode Jump Address Jump Address j 0x0040007c 0x0040007c: the address of the instruction to jump to. When encoding it, take bit 2 to bit 27. 31 26 25 1 j 0x0040007c 1 1 1 1 1 1 opcode Jump Address 1 1 1 1 1 1 1 Encoding = 0x0810001F

How to Encode Branch Instructions 12/1/2018 How to Encode Branch Instructions To encode these branch instructions, we first need to figure out the value for the associated label This will be done by the assembler Note that the MIPS has the alignment restriction, which means all the labels will be a multiple of 4 To increase the range, the address divided by 4 is actually encoded In other words, the address is in terms of words (32 bits), rather than bytes 12/1/2018 week04-3.ppt CDA3100

Encoding Conditional Branch Instructions 12/1/2018 Encoding Conditional Branch Instructions It branches the number of the instructions specified by the offset if register rs equals to register rt In the stored-program concept, we implicitly need a register to hold the address of the current instruction being executed Which is called program counter (PC) (should be called instruction address register) What is the value of PC after we finish executing the current instruction? 12/1/2018 week04-3.ppt CDA3100

Encoding Conditional Branch Instructions 12/1/2018 Encoding Conditional Branch Instructions PC-relative addressing The offset of conditional branch instructions is relative to PC + 4 Since all MIPS instructions are 4 bytes long, the offset refers to the number of words to the next instruction instead of the number of bytes 12/1/2018 week04-3.ppt CDA3100

Encoding bne Encoding = 0x16740002 opcode rs rt Immediate Value rs 12/1/2018 Encoding bne 31 26 25 21 20 16 15 opcode rs rt Immediate Value rs Label/Offset bne $19, $20, Else rt 31 26 25 21 20 16 15 1 1 1 1 1 1 1 1 opcode rs rt Immediate Value 1 1 1 1 1 1 1 1 Encoding = 0x16740002 12/1/2018 week04-3.ppt CDA3100