Classic Computer Magazine Archive COMPUTE! ISSUE 71 / APRIL 1986 / PAGE 107

Screen Clock For IBM

Marc Sugiyama

Have you ever become submerged in a project while working on your computer and suddenly discovered it is hours past your bedtime? Or maybe you need to keep a detailed log of your worktime on the computer for business or tax purposes. If so, this utility is the answer-it constantly displays all this information and more on your monitor screen. It works with IBM PC and PCjr computers using DOS 2.0 or higher.


Large mainframe computers generally provide a sysline on the terminal screen which tells you the current date and time, who has logged on or off, and whether you've received any new electronic mail. Obviously, not all of these things apply to single-user personal computers, but some of the features would be nice to have.
    "Screen Clock" is a short machine language program that prints the day of the week, date, current time, and log-on time at the top of the screen. This information appears no matter what else your computer is doing. You can be running a word processor, copying files, programming, or whateverthe day, date, and time will always be visible.
    You might be wondering how it's possible to keep Screen Clock active while running another program; an IBM PC with PC-DOS isn't capable of multitasking. Screen Clock gets around this restriction by not using any PC-DOS function calls, relying instead on the BIOS (Basic Input/Output System) to handle the screen. This has several fortunate consequences:
    • Sysline updates are not redirected to a file if you're using DOS file redirection.
    • Sysline updates are not printed if you're echoing output to the printer. (But the sysline is printed if you press PrtSc for a screen dump.)
    • Screen Clock always updates the current "active" screen. It doesn't matter if you switch from the monochrome monitor to the color monitor, change pages in the color screens, or even enter a graphics mode-the date and time are always there.

Winding Up The Clock
Type in the program listing below, save a copy on disk, then type RUN. The program is a BASIC loader that creates a machine language file on your disk with the filename CLOCK.COM. To start the clock, simply type CLOCK (upperor lowercase is fine) at the A> DOS prompt. A sysline similar to this should appear on the top line of your screen:

Wed Jan 01, 1986 12:01A (00:37)

    The day of the week, date, and current time are self-explanatory. The figure in parentheses is the elapsed time (in hours and minutes) since Screen Clock was started or reset. This "log-on" time runs up to 23 hours and 59 minutes, then rolls over to 00:00.
    When you run Screen Clock from DOS, you can select various options by appending commands after typing CLOCK. Each command consists of a slash (/) symbol, a character, and sometimes a number. Here are the commands and options:
    /Cn (Chime) where n is an integer from 0 to 3. /C0 means no chiming; /C1 makes the clock chime hourly; /C2 chimes every half-hour; and /C3 chimes every 15 minutes. A chime is a low beep which lasts for less than one second. Even if the screen updates are turned off, Screen Clock always chimes if you have told it to. The default is no chiming.
    /Un (Update) where n is an integer from 1 to 9. This sets how often screen updates are to take place-n is the number of halfseconds between updates. The more frequent the updates, the more often the date and time are refreshed on the screen. However, more frequent updates also make other programs run more slowly. The default is equivalent to /U2 (one second between updates).
    /M (Military time). This selects military (24-hour) time.
    /S (Standard time). This selects standard 12-hour time with an a.m./p.m. marker. Screen Clock defaults to standard time.
    /R (Reset). This resets the logon timer. Screen Clock automatically resets itself to 00:00 when first run.

    For example, typing CLOCK /U3/M/C1 at the DOS prompt loads and runs Screen Clock, sets updates every 1½ seconds, sets military time, and makes the clock chime every hour.

The Disappearing Clock
Occasionally, the Screen Clock sys line may get in the way. For example, it may hide text printed on the top line of the screen. You can make it disappear by pressing CTRL and both SHIFT kevs simultaneously. Pressing this combination again turns the sysline back on.
    Since Screen Clock maintains its own clock, it might not agree precisely with the DOS clock. Gen erally, it's never more than half a minute off.
    Note that the day, date, and time are reset every time you run Screen Clock. If you change the system date and time, you can reset Screen Clock by running it again. For example, the following would reset the display to 8:00 p.m. on February 14 (the A> prompts are supplied by DOS):

A> time 20:00:00
A> date 02-15-86
A> clock

