Home » CEEFAX disks » telesoftware5.adl » 04-03-88/T\OSB16

04-03-88/T\OSB16

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » CEEFAX disks » telesoftware5.adl
Filename: 04-03-88/T\OSB16
Read OK:
File size: 47A9 bytes
Load address: 0000
Exec address: FFFFFFFF
Duplicates

There is 1 duplicate copy of this file in the archive:

File contents
OSBITS - An Exploration of the BBC Micro at Machine Level

By Programmer

..........................................................


Part 16: Vectors


With this module we return to the workings of the BBC Micro
operating system.

You may already know the word 'indirection' from BBC BASIC. 
There you have the indirection operators ? and ! which, when
applied to a byte address, return the number held either in
that byte (with ?) or in the 4 byte word starting at that
byte (with !).  Vectors provide a way of intercepting the
action of routines because those routines are indirected
through the vector. 

Here is an example.  Say we have a subroutine at address
'work'.  We would call it by going JSR work.  The following
code might occur at that address.

                      .work
                      JMP(workvec)

You will recall (I hope) that JMP followed by an address in
brackets means that the microprocessor will jump to the
address held in the two bytes starting at the one in the
brackets.  In this case the execution of the program will
jump to the address held in 'workvec' and 'workvec+1'.
[Note that your vector, as with any indirect JMP address,
should never be the last byte of a page, i.e. have FF as the
last byte of the address.  This is because of a bug in the
6502 which stops it interpreting the jump correctly in this
instance.]


'workvec' is a vector.  But what is the point of flying
around the microprocessor's memory like this?  It should
become clearer when you think that the address 'workvec' is
in RAM, and can be modified by you, whereas the original
call address 'work' was maybe in the operating system in ROM
and so could not be changed.

And why might you want to modify the operation of such a
routine?  Well to a certain extent that is up to your
ingenuity but you could add your own * commands by
intercepting the CLI vector or add a new *FX call by
intercepting the OSBYTE vector.  The thing to remember is
that any intercepting will have a semi-permanent effect and
so could modify all programs run on your machine whatever
the language in which they were written.  I say
semi-permanent because all vectors are reset to their
default values when the BREAK key is pressed.

Let's look at the vectors and then go on to discuss an
intercepting application.

In rising address order the vectors are as follows:

    &200    USERV - The User Vector

Certain unrecognised OSWORD calls, with accumulator values
between 224 and 255 pass this way as do *CODE and *LINE. 
This enables you to set up routines of your own which your
programs can call without needing to know where they are, or
indeed in which processor the calling program is. The user
vector only exists in the I/O processor and the program in
this module uses it with *CODE.

    &202     BRKV - The Break Vector

When an interrupt occurs or a BRK is reached in a program
being executed the OS routes program execution through here. 
The language currently in use usually sets up its own
vectors here but you could put in your own routine.  In
general though this is not an area to play around in, so be
careful or at least expect to crash the machine a few times!
Incidentally, this is nothing to do with pressing the BREAK
key.

    &204 and &206   IRQ1V and IRQ2V  -  Interrupt Vectors

The operating system uses these to process interrupts.  We
will come onto these in another module but for completeness
IRQ1 is the route for all interrupts and IRQ2 is the route
for those the OS does not recognise.

    &208     CLIV - The Command Line Interpreter Vector

All * commands pass this way before the OS decides what to
do with them.  OSCLI indirects through here.

    &20A     BYTEV - OSBYTE Indirection Vector
    &20B     WORDV - OSWORD Indirection Vector

OSBYTE/OSWORD calls indirect this way before being
processed.

    &20E     WRCHV - The Write Character Vector

All writes to the screen or printer or wherever pass through
here.

    &210     RDCHV - The Read Character Vector

Characters read from the current input stream pass this way.

    &212     FILEV - File Vector (OSFILE)
    &214     ARGSV - Arguments Vector (OSARGS)
    &216     BGETV - Byte get Vector (OSBGET)
    &218     BPUTV - Byte put Vector (OSBPUT)
    &21A     GBPBV - Block byte vector (OSGBPB)
    &21C     FINDV - Open and Close File (OSFIND)

These vectors pass the commands for the relevant OS routines
for filing systems.

    &21E     FSCV  - Misc Filing Functions

There are further filing functions, such as reading a
catalogue and checking for End of File that are carried out
down this vector.

    &220     EVNTV - Event Vector

Events are a specially packaged form of interrupt.  We will
come on to events next time.

    &222     UPTV  - User Print Vector

You can write your own printer driver software which will be
called when OSBYTE 5,3 (*FX5,3) is carried out.  The address
of your routine should be placed in this vector.

    &224     NETV  - The Network Vector

This is used by the Econet network system.

    &226     VDUV  - VDU Extension Vector

If a non-standard VDU command is made the OS will come down
this vector.  This can happen if you attempt to plot in a
non graphics mode, or by using an unrecognised PLOT number
or by using VDU23,n with n in the range 2 to 31.

    &228     KEYV  - The Keyboard Vector
    &22A     INSV  - Buffer Insert Vector
    &22C     REMV  - Buffer Remove Vector
    &22E     CNPV  - Buffer Count/Purge Vector

These vectors indirect OS routines to control the keyboard
and buffers.

There is also spare vector space between &230 and &235. 
Some of these vectors occur only in the I/O processor (the
BBC Micro itself) and in the case of events the behaviour of
the system is slightly different when you intercept in a
second processor.  In general I think you would probably
want to run your intercepting code in the I/O processor. 
I'll expand on this in a moment.

For detailed information on the register and flag settings
you might expect on intercepting these vectors you should
consult your advanced guide.  We shall, however, go on to
discuss one vector in more detail.

The WRCHV, write character vector, is the route for all the
bytes sent to the VDU drivers when printing text or drawing
graphics or even clearing the screen.  I wrote a routine to
print out the bytes passing down this vector as an aid to
debugging graphics programs, particularly when using a 32016
second processor.

You don't actually have to do anything to get the bytes
flowing through this vector.  They will do so anyway.  To
understand what the byte actually means we must introduce
the concept of the VDU queue and what I shall call main and
tacked-on bytes.

On page 378 of the original BBC Micro User Guide is a table
which summarises the VDU codes.  If you have this book then
it's worth finding this table.  There are three different
general areas into which bytes can fall.  They can be
control codes, values between 0 and 31, they can be
printable ASCII characters, between 32 and 126, and they can
be extra characters when between 128 and 255.  127 is a
little special in that it is an ASCII character (delete) but
is not strictly printable.

When a byte passes to the VDU drivers it is either printed
or is used to control a function.  The values up to 31
control a function and include such things as changing mode,
clearing the screen and plotting.  The allocation of these
functions is not universal.  Although code 13 is generally
used for a carriage return the same is not true of the other
numbers.

The VDU drivers will sometimes expect a main byte to have
one or more other bytes tacked on to the end to complete a
control sequence.  For example code 22 has to be followed by
a second byte because 22 means 'change screen mode' and the
second byte is the new mode.  When that 22 enters the
drivers the VDU queue is set to 1 and the command is not
processed until that second byte has arrived.  The byte with
the longest queue is 23 (VDU 23) which sets up a queue 9
bytes long.  Only control codes can have tacked on bytes.

When we look at what passes down the write character vector
we must keep an eye on the VDU queue to see what the byte we
have is actually for.  Since we look at a byte BEFORE it
reaches the drivers we are actually one step ahead of them
and reading the queue length gives us an incorrect answer. 
Fortunately we only need to know which bytes are main bytes
and they will always arrive at the driver when the queue is
of zero length.

So how do we read the queue length.  OSBYTE 218 will return
this to us if we enter it with 0 in X and 255 (&FF) in Y. 
This is because 218 is one of many OSBYTE calls that will
read or write separate bits of operating system variables.
The number written into the variable is:

               (old value  AND Y) EOR X

So to read a location you set X to 0 and Y to &FF and the
result is in X.  To write you set X to the value you wish to
write and set Y to 0.  The old value of the variable is in X
on exit.

In the case of OSBYTE 218 the variable is actually the 2's
complement negative of the queue length.

B/osb16 deals with three issues raised by intercepting
vectors.  Firstly the OS is vulnerable during the changing
of a vector.  An interrupt could occur when one of the two
bytes has been changed but before the other.  To stop this
the interrupt flag is set which stops maskable interrupts
occurring.  This will be explained more in the Interrupts
module.

Secondly we must make sure the vector changing routine is
executed only once.  More on this later in this module.

Finally we have to put the routine in the I/O processor to
be sure it will work for all cases and all types of second
processor.  Having done this it is obviously going to be
more difficult to switch the intercept routine on and off
but fortunately there is an OS function we can use.

There are two little known built in * commands, *CODE and
*LINE.  *CODE is followed by up to two bytes, separated by
spaces or commas just like *FX.  *LINE is followed by a
string.  When either is executed in whichever processor in
your computer the I/O processor jumps to the contents of the
User Vector at &200.  In this module I have used *CODE but I
will explain both.

The User Vector should be changed to point to some new code
you have just written which is expecting the *CODE or *LINE. 
The module program will illustrate how.  On entry to your
routine from *CODE the X and Y registers will be set as
for the numbers typed in after *CODE.  The accumulator will
contain zero.  With *LINE followed by text and terminated
with a carriage return the OS will put the line of text
somewhere in memory and on entry to your routine A will
contain 1 and X will contain the low byte of the address
where the OS has stored the string and Y will contain the
high byte.

These are particularly useful if you want to be able to
switch your intercept on and off from the keyboard, as we do
here.  In addition *CODE is equivalent to OSBYTE 136
(*FX136).  If there is no user code pointed to by the user
vector calling *CODE or *LINE will generate a 'Bad Command'
message.

The code generated by B/osb16 is in three parts, although
they make up one program.  The first section changes the
user vector to point to our new code.  The second part
enables *CODE to switch the intercept on and off by
modifying the write character vector or restoring it to its
original value.  The final part is the intercept code
itself.  To use this program you will need a printer
connected and ready to go.  I have used the RS423 input
buffer (page &A) as home for this code and I hope that means
it will work with a serial printer as well as a parallel
one, but I only have a parallel printer.  In case of trouble
change the value of code% in line 110 to, say, &C00 if you
have no user defined characters, or &1600 to make use of
some of the disc drive space (not in a Master).

To modify vectors you first disable interrupts with SEI and
then save the existing contents of the vector somewhere
safe.  Then you put the start address of your piece of code
into the vector (lo byte then hi byte) and finally you
re-enable interrupts again with CLI.  Saving the old vector
contents has two uses.  Firstly you can return them when you
have completely finished with the intercept and secondly you
can chain intercept routines together by jumping to the old
vector contents at the end of your routine.

