CS 354 Midterm 1a, 33.33% Monday, October 9th, 2000 Solution

Similar documents
Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

Operations On Data CHAPTER 4. (Solutions to Odd-Numbered Problems) Review Questions

CSE 351 Midterm - Winter 2015 Solutions

CSE 351 Midterm - Winter 2015

Number System. Introduction. Decimal Numbers

CSC201, SECTION 002, Fall 2000: Homework Assignment #2

Chapter 3: Arithmetic for Computers

Final Labs and Tutors

SIGNED AND UNSIGNED SYSTEMS

CMPSCI 145 MIDTERM #1 Solution Key. SPRING 2017 March 3, 2017 Professor William T. Verts

CSE 351 Midterm - Winter 2017

Name: CMSC 313 Fall 2001 Computer Organization & Assembly Language Programming Exam 1. Question Points I. /34 II. /30 III.

CS101 Lecture 04: Binary Arithmetic

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

Computer Architecture I Midterm I

The type of all data used in a C (or C++) program must be specified

Chapter 4. Operations on Data

More about Binary 9/6/2016

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

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

231 Spring Final Exam Name:

Problem 3: Theoretical Questions: Complete the midterm exam taken from a previous year attached at the end of the assignment.

ECE 30 Introduction to Computer Engineering

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location What to bring:

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

Introduction to Computer Science-103. Midterm

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26)

CS61c MIDTERM EXAM: 3/17/99

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Format. 10 multiple choice 8 points each. 1 short answer 20 points. Same basic principals as the midterm

COMP2611: Computer Organization. Data Representation

N.B. These pastpapers may rely on the knowledge gained from the previous chapters.

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

CS 101: Computer Programming and Utilization

l l l l l l l Base 2; each digit is 0 or 1 l Each bit in place i has value 2 i l Binary representation is used in computers

2. Define Instruction Set Architecture. What are its two main characteristics? Be precise!

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

4/8/17. Admin. Assignment 5 BINARY. David Kauchak CS 52 Spring 2017

Co-processor Math Processor. Richa Upadhyay Prabhu. NMIMS s MPSTME February 9, 2016

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

Lecture 8: Addition, Multiplication & Division

Fundamentals of Programming Session 2

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

LAB A Translating Data to Binary

SISTEMI EMBEDDED. Basic Concepts about Computers. Federico Baronti Last version:

Run time environment of a MIPS program

The type of all data used in a C++ program must be specified

CMSC 313 Fall2009 Midterm Exam 1 Section 01 October 12, 2009

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

17. Instruction Sets: Characteristics and Functions

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

Shift and Rotate Instructions

Zheng-Liang Lu Java Programming 45 / 79

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3

Computer Organisation CS303

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

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Time (self-scheduled): Location Schedule Your Exam: What to bring:

CSc 256 Midterm 1 Fall 2011

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

COS 471A,COS 471B/ELE 375 Midterm

Types, Variables, and Constants

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2)

World Inside a Computer is Binary

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

More Programming Constructs -- Introduction

Chapter 3 Machine Instructions & Programs. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Portland State University. CS201 Section 5. Midterm Exam. Fall 2018

231 Spring Final Exam Name:

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

Number Systems and Computer Arithmetic

CS61C L10 MIPS Instruction Representation II, Floating Point I (6)

Chapter 2 Bits, Data Types, and Operations

DEPARTMENT OF MATHS, MJ COLLEGE

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

CHW 261: Logic Design

Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

Midterm II CS164, Spring 2006

Adding Binary Integers. Part 5. Adding Base 10 Numbers. Adding 2's Complement. Adding Binary Example = 10. Arithmetic Logic Unit

Topic Notes: Bits and Bytes and Numbers

CPS 104 Computer Organization and Programming Lecture-2 : Data representations,

Arithmetic for Computers

Computer Organization CS 206 T Lec# 2: Instruction Sets

COMP2121: Microprocessors and Interfacing. Number Systems

Chapter 2 Bits, Data Types, and Operations

Chapter 4: Data Representations

McGill University School of Computer Science COMP-202A Introduction to Computing 1

Signed Multiplication Multiply the positives Negate result if signs of operand are different

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

CS & IT Conversions. Magnitude 10,000 1,

ECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION

Digital Fundamentals

Topic Notes: Bits and Bytes and Numbers

Number Systems and Their Representations

Divide: Paper & Pencil

CPE300: Digital System Architecture and Design

Chapter 5 : Computer Arithmetic

Transcription:

CS 354 Midterm 1a, 33.33% Monday, October 9th, 2000 Solution Parts Number of Questions Question Format Possible Points Score I 6 Short Answer 20 II 5 Multiple Choice 15 III 5 True or False 10 IV 6 Calculations 30 V 3 Coding 25 Total 100 2000Deb Deppeler page: 1 Page Score: SOLUTION

