Вы находитесь на странице: 1из 3

Department of Electrical and Computer Engineering

University of Texas at Austin


EE 379K, Fall 2000
Y. N. Patt, Instructor
TAs: Kathy Buchheit, Laura Funderburg, Chandresh Jain, Onur Mutlu, Danny Nold,
Kameswar Subramanian, Francis Tseng, Brian Ward
Programming Assignment 4
Due: November 21, 2000 11:59 PM
Integer to Floating-Point Conversion
Problem Statement
In this program we explore how data types can be converted to one another. We ask you
to implement a program in LC-3 assembly language that converts an integer from its 2's
complement representation into its corresponding floating-point representation and
outputs the floating-point equivalent of the 2's complement integer onto the screen. As
the LC-3 does not have a defined floating-point standard, we will first define a 16-bit
floating-point format.
16-Bit Floating-Point Format Definition
By now, you should be familiar with the 32-bit IEEE standard floating-point format. If
you want to refresh your memory, take a look at section 2.7.1 of the textbook. The wordsize of LC-3 is 16 bits. Therefore, to make things easier we will define a 16-bit floatingpoint format to be used in this program. This format consists of 1 sign bit, 6 bits reserved
for the exponent, and 9 bits reserved for the fraction. The format of a floating-point
number looks like the following:

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
s exponent

fraction

The bias of the above definition is 31, and therefore any floating-point number in the
above format evaluates to
(-1)S x 2(exponent - 31) x 1.fraction
Program Details
Your program should perform the following steps:

1. Take a 2's complement number stored in memory location x3100, convert the
number into the floating-point representation specified above, and store the
converted result into memory location x3101. Note that you will have to set
memory location x3100 with a 2's complement value before you execute your
program.
2. Output the 16-bit floating-point representation in 0's and 1's onto the screen.
Sample Output
For example, suppose memory location x3100 contains the value 0000000000011001
(decimal 25) before the program starts. After the program executes, memory location
x3101 should contain the value 0100011100100000 (floating-point 25). The program
should also output the following:
FP representation is 0100011100100000
Suppose memory location x3100 contains the value 1000000000000000

(decimal 32768) before the program starts. After the program executes, memory location x3101
should contain the value 1101110000000000 (floating-point -32768). The program
should also output the following:
FP representation is 1101110000000000

Rules
1. You are not required to perform bounds checking. Note that the 2's complement
number in memory location x3100 contains a number in the range -32768 to
32767.
2. Store the result of the floating-point conversion in memory location x3101.
3. Make sure you follow the output conventions (i.e. the output should be exactly the
same as the sample output shown above).
4. Important: When the fraction field is not enough to accurately represent the
initial integer, truncate the fraction field. The floating-point representation should
be as close as possible in value to the initial integer. For example, if memory
location x3100 contains the 2's complement representation of the integer 4147,
the floating-point representation of 4147 should be 0101011000000110. Note that
if you calculate what floating-point 0101011000000110 corresponds to, you will
get the value of 4144. This is due to the fact that, to be precisely represented in
the above floating-point format, 4147 needs a fraction field of at least 12 bits. But
our floating-point format has a fraction field of 9 bits. Therefore the least
significant three bits in the fraction of 4147 should be discarded. This is called
truncation.
Writing and submitting your program

Your code should have a comment block at the beginning of the file. Include in
this comment block, your name, your ECE login name, student number, and a
brief description of the program. Your description should serve as a general
summary of your program's approach to the problem and will aid in grading. It
will also serve as a guideline for assigning partial credit. It is in your best interest
to make all of your ideas clear through this summary and through commenting
within your code.
We request you place your program at starting at memory location x3000.
Think carefully about the design of your program before you start writing your
code. Try to make a flowchart in the beginning.
This program is due before 11:59pm on November 21. Submit your assembly file
using the submit program or the submit script. The program number is 4.
Check your ECE email to verify that you have submitted your program correctly.
If you don't get a confirmation, we might not see your submission.

Вам также может понравиться