Programmers - Intercepting IM 1

Black Crow #04
                                         
 INTERRUPTION OF INTERRUPTS OF THE 1ST KIND 
                                         
(C) 02/19/2000 by Dr.Lion/RSM            
-------------------------------------------------------
 I must say right away that I have never seen
I haven’t seen any information about this method of organizing
interrupts. So everything is auto
the rights belong to me, i.e. Dr. Lion`у.  
   The essence of the method is as follows.
There is such an interesting thing as ROM 128-
go BASIC, which is now being worked on in every possible way
are perverted, flashing all sorts of things instead
there Real Comander, NEOS etc. So, in
there sits the editor BASIC 128, which for
keyboard reading and system increment
hours uses the same handler
interrupts from ROM BASIC 48. In this case, select
The early interrupt mode is IM 1.
The question immediately arises: What about BASIC
128 starts the standard pre-
ripping from BASIC48 ROM? Let's do it via STS
let's take a look atinterrupt handling procedure
tion in the ROM of the 128th BASIC:                
                                         
#0038 PUSH HL ;save HL.        
        LD HL,#0048;return address to ROM 
        PUSH HL ;BASIC 128.           
        LD HL,#5В00;transfer procedure address
        PUSH HL ;turning on ROM pages 
        LD HL,#0038;address of the called pro-
        PUSH HL ;procedures in BASIC 48.   
        JP #5В00 ;the actual call.    
#0048 POP HL ;exit handler 
        RET ;interrupts.          
                                         
  What do we see? Starting the standard image
The interrupt driver occurs through the res-
dent located in the printer buffer by
address #5В00!!! This resident inverts
4th bit #7FFD(ROM page) and does RET.
Since it is in RAM, we have a re-
real opportunity to pervert him.  
   It turns out that intercepting interrupts from
ROM of the 128th BASIC in IM 1 mode concludes
is in the entry at address #5B00 of the command JP
INTDRIV, where INTDRIV is the address of your
our interrupt handler. The processing itself
the chik should be something like this:     
                                         
INTDRIV DEC SP:DEC SP;we adjust the stack,
        DEC SP:DEC SP;removing unnecessary PUSH.
        DEC SP:DEC SP;three POP HL are possible.  
        PUSH DE ;save the rest
        PUSH BC ;registers, while
        PUSH AF ;HL has already been saved!   
        ... ;procedures.         
        POP AF ;restoring the re-
        POP BC;gisters and output.    
        POP DE                           
        POP HL                           
        EI:RET                           
                                         
That's it! This method has a lot of advantages
assets over the traditional way of organiza-
interrupts, namely:            
                                         
1. No need to create vector tables and
   calculate handler addresses.       
                                         
2. Your interrupt handler may be sitting
   to any address in RAM.               
                                         
3. Before entering TR-DOS there is no need to prohibit
   Issue interrupts with the DI command.          
                                         
4. Enable/disable interrupt handler
   This can be done by resetting/installing the 4th
   port bit #7FFD (that's where the perversion is;)
                                         
   And now about the disadvantages:    
   =======================    
                                         
1.  If the ROMBASIC 128 does not contain ad-
resu #0038 the handler above
then the interceptor will not work.        
                                         
2. From interrupt occurrence to startup
processor passes approximately 100
bars :(                                
                                         
3. The need to monitor the state 4-
bit #7FFD. For the handler to work, it
must be reset to 0.                 
                                         
   Here, perhaps, are all the pros and cons.
Weigh and decide on your choice
re. The purpose of this article was not to impose
some new perversions for the fucked up
SPECTRUM programmers, but only to familiarize
relationship with a new, recently discovered
by me, a feature of our beloved Spec!
                                         
                    See you!

Share your thoughts about the article