EE 352 Homework 1 Redekopp Name:

Similar documents
Mark Redekopp, All rights reserved. EE 352 Unit 4. Assembly and the MARS Simulator Control Flow (Branch Instructions)

1/26/2014. Previously. CSE 2021: Computer Organization. The Load/Store Family (1) Memory Organization. The Load/Store Family (2)

MIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions

EE 109 Unit 10 Assembler Directives and Control Flow

Previously. CSE 2021: Computer Organization. Memory Organization. The Load/Store Family (1) 5/26/2011. Used to transfer data to/from DRAM.

Computer Organization Lab #3.

MIPS Instruction Set Architecture (2)

ICS DEPARTMENT ICS 233 COMPUTER ARCHITECTURE & ASSEMBLY LANGUAGE. Midterm Exam. First Semester (141) Time: 1:00-3:30 PM. Student Name : _KEY

TSK3000A - Generic Instructions

Architecture II. Computer Systems Laboratory Sungkyunkwan University

Field 6-Bit Op Code rs Field rt Field 16-bit Immediate field

Assembly Language Programming. CPSC 252 Computer Organization Ellen Walker, Hiram College

Thomas Polzer Institut für Technische Informatik

Reduced Instruction Set Computer (RISC)

2.1 DOWNLOAD AND INSTALL MARS

Character Is a byte quantity (00~FF or 0~255) ASCII (American Standard Code for Information Interchange) Page 91, Fig. 2.21

Memory. CS 447, Spring /25/16. Memory. Processor (CPU) transfer

Grading: 3 pts each part. If answer is correct but uses more instructions, 1 pt off. Wrong answer 3pts off.

CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014

3. Instruction Set Architecture The MIPS architecture

Question 0. Do not turn this page until you have received the signal to start. (Please fill out the identification section above) Good Luck!

MIPS Reference Guide

Course Administration

Lecture 7: Examples, MARS, Arithmetic

Reduced Instruction Set Computer (RISC)

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes

ISA: The Hardware Software Interface

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook)

ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5

MACHINE LANGUAGE. To work with the machine, we need a translator.

Procedure Calling. Procedure Calling. Register Usage. 25 September CSE2021 Computer Organization

Instruction encoding. MIPS Instruction encoding

Machine Instructions - II. Hwansoo Han

Mark Redekopp, All rights reserved. EE 352 Unit 3 MIPS ISA

CSE 2021: Computer Organization

MIPS Assembly: More about Memory and Instructions CS 64: Computer Organization and Design Logic Lecture #7

CS31001 COMPUTER ORGANIZATION AND ARCHITECTURE. Debdeep Mukhopadhyay, CSE, IIT Kharagpur. Assembler

Mark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA

CDA3100 Midterm Exam, Summer 2013

SPIM & MIPS Programming

CS3350B Computer Architecture MIPS Instruction Representation

Chapter 2. Instruction Set. The MIPS Instruction Set. Arithmetic Operations. Instructions: Language of the Computer

CSCI 402: Computer Architectures. Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI.

8*4 + 4 = 36 each int is 4 bytes

ECE/CS 552: Introduction to Computer Architecture ASSIGNMENT #1 Due Date: At the beginning of lecture, September 22 nd, 2010

MIPS Assembly Language. Today s Lecture

Today s Lecture. MIPS Assembly Language. Review: What Must be Specified? Review: A Program. Review: MIPS Instruction Formats

3. (5 points) Name the 5 components of a computer

Chapter 2. Instructions: Language of the Computer

ECE Exam I February 19 th, :00 pm 4:25pm

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Control MIPS unconditional branch instruction (i.e., jump)

Computer Organization and Components

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 22 September Your Name (please print clearly) Signed.

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

ECE260: Fundamentals of Computer Engineering

Course Administration

ECE260: Fundamentals of Computer Engineering

CSc 256 Midterm (green) Fall 2018

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

Introduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

CS61C : Machine Structures

COMPUTER ORGANIZATION AND DESIGN

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization

MIPS Assembly Language Programming

ICS 233 Computer Architecture & Assembly Language. ICS 233 Computer Architecture & Assembly Language

HW2: MIPS ISA Profs. Daniel A. Menasce, Yutao Zhong, and Duane King Fall 2017 Department of Computer Science George Mason University

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

We will study the MIPS assembly language as an exemplar of the concept.

