CS/COE0447 Computer Organization & Assembly Language Chapter 2 Part 1 In-Class Lab Session (Lab 2) Answer Key.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Goal: Write Programs in Assembly
Lecture 5: MIPS Instruction Set
CS/COE0447 Computer Organization & Assembly Language
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
Chapter 2 Instructions: Language of the Computer
Chapter 2.
CS 61C L13Introduction to MIPS: Instruction Representation I (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
Chapter 2 Instructions: Language of the Computer Part III.
Informationsteknologi Saturday, September 29, 2007 Computer Architecture I - Class 41 Today’s class More assembly language programming.
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 08 MIPS Instruction Representation I Lecturer SOE Dan Garcia
Assembly Language II CPSC 321 Andreas Klappenecker.
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 13 MIPS Instruction Representation I Shanghai Jiaotong University and Lanxiang.
CS61C L13 MIPS Instruction Representation I (1) Garcia, Spring 2007 © UCB Lecturer SOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
Instruction Representation II (1) Fall 2007 Lecture 10: Instruction Representation II.
Computer Architecture CPSC 321 E. J. Kim. Overview Logical Instructions Shifts.
CS61C L13 Introduction to MIPS: Instruction Representation I (1) Garcia © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
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.
RISC Concepts, MIPS ISA and the Mini–MIPS project
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
Instruction Representation II (1) Fall 2005 Lecture 10: Instruction Representation II.
CS61C L9 MIPS Logical & Shift Ops, and Instruction Representation I (1) Beamer, Summer 2007 © UCB Scott Beamer, Instructor inst.eecs.berkeley.edu/~cs61c.
Instruction Representation I (1) Fall 2005 Lecture 05: INSTRUCTION REPRESENTATION.
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 13 MIPS Instruction Representation I The National Science Foundation (NSF)
Lecture Objectives: 1)Define the terms least significant bit and most significant bit. 2)Explain how unsigned integer numbers are represented in memory.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 2 Part 1 In-Class Lab Session (Lab 2)
Computer Architecture Instruction Set Architecture Lynn Choi Korea University.
CSE378 Instr. encoding.1 Instruction encoding The ISA defines –The format of an instruction (syntax) –The meaning of the instruction (semantics) Format.
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.
Fall EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Computer Organization Lecture 5 MIPS Instructions Loops Machine Instructions.
Lecture 4: MIPS Instruction Set
Computer Organization and Architecture Instructions: Language of the Machine Hennessy Patterson 2/E chapter 3. Notes are available with photocopier 24.
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.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 2 Part 2.
9/29: Lecture Topics Conditional branch instructions
CENG 311 Instruction Representation
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.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Lecture 16: 10/29/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
MIPS Arithmetic and Logic Instructions
CS Computer Organization Numbers and Instructions Dr. Stephen P. Carl.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Yaohang Li.
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 08 MIPS Instruction Representation I Guest Lecturer Alan Christopher
Computer Architecture Instruction Set Architecture
COMPUTER ARCHITECTURE & OPERATIONS I
IT 251 Computer Organization and Architecture
Morgan Kaufmann Publishers
Lecture 4: MIPS Instruction Set
IT 251 Computer Organization and Architecture
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
The University of Adelaide, School of Computer Science
Lecture 4: MIPS Instruction Set
CS/COE0447 Computer Organization & Assembly Language
MISP Assembly.
Computer Architecture & Operations I
The University of Adelaide, School of Computer Science
ECE232: Hardware Organization and Design
MIPS History MIPS is a computer family
Instruction encoding The ISA defines Format = Encoding
MIPS History MIPS is a computer family
Instruction encoding The ISA defines Format = Encoding
Instruction encoding The ISA defines Format = Encoding
Instruction encoding The ISA defines Format = Encoding
MIPS History MIPS is a computer family
CS/COE0447 Computer Organization & Assembly Language
MIPS Arithmetic and Logic Instructions
Presentation transcript:

CS/COE0447 Computer Organization & Assembly Language Chapter 2 Part 1 In-Class Lab Session (Lab 2) Answer Key

