CS 2700: Assembly Language and Computer Architecture

Spring 2024 - Lab 4

Due 5/15

  1. Log in with your OIT user name and password so that you will be able to save any files you work on for later use.
  2. Visit our textbook's official web site, select the "SAMPLE MATERIALS" tab, and download the MARIE Simulator file.
  3. Double-click on 'MARIE_Simulator.zip". Most Windows machines will automatically "unzip" (uncompress the file, compressed into the zip file format) if you double-click on the file name.
  4. In Windows, open the Windows Explorer, go to Downloads or Desktop -- wherever your web browser placed the unzipped MARie simulator files.
  5. Copy the marieSim.jar file out into a folder that is not inside the Windows zip file viewer. (Your Desktop is a good choice.) Double-click on the copy of marieSim.jar.
  6. Write and run a complete MARIE assembly program to do this:

    Read in and store 11 integers, each in the range 0-9 (inclusive) - the first 11 digits in a sPC-A code (the numbers at the bottom of a bar code) for some product
    Calculate the UPC-A check digit
    Output the check digit to the user
    

  7. UPC codes (Universal Product Codes, most commonly UPC-A) are printed on many products in our daily lives. The numbers in the code are encoded into black and white bars and printed on the product packaging, for scanners to read. In every UPC-A code, the final (rightmost) digit is a "check digit," included to help prevent small errors in reading, copying and scanning.

    The "check digit" in a UPC-A code is the 12th digit, printed to the right and slightly below the rightmost black bar.

    1. First, calculate the sum of the odd digits (the first, third, fifth, etc). The very first digit in the UPC-A code is printed slightly to the left and below the leftmost black bar on the UPC-A label. It is visually separated from the second digit by a small gap.
    2. Multiply that sum by 3.
    3. Add to this number all the even digits in the UPC-A code (the second, fourth, etc), not including the final check digit itself.
    4. Divide this number by 10 and take the remainder. (Or subtract off 10 repeatedly until the result is less than 10.)
    5. If the result is zero, you're done and that is the check digit.
    6. If the result is not zero, subtract it from 10 and the result is the check digit.
  8. For example, the UPC-A code on a pack of cards in my office is:

         0 73854 60088 7
    
         check = 0 + 3 + 5 + 6 + 0 + 8 = 22
         check = 22 * 3
         check = 66 + 7 + 8 + 4 + 0 + 8 = 93
         check = 93 % 10 = 3  (93 modulus 10)
         check = 10 - 3 = 7, which is the check digit
    
    

  9. MARIE does not have a division operation, so you may want to consider repeated subtraction.

  10. A significant part of the grade for this lab will be determined by good programming style. Good programming style, in this case, will include carefully decomposing the problem into meaningful units of work, naming those units well, use of JnS to appropriately navigate around your source code, and, of course, clear, readable comments.

  11. Every single line of code in your program must have a comment clearly explaining the purpose of that line. No exceptions. The comment on the top line of the source code file must include your first and last names. (Lines of source code specifying variable values should be commented appropriately, as well.)

  12. Be careful to test your program on several real UPC-A codes. The professor has several items you may use if there are no bar codes on any items in your backpack.

  13. Upload the working and tested source code (.mas) to Canvs by the assignment deadline.

Last updated 5/2/2024