Interrupts in Z80. .BIG BRAIN
Hello!!! I have never written in the BIG BRAIN section before, and here I am...
I meant to write about IM2, otherwise ANDY INC. There are already two articles in this section
wrote...
In short, some minds claim that IM2 is the most difficult
what is in the Z80. To be honest, I'm not sure about this, in my opinion it's
the simplest.
What are interruptions? The CPU has three interrupt modes IM0,
IM1, IM2. IM0 on SPECCY are not used, which means we have
two interrupt modes. When the CPU program is executed 50 times per
kundu interrupts its execution and switches to a special subprogram
interrupt handling gram, which in the literature is called
SUPERVISOR. If IM1 mode is enabled, then the processor 50 times per
Kundu goes to ROM cell 5b. There is a testing program there.
sa keyboard. That is, when you work in BASIC, you include
chen mode IM1. IM1 is strictly tied to cell 5b and for us it is not
is of no interest. But IM2 has the ability
programmatically change the location address of the pre-processing program
jerking. ThatYes, we can write the processing procedure ourselves
interrupts.
How to enable IM2. First, you need to understand the principle of a mark, a mark is
these are two bytes that indicate the address at which the
to the interrupt handling program. The mark cannot be placed anywhere
any memory area, it can only be placed at the address in which
rom the low byte is equal to #FF, for example #b1FF. Number #FF, this is a century-
interrupt torus. 0н should always be equal to #FF, if on your
computer vector is not equal to 255, then I sympathize with you. By the way, no
which peripheral devices change the interrupt vector...
Now the program itself:
ORG 25000
DI ;before enabling IM2 interrupts must be disabled
LD A, #FD; we throw #FD into the battery, this number will be
;point to the address where the tag is located
LD DE,30000; place the label (30000) in the register
LD (#FDFF),DE ;we throw the label itself at the address #FDFF
LD I,A ;#FD from A is copied to I
IM 2;turn on IM2
EI ;enable interrupts
RET ;and we fall out of the program
and at address 30000 we need to place a SUPERVISOR
ORG 30000
DI ;disable interrupts
PUSH AF ;save all registers on the stack
PUSH sun;
PUSH DE ;
PUSH IX;
PUSH IY ;
PUSH HL ;
............ ;your program
POP HL; pull out all registers back
POP IY ;
POP IX ;
POP DE ;
POP sun;
POP AF ;
EI;enable interrupts
RET ;return
Now, your program will be executed 50 times per second
interrupt handling. If you need to tie it all to IM1,
then instead of the EI and RET commands you need to put JP 5b at the end. I'm to
For example, in BASIC I hung a Mouzon on an AU.
Alternative registers should also be saved if necessary.
Why is all this needed?
Using IM2, you can organize parallel processes, especially
AU music is often played on IM2.
By the way, if you don’t want to put tags in RAM, then you can
use ready-made labels in ROM, there are also
addresses that end in #FF. On this occasion I
stuck the table, I denotes which number to put in the register
I, address indicates at which address the program should be located
interrupt handling frame.,
║ I │ address ║ I │ address ║ I │ address ║ I │ address ║▒▒
A
║ 0 │ 20430 ║ 1b │ 51984 ║ 32 │ 52513 ║ 48 │ b0208 ║▒▒
║ 1 │ 52818 ║ 17 │ 08729 ║ 33 │ 33485 ║ 49 │ 57b40 ║▒▒
║ 2 │ 222b9 ║ 18 │ 52481 ║ 34 │ 00544 ║ 50 │ 13b27 ║▒▒
║ 3 │ 39020 ║ 19 │ 49749 ║ 35 │ 49537 ║ 51 │ 1325b ║▒▒
║ 4 │ 10419 ║ 20 │ 25075 ║ 3b │ 08527 ║ 52 │ 015b0 ║▒▒
║ 5 │ 02294 ║ 21 │ 51b73 ║ 37 │ 23b70 ║ 53 │ 57124 ║▒▒
║ b │ 29149 ║ 22 │ 515b8 ║ 38 │ 20444 ║ 54 │ 34307 ║▒▒
║ 7 │ 1b039 ║ 23 │ 12493 ║ 39 │ 00288 ║ 55 │ 41231 ║▒▒
║ 8 │ 02088 ║ 24 │ 15582 ║ 40 │ 32348 ║ 5b │ b5535 ║▒▒
║ 9 │ b5129 ║ 25 │ 23842 ║ 41 │ 58154 ║ 57 │ b5535 ║▒▒
║ 10 │ 32802 ║ 2b │ 13824 ║ 42 │ 19754 ║ 58 │ b5535 ║▒▒
║ 11 │ 58888 ║ 27 │ 0730b ║ 43 │ 23b53 ║ 59 │ b5535 ║▒▒
║ 12 │ 53183 ║ 28 │ 49947 ║ 44 │ 07117 ║ b0 │ 00255 ║▒▒
║ 13 │ 52503 ║ 29 │ 02344 ║ 45 │ 55781 ║ b1 │ 00000 ║▒▒
║ 14 │ 143b7 ║ 30 │ 2b573 ║ 4b │ 23713 ║ b2 │ 00255 ║▒▒
║ 15 │ 27928 ║ 31 │ 033b0 ║ 47 │ 045b9 ║ b3 │ 000b0 ║▒▒
,
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒If you do not understand anything at all from what is written here, then
you can go to the “screen” and they will chew everything out for you...
ALEX' 9b
Share your thoughts about the article