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

Project 2 - LMC Programming

DAT 2343 - Winter 2000


Write mnemonic LMC instructions for a program that will input two numbers and calculate and print the value of the first number raised to the power of the second number.  (See the example, below.)
Assemble by hand your mnemonic instructions into LMC numeric codes.
Enter your codes and test your program in the LMC simulator under Windows.  (See LMC Simulator, below.)
Hand in a diskette and printout containing your program.  (See Hand In, below.)

Algorithm Details

Your LMC program should input two numbers and calculate and print the value of the first number raised to the power of the second number.

For example, if the two input numbers were 005 then 004, your code should output 625, which is 005 x 005 x 005 x 005, that is: 005 multiplied by itself 004 times. Note that, by definition, any value raised to the power of 000 is equal to 001.

Use the multiplication subroutine developed in class (available on the Web as well) to perform the multiplication, or develop your own multiplication subroutine. You must handle multiplication by a call to a subroutine.

Your mnemonic instructions must use only "label-style references" in the address/operand field.  Do not use any mailbox numbers - use labels only.  (Also, do not use the ORG pseudo-instruction.  Code should begin at mailbox location zero.)

You may assume that the final result will be no greater than 999; there is no need to check for overflow or other error conditions.


Use the following pseudo-code to develop your mnemonic program:

Enter base 
Enter exponent 
Set power = 1 
While the exponent is greater than 0 
    Call Multiply subroutine to multiply power by base,
        giving new value for power
    Decrement the exponent 
Display power 
Subroutine Multiply (from class and web notes)
    Multiply two arguments
    Return result in calculator

Translate the given pseudo-code into LMC mnemonic instructions.  Hand-assemble your mnemonic instructions into the equivalent LMC numeric codes. 

Download the LMC Simulator (see below), which simulates the "Little Man Computer" with a couple of additional operations. This program should be run from Windows 95/98. Run the "son of LMC" program and load your numeric codes into mailboxes; save your program, as required, on a diskette, using the given file name (below).

Test and, if necessary, debug your program using the "son of LMC" simulator. (Be sure to resave your modified numeric codes if you make changes, and to modify your mnemonic instructions to reflect any such changes.)

Print and hand in your mnemonic instructions on a sheet of paper, and submit a diskette containing your LMC numeric codes and another copy of your mnemonic instructions as a text file on the diskette.  Follow the Hand In format given below.

LMC Simulator under Windows

The simulator comes in two versions.  The basic version, available on Alan Pinck's site, is known to work reasonably under Windows 95/98.  The enhanced version, which permits editing and other features, is new this term.  I recommend you try the enhanced simulator first; if it misbehaves, tell me what went wrong and return to the basic simulator.

The Enhanced Simulator can read the data files saved by the Basic Simulator; but, the Basic Simulator can only read files saved in "old format".  (You will be asked which format you want when you use the "save" feature of the Enhanced Simulator.)  You may submit files on diskette in either format.  Enhanced format is easier to read, since it is one mailbox per line.

Enhanced Simulator (FoSoLMC.EXE)

Download: FriendOfSonOfLMC.EXE

If you have Visual Basic 6.0 on your computer, you should only need the actual program executable, given above. If you don't have Visual Basic 6.0 or the Visual Basic Runtime Libraries on your computer you will need to download and install them using the (large!) Setup Kit available here.

The above links are local Algonquin copies of the original files kept on Christopher Hyne's F.O.S.O.L.M.C. site.

Basic Simulator (SonOfLMC.EXE)

Download: SonOfLMC.EXE

The Basic Simulator requires certain Dynamic Link Libraries which are commonly installed on many systems (all college lab computers should have these files). Specifically, this program was created using Visual Basic version 4 and needs VB40032.DLL.

If your computer does not have any of the required files, you can download a .ZIP version of the entire package including all support files from:

Alan Pinck Little Man Computer FTP site

The available files include: SonOfLMC.ZIP... the complete executable package (4Mb) Son_P1.ZIP, Son_P2.ZIP, Son_P3.ZIP, Son_P4.ZIP... all the same files as the above but broken up into 4 collections, each of which should fit on a 1.4Mb disk.

Hand In

Create and hand in a copy of a diskette (please keep the original in case the copy is unreadable) containing three text-only files, and a printout:
  1. File 1: A README.TXT text file containing the Ian Allen Assignment Submission label.
  2. File 2: A MNEMONIC.TXT text file containing the mnemonic instructions of your LMC program.
  3. File 3: A P2CODES.LMC "save" text file from the LMC simulator containing the LMC numeric codes of your assembled program.  I accept both Enhanced and Basic save formats.
  4. Printout: Print a clear copy of your five-column (plus comments) MNEMONIC.TXT file for submission with your diskette.  Ensure that the document prints neatly - pay attention to margins and indentation.  Ensure that all labels used have defined locations.  No numeric arguments/operands are allowed - submit mnemonic instructions with labels only in this file.

Text Files Only

All three submission files must be plain text only.  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.


If there are any problems, please let me know immediately!


Web Author: Ian! D. Allen      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.