================================================================= Assignment #12 - Dumping and Decoding a Big-Endian Binary File ================================================================= - Ian! D. Allen - idallen@idallen.ca - www.idallen.com Available online: Thursday March 31, 2011 Upload due date in the Blackboard Assignment Area: Upload the answer file before 23:59 (midnight) on Wednesday April 6, 2011. You will be emailed your correct answers after the due date. Submission method: Create a plain text file using the exact name "assignment12.txt" Upload the file via the Assignment12 "Upload File" facility in Blackboard. Use "Attach File" and "Submit" to upload your plain text file. No wordprocessor documents. Do not send email. Use only "Attach File". Use the file name given above. Upload only one single file of plain text, not HTML, not MSWord. No fonts, no word-processing. Plain text only. Did I mention that the format is plain text (VIM/Nano/Pico/Gedit or Notepad)? NO WORD PROCESSOR DOCUMENTS ACCEPTED. No marks are awarded for submitting under the wrong assignment number. ----------------------------------------------------------------------------- You can do this assignment on any machine that has a hexadecimal DUMP utility, similar to those found in Unix/Linux and DOS/Windows. The answers must be submitted in plain text via the "Assignments" upload. Note: The personalized, custom data file I give you is an unprintable, binary format file. Every file is unique. It is not printable or viewable on your screen. It will look like garbage in any text editor you might use. Do not try to print it. Your answer file must be exactly four lines long. Only four lines. ----------------------------------------------------------------------------- Instructions ------------ 1. Download this personalized, custom binary file (use your own userid) to your computer from one of these locations: http://teaching.idallen.com/cst8281/11w/notes/data/abcd0001.bin http://teaching.idallen.org/cst8281/11w/notes/data/abcd0001.bin http://acadunix.algonquincollege.com/~alleni/teaching/cst8281/11w/notes/data/abcd0001.bin Replace abcd0001 by your 8-character Algonquin userid. Each person will have a different binary file. Save your binary data file onto your local computer. Do not try to print this binary file. 2. If necessary, rename the file on your computer to have a short MS-DOS 8.3 file name, e.g. MY.BIN - some dumping programs (e.g. DOS DEBUG) will not open long file names. Use an 8.3 file name. 3. Use a file dump utility (e.g. Hexedit, DOS DEBUG, or the Linux "od" command) to display the hexadecimal byte contents of your personal data file. Using your knowledge of data encoding, decode the four 30-byte records in this file into letters and decimal numbers, following the record format described below. Follow the format. 4. Enter your 20 answers into a text file in the format described below. Use the format described below for this plain text answer file. 5. Submit your four-line plain text answer file for marking, using the correct file name, before the due date, using the Blackboard "Assignment" upload method described above. Input File Record Format ------------------------ Each record in your personal data file has the same structure. There are five fixed-length fields in each of the four records: 1. one field of 6 EBCDIC-encoded characters 2. one 32-bit 2's complement field 3. one 32-bit IEEE 754 normalized floating point field 4. one 8 byte field of ASCII characters 5. one 8 byte field of UNICODE-16 characters Adding up the above five field sizes, you see that each record is 30 bytes long. There are four records in your data file, giving a total file size of 120 bytes. (Make sure your downloaded data file is exactly this big, before you begin!) As implied by the EBCDIC fields, this is an IBM mainframe simulated file in big-endian byte order; as a result, the 2's complement and the floating point fields are not in the reverse byte order you would expect for Intel hardware. The byte order you see in the dump is the byte order you decode. Decode the file into four records with five fields each. Decode the first field of each record from EBCDIC into ASCII characters; decode the next two numeric fields into ordinary decimal numbers, e.g. -123, 123.456, etc. Decode the fourth field into plain ASCII text. Decode the last field from Unicode-16 to plain ASCII. You will have a total of 4*5=20 fields decoded, which is four records of five fields each. If you can't decode any particular field, use a zero as a place-holder. Output File Format: Record your decoded Answers ----------------------------------------------- After you have decoded all 20 fields in the data file, enter your 20 answers into a plain text answer file (e.g. using Windows Notepad or Unix/Linux VI). The answer file should contain *nothing except your answers*. (Do not include your name or any assignment label.) Your answer file must be exactly four lines long. Each line should contain five non-blank fields separated by one or more spaces. If you didn't decode some fields, put zeroes into your answer file as place-holders for those undecoded fields. See the example below. Make sure that you don't put spaces in negative numbers between the negative sign and the number. Make sure that all floating-point numbers have no spaces in them. None of the 20 fields should contain any spaces. For full marks, you must have no extra spaces in your answers. Your answer file must have this 4-line sample format: ABCDEF -2199 -353.042605 ABCDEFGH UrPt KHJYbz 1699 499.872105 XBL32rjC kYfE MCOUhw 899 -999.185200 WXM31suK MtRo 0 -3199 0 UAH22hrI kMyW The zeroes are place-holders indicating fields that were not decoded. Do not put any extra spaces in your answers. No extra spaces! There are exactly four lines. Each line has exactly five fields on it. Your answer file must be exactly four lines long. Four. Submission Method ----------------- Upload your four-line, plain-text answer file, using the correct file name, to the "Assignments" upload area for this week. Your answer file must be exactly four lines long. -- | Ian! D. Allen - idallen@idallen.ca - Ottawa, Ontario, Canada | Home Page: http://idallen.com/ Contact Improv: http://contactimprov.ca/ | College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/ | Defend digital freedom: http://eff.org/ and have fun: http://fools.ca/