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

Similar documents
CSC201, SECTION 002, Fall 2000: Homework Assignment #3

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

Introduction to Computers and Programming. Numeric Values

COMP Overview of Tutorial #2

MACHINE LEVEL REPRESENTATION OF DATA

Number System. Introduction. Decimal Numbers

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

Number Systems. Both numbers are positive

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

Inf2C - Computer Systems Lecture 2 Data Representation

CS 101: Computer Programming and Utilization

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

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

Chapter 3: Arithmetic for Computers

CS101 Lecture 04: Binary Arithmetic

Number representations

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

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction

Divide: Paper & Pencil

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

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

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

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

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

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

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

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

CHW 261: Logic Design

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

Project 3: RPN Calculator

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

More Programming Constructs -- Introduction

Lecture 2: Number Systems

Chapter 4. Operations on Data

Floating Point. EE 109 Unit 20. Floating Point Representation. Fixed Point

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

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

ECE260: Fundamentals of Computer Engineering

Introduction to Computer Science-103. Midterm

Introduction to Computer Science. Homework 1

UNIT 7A Data Representation: Numbers and Text. Digital Data

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

Chapter 2 Bits, Data Types, and Operations

Final Labs and Tutors

LAB WORK NO. 2 THE INTERNAL DATA REPRESENTATION

Objectives. Connecting with Computer Science 2

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

Programming Studio #1 ECE 190

CS & IT Conversions. Magnitude 10,000 1,

BINARY SYSTEM. Binary system is used in digital systems because it is:

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

EE 109 Unit 20. IEEE 754 Floating Point Representation Floating Point Arithmetic

More about Binary 9/6/2016

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

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

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

COMPUTER ARITHMETIC (Part 1)

COMP2611: Computer Organization. Data Representation

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

Chapter 2 Bits, Data Types, and Operations

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

General Instructions. You can use QtSpim simulator to work on these assignments.

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

Computer Organisation CS303

Chapter 1 Emad Felemban

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

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Chapter 2 Data Representations

EE 109 Unit 19. IEEE 754 Floating Point Representation Floating Point Arithmetic

Chapter Three. Arithmetic

COMPUTER ORGANIZATION AND. Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers

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

Floating Point Arithmetic

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

Programming Studio #1 ECE 190

Chapter 5 : Computer Arithmetic

Digital Fundamentals

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

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

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

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

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29

Data Representations & Arithmetic Operations

Advanced Computer Architecture-CS501

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other

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

Organisasi Sistem Komputer

M1 Computers and Data

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

Signed umbers. Sign/Magnitude otation

Chapter 2 Bits, Data Types, and Operations

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

Module 2: Computer Arithmetic

Signed Binary Numbers

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

Internal Data Representation

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

COMP2121: Microprocessors and Interfacing. Number Systems

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

Transcription:

1 of 7 11/8/2003 7:34 PM CSC201, SECTION 002, Fall 2000: Homework Assignment #2 DUE DATE Monday, October 2, at the start of class. INSTRUCTIONS FOR PREPARATION Neat, in order, answers easy to find. Staple the pages together at the upper left corner. Fold lengthwise. On the outside write the course number, the assignment number, the date, and your name. Thanks for your help. PROBLEMS 3. (3) Convert the following decimal numbers into hexadecimal and binary: (example: 17 decimal = 11h, or 10001b) 20 201 3. 2021 (3) Convert the following hexadecimal or binary numbers into decimal: 0Ah 2Fh 3. 1001001001b (5) Using 5 bits for each, show the unsigned, signed-magnitude, and twos-complement representations for: 0

2 of 7 11/8/2003 7:34 PM +16 3. +3 4. -5 5. -16 Just say "can't be done" for cases that can't be represented. 4. (3) 3. What SASM macro is used to extend the precision of a twos-complement 8-bit number to 32 bits? If the unsigned binary number 1010 is extended to 8 bits (with zero fill), what is the 8-bit result in binary, and what does this represent, in decimal? If the signed twos-complement number 1010 is extended to 8 bits (with sign extension), what is the 8-bit result in binary, and what does this represent in decimal? 5. (2) Convert the binary fraction.101 into decimal. Convert the decimal fraction.205 into binary. 6. (3) Normalize the following floating point numbers: Sign of mantissa Exponent (in decimal) Mantissa (in binary) 1 +8 11001 0-2 0.00011101 0-100 1100110.0 7. (2) What do the following floating point numbers represent in decimal? Sign of mantissa Exponent (in decimal) Mantissa (in binary) 0-4 0111 1 +6 0010 8. (2) In decimal, what is the maximum positive value for the exponent in the single-precision floating-point standard, and the minium negative value? In decimal, what is the maximum positive value for the mantissa in the single-precision floating-point standard, and the minimum non-zero positive value?

