CSc 3210
Computer Organization and Programming
Fall Quarter 1998
Programming Assignment #2 (Due: 19 October 1998, Monday)
Assignment Objectives:
To gain experience with
program control (procedures and jump instructions), screen
processing in text mode, and simple keyboard processing.
Problem Description:
Write an assembler program that will
simulate an alarm clock on the screen.
When your program begins, the screen should be cleared and the
following should be displayed and the clock should keep advancing
(at the rate of approximately 1 second per second).
The alarm clock should have the following functionality:
- Alarm ON/OFF: When the user presses the o
key, the alarm status should toggle between ON and OFF.
You may assume that the alarm is OFF when your program
begins. When the alarm is ON, the display should
have an asterix after the time as follows:
- Set Alarm Time: When the user presses the a
key, the display should switch to the following:
and the user should be allowed to use the up arrow and
the down arrow keys to increase or decrease the hours
or minutes
setting of the alarm time. The user should be able to switch between
setting hours and minutes by pressing the h or the m
keys. To begin with, you may assume that the hour will be set
with the arrow keys. Once the user is satisfied with the
alarm setting, the a key may once again be pressed to
return to the time display.
IMPORTANT NOTE: While the
alarm time is being set, the clock should keep running
and not lose time! Also,
while setting the alarm time, the time setting key t
should be ignored. All other commands (the o, the
r and the escape keys) should still be accepted and processed.
- Set Time: When the user presses the t
key, the user may set the time.
The time is set in a similar fashion as the alarm setting
(i.e. with the up arrow, down arrow, h and
the m keys).
IMPORTANT NOTE: While the time is
being set, all other keys should be ignored.
After the user is satisfied with the time setting,
the t key may once again be pressed
to return to the regular time display. Note that while
setting the time, it does not make sense to keep running
the clock!
- Reset Time: When the user presses the r
key, the time should be reset to AM 12:00:00
and the clock should start ticking immediately after the
reset.
- Sound Alarm:
If the alarm status is ON and the alarm setting
is the same as the time, the program should sound the
alarm (send the BELL character 20 to 30 times to the
screen).
- Exit Program: The program should terminate when
the escape key is pressed at any time except while setting the
time.
Submission Instructions: Electronically submit clock.asm
and clock.exe by the deadline and submit program listing of
clock.asm.
Hints:
- Start small. For example, you might first write a program
that simply clears the screen and draws the box. Then, add the
time to the box. Make the clock tick next. Then, start adding
the functionality one at a time.
- To introduce a 1 second delay, you may set up a separate
procedure which has several nested loops. I set up one with
3 levels of nesting with the number of iterations being
10H, 100H and 100H for the outer, middle and inner loop
respectively. You may experiment with these numbers to get a reasonable
delay. It does not have to be exact one second!
- You will need to make the cursor disappear (to avoid an
annoying flicker). Use INT 10H, function 03H, to determine the
top and bottom scan lines of the cursor. Save these in the
data segment. Then use INT 10H, function 01H, to make the cursor
invisible. Just before the program terminates, use the same
interrupt to restore the cursor to its original size.
- Some new DOS/BIOS services to use in this assignment (you will
need some of the services used in Assignment 1 as well):
INT 10H, Function 01H: Set Cursor Size
Useful for changing the size of the cursor or making it disappear
entirely. See Page 162 of the text for details. To make the
cursor disappear, put 20H in CH before performing the interrupt.
INT 16H, Function 11H: Determine if key pressed
Useful to check if the user has pressed any key. See P 191 for details.
INT 16H, Function 10H: Read key from keyboard
Useful after we have determined that the user has pressed a key.
- You will need to use the extended ASCII codes for the characters
that will make up the box containing the time (see Page 171 of text).
These are: CDH for Horizontal double line, BAH for Vertical double line,
C9H for Top Left, C8H for Bottom Left, BBH for Top Right and
BCH for Bottom Right.
- Be careful not to display 12:00:00 as 00:00:00.
- Be careful about midnight and noon transitions.
Raj Sunderraman