C code inicator of NMI handler

Discussion about other targets
Post Reply
Creator
Member
Posts: 20
Joined: Tue Feb 21, 2023 4:07 am

C code inicator of NMI handler

Post by Creator »

How to I indicate in the C code that a routine is the NMI handler ?

I have spent some time in the bowels of https://github.com/z88dk/z88dk/wiki without finding that info. I am using #pragma output CRT_ENABLE_NMI = -1 and I see that it did put a hook at 66h but where it points has only a retn where I need my NMI handler to be or pointed to.

Standalone Z80 bd.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Re: C code inicator of NMI handler

Post by dom »

This does work for me:

Code: Select all

void z80_nmi() __critical __interrupt
{
}

void main( void ) {
}
Then compile with (for newlib):

Code: Select all

zcc +z80 eg.c -pragma-define:CRT_ENABLE_NMI=2 -m
and for classic:

Code: Select all

zcc +z80 eg.c -clib=classic -pragma-define:CRT_ENABLE_NMI=2 -m
And the nmi routine is correctly bound.
Creator
Member
Posts: 20
Joined: Tue Feb 21, 2023 4:07 am

Re: C code inicator of NMI handler

Post by Creator »

Yes, thank you, that does it. Are there other places for info that I should be looking at ?
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Re: C code inicator of NMI handler

Post by dom »

For classic, the pragma page is here: https://github.com/z88dk/z88dk/wiki/Classic--Pragmas

They're mostly the same for newlib but, of course, CRT_ENABLE_NMI varies slightly to cope with some of the classic targets that need NMI hooked by the CRT.
Post Reply