3 of 7 11/8/2003 7:34 PM 9. (2) Write the decimal value -10.5 in binry FPS representation (but represent the exponent in decimal). Write the decimal value +.008 in binary FPS representation (but represent the exponent in decimal). 10. (5) For each of the following, assume op1 = 10100011b and op2 = 11000101b. Ignore the fact that SASM logical and arithmetic operations work on doublewords instead of byte-length operands. What will be the new value of op1 after executing the instruction: lnot op1 lneg op1 3. land op1, op2 4. lor op1, op2 5. lxor op1, op2 1 (3) Write the SASM code to clear bits 3-0 (least significant 4 bits) of a doubleword operand labeled "op1". Write the SASM code to set bits 7-4 of operand "op1". 3. Write the SASM code to insert the value '0111' into bits 11-8 of operand "op1". 1 (4) Ignore the fact that shifting is defined for doublewords, rather than bytes, in SASM. If the value of op1 = 10000101b, what will be the new binary value of op1 after executing the instruction "rlsh op1"? If the value of op1 = 10000101b, what will be the new binary value of op1 after executing the instruction "rash op1"? 3. If the value of op1 = 10000101b, what will be the new binary value of op1 after executing the instruction "rrot op1"? 4. If the value of op1 = 10000101b, what will be the new binary value of op1 after executing the instruction "llsh op1"? 13. (3) 3. Suppose op1 is a twos-complement (signed) binary number with value 10000100b. What is this value in decimal, and (also in decimal) what is the new value of op1 after executing "rash op1"? Suppose op1 is a twos-complement (signed) binary number with value 00001101b. What is this value in decimal, and (also in decimal) what is the new value of op1 after executing "rash op1"? Suppose op1 is an unsigned binary number with value 10000100b. What is

4 of 7 11/8/2003 7:34 PM this value in decimal, and (also in decimal) what is the new value of op1 after executing "llsh op1"? 14. (2) What is the result, in binary, of multiplying the unsigned binary numbers 1001b and 0111b? What are the results (quotient and remainder), in binary, of dividing the unsigned binary number 100011b by 000110b? 15. (3) Do addition of the following 4-bit unsigned operands, show the 4-bit sum, and indicate when overflow occurs. 0110b + 0101b 0011b + 0100b 3. 1010b + 0110b 16. 17. (4) Do the indicated operation (addition or subtraction) of the following 4-bit twos-complement (signed) operands, show the 4-bit result, and indicate when overflow occurs. 0110b + 0101b 0101b - 0110b 3. 1001b - 0010b 4. 1110b + 1111b (3) Show the normalized floating point representation (decimal exponent, 4-bit mantissa (including the bit to the left of the binary point)) of the results of doing the following floating point operations: First operand (sign, exponent in decimal, mantissa) operation 0, +5, 110 + 0, +2, 010 1, +5, 110 * 0, +3, 010 0, +5, 110 / 0, +3, 010 Second operand (sign, exponent in decimal, mantissa) PROGRAMMING (30 points) Write a SASM program (named "hw2a.asm") that reads in character strings and determines if each is a syntactically valid decimal real number. The

5 of 7 11/8/2003 7:34 PM syntax rules for real numbers are as follows: A real number has two parts: a mantissa, which is mandatory, and an exponent, which is optional. The mantissa has 4 parts: a sign, an integer part, a decimal point, and a fractional part. The sign, which is optional, must be either + or - One or both of the integer part and the fractional part must be present. 3. The decimal point separates the integer and fractional parts. If there is only an integer part, there must not be a decimal point. If there is only a fractional part, there must be a decimal point. 4. The integer part and the fractional part have the same syntax. Each consists of one or more occurrences of the decimal digits 0--9. 3. The exponent consists of 3 parts: the exponent indicator, the sign, and an integer part. The exponent indicator, which is required, must be the letter E or the letter e. The sign, which is optional, must be either + or -. 3. The integer part, which is required, consists of one or more occurences of the decimal digits 0--9. Your program should expect each string to be on a line terminated with LF/CR. Every string will consist entirely of letters, digits, and punctuation marks; there will not be any embedded spaces. Here is an example of running the program. The input to the program is shown indented for clarity. In the real input, there will not be any indentation. 123E+10 3E1.E +-1E3 0E.3.123e-10-23E-3.351 abc +-.

6 of 7 11/8/2003 7:34 PM -.23E-.23 1E+15 0 0.0E0 (20) Write a program (named "hw2b.asm") which will read a string representing a single unsigned decimal integer, and print the hex (8 hex digit) and binary (32 binary digit) representations, in ASCII. An example of running the program is the following (input indented for clarity, not actually indented when being tested): 266 = 0000010Ah, 00000000000000000000000100001010b WARNING! Keep all your program files strictly in your EOS locker space, with no access given to other users. Do not put your files on the local machine, such as in temp space! If you do, you are inviting someone else to use your code, since files on the local PC file system are not protected. Use submit to turn in your 2 programs, one at a time. Be sure your programs include a header comment indicating the assignment, date, and your name. Include a reasonable number of comments in your code as well. One piece of advice. You may have difficulties with both the logic of the program, and writing the program in SASM. If that is the case, you will find it easier to first write the program in a high-level language, such as C, and make sure you get the logic right. Then manually translate your high-level code into SASM, making sure you get the assembly language programming right. GRADING This homework is graded on a scale of 100 points; the points for each problem are shown above. The homework score will be weighted to contribute 5% of your course grade. Problems will be graded according to the following interpretation: All right = full credit halfway to mostly right = half credit

7 of 7 11/8/2003 7:34 PM Not much or none right = no credit