[SOLVED] 代写 LC-3 assembly Integer to Floating-Point Conversion

30 $

File Name: 代写_LC-3_assembly_Integer_to_Floating-Point_Conversion.zip
File Size: 536.94 KB

SKU: 8555086104 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


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 word size of LC-3 is 16 bits. Therefore, to make things easier we will define a 16-bit floating point 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:

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 x4000, convert the number into the floating-point representation specified above, and store the converted result into memory location x4001. Note that you will have to set memory location x4000 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 x4000 contains the value 0000000000011001
(decimal 25) before the program starts. After the program executes, memory location
X4001 should contain the value 0100011100100000 (floating-point 25). The program
should also output the following:
FP representation is 0100011100100000

Suppose memory location x4000 contains the value 1000000000000000 (decimal –
32768) before the program starts. After the program executes, memory location x4001
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 x4000 contains a number in the range -32768 to
32767.
2. Store the result of the floating-point conversion in memory location x4001.
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 x4000 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 testing your program
Your code should have a comment block at the beginning of the file containing your name, your 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.

IMPORTANT NOTE:
The first line of your program must specify the memory address of where you want your program to be placed (using the .ORIG pseudo-op).
We request you place your program at x3000.

What to turn in
Please put all your files (lab2.asm, and lab2_readme.docx)
Test cases:
No
Dec
Hex
Float
Value
1
-32768
X8000
Xdc00
-32768
2
32767
X7fff
X5bff
32736
3
4147
X1033
X5606
4044
4
0
X0000
X0000
0
5
1
X0001
X3e00
1
6
-1
xffff
Xbe00
-1

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 LC-3 assembly Integer to Floating-Point Conversion
30 $