Software - Where do “glitchy” programs come from?

Impulse #01
--------------------------------
                                
 Where do `glitchy` come from?     
                    programs?  
                                
--------------------------------
                                
 This article will discuss
o glitches, how they appear in
programs, and what to do to
there were none.                
 Usually, before the release of any
or software product, author
it is carefully checked, corrected
Letting you know the errors you noticed. However yes-
after a good check
"flawlessly" working software
ma running on your computer
your friend, can behave
completely different.                   
 Now I will try to consider
especially important and frequent
reasons why programs
can work correctly on one
their computers and do not work
on others.                      
                                
 So, let's start:                
                                
 Let's start with, perhaps, the most
the main thing is correct work with IM2
interruptions, because due to
incorrect work with them is possible
allow three serious ones at once
errors, which, by the way, are
ice timeare the most
common.              
                                
 Let's look at them in order:    
                                
 As is known, for processing
IM2 interrupts should be configured
dig only one register-register
interrupt vector I, and then
the computer itself will determine the need
the address given to him, counting the register
I is the high byte, a is the low byte
is read from the data bus, and,
as a rule, it is always equal to #FF.
But this is not entirely true. Sometimes with
data bus can be considered different
Any value other than #FF in
In this case, hebep-
address, and execution of the subroutine
Interrupt processing frames are
melts somewhere... This is usually the
det to the death of the program (or even
to random formatting of dis-
ka)...                          
                                
 To eliminate such
Therefore, you need to build a table
of 257 identical bytes, a low
the lowest and most significant byte of the address sub-
interrupt processing programs
must be equal to the byte from the table
faces,                           
 for example:                    
                                
 LD HL,#8000 ;Building a table.
   LD DE,#8001                 
 LD BC,#0100                 
   LD(HL),#81                 
   LD A,H                      
   LDIR                         
   LD I,A                      
   LD A,#C3                    
   LD HL,BYSH                  
   LD (#8181),A                
   LD (#8182),HL               
                                
 Here is the address of the subroutine
interrupt operation should be
equals the `BYSH` label.             
 True, this method requires
257 bytes of memory, but it’s possible
be sure that the program
will work on all computers
rah.                            
                                
 The second thing about interruption is
niy is working with a disk.      
                                
 The fact is that computers
which we use in Brest,
(and this is "BYTE") have separate
memory fields, and when accessing
the disk needs to be written to register I
value #3F. If this is not done
Well, then no reading/writing
will not happen, but will appear on the screen
this is a message like `Disk
Yeggog... ` or it will just happen
program freezes.  The best
case, disk speed
will slow down 10-20 times.  
                                
 To prevent this from happening,
you need to access the disk example -
but like this:IM 1                     
       PUSH AF                  
       LD A,I                   
       LD(VLAD+1),A            
       LD A,#3F                 
       LD I,A                   
       POP AF                   
       CALL disk                
VLAD LD A,0                   
       LD I,A                   
       IM 2                     
                                
 And also, regarding the interruption
ny: since in BYTES there are separate
nal memory fields, if with IM2
interrupt vector I position
in `slow` memory (for example
#С000-#FFFF), then at each pre-
tearing there will be about 3000 clock cycles
just get lost. Keep this in mind
duh, because we usually have
it is for this reason that the slowdown
Most INTROs are included.  Better
total interrupt table pacno-
lag in addresses #8000-#BFOO.   
                                
 One more thing I would like
pay attention - these are drivers
read/write to disk.          
                                
 There are some types of Soviet
disk drives, which after remaining
new engine moves the head
one track back.   Next time
When accessing the disk, the head is
already in a shifted position
and ariseserror.  If your
the driver does not have error handling
side, the program either freezes,
or reads some nonsense.  If
the same has, then the head first
will jump to track 0, then ver-
not on the right one, and only then
read or write will occur.
                                
 To prevent this from happening
it is necessary from the very beginning to re-
positioned to the desired position
horn and after that you can chi-
write/write as much as you like,
if you are sure that between dis-
kovyh operations engine dis-
The driver won't have time to stop.  
                                
 And, probably, the last glitch,
which concerns only a few
types of disk drives - speed
engine rotation.           
                                
 Some drives have one
well, a nasty feature: when edited
When approaching them, spin up the engine
lasts too long
(up to 1 sec). This, of course, leads
leads to an error and usually freezes
nu.                            
                                
 There is only one way out: after
positioning must be maintained
press pause so that any movement
tel managed to packpy well-
crawl.                         
                                
 And what else would you like here?add?                       
                                
 After such a number of
Loviy, I think, is the best choice
will use #3D13.  B
in this case you have 98% ha-
pahtuu that this will work
on any computer and disk drive.
In addition, in Brest we have
controllers in which everything is dis-
The ports do not match
standard ports (although they have
TR-DOS ROM contains their emulator,
but it does not provide complete
guarantees), so most
There are simply no Turbo Loaders on them
works.                       
 Well, if, of course, you are sure
that your Turbo Loader will be free
work flawlessly, observing everything
the above conditions may-
you can use it.             
                                
   One last thing, this is the topic
port #7FFD, it was already mentioned
a lot has been written on different computers
youtube publications: never
switch memory pages
command OUT (#FD),A.  For these
always use goals        
switch memory pages
command OUT (#FD),A.  For these
always use goals        
                                
       LD BC,#7FFD (32765)     
       LD A,PAGE               
       OUT (C),Ano switching using
6 bit settings will not give you
full functionality for all
computers.                    
                                
 NOTE:          
                                
 All that is written here is
the result of observations on a computer
tepax "BYTE". If your company
Pewter has some of his own
features that are not mentioned-
in this article, you can write
tell us about them - we will have
in view, and perhaps we will describe in
the next issues of the newspaper.       

Share your thoughts about the article