Message-ID: <37F3FA6B.4B73AF3@virtualis.com> Date: Fri, 01 Oct 1999 10:03:55 +1000 From: Alex Mendes da Costa X-Mailer: Mozilla 4.51 [en] (Win98; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: More Assembly! References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: a5-p05.syd.fl.net.au X-Trace: 1 Oct 1999 10:07:30 +1000, a5-p05.syd.fl.net.au Organization: Customer of First Link Internet Services, Sydney, Australia Lines: 47 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Well, basically, I've got this bit of code written in assembly that I want to use as an interrupt. I've only been working with DJGPP for about a week so far, and I don't fully understand all this protected mode stuff. When I wrote an interrupt in real mode I loaded it into memory and then redirected the interrupt to that place in the memory. But I guess its different for this. Just say I have the following: void interrupt() { asm(" blabla "); } and I want an interrupt to point to it. So I have to: 1. Save the __dpmi_get_protected_mode_interrupt_vector of the interrupt I'm changing. 2. Now I don't understand this bit. It says call __dpmi_lock_linear_region a series of times. But how do I know what region I have to lock? 3. Then call __dpmi_set_protected_mode_interrupt_vector with _my_cs() and my function offset. How do I get my function offset? According to the FAQ that is all I have to do (apart from fix up the interrupt at the end). So can anyone help me with the bits I don't get? Thanks, Alex Eli Zaretskii wrote: > > On Thu, 30 Sep 1999, Alex Mendes da Costa wrote: > > > Sorry I keep asking questions!! I was wondering how its possible to load > > a bit of assembly code that has been written in the inline assembler > > into a place in memory, for use in an interrupt. > > Not at run time. You need to assemble the code separately, and put into > your program an array of bytes that are the opcodes of the handler. Then > use memcpy or whatever to copy them. > > But I really don't understand why do you need to go to such lengths? > Can't you simply install your function, however it is written, as an > interrupt handler? (Section 18.9 of the DJGPP FAQ tells you how.) Why > do you need to copy it somewhere?