Lines 250 to 410 save the existing user vector contents in
'old_user' and then replace them with the address of the
code starting at 'user'.  So that a second execution of this
piece of code will not attempt to reset the vectors again
the code checks that the high byte values are different
between the position of the new code ('user) and the
contents of the user vector.  Since the user vector usually
points way up into the OS ROM there should be no problems.

Lines 430 to 920 use *CODE to enable or disable the
intercept.  If the number in the accumulator is not 0 then
we are not responding to a *CODE so the routine branches to
'over_entry' where it jumps to the old vector contents. 
This means that a separate user vector user, like *CODE with
X>1 or *LINE, will still function.

We want X to be 0 or 1 on entry, if it is neither then the
routine also reaches 'over_entry' but if it is either then
we have to see which it is.  A flag, at 'intercept_flag' is
used to make sure that we do not try to reset a vector that
is already reset.  This is an alternative way of stopping
code pointing to itself and locking the machine out.

The intercept itself, starting at line 910, is bracketed
with pushes and pulls to the stack.  The status register,
followed by the X and Y registers is pushed, to be pulled in
the reverse order later.  The accumulator is stored in a
byte labelled 'accustore' for easy access.

Once the registers are saved we direct all output to the
printer using OSBYTE 3 with X=10.  On exit the old X value
is in X and we put that on the stack for use later.

The 'vdu_queue' subroutine returns with the size of the
queue in A and if that is the first character in a set of
bytes then we have to start a new line, print the character
if it is printable, print its hex value (in brackets), and
use spaces to get a neat layout.  All printing in this
routine is carried out using a non-vectored version of
OSWRCH called NVOSWRCH so that the intercepts don't get tied
up in knots.

If we are dealing with a tacked on byte, i.e. the VDU queue
routine returns something other than zero, we continue
printing hex values in brackets across the page.

Finally we restore the printer to its previous state using
OSBYTE 3 and the old value of X from the stack.  Registers
are pulled back from the stack and we head off back down the
old write character vector.  If we were to RTS here rather
than follow the old vector nothing would reach the screen. 
Try it and see.

The 'print_hex' subroutine at line 1460 is exactly like the
one in Module 6 except that to print a nybble I have used a
different method.  It's worth comparing the two particularly
if you feel there is any risk associated with using the
decimal mode on the 6502.  I'll come back to this under
interrupts!  There are two 'tricks' worth remembering here. 
Firstly as we have already masked off the top nybble of the
byte with AND &0F we cannot have anything in the top nybble. 
So if we want to add 48 (&30) we can do this by ORing with
&30 since this does not affect the lower nybble.  The reason
for doing this is that it replaces a CLC and an ADC with one
ORA which is smaller, faster and neater.  The second trick
is that following a BCC where you don't branch the carry
flag has to be set so if we ADC we are adding an extra one. 
Again this saves a CLC and so saves space and time.  (My
thanks to Peter Vince for reminding me of that one.)

The 'vdu_queue' subroutine uses OSBYTE 218 as explained
earlier.  It is simpler to take a 2's complement by EORing
with &FF and adding 1 than by subtracting from zero because
you don't have to find somewhere to store the number while
you LDA #0.

When you have RUN the program there will be a little line
you can copy across in order to *SAVE the machine code. 
This program will only run in the I/O processor, so switch
off your second processor if you have one.  The final
machine code will run from disc by just typing *wcint and
this will automatically load into the I/O processor because
I have set the top 16 bits of the 32 bit addresses in line
2030.  [I adopt a personal policy of using lower case
letters for any machine code program name.]

To try it out type in *wcint and then make sure your printer
is on and ready.  Type *CODE 1 and everything you then enter
will be intercepted.  Type *CODE to stop it (*CODE is
equivalent to *CODE 0).

If you enter:        *CODE 1
                     MODE 4
                     MOVE &321,&123
                     CLS
                     *CODE

you should get the following output.

    > [&3E]
    M [&4D]
    O [&4F]
    D [&44]
    E [&45]
      [&20]
    4 [&34]
      [&0A]
      [&0D]
      [&16] [&04]
    > [&3E]
    M [&4D]
    O [&4F]
    V [&56]
    E [&45]
      [&20]
    & [&26]
    3 [&33]
    2 [&32]
    1 [&31]
    , [&2C]
    & [&26]
    1 [&31]
    2 [&32]
    3 [&33]
      [&0A]
      [&0D]
      [&19] [&04] [&21] [&03] [&23] [&01]
    > [&3E]
    C [&43]
    L [&4C]
    S [&53]
      [&0A]
      [&0D]
      [&0C]
    > [&3E]
    * [&2A]
    C [&43]
    O [&4F]
    D [&44]
    E [&45]
      [&0A]
      [&0D]

This is showing how BASIC commands are translated into bytes
to be sent to the VDU drivers.  If you enable the intercept
while running a program you will get a similar, if much more
succinct, result.  The output can be SPOOLED to disc
although you will get extra characters with each byte where
it is printable.

This intercept method can be applied to any vector although
only the RDCH and WRCH carry any significant information in
the accumulator.  The CLI vector passes useful information
in X and Y pointing to strings.  You could modify this
routine to work with other vectors, but don't bother with
the EVENT, BREAK or IRQ vectors as you will simply crash the
machine there.  Those vectors are too sensitive.

Next time ..... EVENTS.  Until then, happy intercepting.
00000000  4f 53 42 49 54 53 20 2d  20 41 6e 20 45 78 70 6c  |OSBITS - An Expl|
00000010  6f 72 61 74 69 6f 6e 20  6f 66 20 74 68 65 20 42  |oration of the B|
00000020  42 43 20 4d 69 63 72 6f  20 61 74 20 4d 61 63 68  |BC Micro at Mach|
00000030  69 6e 65 20 4c 65 76 65  6c 0d 0d 42 79 20 50 72  |ine Level..By Pr|
00000040  6f 67 72 61 6d 6d 65 72  0d 0d 2e 2e 2e 2e 2e 2e  |ogrammer........|
00000050  2e 2e 2e 2e 2e 2e 2e 2e  2e 2e 2e 2e 2e 2e 2e 2e  |................|
*
00000080  2e 2e 2e 2e 0d 0d 0d 50  61 72 74 20 31 36 3a 20  |.......Part 16: |
00000090  56 65 63 74 6f 72 73 0d  0d 0d 57 69 74 68 20 74  |Vectors...With t|
000000a0  68 69 73 20 6d 6f 64 75  6c 65 20 77 65 20 72 65  |his module we re|
000000b0  74 75 72 6e 20 74 6f 20  74 68 65 20 77 6f 72 6b  |turn to the work|
000000c0  69 6e 67 73 20 6f 66 20  74 68 65 20 42 42 43 20  |ings of the BBC |
000000d0  4d 69 63 72 6f 0d 6f 70  65 72 61 74 69 6e 67 20  |Micro.operating |
000000e0  73 79 73 74 65 6d 2e 0d  0d 59 6f 75 20 6d 61 79  |system...You may|
000000f0  20 61 6c 72 65 61 64 79  20 6b 6e 6f 77 20 74 68  | already know th|
00000100  65 20 77 6f 72 64 20 27  69 6e 64 69 72 65 63 74  |e word 'indirect|
00000110  69 6f 6e 27 20 66 72 6f  6d 20 42 42 43 20 42 41  |ion' from BBC BA|
00000120  53 49 43 2e 20 0d 54 68  65 72 65 20 79 6f 75 20  |SIC. .There you |
00000130  68 61 76 65 20 74 68 65  20 69 6e 64 69 72 65 63  |have the indirec|
00000140  74 69 6f 6e 20 6f 70 65  72 61 74 6f 72 73 20 3f  |tion operators ?|
00000150  20 61 6e 64 20 21 20 77  68 69 63 68 2c 20 77 68  | and ! which, wh|
00000160  65 6e 0d 61 70 70 6c 69  65 64 20 74 6f 20 61 20  |en.applied to a |
00000170  62 79 74 65 20 61 64 64  72 65 73 73 2c 20 72 65  |byte address, re|
00000180  74 75 72 6e 20 74 68 65  20 6e 75 6d 62 65 72 20  |turn the number |
00000190  68 65 6c 64 20 65 69 74  68 65 72 20 69 6e 0d 74  |held either in.t|
000001a0  68 61 74 20 62 79 74 65  20 28 77 69 74 68 20 3f  |hat byte (with ?|
000001b0  29 20 6f 72 20 69 6e 20  74 68 65 20 34 20 62 79  |) or in the 4 by|
000001c0  74 65 20 77 6f 72 64 20  73 74 61 72 74 69 6e 67  |te word starting|
000001d0  20 61 74 20 74 68 61 74  0d 62 79 74 65 20 28 77  | at that.byte (w|
000001e0  69 74 68 20 21 29 2e 20  20 56 65 63 74 6f 72 73  |ith !).  Vectors|
000001f0  20 70 72 6f 76 69 64 65  20 61 20 77 61 79 20 6f  | provide a way o|
00000200  66 20 69 6e 74 65 72 63  65 70 74 69 6e 67 20 74  |f intercepting t|
00000210  68 65 0d 61 63 74 69 6f  6e 20 6f 66 20 72 6f 75  |he.action of rou|
00000220  74 69 6e 65 73 20 62 65  63 61 75 73 65 20 74 68  |tines because th|
00000230  6f 73 65 20 72 6f 75 74  69 6e 65 73 20 61 72 65  |ose routines are|
00000240  20 69 6e 64 69 72 65 63  74 65 64 0d 74 68 72 6f  | indirected.thro|
00000250  75 67 68 20 74 68 65 20  76 65 63 74 6f 72 2e 20  |ugh the vector. |
00000260  0d 0d 48 65 72 65 20 69  73 20 61 6e 20 65 78 61  |..Here is an exa|
00000270  6d 70 6c 65 2e 20 20 53  61 79 20 77 65 20 68 61  |mple.  Say we ha|
00000280  76 65 20 61 20 73 75 62  72 6f 75 74 69 6e 65 20  |ve a subroutine |
00000290  61 74 20 61 64 64 72 65  73 73 0d 27 77 6f 72 6b  |at address.'work|
000002a0  27 2e 20 20 57 65 20 77  6f 75 6c 64 20 63 61 6c  |'.  We would cal|
000002b0  6c 20 69 74 20 62 79 20  67 6f 69 6e 67 20 4a 53  |l it by going JS|
000002c0  52 20 77 6f 72 6b 2e 20  20 54 68 65 20 66 6f 6c  |R work.  The fol|
000002d0  6c 6f 77 69 6e 67 0d 63  6f 64 65 20 6d 69 67 68  |lowing.code migh|
000002e0  74 20 6f 63 63 75 72 20  61 74 20 74 68 61 74 20  |t occur at that |
000002f0  61 64 64 72 65 73 73 2e  0d 0d 20 20 20 20 20 20  |address...      |
00000300  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000310  2e 77 6f 72 6b 0d 20 20  20 20 20 20 20 20 20 20  |.work.          |
00000320  20 20 20 20 20 20 20 20  20 20 20 20 4a 4d 50 28  |            JMP(|
00000330  77 6f 72 6b 76 65 63 29  0d 0d 59 6f 75 20 77 69  |workvec)..You wi|
00000340  6c 6c 20 72 65 63 61 6c  6c 20 28 49 20 68 6f 70  |ll recall (I hop|
00000350  65 29 20 74 68 61 74 20  4a 4d 50 20 66 6f 6c 6c  |e) that JMP foll|
00000360  6f 77 65 64 20 62 79 20  61 6e 20 61 64 64 72 65  |owed by an addre|
00000370  73 73 20 69 6e 0d 62 72  61 63 6b 65 74 73 20 6d  |ss in.brackets m|
00000380  65 61 6e 73 20 74 68 61  74 20 74 68 65 20 6d 69  |eans that the mi|
00000390  63 72 6f 70 72 6f 63 65  73 73 6f 72 20 77 69 6c  |croprocessor wil|
000003a0  6c 20 6a 75 6d 70 20 74  6f 20 74 68 65 0d 61 64  |l jump to the.ad|
000003b0  64 72 65 73 73 20 68 65  6c 64 20 69 6e 20 74 68  |dress held in th|
000003c0  65 20 74 77 6f 20 62 79  74 65 73 20 73 74 61 72  |e two bytes star|
000003d0  74 69 6e 67 20 61 74 20  74 68 65 20 6f 6e 65 20  |ting at the one |
000003e0  69 6e 20 74 68 65 0d 62  72 61 63 6b 65 74 73 2e  |in the.brackets.|
000003f0  20 20 49 6e 20 74 68 69  73 20 63 61 73 65 20 74  |  In this case t|
00000400  68 65 20 65 78 65 63 75  74 69 6f 6e 20 6f 66 20  |he execution of |
00000410  74 68 65 20 70 72 6f 67  72 61 6d 20 77 69 6c 6c  |the program will|
00000420  0d 6a 75 6d 70 20 74 6f  20 74 68 65 20 61 64 64  |.jump to the add|
00000430  72 65 73 73 20 68 65 6c  64 20 69 6e 20 27 77 6f  |ress held in 'wo|
00000440  72 6b 76 65 63 27 20 61  6e 64 20 27 77 6f 72 6b  |rkvec' and 'work|
00000450  76 65 63 2b 31 27 2e 0d  5b 4e 6f 74 65 20 74 68  |vec+1'..[Note th|
00000460  61 74 20 79 6f 75 72 20  76 65 63 74 6f 72 2c 20  |at your vector, |
00000470  61 73 20 77 69 74 68 20  61 6e 79 20 69 6e 64 69  |as with any indi|
00000480  72 65 63 74 20 4a 4d 50  20 61 64 64 72 65 73 73  |rect JMP address|
00000490  2c 0d 73 68 6f 75 6c 64  20 6e 65 76 65 72 20 62  |,.should never b|
000004a0  65 20 74 68 65 20 6c 61  73 74 20 62 79 74 65 20  |e the last byte |
000004b0  6f 66 20 61 20 70 61 67  65 2c 20 69 2e 65 2e 20  |of a page, i.e. |
000004c0  68 61 76 65 20 46 46 20  61 73 20 74 68 65 0d 6c  |have FF as the.l|
000004d0  61 73 74 20 62 79 74 65  20 6f 66 20 74 68 65 20  |ast byte of the |
000004e0  61 64 64 72 65 73 73 2e  20 20 54 68 69 73 20 69  |address.  This i|
000004f0  73 20 62 65 63 61 75 73  65 20 6f 66 20 61 20 62  |s because of a b|
00000500  75 67 20 69 6e 20 74 68  65 0d 36 35 30 32 20 77  |ug in the.6502 w|
00000510  68 69 63 68 20 73 74 6f  70 73 20 69 74 20 69 6e  |hich stops it in|
00000520  74 65 72 70 72 65 74 69  6e 67 20 74 68 65 20 6a  |terpreting the j|
00000530  75 6d 70 20 63 6f 72 72  65 63 74 6c 79 20 69 6e  |ump correctly in|
00000540  20 74 68 69 73 0d 69 6e  73 74 61 6e 63 65 2e 5d  | this.instance.]|
00000550  0d 0d 0d 27 77 6f 72 6b  76 65 63 27 20 69 73 20  |...'workvec' is |
00000560  61 20 76 65 63 74 6f 72  2e 20 20 42 75 74 20 77  |a vector.  But w|
00000570  68 61 74 20 69 73 20 74  68 65 20 70 6f 69 6e 74  |hat is the point|
00000580  20 6f 66 20 66 6c 79 69  6e 67 0d 61 72 6f 75 6e  | of flying.aroun|
00000590  64 20 74 68 65 20 6d 69  63 72 6f 70 72 6f 63 65  |d the microproce|
000005a0  73 73 6f 72 27 73 20 6d  65 6d 6f 72 79 20 6c 69  |ssor's memory li|
000005b0  6b 65 20 74 68 69 73 3f  20 20 49 74 20 73 68 6f  |ke this?  It sho|
000005c0  75 6c 64 0d 62 65 63 6f  6d 65 20 63 6c 65 61 72  |uld.become clear|
000005d0  65 72 20 77 68 65 6e 20  79 6f 75 20 74 68 69 6e  |er when you thin|
000005e0  6b 20 74 68 61 74 20 74  68 65 20 61 64 64 72 65  |k that the addre|
000005f0  73 73 20 27 77 6f 72 6b  76 65 63 27 20 69 73 0d  |ss 'workvec' is.|
00000600  69 6e 20 52 41 4d 2c 20  61 6e 64 20 63 61 6e 20  |in RAM, and can |
00000610  62 65 20 6d 6f 64 69 66  69 65 64 20 62 79 20 79  |be modified by y|
00000620  6f 75 2c 20 77 68 65 72  65 61 73 20 74 68 65 20  |ou, whereas the |
00000630  6f 72 69 67 69 6e 61 6c  0d 63 61 6c 6c 20 61 64  |original.call ad|
00000640  64 72 65 73 73 20 27 77  6f 72 6b 27 20 77 61 73  |dress 'work' was|
00000650  20 6d 61 79 62 65 20 69  6e 20 74 68 65 20 6f 70  | maybe in the op|
00000660  65 72 61 74 69 6e 67 20  73 79 73 74 65 6d 20 69  |erating system i|
00000670  6e 20 52 4f 4d 0d 61 6e  64 20 73 6f 20 63 6f 75  |n ROM.and so cou|
00000680  6c 64 20 6e 6f 74 20 62  65 20 63 68 61 6e 67 65  |ld not be change|
00000690  64 2e 0d 0d 41 6e 64 20  77 68 79 20 6d 69 67 68  |d...And why migh|
000006a0  74 20 79 6f 75 20 77 61  6e 74 20 74 6f 20 6d 6f  |t you want to mo|
000006b0  64 69 66 79 20 74 68 65  20 6f 70 65 72 61 74 69  |dify the operati|
000006c0  6f 6e 20 6f 66 20 73 75  63 68 20 61 0d 72 6f 75  |on of such a.rou|
000006d0  74 69 6e 65 3f 20 20 57  65 6c 6c 20 74 6f 20 61  |tine?  Well to a|
000006e0  20 63 65 72 74 61 69 6e  20 65 78 74 65 6e 74 20  | certain extent |
000006f0  74 68 61 74 20 69 73 20  75 70 20 74 6f 20 79 6f  |that is up to yo|
00000700  75 72 0d 69 6e 67 65 6e  75 69 74 79 20 62 75 74  |ur.ingenuity but|
00000710  20 79 6f 75 20 63 6f 75  6c 64 20 61 64 64 20 79  | you could add y|
00000720  6f 75 72 20 6f 77 6e 20  2a 20 63 6f 6d 6d 61 6e  |our own * comman|
00000730  64 73 20 62 79 0d 69 6e  74 65 72 63 65 70 74 69  |ds by.intercepti|
00000740  6e 67 20 74 68 65 20 43  4c 49 20 76 65 63 74 6f  |ng the CLI vecto|
00000750  72 20 6f 72 20 61 64 64  20 61 20 6e 65 77 20 2a  |r or add a new *|
00000760  46 58 20 63 61 6c 6c 20  62 79 0d 69 6e 74 65 72  |FX call by.inter|
00000770  63 65 70 74 69 6e 67 20  74 68 65 20 4f 53 42 59  |cepting the OSBY|
00000780  54 45 20 76 65 63 74 6f  72 2e 20 20 54 68 65 20  |TE vector.  The |
00000790  74 68 69 6e 67 20 74 6f  20 72 65 6d 65 6d 62 65  |thing to remembe|
000007a0  72 20 69 73 0d 74 68 61  74 20 61 6e 79 20 69 6e  |r is.that any in|
000007b0  74 65 72 63 65 70 74 69  6e 67 20 77 69 6c 6c 20  |tercepting will |
000007c0  68 61 76 65 20 61 20 73  65 6d 69 2d 70 65 72 6d  |have a semi-perm|
000007d0  61 6e 65 6e 74 20 65 66  66 65 63 74 20 61 6e 64  |anent effect and|
000007e0  0d 73 6f 20 63 6f 75 6c  64 20 6d 6f 64 69 66 79  |.so could modify|
000007f0  20 61 6c 6c 20 70 72 6f  67 72 61 6d 73 20 72 75  | all programs ru|
00000800  6e 20 6f 6e 20 79 6f 75  72 20 6d 61 63 68 69 6e  |n on your machin|
00000810  65 20 77 68 61 74 65 76  65 72 0d 74 68 65 20 6c  |e whatever.the l|
00000820  61 6e 67 75 61 67 65 20  69 6e 20 77 68 69 63 68  |anguage in which|
00000830  20 74 68 65 79 20 77 65  72 65 20 77 72 69 74 74  | they were writt|
00000840  65 6e 2e 20 20 49 20 73  61 79 0d 73 65 6d 69 2d  |en.  I say.semi-|
00000850  70 65 72 6d 61 6e 65 6e  74 20 62 65 63 61 75 73  |permanent becaus|
00000860  65 20 61 6c 6c 20 76 65  63 74 6f 72 73 20 61 72  |e all vectors ar|
00000870  65 20 72 65 73 65 74 20  74 6f 20 74 68 65 69 72  |e reset to their|
00000880  0d 64 65 66 61 75 6c 74  20 76 61 6c 75 65 73 20  |.default values |
00000890  77 68 65 6e 20 74 68 65  20 42 52 45 41 4b 20 6b  |when the BREAK k|
000008a0  65 79 20 69 73 20 70 72  65 73 73 65 64 2e 0d 0d  |ey is pressed...|
000008b0  4c 65 74 27 73 20 6c 6f  6f 6b 20 61 74 20 74 68  |Let's look at th|
000008c0  65 20 76 65 63 74 6f 72  73 20 61 6e 64 20 74 68  |e vectors and th|
000008d0  65 6e 20 67 6f 20 6f 6e  20 74 6f 20 64 69 73 63  |en go on to disc|
000008e0  75 73 73 20 61 6e 0d 69  6e 74 65 72 63 65 70 74  |uss an.intercept|
000008f0  69 6e 67 20 61 70 70 6c  69 63 61 74 69 6f 6e 2e  |ing application.|
00000900  0d 0d 49 6e 20 72 69 73  69 6e 67 20 61 64 64 72  |..In rising addr|
00000910  65 73 73 20 6f 72 64 65  72 20 74 68 65 20 76 65  |ess order the ve|
00000920  63 74 6f 72 73 20 61 72  65 20 61 73 20 66 6f 6c  |ctors are as fol|
00000930  6c 6f 77 73 3a 0d 0d 20  20 20 20 26 32 30 30 20  |lows:..    &200 |
00000940  20 20 20 55 53 45 52 56  20 2d 20 54 68 65 20 55  |   USERV - The U|
00000950  73 65 72 20 56 65 63 74  6f 72 0d 0d 43 65 72 74  |ser Vector..Cert|
00000960  61 69 6e 20 75 6e 72 65  63 6f 67 6e 69 73 65 64  |ain unrecognised|
00000970  20 4f 53 57 4f 52 44 20  63 61 6c 6c 73 2c 20 77  | OSWORD calls, w|
00000980  69 74 68 20 61 63 63 75  6d 75 6c 61 74 6f 72 20  |ith accumulator |
00000990  76 61 6c 75 65 73 0d 62  65 74 77 65 65 6e 20 32  |values.between 2|
000009a0  32 34 20 61 6e 64 20 32  35 35 20 70 61 73 73 20  |24 and 255 pass |
000009b0  74 68 69 73 20 77 61 79  20 61 73 20 64 6f 20 2a  |this way as do *|
000009c0  43 4f 44 45 20 61 6e 64  20 2a 4c 49 4e 45 2e 20  |CODE and *LINE. |
000009d0  0d 54 68 69 73 20 65 6e  61 62 6c 65 73 20 79 6f  |.This enables yo|
000009e0  75 20 74 6f 20 73 65 74  20 75 70 20 72 6f 75 74  |u to set up rout|
000009f0  69 6e 65 73 20 6f 66 20  79 6f 75 72 20 6f 77 6e  |ines of your own|
00000a00  20 77 68 69 63 68 20 79  6f 75 72 0d 70 72 6f 67  | which your.prog|
00000a10  72 61 6d 73 20 63 61 6e  20 63 61 6c 6c 20 77 69  |rams can call wi|
00000a20  74 68 6f 75 74 20 6e 65  65 64 69 6e 67 20 74 6f  |thout needing to|
00000a30  20 6b 6e 6f 77 20 77 68  65 72 65 20 74 68 65 79  | know where they|
00000a40  20 61 72 65 2c 20 6f 72  0d 69 6e 64 65 65 64 20  | are, or.indeed |
00000a50  69 6e 20 77 68 69 63 68  20 70 72 6f 63 65 73 73  |in which process|
00000a60  6f 72 20 74 68 65 20 63  61 6c 6c 69 6e 67 20 70  |or the calling p|
00000a70  72 6f 67 72 61 6d 20 69  73 2e 20 54 68 65 20 75  |rogram is. The u|
00000a80  73 65 72 0d 76 65 63 74  6f 72 20 6f 6e 6c 79 20  |ser.vector only |
00000a90  65 78 69 73 74 73 20 69  6e 20 74 68 65 20 49 2f  |exists in the I/|
00000aa0  4f 20 70 72 6f 63 65 73  73 6f 72 20 61 6e 64 20  |O processor and |
00000ab0  74 68 65 20 70 72 6f 67  72 61 6d 20 69 6e 0d 74  |the program in.t|
00000ac0  68 69 73 20 6d 6f 64 75  6c 65 20 75 73 65 73 20  |his module uses |
00000ad0  69 74 20 77 69 74 68 20  2a 43 4f 44 45 2e 0d 0d  |it with *CODE...|
00000ae0  20 20 20 20 26 32 30 32  20 20 20 20 20 42 52 4b  |    &202     BRK|
00000af0  56 20 2d 20 54 68 65 20  42 72 65 61 6b 20 56 65  |V - The Break Ve|
00000b00  63 74 6f 72 0d 0d 57 68  65 6e 20 61 6e 20 69 6e  |ctor..When an in|
00000b10  74 65 72 72 75 70 74 20  6f 63 63 75 72 73 20 6f  |terrupt occurs o|
00000b20  72 20 61 20 42 52 4b 20  69 73 20 72 65 61 63 68  |r a BRK is reach|
00000b30  65 64 20 69 6e 20 61 20  70 72 6f 67 72 61 6d 0d  |ed in a program.|
00000b40  62 65 69 6e 67 20 65 78  65 63 75 74 65 64 20 74  |being executed t|
00000b50  68 65 20 4f 53 20 72 6f  75 74 65 73 20 70 72 6f  |he OS routes pro|
00000b60  67 72 61 6d 20 65 78 65  63 75 74 69 6f 6e 20 74  |gram execution t|
00000b70  68 72 6f 75 67 68 20 68  65 72 65 2e 20 0d 54 68  |hrough here. .Th|
00000b80  65 20 6c 61 6e 67 75 61  67 65 20 63 75 72 72 65  |e language curre|
00000b90  6e 74 6c 79 20 69 6e 20  75 73 65 20 75 73 75 61  |ntly in use usua|
00000ba0  6c 6c 79 20 73 65 74 73  20 75 70 20 69 74 73 20  |lly sets up its |
00000bb0  6f 77 6e 0d 76 65 63 74  6f 72 73 20 68 65 72 65  |own.vectors here|
00000bc0  20 62 75 74 20 79 6f 75  20 63 6f 75 6c 64 20 70  | but you could p|
00000bd0  75 74 20 69 6e 20 79 6f  75 72 20 6f 77 6e 20 72  |ut in your own r|
00000be0  6f 75 74 69 6e 65 2e 20  20 49 6e 0d 67 65 6e 65  |outine.  In.gene|
00000bf0  72 61 6c 20 74 68 6f 75  67 68 20 74 68 69 73 20  |ral though this |
00000c00  69 73 20 6e 6f 74 20 61  6e 20 61 72 65 61 20 74  |is not an area t|
00000c10  6f 20 70 6c 61 79 20 61  72 6f 75 6e 64 20 69 6e  |o play around in|
00000c20  2c 20 73 6f 20 62 65 0d  63 61 72 65 66 75 6c 20  |, so be.careful |
00000c30  6f 72 20 61 74 20 6c 65  61 73 74 20 65 78 70 65  |or at least expe|
00000c40  63 74 20 74 6f 20 63 72  61 73 68 20 74 68 65 20  |ct to crash the |
00000c50  6d 61 63 68 69 6e 65 20  61 20 66 65 77 20 74 69  |machine a few ti|
00000c60  6d 65 73 21 0d 49 6e 63  69 64 65 6e 74 61 6c 6c  |mes!.Incidentall|
00000c70  79 2c 20 74 68 69 73 20  69 73 20 6e 6f 74 68 69  |y, this is nothi|
00000c80  6e 67 20 74 6f 20 64 6f  20 77 69 74 68 20 70 72  |ng to do with pr|
00000c90  65 73 73 69 6e 67 20 74  68 65 20 42 52 45 41 4b  |essing the BREAK|
00000ca0  0d 6b 65 79 2e 0d 0d 20  20 20 20 26 32 30 34 20  |.key...    &204 |
00000cb0  61 6e 64 20 26 32 30 36  20 20 20 49 52 51 31 56  |and &206   IRQ1V|
00000cc0  20 61 6e 64 20 49 52 51  32 56 20 20 2d 20 20 49  | and IRQ2V  -  I|
00000cd0  6e 74 65 72 72 75 70 74  20 56 65 63 74 6f 72 73  |nterrupt Vectors|
00000ce0  0d 0d 54 68 65 20 6f 70  65 72 61 74 69 6e 67 20  |..The operating |
00000cf0  73 79 73 74 65 6d 20 75  73 65 73 20 74 68 65 73  |system uses thes|
00000d00  65 20 74 6f 20 70 72 6f  63 65 73 73 20 69 6e 74  |e to process int|
00000d10  65 72 72 75 70 74 73 2e  20 20 57 65 0d 77 69 6c  |errupts.  We.wil|
00000d20  6c 20 63 6f 6d 65 20 6f  6e 74 6f 20 74 68 65 73  |l come onto thes|
00000d30  65 20 69 6e 20 61 6e 6f  74 68 65 72 20 6d 6f 64  |e in another mod|
00000d40  75 6c 65 20 62 75 74 20  66 6f 72 20 63 6f 6d 70  |ule but for comp|
00000d50  6c 65 74 65 6e 65 73 73  0d 49 52 51 31 20 69 73  |leteness.IRQ1 is|
00000d60  20 74 68 65 20 72 6f 75  74 65 20 66 6f 72 20 61  | the route for a|
00000d70  6c 6c 20 69 6e 74 65 72  72 75 70 74 73 20 61 6e  |ll interrupts an|
00000d80  64 20 49 52 51 32 20 69  73 20 74 68 65 20 72 6f  |d IRQ2 is the ro|
00000d90  75 74 65 0d 66 6f 72 20  74 68 6f 73 65 20 74 68  |ute.for those th|
00000da0  65 20 4f 53 20 64 6f 65  73 20 6e 6f 74 20 72 65  |e OS does not re|
00000db0  63 6f 67 6e 69 73 65 2e  0d 0d 20 20 20 20 26 32  |cognise...    &2|
00000dc0  30 38 20 20 20 20 20 43  4c 49 56 20 2d 20 54 68  |08     CLIV - Th|
00000dd0  65 20 43 6f 6d 6d 61 6e  64 20 4c 69 6e 65 20 49  |e Command Line I|
00000de0  6e 74 65 72 70 72 65 74  65 72 20 56 65 63 74 6f  |nterpreter Vecto|
00000df0  72 0d 0d 41 6c 6c 20 2a  20 63 6f 6d 6d 61 6e 64  |r..All * command|
00000e00  73 20 70 61 73 73 20 74  68 69 73 20 77 61 79 20  |s pass this way |
00000e10  62 65 66 6f 72 65 20 74  68 65 20 4f 53 20 64 65  |before the OS de|
00000e20  63 69 64 65 73 20 77 68  61 74 20 74 6f 0d 64 6f  |cides what to.do|
00000e30  20 77 69 74 68 20 74 68  65 6d 2e 20 20 4f 53 43  | with them.  OSC|
00000e40  4c 49 20 69 6e 64 69 72  65 63 74 73 20 74 68 72  |LI indirects thr|
00000e50  6f 75 67 68 20 68 65 72  65 2e 0d 0d 20 20 20 20  |ough here...    |
00000e60  26 32 30 41 20 20 20 20  20 42 59 54 45 56 20 2d  |&20A     BYTEV -|
00000e70  20 4f 53 42 59 54 45 20  49 6e 64 69 72 65 63 74  | OSBYTE Indirect|
00000e80  69 6f 6e 20 56 65 63 74  6f 72 0d 20 20 20 20 26  |ion Vector.    &|
00000e90  32 30 42 20 20 20 20 20  57 4f 52 44 56 20 2d 20  |20B     WORDV - |
00000ea0  4f 53 57 4f 52 44 20 49  6e 64 69 72 65 63 74 69  |OSWORD Indirecti|
00000eb0  6f 6e 20 56 65 63 74 6f  72 0d 0d 4f 53 42 59 54  |on Vector..OSBYT|
00000ec0  45 2f 4f 53 57 4f 52 44  20 63 61 6c 6c 73 20 69  |E/OSWORD calls i|
00000ed0  6e 64 69 72 65 63 74 20  74 68 69 73 20 77 61 79  |ndirect this way|
00000ee0  20 62 65 66 6f 72 65 20  62 65 69 6e 67 0d 70 72  | before being.pr|
00000ef0  6f 63 65 73 73 65 64 2e  0d 0d 20 20 20 20 26 32  |ocessed...    &2|
00000f00  30 45 20 20 20 20 20 57  52 43 48 56 20 2d 20 54  |0E     WRCHV - T|
00000f10  68 65 20 57 72 69 74 65  20 43 68 61 72 61 63 74  |he Write Charact|
00000f20  65 72 20 56 65 63 74 6f  72 0d 0d 41 6c 6c 20 77  |er Vector..All w|
00000f30  72 69 74 65 73 20 74 6f  20 74 68 65 20 73 63 72  |rites to the scr|
00000f40  65 65 6e 20 6f 72 20 70  72 69 6e 74 65 72 20 6f  |een or printer o|
00000f50  72 20 77 68 65 72 65 76  65 72 20 70 61 73 73 20  |r wherever pass |
00000f60  74 68 72 6f 75 67 68 0d  68 65 72 65 2e 0d 0d 20  |through.here... |
00000f70  20 20 20 26 32 31 30 20  20 20 20 20 52 44 43 48  |   &210     RDCH|
00000f80  56 20 2d 20 54 68 65 20  52 65 61 64 20 43 68 61  |V - The Read Cha|
00000f90  72 61 63 74 65 72 20 56  65 63 74 6f 72 0d 0d 43  |racter Vector..C|
00000fa0  68 61 72 61 63 74 65 72  73 20 72 65 61 64 20 66  |haracters read f|
00000fb0  72 6f 6d 20 74 68 65 20  63 75 72 72 65 6e 74 20  |rom the current |
00000fc0  69 6e 70 75 74 20 73 74  72 65 61 6d 20 70 61 73  |input stream pas|
00000fd0  73 20 74 68 69 73 20 77  61 79 2e 0d 0d 20 20 20  |s this way...   |
00000fe0  20 26 32 31 32 20 20 20  20 20 46 49 4c 45 56 20  | &212     FILEV |
00000ff0  2d 20 46 69 6c 65 20 56  65 63 74 6f 72 20 28 4f  |- File Vector (O|
00001000  53 46 49 4c 45 29 0d 20  20 20 20 26 32 31 34 20  |SFILE).    &214 |
00001010  20 20 20 20 41 52 47 53  56 20 2d 20 41 72 67 75  |    ARGSV - Argu|
00001020  6d 65 6e 74 73 20 56 65  63 74 6f 72 20 28 4f 53  |ments Vector (OS|
00001030  41 52 47 53 29 0d 20 20  20 20 26 32 31 36 20 20  |ARGS).    &216  |
00001040  20 20 20 42 47 45 54 56  20 2d 20 42 79 74 65 20  |   BGETV - Byte |
00001050  67 65 74 20 56 65 63 74  6f 72 20 28 4f 53 42 47  |get Vector (OSBG|
00001060  45 54 29 0d 20 20 20 20  26 32 31 38 20 20 20 20  |ET).    &218    |
00001070  20 42 50 55 54 56 20 2d  20 42 79 74 65 20 70 75  | BPUTV - Byte pu|
00001080  74 20 56 65 63 74 6f 72  20 28 4f 53 42 50 55 54  |t Vector (OSBPUT|
00001090  29 0d 20 20 20 20 26 32  31 41 20 20 20 20 20 47  |).    &21A     G|
000010a0  42 50 42 56 20 2d 20 42  6c 6f 63 6b 20 62 79 74  |BPBV - Block byt|
000010b0  65 20 76 65 63 74 6f 72  20 28 4f 53 47 42 50 42  |e vector (OSGBPB|
000010c0  29 0d 20 20 20 20 26 32  31 43 20 20 20 20 20 46  |).    &21C     F|
000010d0  49 4e 44 56 20 2d 20 4f  70 65 6e 20 61 6e 64 20  |INDV - Open and |
000010e0  43 6c 6f 73 65 20 46 69  6c 65 20 28 4f 53 46 49  |Close File (OSFI|
000010f0  4e 44 29 0d 0d 54 68 65  73 65 20 76 65 63 74 6f  |ND)..These vecto|
00001100  72 73 20 70 61 73 73 20  74 68 65 20 63 6f 6d 6d  |rs pass the comm|
00001110  61 6e 64 73 20 66 6f 72  20 74 68 65 20 72 65 6c  |ands for the rel|
00001120  65 76 61 6e 74 20 4f 53  20 72 6f 75 74 69 6e 65  |evant OS routine|
00001130  73 0d 66 6f 72 20 66 69  6c 69 6e 67 20 73 79 73  |s.for filing sys|
00001140  74 65 6d 73 2e 0d 0d 20  20 20 20 26 32 31 45 20  |tems...    &21E |
00001150  20 20 20 20 46 53 43 56  20 20 2d 20 4d 69 73 63  |    FSCV  - Misc|
00001160  20 46 69 6c 69 6e 67 20  46 75 6e 63 74 69 6f 6e  | Filing Function|
00001170  73 0d 0d 54 68 65 72 65  20 61 72 65 20 66 75 72  |s..There are fur|
00001180  74 68 65 72 20 66 69 6c  69 6e 67 20 66 75 6e 63  |ther filing func|
00001190  74 69 6f 6e 73 2c 20 73  75 63 68 20 61 73 20 72  |tions, such as r|
000011a0  65 61 64 69 6e 67 20 61  0d 63 61 74 61 6c 6f 67  |eading a.catalog|
000011b0  75 65 20 61 6e 64 20 63  68 65 63 6b 69 6e 67 20  |ue and checking |
000011c0  66 6f 72 20 45 6e 64 20  6f 66 20 46 69 6c 65 20  |for End of File |
000011d0  74 68 61 74 20 61 72 65  20 63 61 72 72 69 65 64  |that are carried|
000011e0  20 6f 75 74 0d 64 6f 77  6e 20 74 68 69 73 20 76  | out.down this v|
000011f0  65 63 74 6f 72 2e 0d 0d  20 20 20 20 26 32 32 30  |ector...    &220|
00001200  20 20 20 20 20 45 56 4e  54 56 20 2d 20 45 76 65  |     EVNTV - Eve|
00001210  6e 74 20 56 65 63 74 6f  72 0d 0d 45 76 65 6e 74  |nt Vector..Event|
00001220  73 20 61 72 65 20 61 20  73 70 65 63 69 61 6c 6c  |s are a speciall|
00001230  79 20 70 61 63 6b 61 67  65 64 20 66 6f 72 6d 20  |y packaged form |
00001240  6f 66 20 69 6e 74 65 72  72 75 70 74 2e 20 20 57  |of interrupt.  W|
00001250  65 20 77 69 6c 6c 0d 63  6f 6d 65 20 6f 6e 20 74  |e will.come on t|
00001260  6f 20 65 76 65 6e 74 73  20 6e 65 78 74 20 74 69  |o events next ti|
00001270  6d 65 2e 0d 0d 20 20 20  20 26 32 32 32 20 20 20  |me...    &222   |
00001280  20 20 55 50 54 56 20 20  2d 20 55 73 65 72 20 50  |  UPTV  - User P|
00001290  72 69 6e 74 20 56 65 63  74 6f 72 0d 0d 59 6f 75  |rint Vector..You|
000012a0  20 63 61 6e 20 77 72 69  74 65 20 79 6f 75 72 20  | can write your |
000012b0  6f 77 6e 20 70 72 69 6e  74 65 72 20 64 72 69 76  |own printer driv|
000012c0  65 72 20 73 6f 66 74 77  61 72 65 20 77 68 69 63  |er software whic|
000012d0  68 20 77 69 6c 6c 20 62  65 0d 63 61 6c 6c 65 64  |h will be.called|
000012e0  20 77 68 65 6e 20 4f 53  42 59 54 45 20 35 2c 33  | when OSBYTE 5,3|
000012f0  20 28 2a 46 58 35 2c 33  29 20 69 73 20 63 61 72  | (*FX5,3) is car|
00001300  72 69 65 64 20 6f 75 74  2e 20 20 54 68 65 20 61  |ried out.  The a|
00001310  64 64 72 65 73 73 0d 6f  66 20 79 6f 75 72 20 72  |ddress.of your r|
00001320  6f 75 74 69 6e 65 20 73  68 6f 75 6c 64 20 62 65  |outine should be|
00001330  20 70 6c 61 63 65 64 20  69 6e 20 74 68 69 73 20  | placed in this |
00001340  76 65 63 74 6f 72 2e 0d  0d 20 20 20 20 26 32 32  |vector...    &22|
00001350  34 20 20 20 20 20 4e 45  54 56 20 20 2d 20 54 68  |4     NETV  - Th|
00001360  65 20 4e 65 74 77 6f 72  6b 20 56 65 63 74 6f 72  |e Network Vector|
00001370  0d 0d 54 68 69 73 20 69  73 20 75 73 65 64 20 62  |..This is used b|
00001380  79 20 74 68 65 20 45 63  6f 6e 65 74 20 6e 65 74  |y the Econet net|
00001390  77 6f 72 6b 20 73 79 73  74 65 6d 2e 0d 0d 20 20  |work system...  |
000013a0  20 20 26 32 32 36 20 20  20 20 20 56 44 55 56 20  |  &226     VDUV |
000013b0  20 2d 20 56 44 55 20 45  78 74 65 6e 73 69 6f 6e  | - VDU Extension|
000013c0  20 56 65 63 74 6f 72 0d  0d 49 66 20 61 20 6e 6f  | Vector..If a no|
000013d0  6e 2d 73 74 61 6e 64 61  72 64 20 56 44 55 20 63  |n-standard VDU c|
000013e0  6f 6d 6d 61 6e 64 20 69  73 20 6d 61 64 65 20 74  |ommand is made t|
000013f0  68 65 20 4f 53 20 77 69  6c 6c 20 63 6f 6d 65 20  |he OS will come |
00001400  64 6f 77 6e 0d 74 68 69  73 20 76 65 63 74 6f 72  |down.this vector|
00001410  2e 20 20 54 68 69 73 20  63 61 6e 20 68 61 70 70  |.  This can happ|
00001420  65 6e 20 69 66 20 79 6f  75 20 61 74 74 65 6d 70  |en if you attemp|
00001430  74 20 74 6f 20 70 6c 6f  74 20 69 6e 20 61 0d 6e  |t to plot in a.n|
00001440  6f 6e 20 67 72 61 70 68  69 63 73 20 6d 6f 64 65  |on graphics mode|
00001450  2c 20 6f 72 20 62 79 20  75 73 69 6e 67 20 61 6e  |, or by using an|
00001460  20 75 6e 72 65 63 6f 67  6e 69 73 65 64 20 50 4c  | unrecognised PL|
00001470  4f 54 20 6e 75 6d 62 65  72 0d 6f 72 20 62 79 20  |OT number.or by |
00001480  75 73 69 6e 67 20 56 44  55 32 33 2c 6e 20 77 69  |using VDU23,n wi|
00001490  74 68 20 6e 20 69 6e 20  74 68 65 20 72 61 6e 67  |th n in the rang|
000014a0  65 20 32 20 74 6f 20 33  31 2e 0d 0d 20 20 20 20  |e 2 to 31...    |
000014b0  26 32 32 38 20 20 20 20  20 4b 45 59 56 20 20 2d  |&228     KEYV  -|
000014c0  20 54 68 65 20 4b 65 79  62 6f 61 72 64 20 56 65  | The Keyboard Ve|
000014d0  63 74 6f 72 0d 20 20 20  20 26 32 32 41 20 20 20  |ctor.    &22A   |
000014e0  20 20 49 4e 53 56 20 20  2d 20 42 75 66 66 65 72  |  INSV  - Buffer|
000014f0  20 49 6e 73 65 72 74 20  56 65 63 74 6f 72 0d 20  | Insert Vector. |
00001500  20 20 20 26 32 32 43 20  20 20 20 20 52 45 4d 56  |   &22C     REMV|
00001510  20 20 2d 20 42 75 66 66  65 72 20 52 65 6d 6f 76  |  - Buffer Remov|
00001520  65 20 56 65 63 74 6f 72  0d 20 20 20 20 26 32 32  |e Vector.    &22|
00001530  45 20 20 20 20 20 43 4e  50 56 20 20 2d 20 42 75  |E     CNPV  - Bu|
00001540  66 66 65 72 20 43 6f 75  6e 74 2f 50 75 72 67 65  |ffer Count/Purge|
00001550  20 56 65 63 74 6f 72 0d  0d 54 68 65 73 65 20 76  | Vector..These v|
00001560  65 63 74 6f 72 73 20 69  6e 64 69 72 65 63 74 20  |ectors indirect |
00001570  4f 53 20 72 6f 75 74 69  6e 65 73 20 74 6f 20 63  |OS routines to c|
00001580  6f 6e 74 72 6f 6c 20 74  68 65 20 6b 65 79 62 6f  |ontrol the keybo|
00001590  61 72 64 0d 61 6e 64 20  62 75 66 66 65 72 73 2e  |ard.and buffers.|
000015a0  0d 0d 54 68 65 72 65 20  69 73 20 61 6c 73 6f 20  |..There is also |
000015b0  73 70 61 72 65 20 76 65  63 74 6f 72 20 73 70 61  |spare vector spa|
000015c0  63 65 20 62 65 74 77 65  65 6e 20 26 32 33 30 20  |ce between &230 |
000015d0  61 6e 64 20 26 32 33 35  2e 20 0d 53 6f 6d 65 20  |and &235. .Some |
000015e0  6f 66 20 74 68 65 73 65  20 76 65 63 74 6f 72 73  |of these vectors|
000015f0  20 6f 63 63 75 72 20 6f  6e 6c 79 20 69 6e 20 74  | occur only in t|
00001600  68 65 20 49 2f 4f 20 70  72 6f 63 65 73 73 6f 72  |he I/O processor|
00001610  20 28 74 68 65 0d 42 42  43 20 4d 69 63 72 6f 20  | (the.BBC Micro |
00001620  69 74 73 65 6c 66 29 20  61 6e 64 20 69 6e 20 74  |itself) and in t|
00001630  68 65 20 63 61 73 65 20  6f 66 20 65 76 65 6e 74  |he case of event|
00001640  73 20 74 68 65 20 62 65  68 61 76 69 6f 75 72 20  |s the behaviour |
00001650  6f 66 0d 74 68 65 20 73  79 73 74 65 6d 20 69 73  |of.the system is|
00001660  20 73 6c 69 67 68 74 6c  79 20 64 69 66 66 65 72  | slightly differ|
00001670  65 6e 74 20 77 68 65 6e  20 79 6f 75 20 69 6e 74  |ent when you int|
00001680  65 72 63 65 70 74 20 69  6e 20 61 0d 73 65 63 6f  |ercept in a.seco|
00001690  6e 64 20 70 72 6f 63 65  73 73 6f 72 2e 20 20 49  |nd processor.  I|
000016a0  6e 20 67 65 6e 65 72 61  6c 20 49 20 74 68 69 6e  |n general I thin|
000016b0  6b 20 79 6f 75 20 77 6f  75 6c 64 20 70 72 6f 62  |k you would prob|
000016c0  61 62 6c 79 0d 77 61 6e  74 20 74 6f 20 72 75 6e  |ably.want to run|
000016d0  20 79 6f 75 72 20 69 6e  74 65 72 63 65 70 74 69  | your intercepti|
000016e0  6e 67 20 63 6f 64 65 20  69 6e 20 74 68 65 20 49  |ng code in the I|
000016f0  2f 4f 20 70 72 6f 63 65  73 73 6f 72 2e 20 0d 49  |/O processor. .I|
00001700  27 6c 6c 20 65 78 70 61  6e 64 20 6f 6e 20 74 68  |'ll expand on th|
00001710  69 73 20 69 6e 20 61 20  6d 6f 6d 65 6e 74 2e 0d  |is in a moment..|
00001720  0d 46 6f 72 20 64 65 74  61 69 6c 65 64 20 69 6e  |.For detailed in|
00001730  66 6f 72 6d 61 74 69 6f  6e 20 6f 6e 20 74 68 65  |formation on the|
00001740  20 72 65 67 69 73 74 65  72 20 61 6e 64 20 66 6c  | register and fl|
00001750  61 67 20 73 65 74 74 69  6e 67 73 0d 79 6f 75 20  |ag settings.you |
00001760  6d 69 67 68 74 20 65 78  70 65 63 74 20 6f 6e 20  |might expect on |
00001770  69 6e 74 65 72 63 65 70  74 69 6e 67 20 74 68 65  |intercepting the|
00001780  73 65 20 76 65 63 74 6f  72 73 20 79 6f 75 20 73  |se vectors you s|
00001790  68 6f 75 6c 64 0d 63 6f  6e 73 75 6c 74 20 79 6f  |hould.consult yo|
000017a0  75 72 20 61 64 76 61 6e  63 65 64 20 67 75 69 64  |ur advanced guid|
000017b0  65 2e 20 20 57 65 20 73  68 61 6c 6c 2c 20 68 6f  |e.  We shall, ho|
000017c0  77 65 76 65 72 2c 20 67  6f 20 6f 6e 20 74 6f 0d  |wever, go on to.|
000017d0  64 69 73 63 75 73 73 20  6f 6e 65 20 76 65 63 74  |discuss one vect|
000017e0  6f 72 20 69 6e 20 6d 6f  72 65 20 64 65 74 61 69  |or in more detai|
000017f0  6c 2e 0d 0d 54 68 65 20  57 52 43 48 56 2c 20 77  |l...The WRCHV, w|
00001800  72 69 74 65 20 63 68 61  72 61 63 74 65 72 20 76  |rite character v|
00001810  65 63 74 6f 72 2c 20 69  73 20 74 68 65 20 72 6f  |ector, is the ro|
00001820  75 74 65 20 66 6f 72 20  61 6c 6c 20 74 68 65 0d  |ute for all the.|
00001830  62 79 74 65 73 20 73 65  6e 74 20 74 6f 20 74 68  |bytes sent to th|
00001840  65 20 56 44 55 20 64 72  69 76 65 72 73 20 77 68  |e VDU drivers wh|
00001850  65 6e 20 70 72 69 6e 74  69 6e 67 20 74 65 78 74  |en printing text|
00001860  20 6f 72 20 64 72 61 77  69 6e 67 0d 67 72 61 70  | or drawing.grap|
00001870  68 69 63 73 20 6f 72 20  65 76 65 6e 20 63 6c 65  |hics or even cle|
00001880  61 72 69 6e 67 20 74 68  65 20 73 63 72 65 65 6e  |aring the screen|
00001890  2e 20 20 49 20 77 72 6f  74 65 20 61 20 72 6f 75  |.  I wrote a rou|
000018a0  74 69 6e 65 20 74 6f 0d  70 72 69 6e 74 20 6f 75  |tine to.print ou|
000018b0  74 20 74 68 65 20 62 79  74 65 73 20 70 61 73 73  |t the bytes pass|
000018c0  69 6e 67 20 64 6f 77 6e  20 74 68 69 73 20 76 65  |ing down this ve|
000018d0  63 74 6f 72 20 61 73 20  61 6e 20 61 69 64 20 74  |ctor as an aid t|
000018e0  6f 0d 64 65 62 75 67 67  69 6e 67 20 67 72 61 70  |o.debugging grap|
000018f0  68 69 63 73 20 70 72 6f  67 72 61 6d 73 2c 20 70  |hics programs, p|
00001900  61 72 74 69 63 75 6c 61  72 6c 79 20 77 68 65 6e  |articularly when|
00001910  20 75 73 69 6e 67 20 61  20 33 32 30 31 36 0d 73  | using a 32016.s|
00001920  65 63 6f 6e 64 20 70 72  6f 63 65 73 73 6f 72 2e  |econd processor.|
00001930  0d 0d 59 6f 75 20 64 6f  6e 27 74 20 61 63 74 75  |..You don't actu|
00001940  61 6c 6c 79 20 68 61 76  65 20 74 6f 20 64 6f 20  |ally have to do |
00001950  61 6e 79 74 68 69 6e 67  20 74 6f 20 67 65 74 20  |anything to get |
00001960  74 68 65 20 62 79 74 65  73 0d 66 6c 6f 77 69 6e  |the bytes.flowin|
00001970  67 20 74 68 72 6f 75 67  68 20 74 68 69 73 20 76  |g through this v|
00001980  65 63 74 6f 72 2e 20 20  54 68 65 79 20 77 69 6c  |ector.  They wil|
00001990  6c 20 64 6f 20 73 6f 20  61 6e 79 77 61 79 2e 20  |l do so anyway. |
000019a0  20 54 6f 0d 75 6e 64 65  72 73 74 61 6e 64 20 77  | To.understand w|
000019b0  68 61 74 20 74 68 65 20  62 79 74 65 20 61 63 74  |hat the byte act|
000019c0  75 61 6c 6c 79 20 6d 65  61 6e 73 20 77 65 20 6d  |ually means we m|
000019d0  75 73 74 20 69 6e 74 72  6f 64 75 63 65 0d 74 68  |ust introduce.th|
000019e0  65 20 63 6f 6e 63 65 70  74 20 6f 66 20 74 68 65  |e concept of the|
000019f0  20 56 44 55 20 71 75 65  75 65 20 61 6e 64 20 77  | VDU queue and w|
00001a00  68 61 74 20 49 20 73 68  61 6c 6c 20 63 61 6c 6c  |hat I shall call|
00001a10  20 6d 61 69 6e 20 61 6e  64 0d 74 61 63 6b 65 64  | main and.tacked|
00001a20  2d 6f 6e 20 62 79 74 65  73 2e 0d 0d 4f 6e 20 70  |-on bytes...On p|
00001a30  61 67 65 20 33 37 38 20  6f 66 20 74 68 65 20 6f  |age 378 of the o|
00001a40  72 69 67 69 6e 61 6c 20  42 42 43 20 4d 69 63 72  |riginal BBC Micr|
00001a50  6f 20 55 73 65 72 20 47  75 69 64 65 20 69 73 20  |o User Guide is |
00001a60  61 20 74 61 62 6c 65 0d  77 68 69 63 68 20 73 75  |a table.which su|
00001a70  6d 6d 61 72 69 73 65 73  20 74 68 65 20 56 44 55  |mmarises the VDU|
00001a80  20 63 6f 64 65 73 2e 20  20 49 66 20 79 6f 75 20  | codes.  If you |
00001a90  68 61 76 65 20 74 68 69  73 20 62 6f 6f 6b 20 74  |have this book t|
00001aa0  68 65 6e 0d 69 74 27 73  20 77 6f 72 74 68 20 66  |hen.it's worth f|
00001ab0  69 6e 64 69 6e 67 20 74  68 69 73 20 74 61 62 6c  |inding this tabl|
00001ac0  65 2e 20 20 54 68 65 72  65 20 61 72 65 20 74 68  |e.  There are th|
00001ad0  72 65 65 20 64 69 66 66  65 72 65 6e 74 0d 67 65  |ree different.ge|
00001ae0  6e 65 72 61 6c 20 61 72  65 61 73 20 69 6e 74 6f  |neral areas into|
00001af0  20 77 68 69 63 68 20 62  79 74 65 73 20 63 61 6e  | which bytes can|
00001b00  20 66 61 6c 6c 2e 20 20  54 68 65 79 20 63 61 6e  | fall.  They can|
00001b10  20 62 65 0d 63 6f 6e 74  72 6f 6c 20 63 6f 64 65  | be.control code|
00001b20  73 2c 20 76 61 6c 75 65  73 20 62 65 74 77 65 65  |s, values betwee|
00001b30  6e 20 30 20 61 6e 64 20  33 31 2c 20 74 68 65 79  |n 0 and 31, they|
00001b40  20 63 61 6e 20 62 65 0d  70 72 69 6e 74 61 62 6c  | can be.printabl|
00001b50  65 20 41 53 43 49 49 20  63 68 61 72 61 63 74 65  |e ASCII characte|
00001b60  72 73 2c 20 62 65 74 77  65 65 6e 20 33 32 20 61  |rs, between 32 a|
00001b70  6e 64 20 31 32 36 2c 20  61 6e 64 20 74 68 65 79  |nd 126, and they|
00001b80  20 63 61 6e 0d 62 65 20  65 78 74 72 61 20 63 68  | can.be extra ch|
00001b90  61 72 61 63 74 65 72 73  20 77 68 65 6e 20 62 65  |aracters when be|
00001ba0  74 77 65 65 6e 20 31 32  38 20 61 6e 64 20 32 35  |tween 128 and 25|
00001bb0  35 2e 20 20 31 32 37 20  69 73 20 61 0d 6c 69 74  |5.  127 is a.lit|
00001bc0  74 6c 65 20 73 70 65 63  69 61 6c 20 69 6e 20 74  |tle special in t|
00001bd0  68 61 74 20 69 74 20 69  73 20 61 6e 20 41 53 43  |hat it is an ASC|
00001be0  49 49 20 63 68 61 72 61  63 74 65 72 20 28 64 65  |II character (de|
00001bf0  6c 65 74 65 29 20 62 75  74 0d 69 73 20 6e 6f 74  |lete) but.is not|
00001c00  20 73 74 72 69 63 74 6c  79 20 70 72 69 6e 74 61  | strictly printa|
00001c10  62 6c 65 2e 0d 0d 57 68  65 6e 20 61 20 62 79 74  |ble...When a byt|
00001c20  65 20 70 61 73 73 65 73  20 74 6f 20 74 68 65 20  |e passes to the |
00001c30  56 44 55 20 64 72 69 76  65 72 73 20 69 74 20 69  |VDU drivers it i|
00001c40  73 20 65 69 74 68 65 72  20 70 72 69 6e 74 65 64  |s either printed|
00001c50  0d 6f 72 20 69 73 20 75  73 65 64 20 74 6f 20 63  |.or is used to c|
00001c60  6f 6e 74 72 6f 6c 20 61  20 66 75 6e 63 74 69 6f  |ontrol a functio|
00001c70  6e 2e 20 20 54 68 65 20  76 61 6c 75 65 73 20 75  |n.  The values u|
00001c80  70 20 74 6f 20 33 31 0d  63 6f 6e 74 72 6f 6c 20  |p to 31.control |
00001c90  61 20 66 75 6e 63 74 69  6f 6e 20 61 6e 64 20 69  |a function and i|
00001ca0  6e 63 6c 75 64 65 20 73  75 63 68 20 74 68 69 6e  |nclude such thin|
00001cb0  67 73 20 61 73 20 63 68  61 6e 67 69 6e 67 20 6d  |gs as changing m|
00001cc0  6f 64 65 2c 0d 63 6c 65  61 72 69 6e 67 20 74 68  |ode,.clearing th|
00001cd0  65 20 73 63 72 65 65 6e  20 61 6e 64 20 70 6c 6f  |e screen and plo|
00001ce0  74 74 69 6e 67 2e 20 20  54 68 65 20 61 6c 6c 6f  |tting.  The allo|
00001cf0  63 61 74 69 6f 6e 20 6f  66 20 74 68 65 73 65 0d  |cation of these.|
00001d00  66 75 6e 63 74 69 6f 6e  73 20 69 73 20 6e 6f 74  |functions is not|
00001d10  20 75 6e 69 76 65 72 73  61 6c 2e 20 20 41 6c 74  | universal.  Alt|
00001d20  68 6f 75 67 68 20 63 6f  64 65 20 31 33 20 69 73  |hough code 13 is|
00001d30  20 67 65 6e 65 72 61 6c  6c 79 0d 75 73 65 64 20  | generally.used |
00001d40  66 6f 72 20 61 20 63 61  72 72 69 61 67 65 20 72  |for a carriage r|
00001d50  65 74 75 72 6e 20 74 68  65 20 73 61 6d 65 20 69  |eturn the same i|
00001d60  73 20 6e 6f 74 20 74 72  75 65 20 6f 66 20 74 68  |s not true of th|
00001d70  65 20 6f 74 68 65 72 0d  6e 75 6d 62 65 72 73 2e  |e other.numbers.|
00001d80  0d 0d 54 68 65 20 56 44  55 20 64 72 69 76 65 72  |..The VDU driver|
00001d90  73 20 77 69 6c 6c 20 73  6f 6d 65 74 69 6d 65 73  |s will sometimes|
00001da0  20 65 78 70 65 63 74 20  61 20 6d 61 69 6e 20 62  | expect a main b|
00001db0  79 74 65 20 74 6f 20 68  61 76 65 0d 6f 6e 65 20  |yte to have.one |
00001dc0  6f 72 20 6d 6f 72 65 20  6f 74 68 65 72 20 62 79  |or more other by|
00001dd0  74 65 73 20 74 61 63 6b  65 64 20 6f 6e 20 74 6f  |tes tacked on to|
00001de0  20 74 68 65 20 65 6e 64  20 74 6f 20 63 6f 6d 70  | the end to comp|
00001df0  6c 65 74 65 20 61 0d 63  6f 6e 74 72 6f 6c 20 73  |lete a.control s|
00001e00  65 71 75 65 6e 63 65 2e  20 20 46 6f 72 20 65 78  |equence.  For ex|
00001e10  61 6d 70 6c 65 20 63 6f  64 65 20 32 32 20 68 61  |ample code 22 ha|
00001e20  73 20 74 6f 20 62 65 20  66 6f 6c 6c 6f 77 65 64  |s to be followed|
00001e30  20 62 79 0d 61 20 73 65  63 6f 6e 64 20 62 79 74  | by.a second byt|
00001e40  65 20 62 65 63 61 75 73  65 20 32 32 20 6d 65 61  |e because 22 mea|
00001e50  6e 73 20 27 63 68 61 6e  67 65 20 73 63 72 65 65  |ns 'change scree|
00001e60  6e 20 6d 6f 64 65 27 20  61 6e 64 20 74 68 65 0d  |n mode' and the.|
00001e70  73 65 63 6f 6e 64 20 62  79 74 65 20 69 73 20 74  |second byte is t|
00001e80  68 65 20 6e 65 77 20 6d  6f 64 65 2e 20 20 57 68  |he new mode.  Wh|
00001e90  65 6e 20 74 68 61 74 20  32 32 20 65 6e 74 65 72  |en that 22 enter|
00001ea0  73 20 74 68 65 0d 64 72  69 76 65 72 73 20 74 68  |s the.drivers th|
00001eb0  65 20 56 44 55 20 71 75  65 75 65 20 69 73 20 73  |e VDU queue is s|
00001ec0  65 74 20 74 6f 20 31 20  61 6e 64 20 74 68 65 20  |et to 1 and the |
00001ed0  63 6f 6d 6d 61 6e 64 20  69 73 20 6e 6f 74 0d 70  |command is not.p|
00001ee0  72 6f 63 65 73 73 65 64  20 75 6e 74 69 6c 20 74  |rocessed until t|
00001ef0  68 61 74 20 73 65 63 6f  6e 64 20 62 79 74 65 20  |hat second byte |
00001f00  68 61 73 20 61 72 72 69  76 65 64 2e 20 20 54 68  |has arrived.  Th|
00001f10  65 20 62 79 74 65 20 77  69 74 68 0d 74 68 65 20  |e byte with.the |
00001f20  6c 6f 6e 67 65 73 74 20  71 75 65 75 65 20 69 73  |longest queue is|
00001f30  20 32 33 20 28 56 44 55  20 32 33 29 20 77 68 69  | 23 (VDU 23) whi|
00001f40  63 68 20 73 65 74 73 20  75 70 20 61 20 71 75 65  |ch sets up a que|
00001f50  75 65 20 39 0d 62 79 74  65 73 20 6c 6f 6e 67 2e  |ue 9.bytes long.|
00001f60  20 20 4f 6e 6c 79 20 63  6f 6e 74 72 6f 6c 20 63  |  Only control c|
00001f70  6f 64 65 73 20 63 61 6e  20 68 61 76 65 20 74 61  |odes can have ta|
00001f80  63 6b 65 64 20 6f 6e 20  62 79 74 65 73 2e 0d 0d  |cked on bytes...|
00001f90  57 68 65 6e 20 77 65 20  6c 6f 6f 6b 20 61 74 20  |When we look at |
00001fa0  77 68 61 74 20 70 61 73  73 65 73 20 64 6f 77 6e  |what passes down|
00001fb0  20 74 68 65 20 77 72 69  74 65 20 63 68 61 72 61  | the write chara|
00001fc0  63 74 65 72 20 76 65 63  74 6f 72 0d 77 65 20 6d  |cter vector.we m|
00001fd0  75 73 74 20 6b 65 65 70  20 61 6e 20 65 79 65 20  |ust keep an eye |
00001fe0  6f 6e 20 74 68 65 20 56  44 55 20 71 75 65 75 65  |on the VDU queue|
00001ff0  20 74 6f 20 73 65 65 20  77 68 61 74 20 74 68 65  | to see what the|
00002000  20 62 79 74 65 20 77 65  0d 68 61 76 65 20 69 73  | byte we.have is|
00002010  20 61 63 74 75 61 6c 6c  79 20 66 6f 72 2e 20 20  | actually for.  |
00002020  53 69 6e 63 65 20 77 65  20 6c 6f 6f 6b 20 61 74  |Since we look at|
00002030  20 61 20 62 79 74 65 20  42 45 46 4f 52 45 20 69  | a byte BEFORE i|
00002040  74 0d 72 65 61 63 68 65  73 20 74 68 65 20 64 72  |t.reaches the dr|
00002050  69 76 65 72 73 20 77 65  20 61 72 65 20 61 63 74  |ivers we are act|
00002060  75 61 6c 6c 79 20 6f 6e  65 20 73 74 65 70 20 61  |ually one step a|
00002070  68 65 61 64 20 6f 66 20  74 68 65 6d 0d 61 6e 64  |head of them.and|
00002080  20 72 65 61 64 69 6e 67  20 74 68 65 20 71 75 65  | reading the que|
00002090  75 65 20 6c 65 6e 67 74  68 20 67 69 76 65 73 20  |ue length gives |
000020a0  75 73 20 61 6e 20 69 6e  63 6f 72 72 65 63 74 20  |us an incorrect |
000020b0  61 6e 73 77 65 72 2e 20  0d 46 6f 72 74 75 6e 61  |answer. .Fortuna|
000020c0  74 65 6c 79 20 77 65 20  6f 6e 6c 79 20 6e 65 65  |tely we only nee|
000020d0  64 20 74 6f 20 6b 6e 6f  77 20 77 68 69 63 68 20  |d to know which |
000020e0  62 79 74 65 73 20 61 72  65 20 6d 61 69 6e 20 62  |bytes are main b|
000020f0  79 74 65 73 0d 61 6e 64  20 74 68 65 79 20 77 69  |ytes.and they wi|
00002100  6c 6c 20 61 6c 77 61 79  73 20 61 72 72 69 76 65  |ll always arrive|
00002110  20 61 74 20 74 68 65 20  64 72 69 76 65 72 20 77  | at the driver w|
00002120  68 65 6e 20 74 68 65 20  71 75 65 75 65 20 69 73  |hen the queue is|
00002130  0d 6f 66 20 7a 65 72 6f  20 6c 65 6e 67 74 68 2e  |.of zero length.|
00002140  0d 0d 53 6f 20 68 6f 77  20 64 6f 20 77 65 20 72  |..So how do we r|
00002150  65 61 64 20 74 68 65 20  71 75 65 75 65 20 6c 65  |ead the queue le|
00002160  6e 67 74 68 2e 20 20 4f  53 42 59 54 45 20 32 31  |ngth.  OSBYTE 21|
00002170  38 20 77 69 6c 6c 20 72  65 74 75 72 6e 0d 74 68  |8 will return.th|
00002180  69 73 20 74 6f 20 75 73  20 69 66 20 77 65 20 65  |is to us if we e|
00002190  6e 74 65 72 20 69 74 20  77 69 74 68 20 30 20 69  |nter it with 0 i|
000021a0  6e 20 58 20 61 6e 64 20  32 35 35 20 28 26 46 46  |n X and 255 (&FF|
000021b0  29 20 69 6e 20 59 2e 20  0d 54 68 69 73 20 69 73  |) in Y. .This is|
000021c0  20 62 65 63 61 75 73 65  20 32 31 38 20 69 73 20  | because 218 is |
000021d0  6f 6e 65 20 6f 66 20 6d  61 6e 79 20 4f 53 42 59  |one of many OSBY|
000021e0  54 45 20 63 61 6c 6c 73  20 74 68 61 74 20 77 69  |TE calls that wi|
000021f0  6c 6c 0d 72 65 61 64 20  6f 72 20 77 72 69 74 65  |ll.read or write|
00002200  20 73 65 70 61 72 61 74  65 20 62 69 74 73 20 6f  | separate bits o|
00002210  66 20 6f 70 65 72 61 74  69 6e 67 20 73 79 73 74  |f operating syst|
00002220  65 6d 20 76 61 72 69 61  62 6c 65 73 2e 0d 54 68  |em variables..Th|
00002230  65 20 6e 75 6d 62 65 72  20 77 72 69 74 74 65 6e  |e number written|
00002240  20 69 6e 74 6f 20 74 68  65 20 76 61 72 69 61 62  | into the variab|
00002250  6c 65 20 69 73 3a 0d 0d  20 20 20 20 20 20 20 20  |le is:..        |
00002260  20 20 20 20 20 20 20 28  6f 6c 64 20 76 61 6c 75  |       (old valu|
00002270  65 20 20 41 4e 44 20 59  29 20 45 4f 52 20 58 0d  |e  AND Y) EOR X.|
00002280  0d 53 6f 20 74 6f 20 72  65 61 64 20 61 20 6c 6f  |.So to read a lo|
00002290  63 61 74 69 6f 6e 20 79  6f 75 20 73 65 74 20 58  |cation you set X|
000022a0  20 74 6f 20 30 20 61 6e  64 20 59 20 74 6f 20 26  | to 0 and Y to &|
000022b0  46 46 20 61 6e 64 20 74  68 65 0d 72 65 73 75 6c  |FF and the.resul|
000022c0  74 20 69 73 20 69 6e 20  58 2e 20 20 54 6f 20 77  |t is in X.  To w|
000022d0  72 69 74 65 20 79 6f 75  20 73 65 74 20 58 20 74  |rite you set X t|
000022e0  6f 20 74 68 65 20 76 61  6c 75 65 20 79 6f 75 20  |o the value you |
000022f0  77 69 73 68 20 74 6f 0d  77 72 69 74 65 20 61 6e  |wish to.write an|
00002300  64 20 73 65 74 20 59 20  74 6f 20 30 2e 20 20 54  |d set Y to 0.  T|
00002310  68 65 20 6f 6c 64 20 76  61 6c 75 65 20 6f 66 20  |he old value of |
00002320  74 68 65 20 76 61 72 69  61 62 6c 65 20 69 73 20  |the variable is |
00002330  69 6e 20 58 0d 6f 6e 20  65 78 69 74 2e 0d 0d 49  |in X.on exit...I|
00002340  6e 20 74 68 65 20 63 61  73 65 20 6f 66 20 4f 53  |n the case of OS|
00002350  42 59 54 45 20 32 31 38  20 74 68 65 20 76 61 72  |BYTE 218 the var|
00002360  69 61 62 6c 65 20 69 73  20 61 63 74 75 61 6c 6c  |iable is actuall|
00002370  79 20 74 68 65 20 32 27  73 0d 63 6f 6d 70 6c 65  |y the 2's.comple|
00002380  6d 65 6e 74 20 6e 65 67  61 74 69 76 65 20 6f 66  |ment negative of|
00002390  20 74 68 65 20 71 75 65  75 65 20 6c 65 6e 67 74  | the queue lengt|
000023a0  68 2e 0d 0d 42 2f 6f 73  62 31 36 20 64 65 61 6c  |h...B/osb16 deal|
000023b0  73 20 77 69 74 68 20 74  68 72 65 65 20 69 73 73  |s with three iss|
000023c0  75 65 73 20 72 61 69 73  65 64 20 62 79 20 69 6e  |ues raised by in|
000023d0  74 65 72 63 65 70 74 69  6e 67 0d 76 65 63 74 6f  |tercepting.vecto|
000023e0  72 73 2e 20 20 46 69 72  73 74 6c 79 20 74 68 65  |rs.  Firstly the|
000023f0  20 4f 53 20 69 73 20 76  75 6c 6e 65 72 61 62 6c  | OS is vulnerabl|
00002400  65 20 64 75 72 69 6e 67  20 74 68 65 20 63 68 61  |e during the cha|
00002410  6e 67 69 6e 67 0d 6f 66  20 61 20 76 65 63 74 6f  |nging.of a vecto|
00002420  72 2e 20 20 41 6e 20 69  6e 74 65 72 72 75 70 74  |r.  An interrupt|
00002430  20 63 6f 75 6c 64 20 6f  63 63 75 72 20 77 68 65  | could occur whe|
00002440  6e 20 6f 6e 65 20 6f 66  20 74 68 65 20 74 77 6f  |n one of the two|
00002450  0d 62 79 74 65 73 20 68  61 73 20 62 65 65 6e 20  |.bytes has been |
00002460  63 68 61 6e 67 65 64 20  62 75 74 20 62 65 66 6f  |changed but befo|
00002470  72 65 20 74 68 65 20 6f  74 68 65 72 2e 20 20 54  |re the other.  T|
00002480  6f 20 73 74 6f 70 20 74  68 69 73 0d 74 68 65 20  |o stop this.the |
00002490  69 6e 74 65 72 72 75 70  74 20 66 6c 61 67 20 69  |interrupt flag i|
000024a0  73 20 73 65 74 20 77 68  69 63 68 20 73 74 6f 70  |s set which stop|
000024b0  73 20 6d 61 73 6b 61 62  6c 65 20 69 6e 74 65 72  |s maskable inter|
000024c0  72 75 70 74 73 0d 6f 63  63 75 72 72 69 6e 67 2e  |rupts.occurring.|
000024d0  20 20 54 68 69 73 20 77  69 6c 6c 20 62 65 20 65  |  This will be e|
000024e0  78 70 6c 61 69 6e 65 64  20 6d 6f 72 65 20 69 6e  |xplained more in|
000024f0  20 74 68 65 20 49 6e 74  65 72 72 75 70 74 73 0d  | the Interrupts.|
00002500  6d 6f 64 75 6c 65 2e 0d  0d 53 65 63 6f 6e 64 6c  |module...Secondl|
00002510  79 20 77 65 20 6d 75 73  74 20 6d 61 6b 65 20 73  |y we must make s|
00002520  75 72 65 20 74 68 65 20  76 65 63 74 6f 72 20 63  |ure the vector c|
00002530  68 61 6e 67 69 6e 67 20  72 6f 75 74 69 6e 65 20  |hanging routine |
00002540  69 73 0d 65 78 65 63 75  74 65 64 20 6f 6e 6c 79  |is.executed only|
00002550  20 6f 6e 63 65 2e 20 20  4d 6f 72 65 20 6f 6e 20  | once.  More on |
00002560  74 68 69 73 20 6c 61 74  65 72 20 69 6e 20 74 68  |this later in th|
00002570  69 73 20 6d 6f 64 75 6c  65 2e 0d 0d 46 69 6e 61  |is module...Fina|
00002580  6c 6c 79 20 77 65 20 68  61 76 65 20 74 6f 20 70  |lly we have to p|
00002590  75 74 20 74 68 65 20 72  6f 75 74 69 6e 65 20 69  |ut the routine i|
000025a0  6e 20 74 68 65 20 49 2f  4f 20 70 72 6f 63 65 73  |n the I/O proces|
000025b0  73 6f 72 20 74 6f 0d 62  65 20 73 75 72 65 20 69  |sor to.be sure i|
000025c0  74 20 77 69 6c 6c 20 77  6f 72 6b 20 66 6f 72 20  |t will work for |
000025d0  61 6c 6c 20 63 61 73 65  73 20 61 6e 64 20 61 6c  |all cases and al|
000025e0  6c 20 74 79 70 65 73 20  6f 66 20 73 65 63 6f 6e  |l types of secon|
000025f0  64 0d 70 72 6f 63 65 73  73 6f 72 2e 20 20 48 61  |d.processor.  Ha|
00002600  76 69 6e 67 20 64 6f 6e  65 20 74 68 69 73 20 69  |ving done this i|
00002610  74 20 69 73 20 6f 62 76  69 6f 75 73 6c 79 20 67  |t is obviously g|
00002620  6f 69 6e 67 20 74 6f 20  62 65 0d 6d 6f 72 65 20  |oing to be.more |
00002630  64 69 66 66 69 63 75 6c  74 20 74 6f 20 73 77 69  |difficult to swi|
00002640  74 63 68 20 74 68 65 20  69 6e 74 65 72 63 65 70  |tch the intercep|
00002650  74 20 72 6f 75 74 69 6e  65 20 6f 6e 20 61 6e 64  |t routine on and|
00002660  20 6f 66 66 0d 62 75 74  20 66 6f 72 74 75 6e 61  | off.but fortuna|
00002670  74 65 6c 79 20 74 68 65  72 65 20 69 73 20 61 6e  |tely there is an|
00002680  20 4f 53 20 66 75 6e 63  74 69 6f 6e 20 77 65 20  | OS function we |
00002690  63 61 6e 20 75 73 65 2e  0d 0d 54 68 65 72 65 20  |can use...There |
000026a0  61 72 65 20 74 77 6f 20  6c 69 74 74 6c 65 20 6b  |are two little k|
000026b0  6e 6f 77 6e 20 62 75 69  6c 74 20 69 6e 20 2a 20  |nown built in * |
000026c0  63 6f 6d 6d 61 6e 64 73  2c 20 2a 43 4f 44 45 20  |commands, *CODE |
000026d0  61 6e 64 0d 2a 4c 49 4e  45 2e 20 20 2a 43 4f 44  |and.*LINE.  *COD|
000026e0  45 20 69 73 20 66 6f 6c  6c 6f 77 65 64 20 62 79  |E is followed by|
000026f0  20 75 70 20 74 6f 20 74  77 6f 20 62 79 74 65 73  | up to two bytes|
00002700  2c 20 73 65 70 61 72 61  74 65 64 20 62 79 0d 73  |, separated by.s|
00002710  70 61 63 65 73 20 6f 72  20 63 6f 6d 6d 61 73 20  |paces or commas |
00002720  6a 75 73 74 20 6c 69 6b  65 20 2a 46 58 2e 20 20  |just like *FX.  |
00002730  2a 4c 49 4e 45 20 69 73  20 66 6f 6c 6c 6f 77 65  |*LINE is followe|
00002740  64 20 62 79 20 61 0d 73  74 72 69 6e 67 2e 20 20  |d by a.string.  |
00002750  57 68 65 6e 20 65 69 74  68 65 72 20 69 73 20 65  |When either is e|
00002760  78 65 63 75 74 65 64 20  69 6e 20 77 68 69 63 68  |xecuted in which|
00002770  65 76 65 72 20 70 72 6f  63 65 73 73 6f 72 20 69  |ever processor i|
00002780  6e 0d 79 6f 75 72 20 63  6f 6d 70 75 74 65 72 20  |n.your computer |
00002790  74 68 65 20 49 2f 4f 20  70 72 6f 63 65 73 73 6f  |the I/O processo|
000027a0  72 20 6a 75 6d 70 73 20  74 6f 20 74 68 65 20 63  |r jumps to the c|
000027b0  6f 6e 74 65 6e 74 73 20  6f 66 20 74 68 65 0d 55  |ontents of the.U|
000027c0  73 65 72 20 56 65 63 74  6f 72 20 61 74 20 26 32  |ser Vector at &2|
000027d0  30 30 2e 20 20 49 6e 20  74 68 69 73 20 6d 6f 64  |00.  In this mod|
000027e0  75 6c 65 20 49 20 68 61  76 65 20 75 73 65 64 20  |ule I have used |
000027f0  2a 43 4f 44 45 20 62 75  74 20 49 0d 77 69 6c 6c  |*CODE but I.will|
00002800  20 65 78 70 6c 61 69 6e  20 62 6f 74 68 2e 0d 0d  | explain both...|
00002810  54 68 65 20 55 73 65 72  20 56 65 63 74 6f 72 20  |The User Vector |
00002820  73 68 6f 75 6c 64 20 62  65 20 63 68 61 6e 67 65  |should be change|
00002830  64 20 74 6f 20 70 6f 69  6e 74 20 74 6f 20 73 6f  |d to point to so|
00002840  6d 65 20 6e 65 77 20 63  6f 64 65 0d 79 6f 75 20  |me new code.you |
00002850  68 61 76 65 20 6a 75 73  74 20 77 72 69 74 74 65  |have just writte|
00002860  6e 20 77 68 69 63 68 20  69 73 20 65 78 70 65 63  |n which is expec|
00002870  74 69 6e 67 20 74 68 65  20 2a 43 4f 44 45 20 6f  |ting the *CODE o|
00002880  72 20 2a 4c 49 4e 45 2e  20 0d 54 68 65 20 6d 6f  |r *LINE. .The mo|
00002890  64 75 6c 65 20 70 72 6f  67 72 61 6d 20 77 69 6c  |dule program wil|
000028a0  6c 20 69 6c 6c 75 73 74  72 61 74 65 20 68 6f 77  |l illustrate how|
000028b0  2e 20 20 4f 6e 20 65 6e  74 72 79 20 74 6f 20 79  |.  On entry to y|
000028c0  6f 75 72 0d 72 6f 75 74  69 6e 65 20 66 72 6f 6d  |our.routine from|
000028d0  20 2a 43 4f 44 45 20 74  68 65 20 58 20 61 6e 64  | *CODE the X and|
000028e0  20 59 20 72 65 67 69 73  74 65 72 73 20 77 69 6c  | Y registers wil|
000028f0  6c 20 62 65 20 73 65 74  20 61 73 0d 66 6f 72 20  |l be set as.for |
00002900  74 68 65 20 6e 75 6d 62  65 72 73 20 74 79 70 65  |the numbers type|
00002910  64 20 69 6e 20 61 66 74  65 72 20 2a 43 4f 44 45  |d in after *CODE|
00002920  2e 20 20 54 68 65 20 61  63 63 75 6d 75 6c 61 74  |.  The accumulat|
00002930  6f 72 20 77 69 6c 6c 0d  63 6f 6e 74 61 69 6e 20  |or will.contain |
00002940  7a 65 72 6f 2e 20 20 57  69 74 68 20 2a 4c 49 4e  |zero.  With *LIN|
00002950  45 20 66 6f 6c 6c 6f 77  65 64 20 62 79 20 74 65  |E followed by te|
00002960  78 74 20 61 6e 64 20 74  65 72 6d 69 6e 61 74 65  |xt and terminate|
00002970  64 0d 77 69 74 68 20 61  20 63 61 72 72 69 61 67  |d.with a carriag|
00002980  65 20 72 65 74 75 72 6e  20 74 68 65 20 4f 53 20  |e return the OS |
00002990  77 69 6c 6c 20 70 75 74  20 74 68 65 20 6c 69 6e  |will put the lin|
000029a0  65 20 6f 66 20 74 65 78  74 0d 73 6f 6d 65 77 68  |e of text.somewh|
000029b0  65 72 65 20 69 6e 20 6d  65 6d 6f 72 79 20 61 6e  |ere in memory an|
000029c0  64 20 6f 6e 20 65 6e 74  72 79 20 74 6f 20 79 6f  |d on entry to yo|
000029d0  75 72 20 72 6f 75 74 69  6e 65 20 41 20 77 69 6c  |ur routine A wil|
000029e0  6c 0d 63 6f 6e 74 61 69  6e 20 31 20 61 6e 64 20  |l.contain 1 and |
000029f0  58 20 77 69 6c 6c 20 63  6f 6e 74 61 69 6e 20 74  |X will contain t|
00002a00  68 65 20 6c 6f 77 20 62  79 74 65 20 6f 66 20 74  |he low byte of t|
00002a10  68 65 20 61 64 64 72 65  73 73 0d 77 68 65 72 65  |he address.where|
00002a20  20 74 68 65 20 4f 53 20  68 61 73 20 73 74 6f 72  | the OS has stor|
00002a30  65 64 20 74 68 65 20 73  74 72 69 6e 67 20 61 6e  |ed the string an|
00002a40  64 20 59 20 77 69 6c 6c  20 63 6f 6e 74 61 69 6e  |d Y will contain|
00002a50  20 74 68 65 0d 68 69 67  68 20 62 79 74 65 2e 0d  | the.high byte..|
00002a60  0d 54 68 65 73 65 20 61  72 65 20 70 61 72 74 69  |.These are parti|
00002a70  63 75 6c 61 72 6c 79 20  75 73 65 66 75 6c 20 69  |cularly useful i|
00002a80  66 20 79 6f 75 20 77 61  6e 74 20 74 6f 20 62 65  |f you want to be|
00002a90  20 61 62 6c 65 20 74 6f  0d 73 77 69 74 63 68 20  | able to.switch |
00002aa0  79 6f 75 72 20 69 6e 74  65 72 63 65 70 74 20 6f  |your intercept o|
00002ab0  6e 20 61 6e 64 20 6f 66  66 20 66 72 6f 6d 20 74  |n and off from t|
00002ac0  68 65 20 6b 65 79 62 6f  61 72 64 2c 20 61 73 20  |he keyboard, as |
00002ad0  77 65 20 64 6f 0d 68 65  72 65 2e 20 20 49 6e 20  |we do.here.  In |
00002ae0  61 64 64 69 74 69 6f 6e  20 2a 43 4f 44 45 20 69  |addition *CODE i|
00002af0  73 20 65 71 75 69 76 61  6c 65 6e 74 20 74 6f 20  |s equivalent to |
00002b00  4f 53 42 59 54 45 20 31  33 36 0d 28 2a 46 58 31  |OSBYTE 136.(*FX1|
00002b10  33 36 29 2e 20 20 49 66  20 74 68 65 72 65 20 69  |36).  If there i|
00002b20  73 20 6e 6f 20 75 73 65  72 20 63 6f 64 65 20 70  |s no user code p|
00002b30  6f 69 6e 74 65 64 20 74  6f 20 62 79 20 74 68 65  |ointed to by the|
00002b40  20 75 73 65 72 0d 76 65  63 74 6f 72 20 63 61 6c  | user.vector cal|
00002b50  6c 69 6e 67 20 2a 43 4f  44 45 20 6f 72 20 2a 4c  |ling *CODE or *L|
00002b60  49 4e 45 20 77 69 6c 6c  20 67 65 6e 65 72 61 74  |INE will generat|
00002b70  65 20 61 20 27 42 61 64  20 43 6f 6d 6d 61 6e 64  |e a 'Bad Command|
00002b80  27 0d 6d 65 73 73 61 67  65 2e 0d 0d 54 68 65 20  |'.message...The |
00002b90  63 6f 64 65 20 67 65 6e  65 72 61 74 65 64 20 62  |code generated b|
00002ba0  79 20 42 2f 6f 73 62 31  36 20 69 73 20 69 6e 20  |y B/osb16 is in |
00002bb0  74 68 72 65 65 20 70 61  72 74 73 2c 20 61 6c 74  |three parts, alt|
00002bc0  68 6f 75 67 68 0d 74 68  65 79 20 6d 61 6b 65 20  |hough.they make |
00002bd0  75 70 20 6f 6e 65 20 70  72 6f 67 72 61 6d 2e 20  |up one program. |
00002be0  20 54 68 65 20 66 69 72  73 74 20 73 65 63 74 69  | The first secti|
00002bf0  6f 6e 20 63 68 61 6e 67  65 73 20 74 68 65 0d 75  |on changes the.u|
00002c00  73 65 72 20 76 65 63 74  6f 72 20 74 6f 20 70 6f  |ser vector to po|
00002c10  69 6e 74 20 74 6f 20 6f  75 72 20 6e 65 77 20 63  |int to our new c|
00002c20  6f 64 65 2e 20 20 54 68  65 20 73 65 63 6f 6e 64  |ode.  The second|
00002c30  20 70 61 72 74 0d 65 6e  61 62 6c 65 73 20 2a 43  | part.enables *C|
00002c40  4f 44 45 20 74 6f 20 73  77 69 74 63 68 20 74 68  |ODE to switch th|
00002c50  65 20 69 6e 74 65 72 63  65 70 74 20 6f 6e 20 61  |e intercept on a|
00002c60  6e 64 20 6f 66 66 20 62  79 0d 6d 6f 64 69 66 79  |nd off by.modify|
00002c70  69 6e 67 20 74 68 65 20  77 72 69 74 65 20 63 68  |ing the write ch|
00002c80  61 72 61 63 74 65 72 20  76 65 63 74 6f 72 20 6f  |aracter vector o|
00002c90  72 20 72 65 73 74 6f 72  69 6e 67 20 69 74 20 74  |r restoring it t|
00002ca0  6f 20 69 74 73 0d 6f 72  69 67 69 6e 61 6c 20 76  |o its.original v|
00002cb0  61 6c 75 65 2e 20 20 54  68 65 20 66 69 6e 61 6c  |alue.  The final|
00002cc0  20 70 61 72 74 20 69 73  20 74 68 65 20 69 6e 74  | part is the int|
00002cd0  65 72 63 65 70 74 20 63  6f 64 65 0d 69 74 73 65  |ercept code.itse|
00002ce0  6c 66 2e 20 20 54 6f 20  75 73 65 20 74 68 69 73  |lf.  To use this|
00002cf0  20 70 72 6f 67 72 61 6d  20 79 6f 75 20 77 69 6c  | program you wil|
00002d00  6c 20 6e 65 65 64 20 61  20 70 72 69 6e 74 65 72  |l need a printer|
00002d10  0d 63 6f 6e 6e 65 63 74  65 64 20 61 6e 64 20 72  |.connected and r|
00002d20  65 61 64 79 20 74 6f 20  67 6f 2e 20 20 49 20 68  |eady to go.  I h|
00002d30  61 76 65 20 75 73 65 64  20 74 68 65 20 52 53 34  |ave used the RS4|
00002d40  32 33 20 69 6e 70 75 74  0d 62 75 66 66 65 72 20  |23 input.buffer |
00002d50  28 70 61 67 65 20 26 41  29 20 61 73 20 68 6f 6d  |(page &A) as hom|
00002d60  65 20 66 6f 72 20 74 68  69 73 20 63 6f 64 65 20  |e for this code |
00002d70  61 6e 64 20 49 20 68 6f  70 65 20 74 68 61 74 20  |and I hope that |
00002d80  6d 65 61 6e 73 0d 69 74  20 77 69 6c 6c 20 77 6f  |means.it will wo|
00002d90  72 6b 20 77 69 74 68 20  61 20 73 65 72 69 61 6c  |rk with a serial|
00002da0  20 70 72 69 6e 74 65 72  20 61 73 20 77 65 6c 6c  | printer as well|
00002db0  20 61 73 20 61 20 70 61  72 61 6c 6c 65 6c 0d 6f  | as a parallel.o|
00002dc0  6e 65 2c 20 62 75 74 20  49 20 6f 6e 6c 79 20 68  |ne, but I only h|
00002dd0  61 76 65 20 61 20 70 61  72 61 6c 6c 65 6c 20 70  |ave a parallel p|
00002de0  72 69 6e 74 65 72 2e 20  20 49 6e 20 63 61 73 65  |rinter.  In case|
00002df0  20 6f 66 20 74 72 6f 75  62 6c 65 0d 63 68 61 6e  | of trouble.chan|
00002e00  67 65 20 74 68 65 20 76  61 6c 75 65 20 6f 66 20  |ge the value of |
00002e10  63 6f 64 65 25 20 69 6e  20 6c 69 6e 65 20 31 31  |code% in line 11|
00002e20  30 20 74 6f 2c 20 73 61  79 2c 20 26 43 30 30 20  |0 to, say, &C00 |
00002e30  69 66 20 79 6f 75 0d 68  61 76 65 20 6e 6f 20 75  |if you.have no u|
00002e40  73 65 72 20 64 65 66 69  6e 65 64 20 63 68 61 72  |ser defined char|
00002e50  61 63 74 65 72 73 2c 20  6f 72 20 26 31 36 30 30  |acters, or &1600|
00002e60  20 74 6f 20 6d 61 6b 65  20 75 73 65 20 6f 66 0d  | to make use of.|
00002e70  73 6f 6d 65 20 6f 66 20  74 68 65 20 64 69 73 63  |some of the disc|
00002e80  20 64 72 69 76 65 20 73  70 61 63 65 20 28 6e 6f  | drive space (no|
00002e90  74 20 69 6e 20 61 20 4d  61 73 74 65 72 29 2e 0d  |t in a Master)..|
00002ea0  0d 54 6f 20 6d 6f 64 69  66 79 20 76 65 63 74 6f  |.To modify vecto|
00002eb0  72 73 20 79 6f 75 20 66  69 72 73 74 20 64 69 73  |rs you first dis|
00002ec0  61 62 6c 65 20 69 6e 74  65 72 72 75 70 74 73 20  |able interrupts |
00002ed0  77 69 74 68 20 53 45 49  20 61 6e 64 0d 74 68 65  |with SEI and.the|
00002ee0  6e 20 73 61 76 65 20 74  68 65 20 65 78 69 73 74  |n save the exist|
00002ef0  69 6e 67 20 63 6f 6e 74  65 6e 74 73 20 6f 66 20  |ing contents of |
00002f00  74 68 65 20 76 65 63 74  6f 72 20 73 6f 6d 65 77  |the vector somew|
00002f10  68 65 72 65 0d 73 61 66  65 2e 20 20 54 68 65 6e  |here.safe.  Then|
00002f20  20 79 6f 75 20 70 75 74  20 74 68 65 20 73 74 61  | you put the sta|
00002f30  72 74 20 61 64 64 72 65  73 73 20 6f 66 20 79 6f  |rt address of yo|
00002f40  75 72 20 70 69 65 63 65  20 6f 66 20 63 6f 64 65  |ur piece of code|
00002f50  0d 69 6e 74 6f 20 74 68  65 20 76 65 63 74 6f 72  |.into the vector|
00002f60  20 28 6c 6f 20 62 79 74  65 20 74 68 65 6e 20 68  | (lo byte then h|
00002f70  69 20 62 79 74 65 29 20  61 6e 64 20 66 69 6e 61  |i byte) and fina|
00002f80  6c 6c 79 20 79 6f 75 0d  72 65 2d 65 6e 61 62 6c  |lly you.re-enabl|
00002f90  65 20 69 6e 74 65 72 72  75 70 74 73 20 61 67 61  |e interrupts aga|
00002fa0  69 6e 20 77 69 74 68 20  43 4c 49 2e 20 20 53 61  |in with CLI.  Sa|
00002fb0  76 69 6e 67 20 74 68 65  20 6f 6c 64 20 76 65 63  |ving the old vec|
00002fc0  74 6f 72 0d 63 6f 6e 74  65 6e 74 73 20 68 61 73  |tor.contents has|
00002fd0  20 74 77 6f 20 75 73 65  73 2e 20 20 46 69 72 73  | two uses.  Firs|
00002fe0  74 6c 79 20 79 6f 75 20  63 61 6e 20 72 65 74 75  |tly you can retu|
00002ff0  72 6e 20 74 68 65 6d 20  77 68 65 6e 20 79 6f 75  |rn them when you|
00003000  0d 68 61 76 65 20 63 6f  6d 70 6c 65 74 65 6c 79  |.have completely|
00003010  20 66 69 6e 69 73 68 65  64 20 77 69 74 68 20 74  | finished with t|
00003020  68 65 20 69 6e 74 65 72  63 65 70 74 20 61 6e 64  |he intercept and|
00003030  20 73 65 63 6f 6e 64 6c  79 20 79 6f 75 0d 63 61  | secondly you.ca|
00003040  6e 20 63 68 61 69 6e 20  69 6e 74 65 72 63 65 70  |n chain intercep|
00003050  74 20 72 6f 75 74 69 6e  65 73 20 74 6f 67 65 74  |t routines toget|
00003060  68 65 72 20 62 79 20 6a  75 6d 70 69 6e 67 20 74  |her by jumping t|
00003070  6f 20 74 68 65 20 6f 6c  64 0d 76 65 63 74 6f 72  |o the old.vector|
00003080  20 63 6f 6e 74 65 6e 74  73 20 61 74 20 74 68 65  | contents at the|
00003090  20 65 6e 64 20 6f 66 20  79 6f 75 72 20 72 6f 75  | end of your rou|
000030a0  74 69 6e 65 2e 0d 0d 4c  69 6e 65 73 20 32 35 30  |tine...Lines 250|
000030b0  20 74 6f 20 34 31 30 20  73 61 76 65 20 74 68 65  | to 410 save the|
000030c0  20 65 78 69 73 74 69 6e  67 20 75 73 65 72 20 76  | existing user v|
000030d0  65 63 74 6f 72 20 63 6f  6e 74 65 6e 74 73 20 69  |ector contents i|
000030e0  6e 0d 27 6f 6c 64 5f 75  73 65 72 27 20 61 6e 64  |n.'old_user' and|
000030f0  20 74 68 65 6e 20 72 65  70 6c 61 63 65 20 74 68  | then replace th|
00003100  65 6d 20 77 69 74 68 20  74 68 65 20 61 64 64 72  |em with the addr|
00003110  65 73 73 20 6f 66 20 74  68 65 0d 63 6f 64 65 20  |ess of the.code |
00003120  73 74 61 72 74 69 6e 67  20 61 74 20 27 75 73 65  |starting at 'use|
00003130  72 27 2e 20 20 53 6f 20  74 68 61 74 20 61 20 73  |r'.  So that a s|
00003140  65 63 6f 6e 64 20 65 78  65 63 75 74 69 6f 6e 20  |econd execution |
00003150  6f 66 20 74 68 69 73 0d  70 69 65 63 65 20 6f 66  |of this.piece of|
00003160  20 63 6f 64 65 20 77 69  6c 6c 20 6e 6f 74 20 61  | code will not a|
00003170  74 74 65 6d 70 74 20 74  6f 20 72 65 73 65 74 20  |ttempt to reset |
00003180  74 68 65 20 76 65 63 74  6f 72 73 20 61 67 61 69  |the vectors agai|
00003190  6e 0d 74 68 65 20 63 6f  64 65 20 63 68 65 63 6b  |n.the code check|
000031a0  73 20 74 68 61 74 20 74  68 65 20 68 69 67 68 20  |s that the high |
000031b0  62 79 74 65 20 76 61 6c  75 65 73 20 61 72 65 20  |byte values are |
000031c0  64 69 66 66 65 72 65 6e  74 0d 62 65 74 77 65 65  |different.betwee|
000031d0  6e 20 74 68 65 20 70 6f  73 69 74 69 6f 6e 20 6f  |n the position o|
000031e0  66 20 74 68 65 20 6e 65  77 20 63 6f 64 65 20 28  |f the new code (|
000031f0  27 75 73 65 72 29 20 61  6e 64 20 74 68 65 0d 63  |'user) and the.c|
00003200  6f 6e 74 65 6e 74 73 20  6f 66 20 74 68 65 20 75  |ontents of the u|
00003210  73 65 72 20 76 65 63 74  6f 72 2e 20 20 53 69 6e  |ser vector.  Sin|
00003220  63 65 20 74 68 65 20 75  73 65 72 20 76 65 63 74  |ce the user vect|
00003230  6f 72 20 75 73 75 61 6c  6c 79 0d 70 6f 69 6e 74  |or usually.point|
00003240  73 20 77 61 79 20 75 70  20 69 6e 74 6f 20 74 68  |s way up into th|
00003250  65 20 4f 53 20 52 4f 4d  20 74 68 65 72 65 20 73  |e OS ROM there s|
00003260  68 6f 75 6c 64 20 62 65  20 6e 6f 20 70 72 6f 62  |hould be no prob|
00003270  6c 65 6d 73 2e 0d 0d 4c  69 6e 65 73 20 34 33 30  |lems...Lines 430|
00003280  20 74 6f 20 39 32 30 20  75 73 65 20 2a 43 4f 44  | to 920 use *COD|
00003290  45 20 74 6f 20 65 6e 61  62 6c 65 20 6f 72 20 64  |E to enable or d|
000032a0  69 73 61 62 6c 65 20 74  68 65 0d 69 6e 74 65 72  |isable the.inter|
000032b0  63 65 70 74 2e 20 20 49  66 20 74 68 65 20 6e 75  |cept.  If the nu|
000032c0  6d 62 65 72 20 69 6e 20  74 68 65 20 61 63 63 75  |mber in the accu|
000032d0  6d 75 6c 61 74 6f 72 20  69 73 20 6e 6f 74 20 30  |mulator is not 0|
000032e0  20 74 68 65 6e 0d 77 65  20 61 72 65 20 6e 6f 74  | then.we are not|
000032f0  20 72 65 73 70 6f 6e 64  69 6e 67 20 74 6f 20 61  | responding to a|
00003300  20 2a 43 4f 44 45 20 73  6f 20 74 68 65 20 72 6f  | *CODE so the ro|
00003310  75 74 69 6e 65 20 62 72  61 6e 63 68 65 73 20 74  |utine branches t|
00003320  6f 0d 27 6f 76 65 72 5f  65 6e 74 72 79 27 20 77  |o.'over_entry' w|
00003330  68 65 72 65 20 69 74 20  6a 75 6d 70 73 20 74 6f  |here it jumps to|
00003340  20 74 68 65 20 6f 6c 64  20 76 65 63 74 6f 72 20  | the old vector |
00003350  63 6f 6e 74 65 6e 74 73  2e 20 0d 54 68 69 73 20  |contents. .This |
00003360  6d 65 61 6e 73 20 74 68  61 74 20 61 20 73 65 70  |means that a sep|
00003370  61 72 61 74 65 20 75 73  65 72 20 76 65 63 74 6f  |arate user vecto|
00003380  72 20 75 73 65 72 2c 20  6c 69 6b 65 20 2a 43 4f  |r user, like *CO|
00003390  44 45 20 77 69 74 68 0d  58 3e 31 20 6f 72 20 2a  |DE with.X>1 or *|
000033a0  4c 49 4e 45 2c 20 77 69  6c 6c 20 73 74 69 6c 6c  |LINE, will still|
000033b0  20 66 75 6e 63 74 69 6f  6e 2e 0d 0d 57 65 20 77  | function...We w|
000033c0  61 6e 74 20 58 20 74 6f  20 62 65 20 30 20 6f 72  |ant X to be 0 or|
000033d0  20 31 20 6f 6e 20 65 6e  74 72 79 2c 20 69 66 20  | 1 on entry, if |
000033e0  69 74 20 69 73 20 6e 65  69 74 68 65 72 20 74 68  |it is neither th|
000033f0  65 6e 20 74 68 65 0d 72  6f 75 74 69 6e 65 20 61  |en the.routine a|
00003400  6c 73 6f 20 72 65 61 63  68 65 73 20 27 6f 76 65  |lso reaches 'ove|
00003410  72 5f 65 6e 74 72 79 27  20 62 75 74 20 69 66 20  |r_entry' but if |
00003420  69 74 20 69 73 20 65 69  74 68 65 72 20 74 68 65  |it is either the|
00003430  6e 0d 77 65 20 68 61 76  65 20 74 6f 20 73 65 65  |n.we have to see|
00003440  20 77 68 69 63 68 20 69  74 20 69 73 2e 20 20 41  | which it is.  A|
00003450  20 66 6c 61 67 2c 20 61  74 20 27 69 6e 74 65 72  | flag, at 'inter|
00003460  63 65 70 74 5f 66 6c 61  67 27 20 69 73 0d 75 73  |cept_flag' is.us|
00003470  65 64 20 74 6f 20 6d 61  6b 65 20 73 75 72 65 20  |ed to make sure |
00003480  74 68 61 74 20 77 65 20  64 6f 20 6e 6f 74 20 74  |that we do not t|
00003490  72 79 20 74 6f 20 72 65  73 65 74 20 61 20 76 65  |ry to reset a ve|
000034a0  63 74 6f 72 20 74 68 61  74 0d 69 73 20 61 6c 72  |ctor that.is alr|
000034b0  65 61 64 79 20 72 65 73  65 74 2e 20 20 54 68 69  |eady reset.  Thi|
000034c0  73 20 69 73 20 61 6e 20  61 6c 74 65 72 6e 61 74  |s is an alternat|
000034d0  69 76 65 20 77 61 79 20  6f 66 20 73 74 6f 70 70  |ive way of stopp|
000034e0  69 6e 67 0d 63 6f 64 65  20 70 6f 69 6e 74 69 6e  |ing.code pointin|
000034f0  67 20 74 6f 20 69 74 73  65 6c 66 20 61 6e 64 20  |g to itself and |
00003500  6c 6f 63 6b 69 6e 67 20  74 68 65 20 6d 61 63 68  |locking the mach|
00003510  69 6e 65 20 6f 75 74 2e  0d 0d 54 68 65 20 69 6e  |ine out...The in|
00003520  74 65 72 63 65 70 74 20  69 74 73 65 6c 66 2c 20  |tercept itself, |
00003530  73 74 61 72 74 69 6e 67  20 61 74 20 6c 69 6e 65  |starting at line|
00003540  20 39 31 30 2c 20 69 73  20 62 72 61 63 6b 65 74  | 910, is bracket|
00003550  65 64 0d 77 69 74 68 20  70 75 73 68 65 73 20 61  |ed.with pushes a|
00003560  6e 64 20 70 75 6c 6c 73  20 74 6f 20 74 68 65 20  |nd pulls to the |
00003570  73 74 61 63 6b 2e 20 20  54 68 65 20 73 74 61 74  |stack.  The stat|
00003580  75 73 20 72 65 67 69 73  74 65 72 2c 0d 66 6f 6c  |us register,.fol|
00003590  6c 6f 77 65 64 20 62 79  20 74 68 65 20 58 20 61  |lowed by the X a|
000035a0  6e 64 20 59 20 72 65 67  69 73 74 65 72 73 20 69  |nd Y registers i|
000035b0  73 20 70 75 73 68 65 64  2c 20 74 6f 20 62 65 20  |s pushed, to be |
000035c0  70 75 6c 6c 65 64 20 69  6e 0d 74 68 65 20 72 65  |pulled in.the re|
000035d0  76 65 72 73 65 20 6f 72  64 65 72 20 6c 61 74 65  |verse order late|
000035e0  72 2e 20 20 54 68 65 20  61 63 63 75 6d 75 6c 61  |r.  The accumula|
000035f0  74 6f 72 20 69 73 20 73  74 6f 72 65 64 20 69 6e  |tor is stored in|
00003600  20 61 0d 62 79 74 65 20  6c 61 62 65 6c 6c 65 64  | a.byte labelled|
00003610  20 27 61 63 63 75 73 74  6f 72 65 27 20 66 6f 72  | 'accustore' for|
00003620  20 65 61 73 79 20 61 63  63 65 73 73 2e 0d 0d 4f  | easy access...O|
00003630  6e 63 65 20 74 68 65 20  72 65 67 69 73 74 65 72  |nce the register|
00003640  73 20 61 72 65 20 73 61  76 65 64 20 77 65 20 64  |s are saved we d|
00003650  69 72 65 63 74 20 61 6c  6c 20 6f 75 74 70 75 74  |irect all output|
00003660  20 74 6f 20 74 68 65 0d  70 72 69 6e 74 65 72 20  | to the.printer |
00003670  75 73 69 6e 67 20 4f 53  42 59 54 45 20 33 20 77  |using OSBYTE 3 w|
00003680  69 74 68 20 58 3d 31 30  2e 20 20 4f 6e 20 65 78  |ith X=10.  On ex|
00003690  69 74 20 74 68 65 20 6f  6c 64 20 58 20 76 61 6c  |it the old X val|
000036a0  75 65 0d 69 73 20 69 6e  20 58 20 61 6e 64 20 77  |ue.is in X and w|
000036b0  65 20 70 75 74 20 74 68  61 74 20 6f 6e 20 74 68  |e put that on th|
000036c0  65 20 73 74 61 63 6b 20  66 6f 72 20 75 73 65 20  |e stack for use |
000036d0  6c 61 74 65 72 2e 0d 0d  54 68 65 20 27 76 64 75  |later...The 'vdu|
000036e0  5f 71 75 65 75 65 27 20  73 75 62 72 6f 75 74 69  |_queue' subrouti|
000036f0  6e 65 20 72 65 74 75 72  6e 73 20 77 69 74 68 20  |ne returns with |
00003700  74 68 65 20 73 69 7a 65  20 6f 66 20 74 68 65 0d  |the size of the.|
00003710  71 75 65 75 65 20 69 6e  20 41 20 61 6e 64 20 69  |queue in A and i|
00003720  66 20 74 68 61 74 20 69  73 20 74 68 65 20 66 69  |f that is the fi|
00003730  72 73 74 20 63 68 61 72  61 63 74 65 72 20 69 6e  |rst character in|
00003740  20 61 20 73 65 74 20 6f  66 0d 62 79 74 65 73 20  | a set of.bytes |
00003750  74 68 65 6e 20 77 65 20  68 61 76 65 20 74 6f 20  |then we have to |
00003760  73 74 61 72 74 20 61 20  6e 65 77 20 6c 69 6e 65  |start a new line|
00003770  2c 20 70 72 69 6e 74 20  74 68 65 20 63 68 61 72  |, print the char|
00003780  61 63 74 65 72 0d 69 66  20 69 74 20 69 73 20 70  |acter.if it is p|
00003790  72 69 6e 74 61 62 6c 65  2c 20 70 72 69 6e 74 20  |rintable, print |
000037a0  69 74 73 20 68 65 78 20  76 61 6c 75 65 20 28 69  |its hex value (i|
000037b0  6e 20 62 72 61 63 6b 65  74 73 29 2c 20 61 6e 64  |n brackets), and|
000037c0  0d 75 73 65 20 73 70 61  63 65 73 20 74 6f 20 67  |.use spaces to g|
000037d0  65 74 20 61 20 6e 65 61  74 20 6c 61 79 6f 75 74  |et a neat layout|
000037e0  2e 20 20 41 6c 6c 20 70  72 69 6e 74 69 6e 67 20  |.  All printing |
000037f0  69 6e 20 74 68 69 73 0d  72 6f 75 74 69 6e 65 20  |in this.routine |
00003800  69 73 20 63 61 72 72 69  65 64 20 6f 75 74 20 75  |is carried out u|
00003810  73 69 6e 67 20 61 20 6e  6f 6e 2d 76 65 63 74 6f  |sing a non-vecto|
00003820  72 65 64 20 76 65 72 73  69 6f 6e 20 6f 66 0d 4f  |red version of.O|
00003830  53 57 52 43 48 20 63 61  6c 6c 65 64 20 4e 56 4f  |SWRCH called NVO|
00003840  53 57 52 43 48 20 73 6f  20 74 68 61 74 20 74 68  |SWRCH so that th|
00003850  65 20 69 6e 74 65 72 63  65 70 74 73 20 64 6f 6e  |e intercepts don|
00003860  27 74 20 67 65 74 20 74  69 65 64 0d 75 70 20 69  |'t get tied.up i|
00003870  6e 20 6b 6e 6f 74 73 2e  0d 0d 49 66 20 77 65 20  |n knots...If we |
00003880  61 72 65 20 64 65 61 6c  69 6e 67 20 77 69 74 68  |are dealing with|
00003890  20 61 20 74 61 63 6b 65  64 20 6f 6e 20 62 79 74  | a tacked on byt|
000038a0  65 2c 20 69 2e 65 2e 20  74 68 65 20 56 44 55 20  |e, i.e. the VDU |
000038b0  71 75 65 75 65 0d 72 6f  75 74 69 6e 65 20 72 65  |queue.routine re|
000038c0  74 75 72 6e 73 20 73 6f  6d 65 74 68 69 6e 67 20  |turns something |
000038d0  6f 74 68 65 72 20 74 68  61 6e 20 7a 65 72 6f 2c  |other than zero,|
000038e0  20 77 65 20 63 6f 6e 74  69 6e 75 65 0d 70 72 69  | we continue.pri|
000038f0  6e 74 69 6e 67 20 68 65  78 20 76 61 6c 75 65 73  |nting hex values|
00003900  20 69 6e 20 62 72 61 63  6b 65 74 73 20 61 63 72  | in brackets acr|
00003910  6f 73 73 20 74 68 65 20  70 61 67 65 2e 0d 0d 46  |oss the page...F|
00003920  69 6e 61 6c 6c 79 20 77  65 20 72 65 73 74 6f 72  |inally we restor|
00003930  65 20 74 68 65 20 70 72  69 6e 74 65 72 20 74 6f  |e the printer to|
00003940  20 69 74 73 20 70 72 65  76 69 6f 75 73 20 73 74  | its previous st|
00003950  61 74 65 20 75 73 69 6e  67 0d 4f 53 42 59 54 45  |ate using.OSBYTE|
00003960  20 33 20 61 6e 64 20 74  68 65 20 6f 6c 64 20 76  | 3 and the old v|
00003970  61 6c 75 65 20 6f 66 20  58 20 66 72 6f 6d 20 74  |alue of X from t|
00003980  68 65 20 73 74 61 63 6b  2e 20 20 52 65 67 69 73  |he stack.  Regis|
00003990  74 65 72 73 0d 61 72 65  20 70 75 6c 6c 65 64 20  |ters.are pulled |
000039a0  62 61 63 6b 20 66 72 6f  6d 20 74 68 65 20 73 74  |back from the st|
000039b0  61 63 6b 20 61 6e 64 20  77 65 20 68 65 61 64 20  |ack and we head |
000039c0  6f 66 66 20 62 61 63 6b  20 64 6f 77 6e 20 74 68  |off back down th|
000039d0  65 0d 6f 6c 64 20 77 72  69 74 65 20 63 68 61 72  |e.old write char|
000039e0  61 63 74 65 72 20 76 65  63 74 6f 72 2e 20 20 49  |acter vector.  I|
000039f0  66 20 77 65 20 77 65 72  65 20 74 6f 20 52 54 53  |f we were to RTS|
00003a00  20 68 65 72 65 20 72 61  74 68 65 72 0d 74 68 61  | here rather.tha|
00003a10  6e 20 66 6f 6c 6c 6f 77  20 74 68 65 20 6f 6c 64  |n follow the old|
00003a20  20 76 65 63 74 6f 72 20  6e 6f 74 68 69 6e 67 20  | vector nothing |
00003a30  77 6f 75 6c 64 20 72 65  61 63 68 20 74 68 65 20  |would reach the |
00003a40  73 63 72 65 65 6e 2e 20  0d 54 72 79 20 69 74 20  |screen. .Try it |
00003a50  61 6e 64 20 73 65 65 2e  0d 0d 54 68 65 20 27 70  |and see...The 'p|
00003a60  72 69 6e 74 5f 68 65 78  27 20 73 75 62 72 6f 75  |rint_hex' subrou|
00003a70  74 69 6e 65 20 61 74 20  6c 69 6e 65 20 31 34 36  |tine at line 146|
00003a80  30 20 69 73 20 65 78 61  63 74 6c 79 20 6c 69 6b  |0 is exactly lik|
00003a90  65 20 74 68 65 0d 6f 6e  65 20 69 6e 20 4d 6f 64  |e the.one in Mod|
00003aa0  75 6c 65 20 36 20 65 78  63 65 70 74 20 74 68 61  |ule 6 except tha|
00003ab0  74 20 74 6f 20 70 72 69  6e 74 20 61 20 6e 79 62  |t to print a nyb|
00003ac0  62 6c 65 20 49 20 68 61  76 65 20 75 73 65 64 20  |ble I have used |
00003ad0  61 0d 64 69 66 66 65 72  65 6e 74 20 6d 65 74 68  |a.different meth|
00003ae0  6f 64 2e 20 20 49 74 27  73 20 77 6f 72 74 68 20  |od.  It's worth |
00003af0  63 6f 6d 70 61 72 69 6e  67 20 74 68 65 20 74 77  |comparing the tw|
00003b00  6f 20 70 61 72 74 69 63  75 6c 61 72 6c 79 0d 69  |o particularly.i|
00003b10  66 20 79 6f 75 20 66 65  65 6c 20 74 68 65 72 65  |f you feel there|
00003b20  20 69 73 20 61 6e 79 20  72 69 73 6b 20 61 73 73  | is any risk ass|
00003b30  6f 63 69 61 74 65 64 20  77 69 74 68 20 75 73 69  |ociated with usi|
00003b40  6e 67 20 74 68 65 0d 64  65 63 69 6d 61 6c 20 6d  |ng the.decimal m|
00003b50  6f 64 65 20 6f 6e 20 74  68 65 20 36 35 30 32 2e  |ode on the 6502.|
00003b60  20 20 49 27 6c 6c 20 63  6f 6d 65 20 62 61 63 6b  |  I'll come back|
00003b70  20 74 6f 20 74 68 69 73  20 75 6e 64 65 72 0d 69  | to this under.i|
00003b80  6e 74 65 72 72 75 70 74  73 21 20 20 54 68 65 72  |nterrupts!  Ther|
00003b90  65 20 61 72 65 20 74 77  6f 20 27 74 72 69 63 6b  |e are two 'trick|
00003ba0  73 27 20 77 6f 72 74 68  20 72 65 6d 65 6d 62 65  |s' worth remembe|
00003bb0  72 69 6e 67 20 68 65 72  65 2e 20 0d 46 69 72 73  |ring here. .Firs|
00003bc0  74 6c 79 20 61 73 20 77  65 20 68 61 76 65 20 61  |tly as we have a|
00003bd0  6c 72 65 61 64 79 20 6d  61 73 6b 65 64 20 6f 66  |lready masked of|
00003be0  66 20 74 68 65 20 74 6f  70 20 6e 79 62 62 6c 65  |f the top nybble|
00003bf0  20 6f 66 20 74 68 65 0d  62 79 74 65 20 77 69 74  | of the.byte wit|
00003c00  68 20 41 4e 44 20 26 30  46 20 77 65 20 63 61 6e  |h AND &0F we can|
00003c10  6e 6f 74 20 68 61 76 65  20 61 6e 79 74 68 69 6e  |not have anythin|
00003c20  67 20 69 6e 20 74 68 65  20 74 6f 70 20 6e 79 62  |g in the top nyb|
00003c30  62 6c 65 2e 20 0d 53 6f  20 69 66 20 77 65 20 77  |ble. .So if we w|
00003c40  61 6e 74 20 74 6f 20 61  64 64 20 34 38 20 28 26  |ant to add 48 (&|
00003c50  33 30 29 20 77 65 20 63  61 6e 20 64 6f 20 74 68  |30) we can do th|
00003c60  69 73 20 62 79 20 4f 52  69 6e 67 20 77 69 74 68  |is by ORing with|
00003c70  0d 26 33 30 20 73 69 6e  63 65 20 74 68 69 73 20  |.&30 since this |
00003c80  64 6f 65 73 20 6e 6f 74  20 61 66 66 65 63 74 20  |does not affect |
00003c90  74 68 65 20 6c 6f 77 65  72 20 6e 79 62 62 6c 65  |the lower nybble|
00003ca0  2e 20 20 54 68 65 20 72  65 61 73 6f 6e 0d 66 6f  |.  The reason.fo|
00003cb0  72 20 64 6f 69 6e 67 20  74 68 69 73 20 69 73 20  |r doing this is |
00003cc0  74 68 61 74 20 69 74 20  72 65 70 6c 61 63 65 73  |that it replaces|
00003cd0  20 61 20 43 4c 43 20 61  6e 64 20 61 6e 20 41 44  | a CLC and an AD|
00003ce0  43 20 77 69 74 68 20 6f  6e 65 0d 4f 52 41 20 77  |C with one.ORA w|
00003cf0  68 69 63 68 20 69 73 20  73 6d 61 6c 6c 65 72 2c  |hich is smaller,|
00003d00  20 66 61 73 74 65 72 20  61 6e 64 20 6e 65 61 74  | faster and neat|
00003d10  65 72 2e 20 20 54 68 65  20 73 65 63 6f 6e 64 20  |er.  The second |
00003d20  74 72 69 63 6b 0d 69 73  20 74 68 61 74 20 66 6f  |trick.is that fo|
00003d30  6c 6c 6f 77 69 6e 67 20  61 20 42 43 43 20 77 68  |llowing a BCC wh|
00003d40  65 72 65 20 79 6f 75 20  64 6f 6e 27 74 20 62 72  |ere you don't br|
00003d50  61 6e 63 68 20 74 68 65  20 63 61 72 72 79 0d 66  |anch the carry.f|
00003d60  6c 61 67 20 68 61 73 20  74 6f 20 62 65 20 73 65  |lag has to be se|
00003d70  74 20 73 6f 20 69 66 20  77 65 20 41 44 43 20 77  |t so if we ADC w|
00003d80  65 20 61 72 65 20 61 64  64 69 6e 67 20 61 6e 20  |e are adding an |
00003d90  65 78 74 72 61 20 6f 6e  65 2e 20 0d 41 67 61 69  |extra one. .Agai|
00003da0  6e 20 74 68 69 73 20 73  61 76 65 73 20 61 20 43  |n this saves a C|
00003db0  4c 43 20 61 6e 64 20 73  6f 20 73 61 76 65 73 20  |LC and so saves |
00003dc0  73 70 61 63 65 20 61 6e  64 20 74 69 6d 65 2e 20  |space and time. |
00003dd0  20 28 4d 79 0d 74 68 61  6e 6b 73 20 74 6f 20 50  | (My.thanks to P|
00003de0  65 74 65 72 20 56 69 6e  63 65 20 66 6f 72 20 72  |eter Vince for r|
00003df0  65 6d 69 6e 64 69 6e 67  20 6d 65 20 6f 66 20 74  |eminding me of t|
00003e00  68 61 74 20 6f 6e 65 2e  29 0d 0d 54 68 65 20 27  |hat one.)..The '|
00003e10  76 64 75 5f 71 75 65 75  65 27 20 73 75 62 72 6f  |vdu_queue' subro|
00003e20  75 74 69 6e 65 20 75 73  65 73 20 4f 53 42 59 54  |utine uses OSBYT|
00003e30  45 20 32 31 38 20 61 73  20 65 78 70 6c 61 69 6e  |E 218 as explain|
00003e40  65 64 0d 65 61 72 6c 69  65 72 2e 20 20 49 74 20  |ed.earlier.  It |
00003e50  69 73 20 73 69 6d 70 6c  65 72 20 74 6f 20 74 61  |is simpler to ta|
00003e60  6b 65 20 61 20 32 27 73  20 63 6f 6d 70 6c 65 6d  |ke a 2's complem|
00003e70  65 6e 74 20 62 79 20 45  4f 52 69 6e 67 0d 77 69  |ent by EORing.wi|
00003e80  74 68 20 26 46 46 20 61  6e 64 20 61 64 64 69 6e  |th &FF and addin|
00003e90  67 20 31 20 74 68 61 6e  20 62 79 20 73 75 62 74  |g 1 than by subt|
00003ea0  72 61 63 74 69 6e 67 20  66 72 6f 6d 20 7a 65 72  |racting from zer|
00003eb0  6f 20 62 65 63 61 75 73  65 0d 79 6f 75 20 64 6f  |o because.you do|
00003ec0  6e 27 74 20 68 61 76 65  20 74 6f 20 66 69 6e 64  |n't have to find|
00003ed0  20 73 6f 6d 65 77 68 65  72 65 20 74 6f 20 73 74  | somewhere to st|
00003ee0  6f 72 65 20 74 68 65 20  6e 75 6d 62 65 72 20 77  |ore the number w|
00003ef0  68 69 6c 65 0d 79 6f 75  20 4c 44 41 20 23 30 2e  |hile.you LDA #0.|
00003f00  0d 0d 57 68 65 6e 20 79  6f 75 20 68 61 76 65 20  |..When you have |
00003f10  52 55 4e 20 74 68 65 20  70 72 6f 67 72 61 6d 20  |RUN the program |
00003f20  74 68 65 72 65 20 77 69  6c 6c 20 62 65 20 61 20  |there will be a |
00003f30  6c 69 74 74 6c 65 20 6c  69 6e 65 0d 79 6f 75 20  |little line.you |
00003f40  63 61 6e 20 63 6f 70 79  20 61 63 72 6f 73 73 20  |can copy across |
00003f50  69 6e 20 6f 72 64 65 72  20 74 6f 20 2a 53 41 56  |in order to *SAV|
00003f60  45 20 74 68 65 20 6d 61  63 68 69 6e 65 20 63 6f  |E the machine co|
00003f70  64 65 2e 20 0d 54 68 69  73 20 70 72 6f 67 72 61  |de. .This progra|
00003f80  6d 20 77 69 6c 6c 20 6f  6e 6c 79 20 72 75 6e 20  |m will only run |
00003f90  69 6e 20 74 68 65 20 49  2f 4f 20 70 72 6f 63 65  |in the I/O proce|
00003fa0  73 73 6f 72 2c 20 73 6f  20 73 77 69 74 63 68 0d  |ssor, so switch.|
00003fb0  6f 66 66 20 79 6f 75 72  20 73 65 63 6f 6e 64 20  |off your second |
00003fc0  70 72 6f 63 65 73 73 6f  72 20 69 66 20 79 6f 75  |processor if you|
00003fd0  20 68 61 76 65 20 6f 6e  65 2e 20 20 54 68 65 20  | have one.  The |
00003fe0  66 69 6e 61 6c 0d 6d 61  63 68 69 6e 65 20 63 6f  |final.machine co|
00003ff0  64 65 20 77 69 6c 6c 20  72 75 6e 20 66 72 6f 6d  |de will run from|
00004000  20 64 69 73 63 20 62 79  20 6a 75 73 74 20 74 79  | disc by just ty|
00004010  70 69 6e 67 20 2a 77 63  69 6e 74 20 61 6e 64 0d  |ping *wcint and.|
00004020  74 68 69 73 20 77 69 6c  6c 20 61 75 74 6f 6d 61  |this will automa|
00004030  74 69 63 61 6c 6c 79 20  6c 6f 61 64 20 69 6e 74  |tically load int|
00004040  6f 20 74 68 65 20 49 2f  4f 20 70 72 6f 63 65 73  |o the I/O proces|
00004050  73 6f 72 20 62 65 63 61  75 73 65 0d 49 20 68 61  |sor because.I ha|
00004060  76 65 20 73 65 74 20 74  68 65 20 74 6f 70 20 31  |ve set the top 1|
00004070  36 20 62 69 74 73 20 6f  66 20 74 68 65 20 33 32  |6 bits of the 32|
00004080  20 62 69 74 20 61 64 64  72 65 73 73 65 73 20 69  | bit addresses i|
00004090  6e 20 6c 69 6e 65 0d 32  30 33 30 2e 20 20 5b 49  |n line.2030.  [I|
000040a0  20 61 64 6f 70 74 20 61  20 70 65 72 73 6f 6e 61  | adopt a persona|
000040b0  6c 20 70 6f 6c 69 63 79  20 6f 66 20 75 73 69 6e  |l policy of usin|
000040c0  67 20 6c 6f 77 65 72 20  63 61 73 65 0d 6c 65 74  |g lower case.let|
000040d0  74 65 72 73 20 66 6f 72  20 61 6e 79 20 6d 61 63  |ters for any mac|
000040e0  68 69 6e 65 20 63 6f 64  65 20 70 72 6f 67 72 61  |hine code progra|
000040f0  6d 20 6e 61 6d 65 2e 5d  0d 0d 54 6f 20 74 72 79  |m name.]..To try|
00004100  20 69 74 20 6f 75 74 20  74 79 70 65 20 69 6e 20  | it out type in |
00004110  2a 77 63 69 6e 74 20 61  6e 64 20 74 68 65 6e 20  |*wcint and then |
00004120  6d 61 6b 65 20 73 75 72  65 20 79 6f 75 72 20 70  |make sure your p|
00004130  72 69 6e 74 65 72 0d 69  73 20 6f 6e 20 61 6e 64  |rinter.is on and|
00004140  20 72 65 61 64 79 2e 20  20 54 79 70 65 20 2a 43  | ready.  Type *C|
00004150  4f 44 45 20 31 20 61 6e  64 20 65 76 65 72 79 74  |ODE 1 and everyt|
00004160  68 69 6e 67 20 79 6f 75  20 74 68 65 6e 20 65 6e  |hing you then en|
00004170  74 65 72 0d 77 69 6c 6c  20 62 65 20 69 6e 74 65  |ter.will be inte|
00004180  72 63 65 70 74 65 64 2e  20 20 54 79 70 65 20 2a  |rcepted.  Type *|
00004190  43 4f 44 45 20 74 6f 20  73 74 6f 70 20 69 74 20  |CODE to stop it |
000041a0  28 2a 43 4f 44 45 20 69  73 0d 65 71 75 69 76 61  |(*CODE is.equiva|
000041b0  6c 65 6e 74 20 74 6f 20  2a 43 4f 44 45 20 30 29  |lent to *CODE 0)|
000041c0  2e 0d 0d 49 66 20 79 6f  75 20 65 6e 74 65 72 3a  |...If you enter:|
000041d0  20 20 20 20 20 20 20 20  2a 43 4f 44 45 20 31 0d  |        *CODE 1.|
000041e0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000041f0  20 20 20 20 20 4d 4f 44  45 20 34 0d 20 20 20 20  |     MODE 4.    |
00004200  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00004210  20 4d 4f 56 45 20 26 33  32 31 2c 26 31 32 33 0d  | MOVE &321,&123.|
00004220  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00004230  20 20 20 20 20 43 4c 53  0d 20 20 20 20 20 20 20  |     CLS.       |
00004240  20 20 20 20 20 20 20 20  20 20 20 20 20 20 2a 43  |              *C|
00004250  4f 44 45 0d 0d 79 6f 75  20 73 68 6f 75 6c 64 20  |ODE..you should |
00004260  67 65 74 20 74 68 65 20  66 6f 6c 6c 6f 77 69 6e  |get the followin|
00004270  67 20 6f 75 74 70 75 74  2e 0d 0d 20 20 20 20 3e  |g output...    >|
00004280  20 5b 26 33 45 5d 0d 20  20 20 20 4d 20 5b 26 34  | [&3E].    M [&4|
00004290  44 5d 0d 20 20 20 20 4f  20 5b 26 34 46 5d 0d 20  |D].    O [&4F]. |
000042a0  20 20 20 44 20 5b 26 34  34 5d 0d 20 20 20 20 45  |   D [&44].    E|
000042b0  20 5b 26 34 35 5d 0d 20  20 20 20 20 20 5b 26 32  | [&45].      [&2|
000042c0  30 5d 0d 20 20 20 20 34  20 5b 26 33 34 5d 0d 20  |0].    4 [&34]. |
000042d0  20 20 20 20 20 5b 26 30  41 5d 0d 20 20 20 20 20  |     [&0A].     |
000042e0  20 5b 26 30 44 5d 0d 20  20 20 20 20 20 5b 26 31  | [&0D].      [&1|
000042f0  36 5d 20 5b 26 30 34 5d  0d 20 20 20 20 3e 20 5b  |6] [&04].    > [|
00004300  26 33 45 5d 0d 20 20 20  20 4d 20 5b 26 34 44 5d  |&3E].    M [&4D]|
00004310  0d 20 20 20 20 4f 20 5b  26 34 46 5d 0d 20 20 20  |.    O [&4F].   |
00004320  20 56 20 5b 26 35 36 5d  0d 20 20 20 20 45 20 5b  | V [&56].    E [|
00004330  26 34 35 5d 0d 20 20 20  20 20 20 5b 26 32 30 5d  |&45].      [&20]|
00004340  0d 20 20 20 20 26 20 5b  26 32 36 5d 0d 20 20 20  |.    & [&26].   |
00004350  20 33 20 5b 26 33 33 5d  0d 20 20 20 20 32 20 5b  | 3 [&33].    2 [|
00004360  26 33 32 5d 0d 20 20 20  20 31 20 5b 26 33 31 5d  |&32].    1 [&31]|
00004370  0d 20 20 20 20 2c 20 5b  26 32 43 5d 0d 20 20 20  |.    , [&2C].   |
00004380  20 26 20 5b 26 32 36 5d  0d 20 20 20 20 31 20 5b  | & [&26].    1 [|
00004390  26 33 31 5d 0d 20 20 20  20 32 20 5b 26 33 32 5d  |&31].    2 [&32]|
000043a0  0d 20 20 20 20 33 20 5b  26 33 33 5d 0d 20 20 20  |.    3 [&33].   |
000043b0  20 20 20 5b 26 30 41 5d  0d 20 20 20 20 20 20 5b  |   [&0A].      [|
000043c0  26 30 44 5d 0d 20 20 20  20 20 20 5b 26 31 39 5d  |&0D].      [&19]|
000043d0  20 5b 26 30 34 5d 20 5b  26 32 31 5d 20 5b 26 30  | [&04] [&21] [&0|
000043e0  33 5d 20 5b 26 32 33 5d  20 5b 26 30 31 5d 0d 20  |3] [&23] [&01]. |
000043f0  20 20 20 3e 20 5b 26 33  45 5d 0d 20 20 20 20 43  |   > [&3E].    C|
00004400  20 5b 26 34 33 5d 0d 20  20 20 20 4c 20 5b 26 34  | [&43].    L [&4|
00004410  43 5d 0d 20 20 20 20 53  20 5b 26 35 33 5d 0d 20  |C].    S [&53]. |
00004420  20 20 20 20 20 5b 26 30  41 5d 0d 20 20 20 20 20  |     [&0A].     |
00004430  20 5b 26 30 44 5d 0d 20  20 20 20 20 20 5b 26 30  | [&0D].      [&0|
00004440  43 5d 0d 20 20 20 20 3e  20 5b 26 33 45 5d 0d 20  |C].    > [&3E]. |
00004450  20 20 20 2a 20 5b 26 32  41 5d 0d 20 20 20 20 43  |   * [&2A].    C|
00004460  20 5b 26 34 33 5d 0d 20  20 20 20 4f 20 5b 26 34  | [&43].    O [&4|
00004470  46 5d 0d 20 20 20 20 44  20 5b 26 34 34 5d 0d 20  |F].    D [&44]. |
00004480  20 20 20 45 20 5b 26 34  35 5d 0d 20 20 20 20 20  |   E [&45].     |
00004490  20 5b 26 30 41 5d 0d 20  20 20 20 20 20 5b 26 30  | [&0A].      [&0|
000044a0  44 5d 0d 0d 54 68 69 73  20 69 73 20 73 68 6f 77  |D]..This is show|
000044b0  69 6e 67 20 68 6f 77 20  42 41 53 49 43 20 63 6f  |ing how BASIC co|
000044c0  6d 6d 61 6e 64 73 20 61  72 65 20 74 72 61 6e 73  |mmands are trans|
000044d0  6c 61 74 65 64 20 69 6e  74 6f 20 62 79 74 65 73  |lated into bytes|
000044e0  0d 74 6f 20 62 65 20 73  65 6e 74 20 74 6f 20 74  |.to be sent to t|
000044f0  68 65 20 56 44 55 20 64  72 69 76 65 72 73 2e 20  |he VDU drivers. |
00004500  20 49 66 20 79 6f 75 20  65 6e 61 62 6c 65 20 74  | If you enable t|
00004510  68 65 20 69 6e 74 65 72  63 65 70 74 0d 77 68 69  |he intercept.whi|
00004520  6c 65 20 72 75 6e 6e 69  6e 67 20 61 20 70 72 6f  |le running a pro|
00004530  67 72 61 6d 20 79 6f 75  20 77 69 6c 6c 20 67 65  |gram you will ge|
00004540  74 20 61 20 73 69 6d 69  6c 61 72 2c 20 69 66 20  |t a similar, if |
00004550  6d 75 63 68 20 6d 6f 72  65 0d 73 75 63 63 69 6e  |much more.succin|
00004560  63 74 2c 20 72 65 73 75  6c 74 2e 20 20 54 68 65  |ct, result.  The|
00004570  20 6f 75 74 70 75 74 20  63 61 6e 20 62 65 20 53  | output can be S|
00004580  50 4f 4f 4c 45 44 20 74  6f 20 64 69 73 63 0d 61  |POOLED to disc.a|
00004590  6c 74 68 6f 75 67 68 20  79 6f 75 20 77 69 6c 6c  |lthough you will|
000045a0  20 67 65 74 20 65 78 74  72 61 20 63 68 61 72 61  | get extra chara|
000045b0  63 74 65 72 73 20 77 69  74 68 20 65 61 63 68 20  |cters with each |
000045c0  62 79 74 65 20 77 68 65  72 65 0d 69 74 20 69 73  |byte where.it is|
000045d0  20 70 72 69 6e 74 61 62  6c 65 2e 0d 0d 54 68 69  | printable...Thi|
000045e0  73 20 69 6e 74 65 72 63  65 70 74 20 6d 65 74 68  |s intercept meth|
000045f0  6f 64 20 63 61 6e 20 62  65 20 61 70 70 6c 69 65  |od can be applie|
00004600  64 20 74 6f 20 61 6e 79  20 76 65 63 74 6f 72 20  |d to any vector |
00004610  61 6c 74 68 6f 75 67 68  0d 6f 6e 6c 79 20 74 68  |although.only th|
00004620  65 20 52 44 43 48 20 61  6e 64 20 57 52 43 48 20  |e RDCH and WRCH |
00004630  63 61 72 72 79 20 61 6e  79 20 73 69 67 6e 69 66  |carry any signif|
00004640  69 63 61 6e 74 20 69 6e  66 6f 72 6d 61 74 69 6f  |icant informatio|
00004650  6e 20 69 6e 0d 74 68 65  20 61 63 63 75 6d 75 6c  |n in.the accumul|
00004660  61 74 6f 72 2e 20 20 54  68 65 20 43 4c 49 20 76  |ator.  The CLI v|
00004670  65 63 74 6f 72 20 70 61  73 73 65 73 20 75 73 65  |ector passes use|
00004680  66 75 6c 20 69 6e 66 6f  72 6d 61 74 69 6f 6e 0d  |ful information.|
00004690  69 6e 20 58 20 61 6e 64  20 59 20 70 6f 69 6e 74  |in X and Y point|
000046a0  69 6e 67 20 74 6f 20 73  74 72 69 6e 67 73 2e 20  |ing to strings. |
000046b0  20 59 6f 75 20 63 6f 75  6c 64 20 6d 6f 64 69 66  | You could modif|
000046c0  79 20 74 68 69 73 0d 72  6f 75 74 69 6e 65 20 74  |y this.routine t|
000046d0  6f 20 77 6f 72 6b 20 77  69 74 68 20 6f 74 68 65  |o work with othe|
000046e0  72 20 76 65 63 74 6f 72  73 2c 20 62 75 74 20 64  |r vectors, but d|
000046f0  6f 6e 27 74 20 62 6f 74  68 65 72 20 77 69 74 68  |on't bother with|
00004700  0d 74 68 65 20 45 56 45  4e 54 2c 20 42 52 45 41  |.the EVENT, BREA|
00004710  4b 20 6f 72 20 49 52 51  20 76 65 63 74 6f 72 73  |K or IRQ vectors|
00004720  20 61 73 20 79 6f 75 20  77 69 6c 6c 20 73 69 6d  | as you will sim|
00004730  70 6c 79 20 63 72 61 73  68 20 74 68 65 0d 6d 61  |ply crash the.ma|
00004740  63 68 69 6e 65 20 74 68  65 72 65 2e 20 20 54 68  |chine there.  Th|
00004750  6f 73 65 20 76 65 63 74  6f 72 73 20 61 72 65 20  |ose vectors are |
00004760  74 6f 6f 20 73 65 6e 73  69 74 69 76 65 2e 0d 0d  |too sensitive...|
00004770  4e 65 78 74 20 74 69 6d  65 20 2e 2e 2e 2e 2e 20  |Next time ..... |
00004780  45 56 45 4e 54 53 2e 20  20 55 6e 74 69 6c 20 74  |EVENTS.  Until t|
00004790  68 65 6e 2c 20 68 61 70  70 79 20 69 6e 74 65 72  |hen, happy inter|
000047a0  63 65 70 74 69 6e 67 2e  0d                       |cepting..|
000047a9
04-03-88/T\OSB16.m0
04-03-88/T\OSB16.m1
04-03-88/T\OSB16.m2
04-03-88/T\OSB16.m4
04-03-88/T\OSB16.m5