CS611
Spring 2003
Programming Assignment 3
Due Sunday March 9


The IAS computer supports 40-bit 2's complement values. The machine is connected (conceptually) to an input card reader and an output card punch. A card punch, whether human driven or computer driven, has only 16 keys, labeled with 0-9 and a-f. Each key produces a 4-bit output, which is equivalent to the standard hexadecimal encoding of the key's label. A card contains 12 40-bit words, represented with 120 4-bit symbols. Each symbol is printed at the top of the card with its corresponding bit pattern represented via holes punched in the column below the symbol.

This arrangement allows the machine to output numbers in a primitive, human-readable, decimal notation. A 40-bit binary value requires up to 12 decimal digits plus a sign indicator. An individual decimal digit can be represented with its corresponding hexadecimal value and the sign can (inelegantly and arbitrarily) be represented by 'a' standing for '+' and 'b' standing for '-'. In this manner, therefore, up to 13 4-bit symbols (52 bits) are required to represent a 40-bit binary value.

So, for example, the 40-bit value 0000000100 (displayed in hexadecimal) could be converted to decimal and then punched on a card using 13 columns as a000000000256. And ffffffffff could be punched as b000000000001.

Likewise, this scheme could be used to input data. A human could punch a card using the decimal notation. The computer could then read the card, convert the decimal value to binary, and then compute with the value.

Your assignment is to write two progams using IAS assembly language:

  1. btod.asm: convert a 40-bit binary value to a 52-bit binary-decimal value.
  2. dtob.asm: convert a 52-bit binary-decimal value to a 40-bit binary value.

The programs should read their single input from a card and they should write their single output to a card. The 52-bit values will be stored on the first two words of a card: the sign character will be in bits 36-39 of the first word, the highest-order digit will be in bits 32-35, the next highest-order digit will be in bits 28-31, and so on down to the bottom of the first word. The three lowest-order digits will be in the high-order bits of the second word. As in the first word, the higher-order digits will be in the higher-order bits.

You may assume on input that the rest of the card contains only zeros. Likewise, when you write a card, set the unused portion of the card to zeros.

The programs should leave a status value in the MQ register. If the conversion was successful, set MQ to 1. If the conversion failed, set MQ to 0.

Test your programs using the IAS simulator. Note: you can create input cards using the punchcard utility in ~cs611/bin/punchcards.

Each program will be worth 50 points.

Place the btod program in the file btod.asm. Place the dtob program in the file dtob.asm.

Your program will be graded primarily by testing it for correct functionality. However, good program structure and documentation is absolutely critical for assembly language programs. Therefore, you may lose points if your program is not properly structured or adequately documented.

Your assignment should be submitted for grading from a CIS Linux machine (e.g. turing.unh.edu). To turn in this assignment, type:
~cs611/bin/submit prog3 btod.asm dtob.asm

Do not turn in any other files!

Submissions can be checked from a CIS Linux machine by typing:
~cs611/bin/scheck prog3

To receive full credit for the assignment, you must turn in your files prior to 8am on Monday March 10. Late submissions will be accepted at the penalty of 5 points per day up to one week late.

Your programs will be graded using a CIS Linux machine (e.g. turing.unh.edu) so be sure to test in that environment.

Remember: as always you are expected to do your own work on this assignment.


Last modified on March 3, 2003.

Comments and questions should be directed to hatcher@unh.edu