microsoft c/ interrupt handler prob
brian_helterline
brianh at hpcvia.CV.HP.COM
Tue Feb 26 04:01:39 AEST 1991
lizac at maccs.dcss.mcmaster.ca (herman) writes:
>Is there any reliable way to use a function written in microsoft c version 6.0
>as an interrupt handler? I tried the following...
>
>void serial_handler(void)
if this function is an interrupt handler, you have to declare it using
the _interrupt type modifier (e.g. _interrupt void serial_handler(void))
>
>{
> asm {pusha}
> t_serial_handler(); /* this function is void t_serial_handler(void) */
> asm {
> popa
> pop si /* this line and the next are from memory ,but i am */
> pop di /* sure that they are in the correct order in my prog */
> leave
> iret }
>}
>(and then put the segment and offset of the serial_handler routine at
>interrupt 0ch vector location).
>it sort of works. I get characters from my t_serial_handler routine, but
>intermittently, and after about 8 to 16, the computer either 1) locks up
>2) returns to DOS, after which any DOS command locks up the computer.
>My t_serial_handler routine is very simple. I think the problem is
>the way that i link the interrupt vector to it.
In general, you aren't free to do anything you like inside an interrupt
handler. Only certain things can be done, especially anything that involves
calls to DOS (e.g. printf())
>Is there an easy way to point to an interrupt handler written in c 6.0?
>Have I erred in my definition of serial_handler?
The easiest way is to use _dos_getvect() & _dos_setvect().
>If you have any insight about this problem, could you please email me
>and let me know what i've done wrong?
>thanks.
>--
>herman love your nails lizac at maccs.dcss.mcmaster.ca or something
>----------
More information about the Comp.lang.c
mailing list