You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Interrupts.md
+22-25Lines changed: 22 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,10 +13,10 @@ using a I/O address. IME can be modified by
13
13
the following instructions/events only:
14
14
15
15
```
16
-
EI ;Enables interrupts (that is, IME=1)
17
-
DI ;Disables interrupts (that is, IME=0)
18
-
RETI ;Enables interrupts and returns (same as the instruction sequence EI, RET)
19
-
<INT> ;Disables interrupts and calls interrupt vector
16
+
EI ;Enables interrupts (that is, IME=1)
17
+
DI ;Disables interrupts (that is, IME=0)
18
+
RETI ;Enables interrupts and returns (same as the instruction sequence EI, RET)
19
+
<INT> ;Disables interrupts and calls interrupt vector
20
20
```
21
21
22
22
where \<INT\> means the operation which is automatically executed by the
@@ -29,21 +29,21 @@ This interacts with the [`halt` bug](<#halt bug>) in an interesting way.
29
29
## FFFF - IE - Interrupt Enable (R/W)
30
30
31
31
```
32
-
Bit 0: VBlank Interrupt Enable (INT 40h) (1=Enable)
33
-
Bit 1: LCD STAT Interrupt Enable (INT 48h) (1=Enable)
34
-
Bit 2: Timer Interrupt Enable (INT 50h) (1=Enable)
35
-
Bit 3: Serial Interrupt Enable (INT 58h) (1=Enable)
36
-
Bit 4: Joypad Interrupt Enable (INT 60h) (1=Enable)
32
+
Bit 0: VBlank Interrupt Enable (INT $40) (1=Enable)
33
+
Bit 1: LCD STAT Interrupt Enable (INT $48) (1=Enable)
34
+
Bit 2: Timer Interrupt Enable (INT $50) (1=Enable)
35
+
Bit 3: Serial Interrupt Enable (INT $58) (1=Enable)
36
+
Bit 4: Joypad Interrupt Enable (INT $60) (1=Enable)
37
37
```
38
38
39
39
## FF0F - IF - Interrupt Flag (R/W)
40
40
41
41
```
42
-
Bit 0: VBlank Interrupt Request (INT 40h) (1=Request)
43
-
Bit 1: LCD STAT Interrupt Request (INT 48h) (1=Request)
44
-
Bit 2: Timer Interrupt Request (INT 50h) (1=Request)
45
-
Bit 3: Serial Interrupt Request (INT 58h) (1=Request)
46
-
Bit 4: Joypad Interrupt Request (INT 60h) (1=Request)
42
+
Bit 0: VBlank Interrupt Request (INT $40) (1=Request)
43
+
Bit 1: LCD STAT Interrupt Request (INT $48) (1=Request)
44
+
Bit 2: Timer Interrupt Request (INT $50) (1=Request)
45
+
Bit 3: Serial Interrupt Request (INT $58) (1=Request)
46
+
Bit 4: Joypad Interrupt Request (INT $60) (1=Request)
47
47
```
48
48
49
49
When an interrupt signal changes from low to high, the
@@ -70,19 +70,16 @@ from being handled until the program re-enables them, typically by using the `re
70
70
called by the CPU. This is a regular call, exactly like what would be performed by a `call <vector>` instruction (the current PC is pushed on the stack
71
71
and then set to the address of the interrupt vector).
72
72
73
-
According to Z80 datasheets, the following occurs when control is being
74
-
transferred to an interrupt handler:
73
+
The following occurs when control is being transferred to an interrupt handler:
75
74
76
-
1. Two wait states are executed (2 machine cycles pass while nothing
77
-
occurs, presumably the CPU is executing NOPs during this time).
78
-
2. The current PC is pushed onto the stack, this process consumes 2 more
79
-
machine cycles.
80
-
3. The high byte of the PC is set to 0, the low byte is set to the
81
-
address of the handler ($40,$48,$50,$58,$60). This consumes one
82
-
last machine cycle.
75
+
1. Two wait states are executed (2 M-cycles pass while nothing
76
+
occurs, presumably the CPU is executing `nop`s during this time).
77
+
2. The current PC is pushed onto the stack, consuming 2 more M-cycles.
78
+
3. The PC register is set to the address of the handler ($40, $48, $50, $58, $60).
79
+
This consumes one last M-cycle.
83
80
84
-
The entire ISR **should** consume a total of 5 machine cycles. This has
85
-
yet to be tested, but is what the Z80 datasheet implies.
81
+
The entire ISR **should** consume a total of 5 M-cycles.
82
+
This has yet to be tested, but is what the Z80 datasheet implies.
0 commit comments