Answers: MIPS Operations/Operands “Operation” (instruction) “Operand” MIPS operations –Arithmetic operations (integer/floating-point) (add, sub,…) –Logical operations (and, or,…) –Shift operations (shift a certain number of bits to the left or right) –Compare operations (do something if one operand is less than another,…) –Load/stores to transfer data from/to memory –Branch/jump operations –System control operations/coprocessor operations Question: Check on the green card. What is the mnemonic for a shift logical left instruction? _sll_ MIPS operands –General-purpose registers: Question: name 2 of these___$t0, $s3_________ –Fixed registers, e.g., HI/LO registers –Memory location –Immediate value –Question: we saw this instruction in lecture: addi $t3,$zero,4. $t3 is the destination. “addi” is the mnemonic for the instruction. $zero is an operand, and 4 is an operand. What type of operand is $zero? (pick from the above list):_Fixed register, since it always contains 0. What type of operand is 4?_immediate What do you think “I” stands for in “addi”?_immediate

Answer: MIPS Arithmetic Arithmetic Type Instruction: – All arithmetic instructions have 3 operands –Operand order is fixed: destination first –32 registers (page 2 of green card) –Question: What number is $t3? On the green card, we see that $t0-$t7 are So, $t0 is 8, $t1 is 9, $t2 is 10, and $t3 is 11. What number is $s3? 19 (note that this is decimal, not hex. How do we know this? It only makes sense for the numbers to be decimal, since 8 registers are numbered from If the numbers were hex, 8-15 would be how many numbers? 8,9,A,B,C,D,E,F,10,11,12,13,14,15: 14 numbers) Examples add $t0, $s0, $s2# $t0 = $s0 + $s2 sub $s0, $t0, $t1# $s0 = $t0 – $t1 Question: In the sub instruction, which register is rd? $s0 Which register is rs? $t0 Which register is rt? $t1 rd rs rt Operands

Answer: General-Purpose Registers GPR: all can be used as operands in instructions Still, conventions and limitations exist to keep GPRs from being used arbitrarily –r0, termed $zero, always has a value “0” –r31, termed $ra (return address), is reserved for subroutine call/return –Etc. (we’ll see other conventions/limitations later) –Register usage and related software conventions are summarized in “application binary interface” (ABI), which is important when writing system software such as an assembler and a compiler Question: Check the green card: what is the calling convention for $t0-$t7? Temporaries. Note that these conventions are part of the ABI mentioned above. What does ABI stand for? Application Binary Interface.

Answer: R-Format Example add $8,$9,$ Binary number per field representation (use the right # of bits!): Decimal number per field representation: hex representation: __0x012A A

Answer: I-Format Example MIPS Instruction: addi $8,$9,7 $8 is rt; $9 is rs. This instruction adds 7 to the contents of $9 and stores it in $8. Binary number per field representation: Decimal number per field representation: Hex representation:__0x Translate the instruction above to fill in the following tables:

Answer: Verilog (2) SignExtImm = {16{immediate[15]}, immediate} {x,y,z} means xyz (the three concatenated together) {3{a}} means a repeated 3 times: aaa Immediate[15] means bit 15 of the immediate field of the instruction {16{immediate[15]}, immediate} (1) The top bit of the immediate field (2) Repeated 16 times (3) Followed by the immediate field Our specific example:

Answer: Exercise Which instruction has same representation as 35 ten ? A. add $0, $0, $0 B. subu $s0,$s0,$s0 C. lw $0, 0($0) D. addi $0, $0, 35 E. subu $0, $0, $0 F. Trick question! Instructions are not numbers. (yes they are!!!) Answer is E. Note: Registers numbers and names: 0: $0, 8: $t0, 9:$t1, …,16: $s0, 17: $s1, …, Note: Opcodes and function fields (confirm on green card; note error on green card for lw: entry in column should be 23hex rather than 0/23hex) add : opcode = 0, function field = 32 subu : opcode = 0, function field = 35 addi : opcode = 8 lw : opcode =

Answer: Exercise What values are placed into $t0, $t1, $t5 and $t4 by the following pieces of code? addi $t0,$0,0xA23 $t0= addi $t1,$0,0x80001B42 $t1= and $t4,$t0,$t1 $t4= x00000A02 or $t5,$t0,$t1 $t5= x80001B63