CMSC313, Computer Organization & Assembly Language Programming, Fall 2012

Project 1: Nine's Complement

Also available in PDF.

Due: Thursday September 20, 2012 11:59pm


This project is a finger-warming exercise to make sure that everyone can compile an assembly language program, run it through the debugger and submit the requisite files using the systems in place for the programming projects.


For this project, you must do the following:

  1. Modify the assembly language program toupper.asm as follows. Replace all occurrences of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 with its nine's complement. For example, the input string
    I live on 1701 Enterprise Avenue. Call me at 867-5309.
    should be converted to
    I live on 8298 Enterprise Avenue. Call me at 132-4690.
    Here, the nine's complement of a digit is difference between 9 and that digit. Thus, the nine's complement of 4 is 9 − 4 = 5, and the nine's complement of 3 is 6 = 9 − 3. Non-digit characters (e.g., alphabetic characters, punctuation marks) should be left unchanged. Finally, recall that the input and output are strings of ASCII characters. Thus, the 3 is the ASCII character '3' and is stored as numerical value 51 in a single byte. It is not stored as numerical value 3.

  2. Using the UNIX script command, record some sample runs of your program and a debugging session using gdb. In this session, you should fully exercise the debugger. You must set several breakpoints, single step through some instructions, use the automatic display function and examine the contents of memory before and after processing. The script command is initiated by the command script. This puts you in a new UNIX shell which records every character typed or printed to the screen. You exit from this shell by typing exit at the UNIX prompt. A file named typescript is placed in the current directory.
The source code for toupper.asm is available on the GL file system in: /afs/

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 modified assembly language program and 2) the typescript file of your debugging session. The class name for submit is cs313 and the project name is proj1. The UNIX command to do this should look something like:

submit cs313 proj1 nines.asm typescript

Last Modified: 2 Oct 2012 11:37:53 EDT by Richard Chang
to Fall 2012 CMSC 313 Homepage