Part I Short Answer [6 questions for a total of 20 total points] For questions 1 through 6, write your answers clearly and concisely. 1.) (3 points) What is an assembler directive? Assembler directives are instructions to the assembler rather than insturctions to be executed as part of the program. 2.) (2 points) Give an example of an assembler directive that can be used in a SAL program. Examples include.data,.byte,.word,.float,.space,.text 3.) (6 points) List (or briefly explain) each step in the execution of an arithmetic instruction. 1. Fetch the instruction from memory. 2. Update the program counter (PC) to point to the next instruction. 3. Decode the instruction that was retrieved in step 1. 4. Load source operands (this may require 0-2 memory accesses) 5. Execute the instruction 6. Store the results of the execution. 4.) (2 points) Explain how the steps in question 3 would be different if the instruction being executed was a branch instruction instead of an arithmetic instruction. There would be no store of the results, but instead step 6 would modify the program counter if the branch condition was true. 5.) (2 points) Explain how the steps in question 3 would be different if the instruction being executed was a logical or a shift instruction instead of an arithmetic instruction. The steps would be the same as for arithmetic instructions. 6.) (5 points) Describe how the SAL assembly programming language is an abstraction of the underlying machine language of a machine. (Hint: Briefly describe what an abstraction is and how SAL fits that definition.) An abstraction is a simplified model of something that hides unimportant details from view. One way that SAL is an abstraction of a true assembly language and the underlying machine language the fact that it allows the programmer to access memory through labels (like variables) instead of having to use the address of a memory location. 2000Deb Deppeler page: 2 Page Score: SOLUTION

Part II Multiple Choice [5 questions, 3 points each, 15 total points] For questions 1 through 5, choose the one best answer after reading ALL of the choices. Circle the corresponding letter on this page. 1.) Which of the following SAL instructions has the same effect as the Java statement? count++; A. move count, count, 1 B. sub count, count, -1 C. add count, count, 1 D. All of the above E. B and C above 2.) How many distinct values can be represented in 17 bits? A. 2 (17-1) + 1 B. 2 (17-1) C. 2 17 D. 2 17-1 E. 2 (17-1) - 1 3.) What does the following hexidecimal value represent? 0xA3409BC2 A. an unsigned binary integer B. a negative IEEE floating point real C. four characters D. a negative twos complement integer E. can t be determined from information given 4.) Which of the following statements is not true? A. If the head pointer equals the tail pointer of a circular queue, the queue may be empty or full. B. Stacks and queues are implemented in SAL by reserving a contiguous block of memory and using other memory cells to keep track of the contents of that block of memory cells. C. Data can be stored in SAL arrays in either row-major order or column-major order. D. A two- dimensional array of characters can be declared using the syntax: ch:.byte 0 :3:4 E. Data structures are used to organize memory to make data retrieval more efficient. 5.) The range of valid decimal integers that can be represented in 32-bit two s complement is: A. -2,147,483,648 to 2,147,483,648 B. -2,147,483,648 to 2,147,483,647 C. -2,147,483,647 to 2,147,483,648 D. -2,147,483,647 to 2,147,483,647 E. -2,147,483,646 to 2,147,483,647 2000Deb Deppeler page: 3 Page Score: SOLUTION

Part III True or False [5 questions, 2 points each, 10 total points] Circle true or false for each statement. If both are marked your answer will be marked inccorrect. 1.) ( true / false) The MIPS architecture uses two s complement representation to store integer values. 2.) (true / false) Procedures written in SAL can not have parameters. 3.) ( true / false) Read data from and write data to are the only operations that can be performed on memory. 4.) ( true / false) The load address instruction (in SAL) is used to store the return address in an integer variable before making the call to a procedure. 5.) (true / false) High level languages are usually translated directly into machine language by an assembler. FALSE, HLLs are almost always compiled first into assembly language before being assembled into machine language. 2000Deb Deppeler page: 4 Page Score: SOLUTION

