Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Data Type Converter Assignment for CS 061 - Computer Organization & Assembly Language, Assignments of Computer Science

An assignment for cs 061 students to build a data type converter program. The program should take user input of decimal integers, 2's complement binary integers, or hexadecimal numbers and convert them to the other two data types. Collaboration policy, notes, and grading policy.

Typology: Assignments

2009/2010

Uploaded on 03/28/2010

koofers-user-su6-2
koofers-user-su6-2 ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 061 โ€“ Computer Org. & Assembly Lang. Winter -
2004
Assignment 6 โ€“ due Saturday 2/21, 11 pm (secure server turnin)
Collaboration policy:
This program is designed in part for us to determine how well you are able to program. Thus,
every part of the program should be your own original work, and should not be substantially
similar to other students' code, or code from books, previous solutions, the web, etc. -- like
other skills (e.g., surgery), the only way to really learn programming is to do it yourself. Some
collaboration is OK, including discussing the general solution method, and some debugging
assistance after a student has tried hard to solve the bug him/herself. We DO encourage you
to work with others nearby, so if you get stuck, you can get help. But you should not show your
code to another student in order to help that student.
The bottom line is you can talk about the code as much as you like, but you may not write any
code for another student, or let another student copy your code.
Data type converter
Warning: this is a lengthy program โ€“ make sure you get an early start!!!!!
Use the programs you developed in previous assignments (or the solutions posted on the ilearn site) as a starting
point for this assignment: in effect, each previous assignment will become a subroutine in this one.
Build a data type converter that prompts the user to enter one of the following types of input:
a) a decimal integer, indicated by the prefix โ€œ#โ€, in the range โ€“32k to +(32k-1); or
b) a 2โ€™s complement binary integer, indicated by the prefix โ€œbโ€, from 1 to 16 bits; or
c) a hexadecimal number, indicated by the prefix โ€œxโ€, from 1 to 4 digits.
In each case, the number of input digits is not fixed โ€“ i.e. completion of input is indicated by cr/lf (i.e. ASCII char
x0A). Also, the decimal number may be prefixed by + or โ€“ signs, but not the hex or binary numbers.
OUTPUT:
Then, convert the input value to both the other two data types and write them to the console:
e.g. given a decimal input
#10
the output will be something like:
pf3
pf4

Partial preview of the text

Download Data Type Converter Assignment for CS 061 - Computer Organization & Assembly Language and more Assignments Computer Science in PDF only on Docsity!

CS 061 โ€“ Computer Org. & Assembly Lang. Winter -

Assignment 6 โ€“ due Saturday 2/21, 11 pm (secure server turnin)

Collaboration policy:

This program is designed in part for us to determine how well you are able to program. Thus,

every part of the program should be your own original work , and should not be substantially

similar to other students' code, or code from books, previous solutions, the web, etc. -- like

other skills (e.g., surgery), the only way to really learn programming is to do it yourself. Some

collaboration is OK, including discussing the general solution method, and some debugging

assistance after a student has tried hard to solve the bug him/herself. We DO encourage you

to work with others nearby, so if you get stuck, you can get help. But you should not show your

code to another student in order to help that student.

The bottom line is you can talk about the code as much as you like, but you may not write any

code for another student, or let another student copy your code.

Data type converter

Warning: this is a lengthy program โ€“ make sure you get an early start!!!!! Use the programs you developed in previous assignments (or the solutions posted on the ilearn site) as a starting point for this assignment: in effect, each previous assignment will become a subroutine in this one. Build a data type converter that prompts the user to enter one of the following types of input: a) a decimal integer, indicated by the prefix โ€œ#โ€, in the range โ€“32k to +(32k-1); or b) a 2โ€™s complement binary integer, indicated by the prefix โ€œbโ€, from 1 to 16 bits; or c) a hexadecimal number, indicated by the prefix โ€œxโ€, from 1 to 4 digits. In each case, the number of input digits is not fixed โ€“ i.e. completion of input is indicated by cr/lf (i.e. ASCII char x0A). Also, the decimal number may be prefixed by + or โ€“ signs, but not the hex or binary numbers. OUTPUT: Then, convert the input value to both the other two data types and write them to the console: e.g. given a decimal input # the output will be something like:

#10 = b #10 = x0A or you may choose the format: #10 = b0000 0000 0000 1010 #10 = x000A Note that if the number entered is a decimal negative, you will first convert it to 2โ€™s complement binary, and only then convert the resulting binary to hex: Input: # - Output: **# -1 = b1111 1111 1111 1111

-1 = xFFFF**

If a negative binary, or its eqivalent hex is input, the conversion to decimal must show both sign and magnitude: Input: xFFFF Output: xFFFF = b1111 1111 1111 1111 xFFFF = # - Use subroutines for all functions โ€“ input, conversion, and output โ€“ so your โ€œmainโ€ routine will be little more than a sequence of calls to these subroutines. ERROR CHECKING: As in previous assignments, test the input for invalid characters (e.g. letters in a decimal input, letters >F in a hex input, anything other than 0 or 1 in a binary input). For hex numbers, you may choose to restrict input to only upper case letters, or only lower case letters. If an error is detected, output an error message and return to the initial prompt. NOTES:

  1. As indicated, the hex output will be the hex representation of the 2โ€™s complement number โ€“ i.e. do not use +/- signs with the hex data type in either input or output.
  2. You may choose to output binary numbers always as 16 bits, or using only as many bits as are needed to express the number. If you choose the latter, you must ensure that there are enough bits to include the sign information โ€“ e.g. in the example above b1010 would not equal #10 , but would actually be the 4-bit 2โ€™s complement representation of - #6. Likewise, the hex representation of the resulting binary number must have enough digits to include the sign bit: so #10 = x0A , not xA.

Grading policy: Possible points: 10 Program assembles without errors: 3 Program runs correctly on LC-3 simulator 5 Well commented code: 2 Assignment submitted without name and SSN: -5 points (if we can figure out who you are!) Assignment submitted to the wrong folder: WONโ€T BE GRADED!!!!!