UMBC CMSC 313, Computer Organization & Assembly Language, Fall 2004

Project 2: BSD Checksum

Also available in PDF: project2.pdf.


Due: Thursday, September 30, 2004


Objective

The objective of this programming project is to practice designing your own loops and branching code in assembly language and to gain greater familiarity with the i386 instructions set.


Background

Checksums can be used to detect corrupted files. A file might be corrupted during transmission through a network or because the disk drive where the file is stored is damaged.

The BSD Checksum algorithm uses a 16-bit checksum. Initially, the value of the checksum is zero. For each byte of the file (in sequential order), the checksum is rotated 1 bit to the right and the byte is added to the checksum. The value of the checksum after the last byte of the file has been processed is the checksum of the file.

If the checksum of a file changes, then you know that its contents have been altered. However, it is possible for two different files to have the same checksum (since there are only 64K different values for a 16-bit checksum but many more possible files). So, having the same checksum does not guarantee that the file has not been corrupted. A well-designed checksum algorithm should be able to indicate the most common types of file corruption (e.g., transposed bits, single bits flipped).


Assignment

Write an assembly language program that computes the BSD checksum (algorithm given above) of the stdin file. You should output the checksum as a 16-bit binary number to stdout. The intention is for you to use Unix input/output redirection: ./a.out <ifile >ifile.checksum The value of the checksum can be examined using the hexdump command.: hexdump ifile.checksum hexdump -e '1/2 "%u\n"' ifile.checksum

The first hexdump command gives the result in hexadecimal. The second hexdump command gives the value in decimal. (It is a challenge to alias the second command in Unix.)

Some details:


Implementation Notes


Turning in your program

Use the UNIX submit command on the GL system to turn in your project. You should submit two files: 1) the assembly language program and 2) the typescript file of sample runs of your program. The class name for submit is cs313_0101. The name of the assignment name is proj2. The UNIX command to do this should look something like:

submit cs313_0101 proj2 checksum.asm typescript


Last Modified: 22 Jul 2024 11:29:41 EDT by Richard Chang
to Fall 2004 CMSC 313 Section Homepage