Part IV Calculations [6 questions for a total of 30 points] Show all work for these questions. Full credit will not be given without work. Write in English what you would do, if you are unable to complete the actual calculation. If you need more room, use the back of the page and indicate your work continues on the back. Additional work pages may be requested from your exam proctor. You must turn in any additional work pages with your exam. 1.) (6 points) Complete the following table. The column heading tells which number system to use to represent the value for each row. See reference pages for a table of Roman Numerals. decimal unsigned binary base 7 Roman Numerals 55 110 106 LV 118 0110 226 CXVIII 2.) (5 points) Given a 10 x 17 array of words (10 rows x 17 columns) with a base address of 0x00400000, what is the address of the third word in the second row? You should assume byte-addressability and columnmajor order. Show your work for full credit. Use hexidecimal notation to show the final address of the specified word. 0x0040000 + (2-0)(10 rows)(4 bytes) + (1-0)(4 bytes) = 0x00400000 + 8(10) + 4 = 0x00400000 + 01010100 2 = 0x00400000 + 0x54 = 0x00400054 3.) (3 points) What is the 8-bit result of adding the following sign-magnitude numbers? Write OVERFLOW if the result can not be represented in 8-bit sign-magnitude. 10001101 => 1 0001101 1 1001 + 01001-1 1001-1 0001101 ---------- ----------- ----------- 0 1000 change sign to positive after changing order of subtraction 4.) (6 points) What is the decimal equivalent of the following hexidecimal value if it is interpreted as an IEEE 32-bit single precision value? 0x43A6E800 1. Convert to binary 0100 0011 1010 0110 0 1000 0000 0000 2. Separate into SEF S=0 E=1000 0 F=010 0110 0 1000 0000 0000 3. Sign is positive. 4. Exponent e = E - 127 = 135-127 = 8 5. Mantissa = 1.F = 1.010 0110 0 1000 0000 0000 6. Binary value = +1.010 0110 0 1000 X 2 8 7. Un-normalized = 101001101.1101000 X 2 8 8. Decimal value = 256+64+8+4+1 +.5 +.25 +.0625 = 333.8125 2000Deb Deppeler page: 5 Page Score: SOLUTION

5.) (5 points) Perform the following division of two unsigned binary values. 11010011 / 00000 = 00010.001001 (repeats 001 from here) ------------------------- / 11010011.0000000000 ---- 1100 I ---- 1010 ---- --- 01 000 --- 1000 (repeats above) 6.) (5 points) Show the two s complement multiplication of the following two integers. Convert your answer to decimal. 00010101 x 11010 ----------- 1 1 1 1010 * 0000 0000 0001 0101 --------------------- 1 1 1 1 1 1010 1010 1011 (carry bit) 1 1 1 1010 11 1 1 0 1000 + 1 1 1 1010 0000 -------------------------- 1 1 1000 0010 (ignore carry-out of msb) The decimal value is = -124 2000Deb Deppeler page: 6 Page Score: SOLUTION

Part V Coding [3 questions, 25 total points] 1.) Answer the questions that follow this SAL program by examining the code and tracing the execution of this program..data aa:.word 0:32 bb:.word cc:.word dd: ee:.byte.word.text start: la bb, aa la ee, ff b hh ff: la bb, aa add cc, bb, 84 move dd, m[cc] put dd add cc, cc, -2 move dd, m[cc] put dd add move put put cc, bb, 0x45 dd, m[cc] dd dd add cc, bb, 33 move dd, m[cc] put dd put \n gg: done hh: add bb, bb, 32 move dd, ii: move m[bb], dd add dd, dd, 1 add bb, bb, 1 ble dd, 90, ii b (ee) A. (2 points) There is one procedure implemented in this program. What is the label at the start of that procedure? hh B. (5 points) What does that procedure do? It initializes part of the array aa to the ASCII characters from the space character ( ) to the capital letter ( Z ) C. (5 points) What does the program print? TREE! 2000Deb Deppeler page: 7 Page Score: SOLUTION

2.) (8 points) Fill in the following procedure that prints a number in any base between 2 and 10. Assume that the caller has correctly initialized the variable int with a positive decimal value to be represented and the variable base with a valid radix to be used to display the value..data print_integer_ra:.word # the return address has been initialized int:.word # the integer has been initialized base:.word # the base has been initialized result:.byte :50 start:.word result sp:.word result ch:.byte digit:.word quot:.word size:.word.text print_integer: move quot, int next: rem digit, quot, base div quot, quot, base sub ch, digit, 0 move m[sp], ch add sp, sp, size bnez quot,next pnext: sub put bgt b sp, sp, size m[sp] sp, start, pnext (print_integer_ra) 3.) (5 points) What is the binary representation of the contents of variable x after the following code fragment has been executed? (Show the value after each instruction for partial credit).data x:.word.text start: move x, -15 # 1 1 1 1 1 1 1 0001 sll x, x, 4 # 1 1 1 1 1 1 0001 0000 srl x, x, 4 # 0000 1 1 1 1 1 1 0001 ror x, x, 2 # 0100 0011 1 1 1 1 1 1100 # 0 1000 0011 0010 0001 0000 0 1 xor x, x, 0xe83210ef # 1010 1011 1100 1101 0 1 0001 0011 2000Deb Deppeler page: 8 Page Score: SOLUTION