MIPS Assembly Language Programming

LSU EE 4720 Homework 1 Solution Due: 12 February 2016

1 5. Addressing Modes COMP2611 Fall 2015 Instruction: Language of the Computer

CS61C Machine Structures. Lecture 10 - MIPS Branch Instructions II. 2/8/2006 John Wawrzynek. (

CDA3101 Project 1: MIPS Assembler Due 2/5. I. Purpose

Reminder: tutorials start next week!

MIPS Instruction Format

2) Using the same instruction set for the TinyProc2, convert the following hex values to assembly language: x0f

Computer Architecture. Chapter 2-2. Instructions: Language of the Computer

EE 109 Unit 8 MIPS Instruction Set

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture

Q1: /30 Q2: /25 Q3: /45. Total: /100

CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Formats

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly)

SPIM Instruction Set

Lectures 3-4: MIPS instructions

Sheet For the following C code: a = b + c; b = a + c; d = a b; Write an equivalent assembly MIPS program. Solution:

COMP MIPS instructions 2 Feb. 8, f = g + h i;

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

Computer Organization MIPS ISA

ECE 30 Introduction to Computer Engineering

CSc 256 Midterm 1 Fall 2011

MIPS Hello World. MIPS Assembly 1. # PROGRAM: Hello, World! # Data declaration section. out_string:.asciiz "\nhello, World!\n"

ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013

EE 109 Unit 13 MIPS Instruction Set. Instruction Set Architecture (ISA) Components of an ISA INSTRUCTION SET OVERVIEW

Adventures in Assembly Land

Computer Architecture

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

Chapter 2. Instructions:

Transcription:

EE 352 Homework 1 Redekopp Name: Note: Attach all work to receive full credit Score: Pseudo-Instructions 1.) (11 pts.) Expand/convert each of the following pseudo-instructions to an actual MIPS instruction sequence (you may use Section B.10 of the textbook for a list of instructions. Again you can t use the ones marked pseudo-instructions.) For certain pseudoinstructions you will need to use the $at ($1) register as a temporary value (in fact, we have started this for you). Submission Instructions: For blanks, enter the register mnemonic like $t0, $at, etc. For immediate values write them as a 4-digit hex value (e.g. 0x0000). For multiple choice enter the appropriate letter of your select (e.g. a-d). For the beq/bne selection, type in your selection (e.g. beq). Pseudo-Instruction Actual Instruction Seq. 1 a.) li $t0,0x7fffabcd lui $at, ori,, b.) clear $t0 (i.e. assign $t0=0) c.) neg $t5,$t6 (i.e. $t5 = -$t6) Which of the following is not correct? a) XOR $t0,$t0,$t0 b) SUB $t0,$t0,$t0 c) ADD $t0,$0,$0 d) None of the above (i.e. they all work) sub,, d.) bgt $t1,$t2,l1 slt $at,, beq/bne $at,$0,l1 (select one)

Loads and Stores 2.) (18 pts.) Examine each of the following instructions. For the load instructions show the entire 32-bit content of $t1 (in hex) after execution of the instruction. Submission Instructions: Show the full 32-bit hex value of $t1 after each load instructions. Precede the value with the hex modified 0x (e.g. 0x12345678). $t0= 000071A8 ABCD EF01 M[0x71B8] $t1= AB125680 2345 6789 M[0x71B4] BCDE F012 M[0x71B0] 3456 789A M[0x71AC] CDEF 0123 M[0x71A8] 4567 89AB M[0x71A4] DEF0 1234 M[0x71A0] Instruction Result a) lw $t1,8($t0) $t1 = b) lbu $t1,0x13($t0) $t1 = c) lh $t1,-4($t0) $t1 = d) lw $t1,0xfffc($t0) $t1 = e) lb $t1,9($t0) $t1 = f) lhu $t1,-6($t0) $t1 = g) lb $t1,0xf($t0) $t1 = h) lhu $t1,-8($t0) $t1 = i) lb $t1,18($t0) $t1 =

