This page is meant only as a guideline for a potential report. Additionally, not every section will be required for each project. I will announce what I expect for each project in class. Please pay particular attention to the sample source code at the end of the report.
Extended Precision Octal Multiplier
This program requests two octal numbers, up to 20 digits each, and computes and displays their product. After each computation, the user will be allowed to compute another product or exit the program.
This program was developed for an 8088 or greater processor running MS-DOS 2.0. A minimum of 1k of disk space and 1k of RAM are required to run this program.
There are three main stages to this program: input, computation, and output.
Start Stop Length Name Class 00000H 001FFH 00200H _STACK STACK 00200H 002D1H 000D2H _DATA DATA 002D2H 003EEH 0011DH _TEXT CODE Program entry point at 002D:0002
To produce an executable file, at the DOS prompt type:
tasm lab1<enter> tlink lab1<enter>To run this program, at the DOS prompt type:
The program will prompt you for two octal integers of 20 digits or less. At each prompt, type the number and press enter. If you attempt to enter more than 20 digits at either prompt, the computer will beep and not accept the extra digits. The program will then compute the octal product of the two numbers you entered and display it. Then the program will ask whether you would like to repeat the process. Hit 'y' to repeat; hitting any other key will exit the program.
C:\>lab1 Enter 1st number: 156 Enter 2nd number: 4133 The product is : 713432 Again (y/n)?y Enter 1st number: 0u1hk That is not a valid octal number. Enter 1st number: 00032 Enter 2nd number: 9 That is not a valid octal number. Enter 2nd number: 2 The product is : 64 Again (y/n)?n
This program meets all of the required specifications. It can handle all standard input, correctly dealing with 1-20 digit octal numbers with or without leading zeros. It can handle all nonstandard input, requiring the user to reenter any string that contains digits out of the range of 0-7. It does not allow the user to enter more than 20 digits, and it re-prompts the user if he presses <enter> at a prompt without typing any data. Note that all characters not in the range of 0-7 are considered invalid, including minus signs and decimal points. The program produces correct output without leading zeros, and continues or exits properly.
Testing of Non-Trivial Modules:
As described in the Algorithm Statement, above, the program can be broken down into three sections. Each section was tested as it was completed, using the debugger to look at the memory. Output depended on Computation which depended on Input, so they were built and tested in the reverse order. See the Test Table, below, for complete results.
First, the Input stage was built and tested using the debugger to see that the numbers were being stored correctly in memory and that error checking was being correctly performed. Then the Computation stage was developed and tested, again using the debugger to see that the result was being successfully computed and stored in memory in a way that could be printed later. Finally, the Output stage was developed and tested to make sure the screen output corresponded to what was computed and stored in memory by the Computation stage.
Description of Non-Functioning Routines:
There are no non-functioning routines in this program.
Statement of Originality
While some high level ideas were discussed in class, this program was designed and implemented by me, anonymous
Maljugin, Vitaly, et al, The Revolutionary Guide to Assembly Language, Wrox Press, 1993.
Dr. Lovell has requested that I only put a portion of the solution source code on-line. Please look at the comments. This is an excellent example of well documented code that does not have trivial comments (e.g. mov bx, 0 ;moves a zero to bx). The use of clear labels and variable names helps make this code easier to read.
... push cx ; Save outer loop index on stack mov ch,0h ; Prepare cx reg for innerloop repetition mov cl,num1Len ; Set cx to length of number 1 InnerLoop: mov ah,0h ; Clear the accumulator mov al,Buff1[di] ; Load digit of number 1 to al mov dl,Buff2[si] ; Load digit of number 2 to dl mul dl ; Multiply two numbers add al,carry ; Add carry to result add al,[bx] ; Add existing result to al mov dl,08h div dl ; Divide current result by 8 mov [bx],ah ; Save remainder to answer buffer mov carry,al ; Save quotient to the carry dec di ; Decrement number 1 index dec bx ; Decrement answer pointer loop InnerLoop ; Repeat inner loop if cx!=0 dec si ; Decrement number 2 index mov dh,0h mov dl,num1Len ; Reset dl value mov di,dx ; Reset di index dec di pop cx ; Get outerloop index from stack ...Last Modified: January 26, 1999 - Barry E. Mapen