lake@cs.UAlberta.CA (Robert Lake) (01/31/91)
I am trying to set the system alarm timer on my AT to generate an interrupt that I can catch. My code looks something like this: union REGSS { struct XREGS x; struct HREG h; }; struct XREGS { short ax, bx, cx, dx, si, di, ds, es; }; struct HREG { byte al, ah, bl, bh, cl, ch, dl, dh; }; union REGSS sin, sout; short handler(); main() { /* Disable the real time clock alarm */ initialize(); sin.h.ah = 0x07; int86s(0x1A, &sin, &sout); /* * Set the interrupt vector for arithmetic overflow (0x04) to * point to handler() */ initialize(); sin.h.ah = 0x25; sin.h.al = 0x04; sin.x.dx = (short)&handler; int86s(0x21, &sin, &sout); /* * Now set the system alarm timer to generate an interrupt in 5 * seconds. When the timer expires, the system should trigger an * arithmetic overflow. This call should also enable the real * time clock alarm. */ initialize(); sin.h.ah = 0x06; sin.h.dh = 0x05; /* 5 seconds in binary coded decimal format */ int86s(0x1A, &sin, &sout); while (1); /* wait for the timer to expire */ } initialize() { bzero(&sin, sizeof(sin)); bzero(&sout, sizeof(sout)); } short handler() { /* * Eventually we will want to generate another real time clock alarm, * but for now do something simple. */ write(1, "caught the signal\n", 18); } There may be syntax errors in the above, but I think the overall idea is clear. When I compile and run the code, nothing happens (i.e. the write statement in handler() never appears). I must be missing something obvious, but I don't see what it is. Can anyone steer me in the right direction? Thanks in advance. Rob Lake (lake@cs.ualberta.ca) University of Alberta