The log-on time is not reset unless you append the /R command to CLOCK.
    Although Screen Clock makes it appear that your computer is doing more than one thing at a time, it's important to remember that computers can really perform only one task at a time (a factor of the basic architecture of all personal computers to date). If the computer spends some if its time updating the sysline, that's time away from running the main program. Thus, the more often the sysline is updated, the more time it steals from the computer, and the slower the main program seems to run. However, the part of Screen Clock that takes the most time is printing the sysline on the screen. If screen updates are turned off, there is virtually no slowdown. So during heavy number crunching you might want to turn the sysline updates off.
    I've been using Screen Clock quite a bit and haven't noticed much loss of performance at all. It seems that the computer spends a lot of its time waiting for input (from the keyboard, the disk drives, and so on); all we're doing is giving it something else to do in its "spare time." I have yet to find a program which doesn't work with Screen Clock.
    As the power of personal computers increases, it becomes possible to include features once found only on large mainframe computers. A sysline such as Screen Clock is another step in this direction.

How It Works
Mainframe syslines are generally on the bottom row of the screen. The Screen Clock sysline, however, must be on the top row because there's no way via PC-DOS to keep the bottom row from scrolling. The sysline would keep traveling up the screen every time the screen was scrolled. By placing the sysline on the top row, it can be refreshed each time it scrolls off the top of the screen.
    The program itself is broken into two sections, resident and nonresident. The resident portion up dates the internal counters, sounds the chimes, and updates the screen display. It's driven by the user interrupt 1Ch and is executed about 18 times a second. The nonresident part sets the initial date and time and changes the program's options.
    When you execute CLOCK.COM, the program first checks to see if the resident portion is already installed. This is important only when the program returns control to DOS. Then it sets the current date and time and checks for any optional parameters. After this, the program is ready to return to DOS. If the program was already installed, it simply returns to DOS and does nothing else. If it needs to be installed, it first deallocates the environment space, then returns to DOS with the "terminate but stay resident" call to store the resident portion of the program safely in memory.

For instructions on entering this listing, please refer to "COMPUTE!'s Guide to Typing In Programs" in this issue of COMPUTE!.

IBM Screen Clock

EF 100 CLS:LOCATE 10,10:PRINT"Wr
       iting file ..."
OM 110 OPEN "clock.com" FOR OUTP
       UT AS #1
EL 120 FOR I=1 TO 1310:READ BYTE
       :CKSUM=CKSUM+BYTE:IF BYTE
       <0 THEN FOR J=1 TO ABS(BY
       TE):PRINT#I,CHR$(0);:NEXT
        J:GOTO 140
GH 130 PRINT#1,CHR$(BYTE);
GO 140 NEXT I:CLOSE 1
FJ 150 IF CKSUM <> 124185 THEN P
       RINT"** Error in DATA sta
       tements **":KILL ""clock.c
       om ":STOP
HJ 160 PRINT:PRINT"File for cloc
       k.com has been created.":
       END
KN  200 DATA 233,51,4,74,97,110,
       32,70,101,98,32,77
DG  210 DATA 97,114,32,65,112,11
       4,32,77,97,121,32,74
EB  220 DATA 1.17,110,32,74,117,1
       06,32,65,117,103,32,63
NP  230 DATA 101,112,32,79,99,11
       6,32,78,111,118,32,68
NJ  240 DATA 101,99,32,31,28,31,
       30,31,30,31,31,30
FP  250 DATA 31,30,31,83,117,110
       ,32,77,111,110,32,84
JK  260 DATA 117,101,32,87,101,1
       00,32,84,104,117,32,70
PH  270 DATA 114,105,32,83,97,11
       6, SL, -C, 1 , fn, t , o.
AE  280 DATA 19,2,-5,240,18,0,1,
       -86,13,255,80,97
ML  290 DATA 117,108,80,83,81,82
       ,86,87,85,30,6,140
6K  300 DATA 200,142,216,142,192
       ,232,198,1,232,45,0,232
OP  310 DATA 133,0,160,108,1,58,
       6,109,1,114,23,187
BM  320 DATA 91,1,232,158,1,137,
       14,95,1,232,144,0
CJ  330 DATA 128,62,111,1,0,116,
       3,232,250,0,7,31
GI  340 DATA 93,95,94,90,89,91,8
       8,207,180,2,205,22
NC  350 DATA 36,7,60,7,116,6,198
       ,6,115,1,0,195
ON  360 DATA 128,62,115,1,0,117,
       67,128,54,111,1,1
BJ  370 DATA 198,6,115,1,1,128,6
       2,111,1,0,116,4
PE  380 DATA 232,197,0,195,180,1
       5,205,16,136,62,114,1
CN  390 DATA 180,3,205,16,137,22
       ,112,1,180,2,186,-2
OH  400 DATA 205,16,185,31,0,176
       ,32,180,14,205,16,226
HO  410 DATA 250,180,2,13x3,62,11
       4,1,139,22,112,1,205
PM  420 DATA 16,195,128,62,199,1
       ,255,116,25,160,199,1
NA  430 DATA 58,6,198,1,119,5,25
       4,6,199,1,195,198
JA  440 DATA 6,199,1,255,228,97,
       36,252,230,97,195,138
EA  450 DATA 22,197,1,128,250,0,
       117,1,195,128,62,95
DO  460 DATA 1,0,117,8,128,62,19
       6,1,0,116,62,195
DC  470 DATA 128,250,1,116,50,12
       8,62,95,1,30,117,8
PN  480 DATA 128,62,196,1,0,116,
       42,195,128,250,2,116
KK  490 DATA 30,128,62,95,1,15,1
       17,8,128,62,196,1
BF  500 DATA 0,116,22,195,128,62
       ,95,1,45,117,8,128
OM  510 DATA 62,196,1,0,116,7,19
       5,198,6,196,1,0
PO  520 DATA 195,198,6,196,1,1,1
       98,6,199,1,0,176
JJ  530 DATA 182,230,67,184,102,
       10,230,66,138,196,230,66
GF  540 DATA 228,97,12,3,230,97,
       195,198,6,108,1,0
OI  550 DATA 191,116,1,252,139,5
       4,102,1,209,230,209,230
PJ  560 DATA 129,1.98,63,1,185,4,
       0,243,164,139,54,97
GC  570 DATA 1,209,230,209,230,1
       29,198,255,0,185,4,0
OB  580 DATA 243,164,160,99,1,23
       2,22,1,184,44,32,171
FH  590 DATA 160,101,1,232,12,1,
       160,100,1,232,6,1
FO  600 DATA 176,32,170,1-39,14,9
       5,1,138,38,110,1,232
CE  610 DATA 1,1,184,32,40,171,1
       87,104,1,232,58,0
IP  620 DATA 180,1,232,242,0,176
       ,41,170,160,15,205,16
NO  630 DATA 136,62,114,1,180,3,
       205,16,137,22,112,1
FP  640 DATA 180,2,186,-2,205,16
       ,190,116,1,139,207,43
KH  650 DATA 206,172,180,14,205,
       16,226,249,180,2,138,62
IH  660 DATA 114,1,139,22,112,1,
       205,16,195,139,87,2
NB  670 DATA 139,7,187,69,4,247,
       243,179,60,246,243,138
CK  680 DATA 232,138,204,195,187
       ,91,1,232,16,0,115,3
AD  690 DATA 232,43,0,187,104,1,
       232,5,0,254,6,108
JL  700 DATA 1,195,255,7,117,3,2
       55,71,2,131,127,2
DI  710 DATA 24,114,17,129,63,17
       6,0,114,11,199,7,-2
FJ  720 DATA 199,71,2,-2,249,195
       ,248,195,255,6,102,1
AH  730 DATA 131,62,102,1,6,118,
       6,199,6,102,1,-2
IA  740 DATA 254,6,99,1,139,22,9
       7,1,232,49,0,58
OM  750 DATA 22,99,1,115,42,198,
       6,99,1,1,255,6
NI  760 DATA 97,1,131,62,97,1,12
       ,118,26,199,6,97
PL  770 DATA 1,1,0,254,6,100,1,1
       28,62,100,1,99
FA  780 DATA 11B,9,198,6,100,1,0
       ,254,6,101,1,195
PD  790 DATA 138,218,50,255,138,
       151,50,1,128,251,2,117
CA  800 DATA 16,246,6,100,1,3,11
       7,9,128,62,100,1
JH  810 DATA 0,116,2,254,194,195
       ,212,10,5,48,48,134
IG  820 DATA 196,171,195,182,32,
       128,252,1,116,18,182,65
EB  830 DATA 128,253,12,114,5,18
       2,80,128,237,12,10,237
EK  840 DATA 117,2,181,12,138,19
       7,232,217,255,176,58,170
JL  850 DATA 138,193,232,209,255
       ,128,254,32,116,3,138,198
MB  860 DATA 170,195,82,101,113,
       117,105,114,101,115,32,68
BM  870 DATA 79,83,32,50,46,48,3
       2,111,114,32,97,98
CE  880 DATA 111,118,101,46,13,1
       0,36,78,111,119,32,105
PG  890 DATA 110,115,116,97,108,
       108,105,110,103,32,114,10
       1
Fl  900 DATA 115,105,100,101,110
       ,116,32,112,111,114,116,1
       05
BH  910 DATA 111,110,32,111,102,
       32,67,76,79,67,75,46
OK  920 DATA 13,10,36,39,32,117,
       110,107,110,111,119,110
CH  930 DATA 32,112,97,114,97,10
       9,101,116,101,114,46,13
PH  940 DATA 10,36,83,112,101,99
       ,105,102,121,32,97,32
ED  950 DATA 110,117,109,98,101,
       114,32,102,114,111,109,32
JK  960 DATA 49,45,57,32,102,111
       ,114,32,39,85,39,32
KG  970 DATA 115,119,105,116,99,
       104,13,10,36,83,112,101
JE  980 DATA 99,105,102,121,32,9
       7,32,110,117,109,98,101
FO  990 DATA 114,32,102,114,111,
       109,32,48,45,51,32,102
DP  1000 DATA 111,114,32,39,67,3
        9,32,115,119,105,116,99
J6  1010 DATA 104,13,10,36,-2,47
        ,180,48,205,33,60,0
KI  1020 DATA 117,9,186,125,4,18
        0,9,205,33,205,32,184
CC  1030 DATA 0,55,205,33,136,22
        ,53,5,187,125,4,177
PF  1040 DATA 4,211,235,67,137,3
        0,51,5,184,28,53,205
HM  1050 DATA 33,190,200,1,141,1
        27,252,185,4,0,252,243
IE  1060 DATA i66,13i,249,0,116,
        41,180,9,186,154,4,205
10  1070 DATA 33,184,28,37,186,2
        04,1,205,33,30,7,232
JE  1080 DATA 32,0,232,87,0,161,
        44,0,142,192,180,73
KP  1090 DATA 205,33,184,0,49,13
        9,22,51,5,205,33,232
NJ  1100 DATA 8,0,232,63,0,184,0
        ,76,205,33,6,31
KK  1110 DATA 180,0,205,26,137,2
        2,91,1,137,14,93,1
BD  1120 DATA 180,42,205,33,50,2
        28,163,102,1,138,198,163
JD  1130 DATA 97,1,136,22,99,1,1
        98,6,101,1,19,129
BI  1140 DATA 233,108,7,128,249,
        99,118,7,128,233,100,254
DH  1150 DATA 6,101,1,136,14,100
        ,1,195,30,14,31,190
BF  1160 DATA 129,0,252,172,60,3
        2,116,251,60,13,116,51
BN  1170 DATA 58,6,53,5,116,241,
        138,224,36,223,60,82
IL  1180 DATA 116,39,60,77,116,5
        1,60,83,116,55,60,85
0G  1190 DATA 116,59,60,67,116,9
        0,80,178,39,180,2,205
LP  1200 DATA 33,88,138,212,180,
        2,205,33,186,198,4,180
KC  1210 DATA 9,205,33,31,195,38
        ,199,6,104,1,-2,38
CI  1220 DATA 199,6,106,1,-2,235
        ,178,38,198,6,110,1
KE  1230 DATA 1,235,170,38,198,6
        ,110,1,0,235,162,172
OD  1240 DATA 60,49,114,221,60,57
        ,119,17,44,48,177,3
FN  1250 DATA 138,224,210,228,2,
        224,38,136,38,109,1,235
GC  1260 DATA 136,186,221,4,180,
        9,205,33,235,187,172,60
LB  1270 DATA 48,114,13,60,51,11
        9,9,44,48,38,162,197
LO  1280 DATA 1,233,109,255,186,
        8,5,180,9,205,33,235
LM  1290 DATA 160,0