[SOLVED] CSE220 Fall 2015 Homework 1

$25

File Name: CSE220_Fall_2015__Homework_1.zip
File Size: 263.76 KB

5/5 - (1 vote)

CSE220 Fall 2015 Homework 1

Due Friday 9/25/2015 @ 11:59pm via sparky

Thegoalof thishomeworkistobecomefamiliarwithbasicMIPSinstructionsandsyscalls. Youshouldbeabletointerpretpiecesof binarydataasdifferentnumericalformats: signed-magnitude, 1s complement, 2s complement, excess-127, excess-1023 and IEEE-754 single and double precision floating point format. You will also interpret the binary data as ASCIIcharacterswherethebytesarestoredinbothbig endianandlittleendianordering.

You MUST download the SB version of MARS posted on the PIAZZA website. DO NOT USEtheMARSavailableontheofficialwebpage.TheSBversionhasareduced instruction set and additional system calls you will need to complete the homework assignments.

DONOT COPY/SHARECODE!Wewillcheckyourassignmentsagainstthis semester and previous semesters!

Part 1: Read in Value from User

Create a new MIPS program file.
At the top of your program in comments put your name and id.

# Homework #1
# name: MY_NAME
# sbuid: MY_SBU_ID

Add instructions to your .text section of the program to print a string prompt to the screen. The prompt should ask the user to enter an integer number.

You will need to create the string in the .data section.

Enter an integer number:

Use the MARS syscall to read in the user entered integer value (syscall 5).

Fortheremainderoftheassignmentwewillcallthisenteredvalue x. Remember, all numbers read by syscall 5 are stored in binary 2s complement format.

No validation of user input is required in the assignment.

Part 2: Different Numerical Formats

In this part you will use basic MIPS instructions to read/manipulate the bits of x in order to re-represent the number in the binary representation of the other number formats.

Foreachformatyouwillprintatablewhichcontainsalabelstring,thevalueof thebinary representationinthatnumericalformat,thehexadecimalrepresentationof thenumber, the binary value of the number, and the twos complement value of the number.

REP_LABEL: REP_VALUE 0xHEX_VALUE BINARY_VALUE TWOS_COMPLEMENT_VALUE

Sample output examples:

Beginbydefining eachlabelstring inyour.datasection.

Foreachformat,youwillneedto:

  1. Print the labelstring (syscall4)
  2. Manipulatethe x valueintothebinaryrepresentationofthenumericalformat

    using bitwise and mathematical MIPS instructions

  3. Print the integer value of the rows binary representation REP_VALUE
  4. Print the hexadecimalvalue of the binary representation 0xHEX_VALUE (syscall34)
  5. Print the binary value of the representation BINARY_VALUE (syscall 35)
  6. Printthe32-bitbinaryvalueasa2scomplementnumber

    TWOS_COMPLEMENT_VALUE (syscall1)

To print sign magnitude and 1s complement values using MARS, we created additional syscalls. These syscalls are not standard and will not appear in the of f icial MARS documentation.

description syscall

print 1s comp 100 print SM 101

arguments result

$a0 = value to print $a0 = value to print

The largest negative number possible in 2s complement is not representable in signed magnitude format. To account for this, when you are converting the numberfrom2scomplementtoSMusetheinstruction addiu whenadding1.This will prevent the number from causing overflow and terminating your program.

How do I do part 2: manipulate the x value to get the different representations?

As discussed in lecture, bitwise operators can be used to mask, modify, and manipulate the bits in a register.

The following is a list of the MIPS instructions you should consider using to manipulate the bits of the register (you are not limited only to these): ADD, ADDI, AND, OR, NOR, NOT, NEG, SRL, SRA, SLL, SLT.

Ending your program

Aftertranslating to allthe different representations youshouldhave yourprogram quit. Terminate yourprogram withthe exit syscall(10).

Part 3: Extracting IEEE-754 values

In addition to the above, you will also extract inf ormation f or the IEEE-754 f ormats. Assuming that x is an IEEE-754 encoded number, you should extract the following information from the bit representation.

1. Extractthebitsforthe EXPONENT fieldandprintouttheexcess-nvalueandthe signed base 10 number it represents.

For single precision format assume this is the entire representation of the number.
For double precision format assume this is the upper 32 bits of the number.

2. Detect if the value is +, -, NaN, +0, or -0. If so print it out using the following labels: +INF

-INF NaN +0 -0

Add the printed lines to the output of your program.

IEEE-754 single precision: EXCESS_VALUE EXPONENT_VALUE [SPECIAL_VALUE]
IEEE-754 double precision: EXCESS_VALUE EXPONENT_VALUE [SPECIAL_VALUE]

[SPECIAL_VALUE] only needs to be printed if the number is a special value, otherwise it can be left blank.

Do not use FP registers or instructions! Do everything using general purpose registers only.

Part 4: ASCII & Integers

Binary values are just a sequence of bits. Therefore, as we have seen with the number representations in the previous parts, the bits can be interpreted differently to represent different pieces of information. Read in four characters then display these four characters in the same formats as part 2.

Remember each ASCII character f its in 1 byte, 4 characters f it in a word. Dont forget about MARS endianess!

Remember that ASCII characters are just bits, which can be interpreted as numbers. Try loading the decimal value 63 into a register and then print it with the

char syscall. What ASCII character prints?
The system call which reads a character puts the value into the $v0 register. You

will have to use bit shif ting to combine the inputs of each read character in a temp register to complete this part.

Hand-in instructions

See Sparky Submission Instructions on piazza for hand-in instructions.

When writing your program try to comment as much as possible. Try to stay consistent with your formatting. It is much easier for your TA and the professor to help you if we can figure out what your code does quickly. If your program doesnt work correctly the grader may be able to give you partial points, assuming he can read the code that you have written.

Reviews

There are no reviews yet.

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

Shopping Cart
[SOLVED] CSE220 Fall 2015 Homework 1
$25