Project 3
Home Notes & Homework News & Discussion Project 1 Project 2 Project 3 Project 4 Disk DEBUG
Updated:
2003-09-23 11:45

Project 3 - INTEL Assembler Programming

DAT 2343 - Winter 2000

Synopsis

Write INTEL assembler code for a program that will loop reading pairs of numbers.  (Subroutines to read and display numbers are supplied via links, below.)  If both of the numbers input are zero, the program will stop looping.  For each pair of numbers read, the program will subtract the smaller number from the larger number and display a text message and the result of the subtraction.  After the loop is done, a text message followed by the count of the number of subtractions performed should be output.
Assemble your program and produce an executable file in COM format named PROJ3.COM
Hand in a printout of your program and a diskette containing both the PROJ3.ASM source to the program and the running executable PROJ3.COM file.  (See Hand In, below.)

Algorithm Details

Loop reading pairs of numbers, separated by blanks or carriage returns, printing the result of the larger number minus the smaller number. A pair of zeroes ends the loop. A count of the number of subtractions done is output after the loop ends.

Note that the two zeroes that end the program are not counted or subtracted.

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

initialize a subtraction-counter variable to zero
start of loop:
    on a new line, prompt for and input a first number
       - if there is an error in the input, print an error message
         and then break out of the loop (go to after end-of-loop)
    on a new line, prompt for and input a second number
       - if there is an error in the input, print an error message
         and then break out of the loop (go to after end-of-loop)
    if ( both the first number and the second number are zero ) 
         break out of loop (go to after end-of-loop)
    endif
    subtract the smaller number from the larger number
    on a new line, print a text message followed by the result
       of the subtraction
    add one to the subtraction-counter variable
    go back to the start of loop
end of loop
on a new line, print a text message followed by
   the final value of the subtraction-counter variable
end program

Examples

If you type in input to your program as four pairs of numbers followed by two zeroes:

  8 10   44 33   123 0   0 456   0 0

The display on your screen will look something this (your typing in red):

...your prompt here... 8
...your prompt here... 10
...some message text... 2
...your prompt here... 44
...your prompt here... 33
...some message text... 11
...your prompt text... 123
...your prompt text... 0
...some message text... 123
...your prompt text... 0
...your prompt text... 456
...some message text... 456
...your prompt text... 0
...your prompt text... 0
...your subtraction counter message text... 4

You get to choose the wording of your own prompts and messages.  To get the display to look good, you may need to add carriage returns and newlines to the output, otherwise you will find that the prompts will overwrite each other on the screen.

In the assembler implementation of the above algorithm, numbers are read by calling the GETNUM subroutine and are displayed using the SHOWNUM subroutine from the supplied GETSHOW.ASM I/O package.  If the input contains a non-number (check the return status of GETNUM), break out of the loop and display an error message:

...your prompt here... 8
...your prompt here... 10
...some message text... 2
...your prompt here... X
...you print an error message here...
...your subtraction counter message text... 1

 The code for these two subroutines is available here in this one file:

getshow.asm

Choose "save as" in your browser to save this file for use in your programming project. You will need an INCLUDE statement to use it in your own PROJ3.ASM source file.

An example that uses these two subroutines and an INCLUDE statement is here.

Hand In

Hand in a closed but unsealed envelope (not a folder!) containing a copy of a diskette (please keep the original in case the copy is unreadable) containing two text-only files and an executable, and also a printout:
  1. File 1: A README.TXT text file containing the Ian Allen Assignment Submission label.
  2. File 2: A PROJ3.ASM text file containing the source code of your Assembler program.
  3. File 3: A PROJ3.COM file that is the assembled and linked executable file of your program.
  4. Printout: Print a clear copy of your source code PROJ3.ASM file for submission with your diskette.  Ensure that the document prints neatly - pay attention to margins and indentation.  Marks are deducted for mis-formatted output.  Commenting of your code is required.

Text Files Only

Your submitted source code PROJ3.ASM must be plain text only.  (It's the only thing 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.
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.

Problems?

If there are any problems, please let me know immediately!  idallen@ncf.ca

 

Web Author: Ian! D. Allen idallen@idallen.ca      Updated: 2003-09-23 11:45

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.