Chapter 2 CSF 2009 The MIPS Assembly Language: Introduction to Binary System.

Slides:



Advertisements
Similar presentations
C OMPUTER O RGANIZATION AND D ESIGN The Hardware/Software Interface 5 th Edition Chapter 2 Instructions: Language of the Computer.
Advertisements

Lecture 5: MIPS Instruction Set
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
Chapter 2 Instructions: Language of the Computer CprE 381 Computer Organization and Assembly Level Programming, Fall 2013 Zhao Zhang Iowa State University.
The University of Adelaide, School of Computer Science
Data Representation Computer Organization &
Data Representation COE 205
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 4: Arithmetic / Data Transfer Instructions Partially adapted from Computer Organization.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
Lecture 4 Sept 9 Goals: Amdahl’s law Chapter 2 MIPS assembly language instruction formats translating c into MIPS - examples.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
Data Representation ICS 233
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
C OMPUTER O RGANIZATION AND D ESIGN The Hardware/Software Interface 5 th Edition Chapter 2 Instructions: Language of the Computer.
Lecture 5.
CMPT 334 Computer Organization
Computers Organization & Assembly Language
CMPE 325 Computer Architecture II Cem Ergün Eastern Mediterranean University Integer Representation and the ALU.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 3.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
Lecture Objectives: 1)Define the terms least significant bit and most significant bit. 2)Explain how unsigned integer numbers are represented in memory.
CS224 Fall 2011 Chap 2a Computer Organization CS224 Fall 2011 Chapter 2 a With thanks to M.J. Irwin, D. Patterson, and J. Hennessy for some lecture slide.
CSE378 Instr. encoding.1 Instruction encoding The ISA defines –The format of an instruction (syntax) –The meaning of the instruction (semantics) Format.
Character Data and 32-bit Constants (Lecture #20) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying.
Computer Organization CS224 Fall 2012 Lessons 9 and 10.
Strings in MIPS. Chapter 2 — Instructions: Language of the Computer — 2 Character Data Byte-encoded character sets – ASCII: 128 characters 95 graphic,
IFT 201: Unit 1 Lecture 1.3: Processor Architecture-3
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /08/2013 Lecture 10: MIPS Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL STATE.
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive.
Chapter 2 CSF 2009 The MIPS Assembly Language. Stored Program Computers Instructions represented in binary, just like data Instructions and data stored.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Lecture 2: Advanced Instructions, Control, and Branching EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /22/2013 Lecture 12: Character Data Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE.
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.
Chapter 2 — Instructions: Language of the Computer — 1 Conditional Operations Branch to a labeled instruction if a condition is true – Otherwise, continue.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 9 Binary Representation and Logical Operations.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 7, 8 Instruction Set Architecture.
MIPS Instruction Set Architecture Prof. Sirer CS 316 Cornell University.
Lec 6Systems Architecture1 Systems Architecture Lecture 6: Branching and Procedures in MIPS Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
Chapter 2 Instructions: Language of the Computer Part IIa Number Representation.
Data Representation COE 301 Computer Organization Dr. Muhamed Mudawar
CS Computer Organization Numbers and Instructions Dr. Stephen P. Carl.
Chapter 2 Instructions: Language of the Computer.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Yaohang Li.
Data Representation COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum.
Memory Access Instructions Load and Store Addressing Modes Memory Addressing. Base addressing mode. Load byte and store byte: lb, lbu, sb Address alignment.
Arithmetic Operations Add and subtract, three operands Two sources and one destination add a, b, c # a gets b + c All arithmetic operations have this form.
Computer Architecture & Operations I
Memory Access Instructions
COMPUTER ARCHITECTURE & OPERATIONS I
The University of Adelaide, School of Computer Science
Morgan Kaufmann Publishers
The University of Adelaide, School of Computer Science
The University of Adelaide, School of Computer Science
MPIS Instructions Functionalities of instructions Instruction format
The University of Adelaide, School of Computer Science
Computer Architecture & Operations I
The University of Adelaide, School of Computer Science
Chapter 2 Instructions: Language of the Computer
The University of Adelaide, School of Computer Science
MIPS Assembly.
Computer Architecture
Instruction encoding The ISA defines Format = Encoding
Instruction encoding The ISA defines Format = Encoding
CSC3050 – Computer Architecture
MIPS Instruction Set Architecture
Instruction encoding The ISA defines Format = Encoding
Presentation transcript:

Chapter 2 CSF 2009 The MIPS Assembly Language: Introduction to Binary System

Unsigned Binary Integers Given an n-bit number Chapter 2 — Instructions: Language of the Computer — 2 Range: 0 to +2 n – 1 Example = 0 + … + 1× ×2 2 +1×2 1 +1×2 0 = 0 + … = Using 32 bits 0 to +4,294,967,295

2s-Complement Signed Integers Given an n-bit number Chapter 2 — Instructions: Language of the Computer — 3 Range: –2 n – 1 to +2 n – 1 – 1 Example = –1× × … + 1×2 2 +0×2 1 +0×2 0 = –2,147,483, ,147,483,644 = –4 10 Using 32 bits –2,147,483,648 to +2,147,483,647

2s-Complement Signed Integers Bit 31 is sign bit – 1 for negative numbers – 0 for non-negative numbers –(–2 n – 1 ) can’t be represented Non-negative numbers have the same unsigned and 2s- complement representation Some specific numbers – 0: … 0000 – –1: … 1111 – Most-negative: … 0000 – Most-positive: … 1111 Chapter 2 — Instructions: Language of the Computer — 4

Signed Negation Complement and add 1 – Complement means 1 → 0, 0 → 1 Chapter 2 — Instructions: Language of the Computer — 5 Example: negate = … –2 = … = …

Sign Extension Representing a number using more bits – Preserve the numeric value In MIPS instruction set – addi : extend immediate value – lb, lh : extend loaded byte/halfword – beq, bne : extend the displacement Replicate the sign bit to the left – c.f. unsigned values: extend with 0s Examples: 8-bit to 16-bit – +2: => – –2: => Chapter 2 — Instructions: Language of the Computer — 6

Hexadecimal Base 16 – Compact representation of bit strings – 4 bits per hex digit Chapter 2 — Instructions: Language of the Computer — c d a1010e b1011f1111 Example: eca

AND Operations Useful to mask bits in a word – Select some bits, clear others to 0 and $t0, $t1, $t2 Chapter 2 — Instructions: Language of the Computer — $t2 $t $t0

OR Operations Useful to include bits in a word – Set some bits to 1, leave others unchanged or $t0, $t1, $t2 Chapter 2 — Instructions: Language of the Computer — $t2 $t $t0

NOT Operations Useful to invert bits in a word – Change 0 to 1, and 1 to 0 MIPS has NOR 3-operand instruction – a NOR b == NOT ( a OR b ) nor $t0, $t1, $zero Chapter 2 — Instructions: Language of the Computer — $t $t0 Register 0: always read as zero

Character Data Byte-encoded character sets – ASCII: 128 characters 95 graphic, 33 control – Latin-1: 256 characters ASCII, +96 more graphic characters Unicode: 32-bit character set – Used in Java, C++ wide characters, … – Most of the world’s alphabets, plus symbols – UTF-8, UTF-16: variable-length encodings Chapter 2 — Instructions: Language of the Computer — 11

Byte/Halfword Operations Could use bitwise operations MIPS byte/halfword load/store – String processing is a common case lb rt, offset(rs) lh rt, offset(rs) – Sign extend to 32 bits in rt lbu rt, offset(rs) lhu rt, offset(rs) – Zero extend to 32 bits in rt sb rt, offset(rs) sh rt, offset(rs) – Store just rightmost byte/halfword Chapter 2 — Instructions: Language of the Computer — 12

32-bit Constants Most constants are small – 16-bit immediate is sufficient For the occasional 32-bit constant lui rt, constant – Copies 16-bit constant to left 16 bits of rt – Clears right 16 bits of rt to 0 Chapter 2 — Instructions: Language of the Computer — lhi $s0, ori $s0, $s0, 2304