Project 3
Home Weekly Schedule Notes & Homework More Notes! News & Discussion Project 1 Project 2 Project 3 Project 4 Disk DEBUG Calculating  C/H/S
2003-05-04 01:19

Project 3 - Intel Assembler Programming

DAT 2343 - Spring/Summer 2000


  1. Write Intel assembler instructions for a program, using the supplied pseudo-code.
  2. Assemble your program and produce a working executable file in .COM format.
  3. Hand in an envelope containing a diskette and printout of your working program.

Program Description

This program uses DOS interrupt services to read and echo single characters until a letter P or p is seen. After the letter P or p, the code continues to read but does not echo the characters being read. (Think of the characters following P or p as being a hidden "password".)

Whenever a CR is read, echoing of characters is turned on again and a CR+LF is sent to the screen.  (In other words, the no-echo password field ends at the end of a line.)

Whenever a Q or q is seen, the program starts a new line, prints a message containing the count of passwords seen, and exits with a zero return code.

Pseudo-Code Algorithm

If you follow this algorithm closely, the project is reasonably straightforward.

The program chooses between two DOS input functions using a "visibility flag".  One DOS input function (01h) reads and automatically echoes the characters read to the screen; the other input function (07h) reads but does not echo the characters to the screen.  The visibility flag is turned off when a P or p is seen in the input; it is turned back on when a CR is seen:

    set the count of passwords to zero
    set the visibility flag to "on"
    do {
        if ( the visibility flag is on )
            input a character with echo to the screen (DOS 01h)
            if ( the input character is a 'P' or a 'p' )
                turn off the visibility flag
                increment the count of passwords seen
            input a character without any echo to the screen (DOS 07h)
        if ( the input character is a CR )
            turn on the visibility flag
            output CR and LF to the screen
    } while ( the input character is not a 'Q' or a 'q' );
    start a new output line
    print a nice message along with the count of passwords seen
    end program

Notes and Simplifications:

Assume the count of passwords will be less than ten, so that it can be simply converted into a single ASCII character for easy output.

Assume the input will always end with a Q or q, so you don't need to handle any EOF conditions on the input stream.

Use the DOS interrupt services for all your input and output.

For full marks, you must add meaningful comments to your assembler code, explaining how the code actually implements the above pseudo-code.

Make sure that your program handles both upper- and lower-case letters.


If you start up your program and type in this input:

see meq
This is what you should see on your screen as you type the above:
see meq
...some message text about password count... 0
The program exits after printing the password count message.  You get to pick your own text for the above message.  The digit 0 prints because you entered no hidden password fields in the input.  (You did not use the letters P or p anywhere.)  Note: the password count message starts on its own new line.

Here is another example.  If you start your program and type in this input stream:

see mephidden password
visible textPhidden textQ
This is what you should see on your screen as you type the above:
see mep
visible textP
...some message text about password count... 2
The instant a letter P or p is seen, indicating a "password" field, all echoing of input characters being typed stops until a CR is used (or until Q or q causes the program to exit).  The digit 2 prints because you entered two hidden password fields in the input.  (You used the P or p command to turn on "password" mode on two different lines.)  The program exits after printing the password count message.

Solution Size (Approximate)

My implementation of this algorithm used about 34 lines of assembler instructions, plus some additional lines for segment set-up, data for the variables, and data for the output message.  The comments in the code more than doubled the size of the file.

The resulting PROJ3.COM file was 138 bytes long.

Your answer may differ.

Hand In

In a closed, fully labelled, but unsealed envelope submit a copy of a labelled diskette and a single printout.  (Keep a copy of the diskette!)

The labelled diskette must contain these two files, with these exact names:

  1. File 1: A PROJ3.ASM text file containing the Ian Allen Assignment Submission label as a comment, followed by the the source code of your commented Assembler source program.
  2. File 2: A PROJ3.COM file that is the assembled and linked executable version of your PROJ3.ASM source code.

Printout: Print a clear copy of your PROJ3.ASM file for submission in the envelope with your diskette.  Ensure that the document prints neatly - pay attention to margins and indentation.  Full marks are only given for clearly-formatted output.  Since you will ensure that the PROJ3.ASM file begins with an Assignment Submission Label as a comment, you don't need a labelled cover page for the printout.  Just print the file.

For Full Marks

Make sure the PROJ3.ASM source file contains the Ian Allen Assignment Submission label as a comment at the beginning.
Remember to include both files and the printout.  Use the exact file names given.  No variation in spelling of file names is allowed - the program I use to mark these assignments will not find misspelled files on your diskette.
Both files must be in the root directory on the diskette, not under a subdirectory.
Your submitted source code PROJ3.ASM must be plain text only.  (Plain text is the only kind of input that the assembler programs will read!)  Plain text is readable in Windows Notepad or DOS EDIT (or Unix/Linux vi).  Check the format of your files before you submit them.  Do not submit Word or WordPerfect documents.

Web Author: Ian! D. Allen      Updated: 2003-05-04 01:19

Internet Free Zone Level 1 logo Support free and non-commercial Internet.

Any Browser logo This site works best in Any Browser, a campaign for non-specific WWW.

Creative Commons License logo This work is licensed under a Creative Commons License.