g-man@flowzone.EBay.Sun.COM (Luis Navarro) (03/04/91)
I am trying to write a Windows 3.0 application that uses an assembly level interrupt handler to handle MIDI (musical instrument digital interface) input/output and am having some serious problems with the data interfacing. Please read on if you are familar with all or any of the following as they relate to windows programming: 1. MIDI 2. interrupt handlers 3. assembly level routines communicating with Windows C code The following are some more details regarding what I'm trying to do, as well as the problems I'm experiencing: I have obtained some C/assembly code originally written for interrupt driven MIDI communcations in DOS. The assembly level stuff consists of the interrupt handler (an interrupt is generated for every MIDI byte that arrives at the MIDI interface) and the data i/o. The C code uses the assembly routines to do the rest. Now I am trying to use this assembly code in a relative simple windows program and am having some great difficulties. My main objective is to modify the already existing assembly/C code so that the interrupt handler will post a windows message (encapsulating the current MIDI data byte in the message). How does one go about doing this? Furthermore, the interrupt handler appears to work in real mode, but not in standard or 386 as if the data buffer (created and declared in the assembly code) was empty or if interrupts suddenly weren't being generated at all. Any ideas, advice, or general pointers would be greatly appreciated. --Luis (g-man@EBay.Sun.COM)
thj@mtcchi.uucp (XT0221000-Tom Hjellming(ZG90210)0000) (03/06/91)
g-man@flowzone.EBay.Sun.COM (Luis Navarro) writes: >I am trying to write a Windows 3.0 application that uses an assembly >level interrupt handler to handle MIDI (musical instrument digital >interface) input/output and am having some serious problems with the >data interfacing. Please read on if you are familar with all or any of >the following as they relate to windows programming: > 1. MIDI > 2. interrupt handlers > 3. assembly level routines communicating with Windows C code >The following are some more details regarding what I'm trying to do, as >well as the problems I'm experiencing: >I have obtained some C/assembly code originally written for interrupt >driven MIDI communcations in DOS. The assembly level stuff consists of >the interrupt handler (an interrupt is generated for every MIDI byte that >arrives at the MIDI interface) and the data i/o. The C code uses the >assembly routines to do the rest. Now I am trying to use this assembly >code in a relative simple windows program and am having some great >difficulties. >My main objective is to modify the already existing assembly/C code so >that the interrupt handler will post a windows message (encapsulating the >current MIDI data byte in the message). How does one go about doing this? You can use the PostMessage() function. Actually, PostMessage is the ONLY Windows function that you can call while you are processing your interrupt (due to the fact that Windows is non-reentrant). Depending on the frequency of calls to PostMessage(), you may run into problems filling up the application queue. The default message queue can only hold something like 8 messages in it. You can increase the size of the queue using SetMessageQueue() - be sure to do this before your application creates any Windows. Even increasing the size may not be enough. In my application, I had to introduce my own specialized queueing functions that my ISR calls. The queueing functions then post one message to the windows queue to indicate data in the 'other' queue (the queueing functions use a flag to indicate whether or not the message has been posted). >Furthermore, the interrupt handler appears to work in real mode, but not in >standard or 386 as if the data buffer (created and declared in the assembly >code) was empty or if interrupts suddenly weren't being generated at all. >Any ideas, advice, or general pointers would be greatly appreciated. What interrupt are you using? My app is successfully trapping the timer interrupt (IRQ0 or Int 8h), but (as you state) in standard or 386 enhanced mode I was not seeing interrupts on IRQ2 (Int 0Ah) which is a shared interrupt with the second 8259 P.I.C. chip. While I haven't gotten around to asking Microsoft, I suspect that Windows is treating this interrupt specially. Other tidbits that you may already know about: 1) Be sure to put your ISR code in a DLL with FIXED code and data segments. 2) You probably want to also call GlobalPageLock for the code and data segments. 3) If your hardware uses memory-mapped or shared memory at a fixed segment address (say D000:0000 for example), then be sure to convert the real mode segment into a protected mode selector. You can use the DPMI service Int 31h to do this. >--Luis (g-man@EBay.Sun.COM) Enjoy, Tom -- Tom Hjellming Software Consultant Analysts International Corp. (AiC) Schaumburg, IL
brent@well.sf.ca.us (Brent Southard) (03/06/91)
In article <972@grapevine.EBay.Sun.COM> g-man@EBay.Sun.COM (Luis Navarro) writes: >I am trying to write a Windows 3.0 application that uses an assembly >level interrupt handler to handle MIDI... > >I have obtained some C/assembly code originally written for interrupt >driven MIDI communcations in DOS. The assembly level stuff consists of >the interrupt handler (an interrupt is generated for every MIDI byte that >arrives at the MIDI interface) and the data i/o. The C code uses the >assembly routines to do the rest. Now I am trying to use this assembly >code in a relative simple windows program and am having some great >difficulties. The interrupt handler must be in a FIXED code segment, and should be in a DLL (dynamic link library). In order for you to attach the handler to the interrupt in protected mode you will need to use some DPMI (dos protected mode interface) services. You can get the DPMI spec free from Intel, or download it from CompuServe. Sorry, I don't have the number for Intel handy, but someone on the net will... Once your handler is installed, it should be a simple matter for it to dispatch messages to any windows who care to listen. brent -- brent southard (313) 643-1971 | usenet: ...!well!brent ImageTech Corp (313) 353-7900 | bix: brent "When frog licking is outlawed, only outlaws will lick frogs."
mgoerick@hpwad.WAD.HP.COM (#Michael Goericke) (03/20/91)
I'm also trying to trap the timer interrupt but with no success. Can you please post the code that installs the interrupt handler. ------------- Michael Goericke Hewlett Packard Germany