Visual C++ Function Address
Posted: Fri Apr 24, 2009 6:26 pm
Hi,
I have this problem:
1--- the declaration
2--- the values
and
then
3----- the problem (for every irq)
this simple example just works fine:
[ JamesM: Added code tags. ]
I have this problem:
1--- the declaration
Code: Select all
void *irq_routines[16];
Code: Select all
void _cls_irq::InstallHandler(int irq, void (*handler)(tpRegistersStructure *))
{
irq_routines[irq] = (void *)handler;
}
Code: Select all
void handler_Timer(tpRegistersStructure *r)
{
blablabla
}
Code: Select all
IRQ.InstallHandler(0, handler_Timer); //get handler_timer function address and put on irq_routines[0]
Code: Select all
void handler_IRQ(tpRegistersStructure *r)
{
void (*handler)(tpRegistersStructure *r); //pointer for incoming function with this format -> return (void *) and
//get (tpRegistersStructure *r) as parameters
handler = irq_routines[(r->int_no - 32)]; //with this index, get its correspondent function address
(this does not run!!!!!!!!!!!!!!!!!! -> Can you tel me why???
this simple example just works fine:
Code: Select all
void (*p)(int i);
p = myfunction;
(*p)(23); // call myfunction with 23 as parameter