|
|
c m s c 311
s u m m e r 2 0 0 2 |
Due Tuesday, June 11, 11:59 PM (just before midnight)
Late Due Date Sunday, June 16, 11:59 PM (just before midnight)
Posted: June 5, 2002
Addendum
Read this section frequently to check for updates/corrections/clarifications to the projects.
Please note that *all* programming projects in this course (including this one) are to be done independently or with the assistance of the instructional staff of this course only, unless otherwise specified IN PRINT by official webpages.
Please review the policies outlined on the class syllabus concerning the use of class computer accounts and concerning the University's Code of Academic Integrity. The instructors of this course will review the programs submitted by students for potential violations of the Code of Academic Integrity and if it is believed that a violation has occurred it will be referred to the Office of Judicial Programs and the Student Honor Council.
Hardcoding is considered a violation of academic integrity
To change your finger information, type:
chfn
You should ONLY change your name. Please have your first
and last name as you are registered in the system. For example,
if you are registered as "Samir Khuller", please use "Samir Khuller"
rather than "Sammy Khuller" or "Biff Khuller", even if you prefer
to be called "Biff".
Ignore the parts that ask you for your phone number, office, etc. Just hit return, and don't fill anything in.
In addition, you will probably also want to change your password.
passwd
Notice the unusual spelling of "passwd".
This will ask for your original password, then your new password, and the new password again. If you use "ssh", it may take a day or so to take effect (it might work right away though). If you use "telnet", the changes should be immediate.
p0 < input.datThis should cause your output to be printed to the screen.
Note: you do NOT open a file. Write your program as if the user is typing in commands to your program (i.e., read from standard input). Print output to standard output (i.e., to the screen). Input redirection allows the input to be read from a file WITHOUT having to open the file.
Each line of the input file consists of a command or a blank line. A blank line is defined to be 0 or more blank spaces, ending in a newline character (by definition, a line MUST end in a newline character or EOF). Your program should ignore blank lines and not print any output if blank lines are encountered.
After each command, you should print:
===> (3) Command entered: [endian]
where (3) is replaced by the command number (which begins
numbering at 0), and the string in double quotes is the command line
from the input file (obviously, it won't always be "endian").
The output should consist of three equal signs, and a greater than sign, then a space, a left parentheses, the command number, right parentheses, a space, then "Command entered:", a space, and the command surrounded by brackets.
The command line should be surrounded by brackets, and should not have any leading or trailing blanks (i.e., don't print [ endian ], print [endian]).
This line will be referred to as the initial output, and should be printed after reading each non-blank line of input.
Your program should handle the following commands:
After the initial output, print:
This machine is little-endian.
or
This machine is big-endian.
This should be determined by your program. Do not HARDCODE the answer. If you can't figure out how to do it, simply write:
Be careful to spell your output EXACTLY as shown, including the period and the dash.
Unknown endian-ness.
This command has 5 arguments, which is separated by at least one blank space.
num is stored in big-endian format.
or
num is stored in little-endian format.
or
num is neither stored in little-endian nor big-endian format.
where num is replaced by the value typed in. The choice of output depends on what numbers are entered.
You should assume the FIRST 2 hex digits are stored in the memory location with the smallest address, and the next 3 pairs of hex digits are stored in consecutively increasing addresses.
Here's a sample command:
endian 10 00 00 00 0A
You program should print:
===> (3) Command entered: [endian 10 00 00 00 0A]
10 is stored in big-endian format.
where type is either int, short, long, float, double, char, or char *.
After the initial output, you should print:
[int] requires 4 bytes of memory.
where int is replaced by the type entered by the user,
and 4 replaced by the value given by sizeof.
You may assume that only the types listed above are given (thus, you won't be asked to find the type of "unsigned int").
where source is written in base k where 2 <= k <= 36 and base is a value between 2 and 36.
After the initial output, you should print:
Base k: source
Base m: dest
where source is the original number typed in, k
is the base of the original number, m is the new base, and
dest is the new value. You should print m with
as few digits as needed to represent the number (at least one
digit).
source is written as the number, followed by an underscore, followed by a base 10 number representing the source base. For example, 1A23_12 means the number 1A23 in base 12.
Use the convention that A = 10, B = 11, C = 12, etc. Print characters in uppercase.
You may assume source can be stored in an unsigned int (i.e., it's max value is 232 - 1).
You MUST use code to make the appropriate conversions shown in class. Any built-in functions which convert the numbers for you are NOT to be used. (However, you may point out any such functions in a README).
You may assume the source value has correct syntax (i.e., the number is written correctly for the base). Thus, you won't have 99_4 (since 99 is a non-existent number in base 4) in the test files.
where num is a base 10 unsigned number (which you may assume can be stored in a 32 bit value). After the initial output, you should print something of the form:
12 in little-endian is stored as [0C 00 00 00]
where 12 and the 4 pairs of hex digits are replaced by num and the representation in memory (where the first pair of hex digits is stored in the smallest address and the last pair is stored at the largest address).
12 in big-endian is stored as [00 00 00 0C]
where 12 and the 4 pairs of hex digits are replaced by num and the representation in memory (where the first pair of hex digits is stored in the smallest address and the last pair of hex digits is stored at the largest address).
where cmmd is replaced by one of three things: a binary bitstring (just a pattern of 0's and 1's), an octal number, or a hexadecimal value. Binary bitstrings will begin with "0b" (e.g. "0b0111"). Octal numbers begin with a 0 (e.g., "0723"). Hexadecimal numbers begin with "0x" (e.g. "0x10af").
After the initial output, print:
Binary: 1111 1111
Octal: 0377
Hexadecimal: 0xFF
The binary number should printed in groups of 4. If the number
of bits is not evenly divisible by 4, then you should print
the first group by the remainder, and the rest in groups of
4. For example, if you have to print "110000", then print it as
"11 0000".
Octal should be printed with a leading 0. Hexadecimal should be printed with a leading 0x
The length of the binary, octal, and hexadecimal can be arbitrarily long (i.e., can be larger than can be stored in an int or a long). You should use the techniques shown in class for easy conversion between binary, octal, and hexadecimal.
Use as few digits as needed to print the value correctly (using at least one digit)
*** INVALID COMMANDinstead of printing the initial output. Then, you should process the next command.
The number of the output should not change (i.e., other than printing "*** INVALID COMMAND", the output of your program should be the same as if you had no invalid commands in the input file).
(Sample output of this to be posted soon)
|
See the class syllabus for policies concerning email Last Modified: Wed Jun 5 10:38:37 EDT 2002 |
|
|
|
|
|