COMP 180 Computer Organization - all lecture sessions

2001 Spring Semester
Programming Assignment Two
Due: May 11, 2001, 5pm


[Problem | Sample run | Things to know | Prerequisites | References | Grading | Submission | Academic integrity ]
[Handout of 80x86 Assemebly Language Programming] (takes several minutes...)
[Lab 09 | Lab 10]

Problem

You are to write a 80x86 assembly language program to implement a PC Piano. Your program should prompt the user to enter the number (integer) of notes to be played. Then it gets the duration in secs (integer) and frequency (letter) of each note typed in by the user. Please use the following letter-to-frequency mapping:
Letter Frequency
D 256 Hz
R 287 Hz
M 322 Hz
F 341 Hz
S 383 Hz
L 430 Hz
T 483 Hz
d 512 Hz

After reading all inputs, the program concurrently

  1. prints out the system (or real-time) clock and
  2. plays the musical notes.
The screen should not scroll up while the program is in execution.

Note: Since concurrency is a requirement in this assignment, you CANNOT use delay loop to implement the duration. You must know how to interrupt the system clock (lab assignment).

Sample run and requirement

In this assignment, assume all inputs are valid: the user (or the grader) must input non-negative numbers for number of notes to be played, and for their duration. Also, your program can assume either 'D', 'R', 'M', 'F', 'S', 'L', 'T', or 'd' is entered as note frequencies. Therefore, it saves you a lot of checking. You need not make your program's input validation procedure a bullet-proof one.

When hwk2 is run, it prints out "Input number of notes = ". In this example, the user types "3" and press the [Enter] key. Then, he types in 3 notes with their durations and frequencies (in letter). After the last input, the music starts immediately, and the system clock is kept updating.

C:\> hwk2
Input number of notes = 3
3
D
2
R
1
M
14:59:58

Explanation of output:

  1. During 14:59:58--15:00:01, a sound of frequency 256 Hz (`Do') is played. Note that if hwk2 starts executing in the middle of 14:59:58 and 14:59:59, it is also fine with us (since it leads to a simpler implementation).
  2. Then, during 15:00:01--15:00:03, 287 Hz (`Re') is played. Finally, 322 Hz (`Me') is played during 15:00:03--15:00:04.
  3. At 15:00:04 the program terminates.
  4. During 14:59:58--15:00:04, updating the system clock and playing the notes should be done concurrently.
  5. Also, the screen must not scroll up after each clock update.
Alternatively, you can be a composer, by preparing the following music score (do you like Henry Macinni, by the way?), stored as a file (named "notes.txt", for instance):
3
3
D
2
R
1
M

Using the same program without modification, we can redirect the keyboard input to file, without having the user type in all the notes tediously every time the same piece of music is played:

C:\> hwk2 < notes.txt
14:59:58

The same should be heard. You are not required to disable the input prompt "Input number of notes = " if your hwk2 is played with a piece of music score.

Things to know for this homework

You should know the following before starting to code the program:
  1. ASCII-to-binary conversion for user-supplied parameters.
  2. Turning on/off the PC speaker by using 8255 PPI and 8253 timer.
  3. (Packed) BCD-to-ASCII conversion for displaying the system time.
  4. System clock interrupt using INT 1AH.
  5. Print string/buffered keyboard input using INT 21H.

Prerequisites

Granted, you have to implement the following lab exercises. Reading and understanding the labs without actual implementation equal to nothing. The lab exercises will guide you, step-by-step, to the end of successful implementation of the PC Piano. All lab exercises are self-explanatory. We publish them once and for all, for students who want to finish the assignment quick:

Lab 08: [Tasm and Tlink] 8086 architecture and "hello world" program, use of debugger
Lab 09: [program skeleton | full program] "day2date" convertor
Lab 10: [full program] Generating sound using 8255 PPI and 8253 timer
Lab 11: [full program] System clock interrupt
Lab 12: [solutions] Addressing mode

We purposely do not provide many program skeletons in a cut-and-paste ready form. We encourage you to type in the program skeleton and your modification yourself, using an editor such as notepad. Then, assemble and link your .asm and .obj files to produce an .exe file.

References

Reference on 80x86 programming in the textbook is sparse.

We shall put several reference books on 80x86 assembly language in the Library (reserve section). Specifically, you should use turbo assembler (TASM) and turbo linker (TLINK). The TAs will use TASM and TLINK to assemble and link your program, respectively.

We shall also put a 25-page handout, a concise reference manual for 80x86 assembly language, in the reserve section of the Library. All the instructions there are more than sufficient to implement this assignment. Four copies, one for each session, will be reserved in Library, view it on-line here

Grading

Correctness: 70%
  1. Program can be assembled and linked: 10%
  2. Test case 1 (known) : 15%
  3. Test case 2 (known) : 15%
  4. Test case 3 (unkonwn): 10%
  5. Test case 4 (unkonwn): 10%
  6. Test case 5 (unkonwn): 10%
Documentation : 20%
  1. Program contains your name, student id, e-mail, department, lecture and lab session ?: 5%
  2. Program reasonably commented? : 15%
Programming style (procedural or modular approach?): 10%

Submission

Your program will be collected automatically using our automatic collection system (ACS). For easy identification, your name, student number, e-mail address, department, lecture and lab sections should be written clearly as comments at the very beginning of your program. A well-documented program should be kept in a file named as ~yourlogin/comp180/hwk2/hwk2.asm on the Computer Science Department Unix server by 5pm on May 11, 2001. If you want to include your music scores, be sure that the filenames have the extension .txt. Please refer to the detailed instructions
here if you are not familiar with using the ACS for homework submission. Contact your TA or instructor well before the due date if you encounter any problem.

Late submission is NOT allowed.

Academic integrity

Cheating by copying from others, or providing your program to others, are strictly forbidden. Check out the departmental procedures for handling cheating.
Last update Sun Mar 18 12:36:47 HKT 2001