Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ucla-cs!zen!ucbvax!decvax!gsg!ariola From: ariola@gsg.UUCP Newsgroups: comp.sys.ibm.pc Subject: Use DOS interrupt 1C (timer tick) from MSC help needed Message-ID: <338@gsg.UUCP> Date: Wed, 2-Sep-87 18:11:44 EDT Article-I.D.: gsg.338 Posted: Wed Sep 2 18:11:44 1987 Date-Received: Fri, 4-Sep-87 04:36:07 EDT Lines: 66 Keywords: MS-DOS timer interrupt MSC clock System: IBM PC/AT compatible Sofware: running DOS 3.20, MSC vresion 4.0 Problem: use type 1C timer interrupt from a C program. I tried to modify interrupt service routine of type 1C from my main program (see main.c below) to be function 'ciao' which is written in assembly (see file ciao.asm below). I thought I followed all the instructions among 5 different DOS reference books but I was not able to make it working properly. What happened was: the control is transferred to ciao but the segment registers are all screwed up and the machine halts. Can someone points out what's wrong with it? Thanks in advance... (BTW, I was using codeview to debug this.) The following is the source code for assembly routine ciao.asm and its calling C program int.c: ---------------------------------------------------------------------- ; Static Name Aliases ; TITLE ciao1 ; NAME ciao1.C .287 _TEXT SEGMENT BYTE PUBLIC 'CODE' _TEXT ENDS _DATA SEGMENT WORD PUBLIC 'DATA' _DATA ENDS CONST SEGMENT WORD PUBLIC 'CONST' CONST ENDS _BSS SEGMENT WORD PUBLIC 'BSS' _BSS ENDS DGROUP GROUP CONST, _BSS, _DATA ASSUME CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP _TEXT SEGMENT PUBLIC _ciao _ciao PROC NEAR ; Do nothing, just return from interrupt iret _ciao ENDP _TEXT ENDS END ---------------------------------------------------------------------- #include extern ciao(); main () { union REGS irg, org; /* input, output registers */ struct SREGS srg; /* segment registers */ struct { unsigned int seg; unsigned int off; } c; char far *p; p = ( char *)((long)ciao); segread(&srg); c.off = FP_OFF(p); c.seg = srg.cs; srg.ds = c.seg; irg.x.dx = c.off; irg.h.ah = 0x25; irg.h.al = 0x1c; intdosx(&irg, &org, &srg); /* set 1C interrupt to: ciao */ for (;;) printf ("wait..."); }