I've written a small program to test the randomness of the interrupt vector in IM 2. I was inspired by Sigma's interrupt tutorial (archived version if you have problems accessing the original) which, unfortunately, seems to get it wrong. But it is an interesting idea, and I'd like to explore it on hardware.
The program works by writing alternate values to the interrupt table. This restricts us to exploring one bit of the vector at a time, but that is sufficient for this purpose. Say you want to find out what the value of bit 2 (AND mask $04) is. The first 8 bytes of the table will look like this:
Code: Select all
$8a $8a $8a $8a $8b $8b $8b $8b
If bit 2 is zero, the interrupt vector will be either $8a8a or $8a8b. The code at $8a8a looks like this:
Code: Select all
8A8Ah 18h ; JR
8A8Bh 18h ; JR
8A8Ch 17h
...
8AA4 $C3 XX XX ; JP XX XX
The two handlers just increment a register to count how many times they are called. This process is repeated for all 8 bits - with each interrupt being called 1024 times. In the meantime, junk instructions are executed.
Here is a PTI screen:
For each bit, it reports the number of times it was set and reset when the interrupt occurred. Here's the interesting bit - on actual hardware (84+) I get the following:
Code: Select all
# RES # SET
Bit 0: 0 1024
Bit 1: 0 1024
Bit 2: 0 1024
Bit 3: 0 1024
Bit 4: 0 1024
Bit 5: 0 1024
Bit 6: 0 1024
Bit 7: 0 1024
You can download the 83+ binary and/or the TASM source.
Thanks!