Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!ptsfa!ihnp4!laidbak!daveb From: daveb@laidbak.UUCP (Dave Burton) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Re: Accessing data from an interrupt handler Message-ID: <1188@laidbak.UUCP> Date: Fri, 9-Oct-87 13:54:45 EDT Article-I.D.: laidbak.1188 Posted: Fri Oct 9 13:54:45 1987 Date-Received: Sun, 11-Oct-87 17:39:22 EDT References: <330@picuxa.UUCP> Reply-To: daveb@laidbak.UUCP (Dave Burton) Organization: is pretty bad/My method of Lines: 31 Xref: mnetor comp.sys.ibm.pc:8885 comp.lang.c:4807 In article <330@picuxa.UUCP> gp@picuxa.UUCP (Greg Pasquariello X1190) writes: >... >I wrote a test program in MSC 4.0 that will >set up an interrupt handler for the clock interrupt (0x1C). >... >The next thing I did was change the int >handler to increment a word of memory (a variable) rather than print stars, >and when the interrupt was done being serviced, the C program printed the >value of the variable. Problem was, the value was ALWAYS 0. I then ran >the interrupt handler and the C code (a single, small model program) through >Codeview, and found that the variable *WAS* being incremented. Now can anyone >tell me why the variable is incremented when the routine is used as a called >function, but not when the routine is used as an interrupt routine? >... (venturing to speak without the manuals handy...) The way you have described the problem, your variable is not being referenced properly ONLY when called by the interrupt router. I believe (95% sure) that SS is changed when the interrupt is first serviced. If you wish to access any variables from your C program, you must retrieve the SS pointer from the stack, then add the variable's offset to it. A good book to read which addresses this subject is "Supercharging C with Assembly". It is 100% PC/MSDOS specific, but if you're unfortunate enough to be stuck there, this book gives decent advice and examples. -- --------------------"Well, it looked good when I wrote it"--------------------- Verbal: Dave Burton Net: ...!ihnp4!laidbak!daveb V-MAIL: (312) 505-9100 x325 USSnail: 1901 N. Naper Blvd. #include Naperville, IL 60540