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

Similar documents
CONCORDIA UNIVERSITY Department of Computer Science and Software Engineering COMP 228/4 Section PP Midterm Exam

Assembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

Assembly Language. Lecture 2 x86 Processor Architecture

Introduction to Computers and Programming. Numeric Values

Practical Malware Analysis

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

mith College Computer Science Fixed-Point & Floating-Point Number Formats CSC231 Dominique Thiébaut

Computer Organisation CS303

Chapter 3: Arithmetic for Computers

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

mith College Computer Science Fixed & Floating Point Formats CSC231 Fall 2017 Week #15 Dominique Thiébaut

EC 413 Computer Organization

UMBC. A register, an immediate or a memory address holding the values on. Stores a symbolic name for the memory location that it represents.

CSE351 Spring 2018, Midterm Exam April 27, 2018

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated

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

mith College Computer Science Fixed-Point & Floating-Point Number Formats CSC231 Assembly Language Week #13 Dominique Thiébaut

17. Instruction Sets: Characteristics and Functions

Machine and Assembly Language Principles

Assembly level Programming. 198:211 Computer Architecture. (recall) Von Neumann Architecture. Simplified hardware view. Lecture 10 Fall 2012

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

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

Machine Code and Assemblers November 6

Representation of Information

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,...

MACHINE LEVEL REPRESENTATION OF DATA

Computer Architecture and Assembly Language. Practical Session 5

The Instruction Set. Chapter 5

Divide: Paper & Pencil

Number Systems. Both numbers are positive

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

Birkbeck (University of London) Department of Computer Science and Information Systems. Introduction to Computer Systems (BUCI008H4)

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

Number Systems and Computer Arithmetic

Computer Systems Organization V Fall 2009

Ethical Hacking. Assembly Language Tutorial

Review Questions. 1 The DRAM problem [5 points] Suggest a solution. 2 Big versus Little Endian Addressing [5 points]

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

mith College Computer Science Fixed-Point & Floating-Point Number Formats CSC231 Assembly Language Week #14 Dominique Thiébaut

M1 Computers and Data

COMP Overview of Tutorial #2

administrivia today start assembly probably won t finish all these slides Assignment 4 due tomorrow any questions?

Inf2C - Computer Systems Lecture 2 Data Representation

Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

CS , Fall 2004 Exam 1

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

ADDRESSING MODES. Operands specify the data to be used by an instruction

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

Birkbeck (University of London) Department of Computer Science and Information Systems. Introduction to Computer Systems (BUCI008H4)

/ 28 HLL assembly Q4: Conditional instructions / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

CMSC 313 Lecture 08 Project 2 Questions Recap Indexed Addressing Examples Some i386 string instructions A Bigger Example: Escape Sequence Project

Number System. Introduction. Decimal Numbers

Lecture 2 Assembly Language

The ALU consists of combinational logic. Processes all data in the CPU. ALL von Neuman machines have an ALU loop.

CSE2421 FINAL EXAM SPRING Name KEY. Instructions: Signature

Module 2: Computer Arithmetic

Computer (Literacy) Skills. Number representations and memory. Lubomír Bulej KDSS MFF UK

Numerical Representations On The Computer: Negative And Rational Numbers

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C

CMSC 313 Lecture 07. Short vs Near Jumps Logical (bit manipulation) Instructions AND, OR, NOT, SHL, SHR, SAL, SAR, ROL, ROR, RCL, RCR

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

Topic Notes: Bits and Bytes and Numbers

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

COS 140: Foundations of Computer Science

Sample Exam I PAC II ANSWERS

Floating Point Arithmetic

ALT-Assembly Language Tutorial

Numerical Representations On The Computer: Negative And Rational Numbers

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

FLOATING POINT NUMBERS

Topic Notes: Bits and Bytes and Numbers

UMBC. contain new IP while 4th and 5th bytes contain CS. CALL BX and CALL [BX] versions also exist. contain displacement added to IP.

SOEN228, Winter Revision 1.2 Date: October 25,

mith College Computer Science CSC231 - Assembly Week #3 Dominique Thiébaut