3.) (7 pts.) Assume the contents of all memory locations shown below are initially 0. Perform each store instruction and then show the contents of all memory locations after all stores have been executed. Submission Instructions: Show the full 32-bit hex value of each word of memory Precede the value with the hex modified 0x (e.g. 0x12345678). Remember memory locations not changed by the store instructions should be filled with 0 s. $t0= 000071A8 Final M[0x71B8] $t1= AB125680 Memory M[0x71B4] Contents M[0x71B0] After M[0x71AC] All Stores M[0x71A8] M[0x71A4] M[0x71A0] Instruction Result a) sw $t1,8($t0) (Show in memory above) b) sb $t1,0x0d($t0) c) sh $t1,-2($t0) d) sb $t1,0xfffa($t0) e) sh $t1,4($t0)

MIPS Assembly 4.) (26 pts.) The following assembly instruction sequence implements an expression of a C- style high level language. a. Fill in the indicated result of each instruction. Assume the following initial values are true at the beginning of execution of the first instruction. Further assume all registers contain 0 s initially. Submission Instructions: Show the full 32-bit hex value of each register after execution of the instruction. Begin the value with the hex modified 0x (e.g. 0x12345678). C Variable Name Memory Contents Start Address Z 7E12 048A 0x1000E010 D 0000 0008 0x1000E00c C 4FFD 3447 0x1000E008 B 0000 0005 0x1000E004 A 68CE 8932 0x1000E000 i) lui $s0,0x1000 $s0 = ii) ori $s0,$s0,0xe000 $s0 = iii) lw $s1,0($s0) $s1 = iv) lw $s2,4($s0) $s2 = v) lw $s3,8($s0) $s3 = vi) addi $s0,$s0,16 $s0 = vii) lw $s4,-4($s0) $s4 = viii) mul $t0,$s2,$s4 $t0 = ix) addi $t0,$t0,8 $t0 = x) sub $s1,$s1,$s3 $s1 = xi) sll $s1,$s1,1 $s1 = xii) add $s5,$t0,$s1 $s5 = xiii) sw $s5,0($s0) b. Assume that the memory addresses correspond to C variables (shown above) of type int. Now use your understanding of the above instruction sequence to translate the MIPS instructions into a corresponding C style assignment statement. Select the appropriate answer below. Submission Instructions: Enter the appropriate letter representing your selection. a) Z = B*(Z+8) (A-C)/2; b) Z = B*(Z+8) 2*(A-C); c) Z = B*D + 8 + (A-C)/2; d) Z = B*D + 8 + 2*(A-C);

Assembler Directives 5.) (8 pts.) Examine the following C program variable declarations and translate them to the appropriate directives. Submission Instructions: Enter the number of your desired selection. a. short int x = 6; 1. x:.word 6 2. x:.half 6 3. x:.space 6 4. x:.align 6 b. unsigned char msg[8] = {1,4,9,7,3,6,8,2}; 1. msg:.unsigned 1,4,9,7,3,6,8,2 2. msg:.byte 0x14973682 3. msg:.byte 1,4,9,7,3,6,8,2 4. msg:.half 1,4,9,7,3,6,8,2 c. int data[100]; 1. data:.word 100 2. data:.space 100 3. data:.space 200 4. data:.space 0x190 d. char str[] = hello\n 1. str:.ascii hello\n 2. str:.asciiz hello\n 3. str:.byte hello\n 4. str:.asciiz hello

HLL to Assembly Translation 6.) (30 pts.) Translate the following C code statements to an equivalent assembly language implementation. Submission Instructions: For constants/numbers enter your values in decimal. For registers, use the descriptive mnemonic (i.e. $t0, $s1). For labels, just enter it as shown. For opcodes, enter the full opcode (e.g. b => enter bgt ). short data[20]; for(int i=0;i < 20; i++){ data[i] = data[i] + 5; } // let i be stored in $t0 int *x, *y; if(*x >= 10 && *y < 5) code A else if (*x < 10 *y > 5) code B else code C data.space.text la $s0,data add $t0,, li $t4, L0: slt $t1,,$t4 L1: b $t1,$zero, L2: sll $t2,$t0, L3: add $s1,,$t2 L4: lh $t3, L5: addi $t3,,5 L6: sh $t3, L7: addi $t0,, L8: b L9: x.space 4 y.space 4 la $s0,x la $s1,y addi $t0,,10 addi $t1,,5 lw $s2,0($s0) lw $s3,0($s1) lw $t2, lw $t3, blt,$t0, b $t3,, L1: Code A instructions L2: b L3: b $t2,$t0, L4: b $t3,$t1, L5: Code B instructions L6: b L7: Code C instructions L8: