home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / pascal / 7387 < prev    next >
Encoding:
Text File  |  1992-12-11  |  2.2 KB  |  60 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!utcsri!torn!watserv2.uwaterloo.ca!mach1!litt3509
  3. From: litt3509@mach1.wlu.ca (Carl Litt u)
  4. Subject: Alarm interrupt programming in TP6 -- Please read
  5. Message-ID: <Bz41KB.Jt8@mach1.wlu.ca>
  6. Sender: litt3509@mach1.wlu.ca
  7. Organization: Wilfrid Laurier University
  8. Date: Fri, 11 Dec 1992 19:45:46 GMT
  9. Lines: 49
  10.  
  11. One little peice of info that I picked up while flipping through one of
  12. my MSDOS programming reference manuals, is that the IBM has a software
  13. interrupt for a built-in alarm.  Basically, the way it works is that
  14. the system clock interrupt 1A (hex) has a service that allows you to
  15. program the alarm to activate interrupt 4A (hex) at a given time.  The
  16. So what you do is make a user interrupt procedure and link it to Int 4A,
  17. and when the alarm goes off, your procedure will run.  I suspect this is
  18. the way some viruses work.  Anyways, I'm trying to write a program to make
  19. use of this 'alarm', but it doesn't seem to work.  Here's what I've got:
  20.  
  21. program TestAlarm;
  22. uses dos;
  23. var regs : registers;
  24.     tempptr : pointer;
  25.  
  26. procedure AlarmProc; interrupt;
  27. begin {AlarmProc}
  28.     writeln('The alarm has sounded');
  29. end; {AlarmProc}
  30.  
  31. procedure {main}
  32.     checkbreak:=false;
  33.     setintvec($4A,@AlarmProc);
  34.     with regs do begin
  35.         ah:=6;     {the service that sets the alarm}
  36.         cl:=0;     {0 hours}
  37.         ch:=0;     {0 minutes}
  38.         dl:=30;    {30 seconds}
  39.     end;
  40.     intr($1A,regs);
  41.     write('Waiting for the alarm to go off...press any key to exit');
  42.     repeat until keypressed;
  43.     checkbreak:=true;
  44. end. {main}
  45.  
  46. What I expect to program to do is write a message to the screen, and wait.
  47. After 30 seconds, the 'alarm' goes off, and my AlarmProc interrupt gets
  48. called.  But, in my tests, the alarm never goes off.  I have 2 sources
  49. of information on the alarm, and one says the alarm goes off after the
  50. given amount of time has elapsed.  The other says the alarm goes off
  51. when the real-time clock reaches the given time.  I've tried it both
  52. ways, and it doesn't work.  Has anyone been playing around with this
  53. alarm, and if you got it to work, how did you do it?
  54.  
  55. BTW: Right now my only concern is getting the alarm to go off.  I don't
  56. care what the program does after the alarm goes off.
  57.  
  58. litt3509@mach1.wlu.ca
  59.  
  60.