The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: AndyR on March 11, 2005, 09:54:44 AM

Title: MIDI in routines with callback?
Post by: AndyR on March 11, 2005, 09:54:44 AM
Hi all,

I'm new to windows ASM programming so treat me gently!

I wonder if anybody knows of any examples of a MIDI IN program with a callback process in MASM32. I found one in C and converted it, but the callback routine is declared as type CALLBACK and don't quite know what to do with it! How do I create it in ASM?

Grateful for any advise, examples or links etc.

Thanks

Andy.
Title: Re: MIDI in routines with callback?
Post by: Tedd on March 11, 2005, 11:45:13 AM
You don't actually need to do anything special with the callback function. The CALLBACK type is just a C thing, there's no need for it in asm.
So just define the function as normal, and as long as you give the address to the registration function, then it should all work fine (assuming everything else is correct :bdg)
Title: Re: MIDI in routines with callback?
Post by: AndyR on March 11, 2005, 04:19:04 PM
Hi all, :wink :wink
Thanks for that Tedd. The reason for asking the question was that I've already tried running the prog, but it seems unstable, so I thought that the CALLBACK thing might have something to with it. I must have something not quite right.
I would be nice to have an example.  :wink

Title: Re: MIDI in routines with callback?
Post by: sluggy on March 13, 2005, 01:07:33 AM
Are you sure that the original C code was not buggy? Are you using global variables in the callback function, or are you calling out to other functions from the callback?

Title: Re: MIDI in routines with callback?
Post by: MichaelW on March 13, 2005, 04:01:53 AM
And are you sure that your callback is preserving the values in EBP, EBX, EDI, or ESI.
Title: Re: MIDI in routines with callback?
Post by: mariø on March 15, 2005, 07:28:38 PM
if you can post your code maybe some can help you (i think that all people that know masm understand any hight level language)
Title: Re: MIDI in routines with callback?
Post by: pbrennick on March 15, 2005, 08:14:32 PM
Hi AndyR,
Just to amplify, you better make sure you are pushing and popping those registers mentioned by Michael if you are using them.  Or else you can include a 'uses' statement in the procedure declaration.  Anything else will cause Windows to hiccup or worse.

Paul
Title: Re: MIDI in routines with callback?
Post by: AndyR on March 21, 2005, 07:34:38 AM
Hi all,

Sorry for the late reply, my phone line came down in a storm, they've only just fixed it.
Yes, you were all right, I figured it out for myself in the end, a couple of pushes and pops and it burst into action.
Thanks to all for your help.

Andy.