Question 4.2 2: (Solution, p 5) Suppose that the HYMN CPU begins with the following in memory. addr data (translation) LOAD 11110

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

Introduction to Computer Science-103. Midterm

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

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

System Programming and Computer Architecture (Fall 2009)

Chapter Three. Arithmetic

CS 3843 Final Exam Fall 2012

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 4 Solution

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

UW CSE 351, Winter 2013 Midterm Exam

CS 101: Computer Programming and Utilization

Complex Instruction Set Computer (CISC)

Module 3 Instruction Set Architecture (ISA)

Compiler construction. x86 architecture. This lecture. Lecture 6: Code generation for x86. x86: assembly for a real machine.

15-213/18-243, Spring 2011 Exam 1

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

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

16.317: Microprocessor Systems Design I Fall 2014

COMPUTER ORGANIZATION & ARCHITECTURE

Data Representation and Architecture Modeling Year 1 Exam preparation

Course Syllabus [1/2]

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

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

Transcription:

CMSC 313 Fall 2001 Computer Organization & Assembly Language Programming Exam 1 Name: Question Points I. /34 II. /30 III. /36 TOTAL: /100 Instructions: 1. This is a closed-book, closed-notes exam. 2. You have 75 minutes for the exam. 3. Calculators are not allowed.

I. Multiple Choice (2 points each) For each question in this section, circle 1 answer. Choose the best answer. 1. In an n-bit one s complement representation, (a) 2 n 1 integers can be represented. (b) an end-around carry is required when performing addition. (c) negation is performed by complementing every bit. (d) all of the above are true. 2. An overflow has occurred when adding two s complement numbers, if (a) there is a carry out of the most-significant bit (MSB). (b) there is a carry into the MSB. (c) the carry into the MSB differs from the carry out of the MSB. (d) the carry into the MSB equals the carry out of the MSB. 3. When 2 two s complement numbers are added, a carry out of the most-significant bit indicates (a) an overflow has occurred. (b) the result is negative. (c) the result is correct as long as the addends are negative. (d) none of the above. 4. The IEEE floating point representation uses an excess 127 representation for the exponent and a signed magnitude representation for the mantissa because (a) it is the easiest format for addition. (b) the size of two numbers can be compared directly. (c) multiplication and division are possible with this format. (d) this representation requires fewer bits than the alternatives. 5. In the process of normalizing a floating point number, a mantissa with leading zeroes is shifted left and the exponent is (a) decreased by the number of positions the mantissa is shifted. (b) increased by the number of positions the mantissa is shifted. (c) divided by 2. (d) unchanged. 1

6. A CPU designed using a RISC architecture allows (a) assembly language programs to be written more easily. (b) programs to be written with fewer instructions. (c) the processor to run at a faster clock speed. (d) all of the above. 7. On the Intel Pentium CPU, the ModRM byte (a) designates the registers to be used by an instruction. (b) specifies the memory location to be referenced. (c) permits indirect addressing. (d) changes the instruction to 16-bit mode. 8. Executing a CALL instruction on the Intel Pentium CPU causes changes in (a) the ESP register. (b) the EBP register. (c) the ESP and EBP registers. (d) the ESP, EBP and EAX registers. 9. Which of the following is not a legal instruction for the Intel Pentium CPU? (a) add eax, ebx (b) add [eax], [ebx] (c) add [eax], ebx (d) add eax, [ebx] 10. The difference between a short jump and a near jump is: (a) NASM does not handle conditional near jumps. (b) a short jump uses an 8-bit relative address and a near jump uses a 32-bit relative address (c) a short jump uses relative addresses and a near jump uses absolute addresses. (d) a short jump uses an 8-bit absolute address and a near jump uses a 32-bit absolute address. 2

