Stack overflow while using H.KEYI hook

Page 4/4
1 | 2 | 3 |

Par Grauw

Ascended (10560)

Portrait de Grauw

04-09-2020, 00:53

ROUTINE:
    in a,(#66)
    bit 1,a
    jr z,SPLIT
    bit 0,a
    jr z,REFRESH

Don’t you have those flags reversed? I would expect a 1 (nz) indicates an interrupt, not a 0 (z).

Par tvalenca

Paladin (747)

Portrait de tvalenca

04-09-2020, 19:41

Grauw wrote:
ROUTINE:
    in a,(#66)
    bit 1,a
    jr z,SPLIT
    bit 0,a
    jr z,REFRESH

Don’t you have those flags reversed? I would expect a 1 (nz) indicates an interrupt, not a 0 (z).

Yes, it may be reversed. But this code will be triggered on a non-V9990 INT and should "do nothing and exit".
Anyway, i reversed and it stopped crashing. but this is bugging me, Just works is not as good as "it didn't worked because xyz".

Par Grauw

Ascended (10560)

Portrait de Grauw

04-09-2020, 20:20

jr z: It jumps to the handler if the bit is 0.
jr nz: It jumps to the handler if the bit is 1.

The hang occurs if an interrupt occurs which is not handled, because the interrupt continues to be triggered again as soon as it ei’s and returns at the end, and control is never returned to the main program. I think interrupt flag bit value 1 means: interrupt. Flag bit value 0 means: no interrupt. Unfortunately the V9990 manual is not explicit about this I think, but it is the most logical meaning of the bit values, and if it no longer crashes that seems to confirm it. The openMSX source code also confirms this.

Par tvalenca

Paladin (747)

Portrait de tvalenca

08-09-2020, 15:06

Oh, now I get it. The interrupt signal from V9990 will be kept raised until my code resets it, but since my ISR didn't catch this interrupt, the moment interrupts get enabled it will trigger another INT and loop forever.

Many thanks, Grauw!

Page 4/4
1 | 2 | 3 |