Z80 IM1 vs JR - redcode/Z80 GitHub Wiki

Platform: ZX Spectrum
Author: Helcmanovsky, Peter
Release date: 2022-02-11
License: MIT
Links: Discord post 1, Discord post 2
Download: tap, asm (hosted) - tap, asm (Discord post)

Description

Test to verify that IM1 mode will call handler at 38h even when interrupt happens during jr instruction and never the 30h handler (the Visual Z80 Remix simulator had a bug and was wrongly landing at 30h when IM1 interrupt happened during jr instruction).

How it works:

Waits for interrupt with halt, prepares values in registers (BC=2, HL=0) and goes into long-enough block of jr $+2 instructions to hit another interrupt request during jr. At the end of the block it returns back to BASIC with zero when IM1 handler at 38h was called and some non-zero address when BC_SPACES at 30h was called.

Accidentally called 30h routine would work as BC_SPACES, allocating BC bytes of the BASIC work buffer and return address to the new space in HL, while 38h IM1 handler does preserve all register, so HL will stay zero, then HL is returned to BASIC as return value and checked by the BASIC part of test to print result.

Expected results

img

⚠️ **GitHub.com Fallback** ⚠️