11. What is the effect of the following instruction? mov ecx, [esi + eax] (a) The content of esi is added to the content of eax andthesumisstoredinecx. (b) The content of the memory location whose address is stored in esi is added to the content of eax. This sum is stored in ecx. (c) The source operand is stored in memory. The address of this memory location is computed by adding the content of esi to the content of eax. (d) The source operand is the sum of two memory locations. The first memory location s addressisstoredinesi, the second s in eax. 12. The difference between a signed conditional jump (e.g., jge) and an unsigned conditional jump (e.g., jae) is: (a) A signed jump must be preceded by a signed comparison and an unsigned jump by an unsigned comparison. (b) An unsigned jump can only jump to locations with higher memory addresses, but a signed jump can jump to higher or lower addresses. (c) Nothing, jge and jae are mnemonics for the same machine instruction. (d) none of the above. 13. The PDP-8 was (a) the fastest computer available when it was first sold. (b) the first widely sold minicomputer. (c) a high-performance RISC machine. (d) an early 8-bit computer. 14. The PDP-8 instructions referenced addresses throughout the entire memory (a) using index registers. (b) directly in the instruction s address field. (c) using relative addressing. (d) none of the above. 3

15. Consider a label foo in the.data section of an assembly language program. If the program is transformed into an executable program with the tools used for the projects in this class, a virtual memory address is assigned to foo (a) by the assembler. (b) by the linking-loader during the linking phase. (c) by the linking-loader during the loading phase. (d) none of the above. 16. The Linux operating system has a virtual memory system that (a) uses segment registers to achieve memory protection. (b) limits each process to 64 megabytes of physical memory in 32-bit mode. (c) provides each process with 4 gigabytes of physical memory. (d) assigns every process its own set of page tables. 17. A two-pass assembler takes two passes to (a) determine the number of bytes in each instruction. (b) resolve external references. (c) resolve forward references. (d) all of the above 4

II. Short Answers (3 points each) For each question in this section, show all of your work. Clearly indicate your final answer. 1. Describe the fetch-execute cycle. 2. Give the binary representation of -15 in each of the following data representations (a) 8 bit one s complement (b) 8 bit signed magnitude (c) 8 bit excess 127 3. What decimal number is represented by the following 8 bit two s complement integers? (a) 00010110 (b) 11110101 (c) 11110001 5

4. Add the hexadecimal numbers 7C9 and 77. 5. A floating point representation uses a sign bit, a 4-bit exponent in excess 7 notation, and a 5-bit fractional mantissa with no hidden bit. (a) (2 points) What number is represented by the binary sequence: 0 1001 11000 (b) (1 point) Is the binary sequence in part a) in normalized form? 6. Four contiguous bytes in memory contain the hexadecimal values 12, 34, 56 and 78 in the order of increasing address. If these bytes are used to store a 32-bit integer in little-endian format, what is the integer? (Give your answer in hexadecimal.) 7. What is 24 10 in base 7? 8. Multiply the following 4 bit two s complement numbers: 1110 1101. What is the result in decimal? 6

9. Give one reason for a CPU to have an interrupt mechanism. 10. Consider the virtual memory system used by Linux running on an Intel Pentium CPU. (a) (2 points) Name two advantages for having virtual memory. (b) (1 point) Name one disadvantage for having virtual memory. 7

III. Short Programs (12 points each) 1. Consider the following code fragment. What are the contents of the eax, ebx and ecx registers after the code fragment has been executed? Show your work. section.data x: dd 32 y: dd 17 section.text mov eax, x mov ebx, [eax] mov ecx, [eax + 4] add ebx, [x] add ecx, ebx mov eax, [eax] 2. Consider a C function prime with the following function prototype: int prime(int n, int m); This function returns the first prime number between n and m, inclusive. Write an assembly language program which calls the function prime to find the first prime number between 1500 and 3000 and stores this number in the ecx register. Recall that 4-byte values returned from a C function are stored in the eax register. 8

3. Consider the following C function prototype: void larger(int *result_ptr, int *ptr1, int *ptr2); A program that implements this function should examine the int values stored at the locations designated by ptr1 and ptr2, then store the larger of these two int values at the location specified by result ptr. Write an assembly language program that implements the function larger. Your program must follow the parameter passing convention for C functions as described for Project 2. 9

This page intentionally left blank. 10