From: John Fine Newsgroups: alt.os.development,alt.os.assembly,comp.lang.asm.x86,comp.os.msdos.djgpp,alt.lang.asm Subject: Re: ISR with DJGPP in a kernel. Date: 8 Jan 2000 15:17:11 GMT Organization: Group Moderator Lines: 31 Sender: news Approved: Message-ID: <857kdn$6gf$1@bob.news.rcn.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: s5dp6P+QjbeofN6K+U0gqqFwb+Xw/Uwknqn01ejiph0= X-Complaints-To: abuse AT rcn DOT com NNTP-Posting-Date: 8 Jan 2000 15:17:11 GMT X-Accept-Language: en X-Track2: 2 X-Mozilla-Status: 0801 X-Apparently-To: clax86 AT yahoo DOT com via web1704.mail.yahoo.com X-Track: 1-1: 40 X-Mailer: Mozilla 4.51 [en]C-CCK-MCD {Typeline;BankBoston} (WinNT; U) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Groman wrote: > Now I want to create a handler for 0(the timer) in C... > now, how exactly do I do that... I mean it jumps out of the code right in > the middle of the function...and starts another one? > > that doesn't sound right... It is very tricky to write an ISR in DJGPP C. It isn't worth the trouble. > shoud I do the handler in assembly that calls C functions then? Yes. That is the best way. Remember, before calling the C routine, the assembler routine must save the registers that aren't saved by C routines and must set DS and ES equal to SS (I'm assuming you can set up the interrupt conditions so that SS will be correct on entry to the interrupt. That is almost automatic as long as the ISR is in ring 0 and you have only one ring 0 stack segment per TSS). > or is there a way to turn an ordinary DJGPP function > into a handler... I'm fairly sure there isn't. Some Borland C compilers support keywords to declare a routine as an ISR; Gnu C doesn't. You could put some inline ASM at the start and end of the C routine, but it is very hard to coordinate with the entry and epilog code inserted by the compiler. -- http://www.erols.com/johnfine/ http://www.geocities.com/SiliconValley/Peaks/8600/