Is IM2 mode supported on the ZX81 ?
Posted: Sun May 31, 2020 2:08 pm
Hello,
This code crashes, tested on ZesarUX and ZXSP. Is IM2 mode supported on this target ? maybe the vector table has to be located elsewhere ?
This code crashes, tested on ZesarUX and ZXSP. Is IM2 mode supported on this target ? maybe the vector table has to be located elsewhere ?
Code: Select all
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <zx81.h>
#include <im2.h>
// zcc +zx81 -create-app isr03.c
int x = 0;
M_BEGIN_ISR(isr)
{
++x;
}
M_END_ISR
void main(void)
{
#asm
di
#endasm
im2_Init((void *)0xd300); // place z80 in im2 mode with interrupt vector table located at 0xd300
memset((void *)0xd300, 0xd4, 257); // initialize 257-byte im2 vector table with all 0xd4 bytes
bpoke(0xd4d4, 195); // POKE jump instruction at address 0xd4d4 (interrupt service routine entry)
wpoke(0xd4d5, (unsigned int) isr); // POKE isr address following the jump instruction
#asm
ei
#endasm
loop:
//do stuff
goto loop;
}