================================================================= Assignment #04 - Decoding a Binary File ================================================================= - Ian! D. Allen - idallen@idallen.ca - www.idallen.com Available online: Friday October 15, 2010 Upload due date in the Blackboard Assignment Area: Upload "assignment04.txt" before 19:00 (7pm) on Thursday October 21, 2010 Answers will be posted shortly after the due date/time and discussed in class, if there are any questions about the answers. Submission method: Upload via the "Assignments" assignment04 upload. 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 (e.g. using Notepad)? Answers will be posted after the due date/time so that you can check your answers before coming to class and ask questions about the answers in class. Please check your answers (and my answers!). I go over each assignment in class if there are questions about the answers. No questions means no review - I'll presume you know the material. Questions similar to ones on these assignments will appear on your tests and exams. This assignment will be marked. See the Week 1 Notes for details. ============================================================================== You can do this project on any machine that has a hexadecimal DUMP utility, similar to those found in Unix/Linux and DOS. The decoded answers must be submitted in plain text via the "Assignments" upload. A sample decoded file is below. Follow the format precisely. Note: The project data file I give you is an unprintable, binary format file. 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. Instructions 1. Download this binary file to your computer from one of these locations: http://teaching.idallen.com/dat2343/10f/notes/data/abcd0001.bin http://teaching.idallen.org/dat2343/10f/notes/data/abcd0001.bin http://acadunix.algonquincollege.com/~alleni/teaching/dat2343/10f/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 plain ASCII and decimal numbers, following the record format described below. 4. Enter your 20 answers into a text file in the format described below. Use the format described below for this plain text file. A sample decoded file is below. Follow the format precisely. 5. Submit your plain text file for marking, using the correct file name, before the due date using the Blackboard "Assignment" upload method. A sample decoded file is below. Follow the format precisely. 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. A sample decoded file is below. Follow the format precisely. 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 an assignment label.) The answer file must be four lines long. Each line should contain five non-blank answer 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. A sample decoded file is below. Follow the format precisely. 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 file will have this 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 must be exactly four lines in the answer file. Each line must have exactly five blank-separated fields on it. Submission Method Upload your plain-text answer file, using the correct file name, to the "Assignments" upload area for this week. The upload file format is critical. Follow the example format precisely. -- | 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/