Home » CEEFAX disks » telesoftware2.adl » 11_10_87/T\INDEX

11_10_87/T\INDEX

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 » telesoftware2.adl
Filename: 11_10_87/T\INDEX
Read OK:
File size: 78AC bytes
Load address: 0000
Exec address: 0000
File contents
      OSBITS - An Exploration of the BBC Micro at Machine Level

      by Programmer

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



                            I N D E X
                            =========


      Part 0:  The History Of Computing
      Part 1:  The BBC Assembler
      Part 2:  Counting Two By Two
      Part 3:  The Registers and Flags
      Part 4:  Memory
      Part 5:  Operating System Calls (I) - OSBYTE and OSWORD
      Part 6:  Rotating and Shifting
      Part 7:  Operating System Calls (II) - I/0
      Part 8:  Logical Operators
      Part 9:  Operating System Calls (III)
      Part 10: Opcodes and Error Messages
      Part 11: Inputting Numbers
      Part 12: ASCII to Binary Conversion
      Part 13: Multi-Byte Multiplication
      Part 14: Binary to ASCII Conversion
      Part 15: Multi-byte Division
      Part 16: Vectors
      Part 17: Events
      Part 18: Interrupts I   -  Mouse driver
      Part 19: Interrupts II  -  Palette Switching using Timers
      Part 20: Real Numbers  -  Fixed Point Arithmetic
      Part 21: Real Numbers  -  Fixed Point Mandelbrot Set
      Part 22: Floating Point Arithmetic
      Part 23: Floating Point Arithmetic II
      Part 24: Sideways ROMs
      Part 25: Legal and Illegal Code
      Part 26: Editing Your Source Code





      OSBITS is a series of 26 modules providing an introduction
to machine code programming on the BBC micro.

      The course refers to the BBC micro's 6502 assembler, but the
principles involved apply to a wide range of computers.

      To help identification, text files are named T/OSB... and
associated programs are B/OSB...

THE HISTORY OF COMPUTING

      A preface to an exploration of the BBC Micro at Machine
      level.   A bit of light relief to start with - a text only
      module with some historical background to computers and
      computing.

      This file briefly tells the story of the development of
      computers.  It shows that, although the home micro has only
      been around for the last five years or so, the story of
      computing goes back centuries.


Part 1: The BBC Assembler.

      BBC Basic includes an assembler for the 6502 microprocessor
      which the BBC Micro contains.  This assembler takes your
      assembly language program and converts it into machine code. 
      This code is the 'natural' language of the micro, and by
      using it you will get a faster and smaller program and will
      also be able to do things that are impossible from BASIC.

      The text file describes the operation of the BBC assembler,
      and shows you how to set it up in your programs.  The
      assembler is part of BBC BASIC, and this module also shows
      you how to enlist some help from BASIC with your machine
      code programming.

      The program B/osb01 is a simple example of an assembly
      language program which prints a message on the screen, a
      sort of confidence test.


Part 2: Counting Two By Two

      The BBC Micro handles its numbers in groups of eight binary
      digits called bits, which together are called a byte.  Each
      of the bits is either set to 1, or cleared to 0.  With a
      byte you can represent any number between 0 and 255.  All
      the calculating within the computer is done by manipulating
      these bytes, either singly or in groups.  By grouping bytes
      into 'words' you can work with larger numbers.

      The text file discusses binary numbers, and describes how to
      add and subtract them.  This raises the important concept of
      'carrying' a bit on from an addition, or 'borrowing' during
      subtraction, just as in decimal arithmetic.

      The program in this module makes use of carry to add and
      subtract two 4-byte numbers, and to compare the answer from
      the machine code with the answer from BASIC.


Part 3: The Registers and Flags

      Most of the instructions carried out by the microprocessor
      set or clear its flags.  The carry flag we used in addition
      and subtraction is such a flag.  The text file looks at the
      registers and flags of the micro, and shows how to load and
      save a byte.  The effect of an operation on the flags leads
      to decision making with jumps and branches and calls to
      subroutines.

      In the program B/osb03 is a routine that detects whether a
      key pressed is an upper or lower case letter, a number,
      punctuation, or a control code, and prints out a message
      accordingly.


Part 4: Memory

      Unlike BASIC, it is up to you where you put your machine
      code.  This means you have to know a bit about how the BBC
      Micro uses its memory.  Initially you can enlist the help of
      the BASIC DIMension statement, but eventually you will be on
      your own.

      This week's text file shows how the memory of the micro is
      laid out and used.  With this background you should find it
      easy to position your machine code programs where they will
      be most useful and trouble free.  Often it is also necessary
      to position variables and the like in memory within a
      program. This is more difficult in BASIC 1 than in later
      BASICs, and the routines demonstrated in B/osb04 are
      explained.

      The program B/osb04 consists of a set of BASIC functions
      which can be used in BASIC 1 to position variables in a
      machine code program, hence mimicking the action of EQU in
      later BASICs.  Also included are a couple of extra
      pseudo-operatives EQUM and EQUF, which respectively fill a
      block of memory with a specified byte, and convert a number
      to BASIC's floating point format, storing it in memory.


Part 5: Operating System Calls (I) - OSBYTE and OSWORD

      Operating System routines, which you call as subroutines,
      make light work of tasks that could otherwise be very
      difficult.  They also help preserve the compatibility of
      software with different versions of the Operating System. 
      The text file with this module shows how to set up OSBYTE
      and OSWORD routines and gives examples of what they can do.

      B/osb05 is a small program which uses an OSBYTE call, number
      121, that scans the keyboard and returns a number
      corresponding to the key pressed down at the time.  This is
      then used as a parameter in an OSWORD call which plays a note
      on the sound chip, the pitch depending on which key is
      pressed.


Part 6: Rotating and Shifting

      There are instructions in the 6502 set to enable you to move
      all the bits of a byte up or down one, effectively
      multiplying or dividing the byte by 2.  The bit that would
      'fall off the end' goes into the Carry flag.  One pair of
      such commands put zero in the vacated bit, while the other
      pair put the old Carry value in.

      This module gives details of the four bit-shifting
      instructions, and also discusses temporary storage of
      variables during a program using both memory and the stack. 
      It shows a further method of easily making space for a
      variable into memory.

      The program B/osb06 takes a byte that you type in by
      pressing a key, and using the bit shifting instructions,
      prints its value out in three ways - binary, hexadecimal and
      decimal.


Part 7: Operating System Calls (II) - I/0

      This second look at Operating System routines deals with
      those relating to input and output.   It's one of the
      beauties of the BBC Micro's OS that the routines for input
      and output (I/O) are independent of the source or
      destination of that I/O.  The selection of source and
      destination (known as the input and output stream) are the
      province of some of the OSBYTE calls.

      B/osb07 sets up the routine which will print out a string
      proportionally spaced.  To use it you must be in Mode 1 or
      Mode 4, and define a string variable to be your required
      string.  The graphics cursor must be positioned where you
      want the printing to start by using MOVE.


Part 8: Logical Operators

      We're back to comparisons in this module.  Already you have
      come across branching operations carried out conditionally
      on the setting of certain flags in the processor status
      register; mnemonics like BNE, BEQ, and BMI.  Logical
      operators enable us to compare the bits of one byte with the
      bits of another, and essentially there are three types of
      comparison.  This module explains the logical operators AND,
      ORA, and EOR, and also BIT which is similar to AND.  These
      instructions can be used to affect individual bits of a 
      byte.

      It's a simple little piece of code in this module.  The
      ASCII codes are arranged such that the code for a letter,
      when ANDed with &DF, will always produce the code for upper
      case, and B/osb08 does simply that.  However, being simple
      it does not produce a satisfactory result for all the other
      keys on the keyboard.  This approach is one of the ways to
      legislate against people who turn off (or on) the CAPS LOCK
      on their micro when you expect it the other way around.


Part 9: Operating System Calls (III)

      There are many more OS routines besides those mentioned in
      earlier modules.  Some of them, like OSFILE are used to
      operate the filing systems.  One, OSCLI, gives access to the
      "Command-Line Interpreter" of the micro.  There is also a
      group of routines which Acorn have left undocumented, but
      any use of these must be cautious.

      This module lists the final set of these operating system
      routines, together with their call and vector addresses.
      (Vectors will be described in a later module.)  Detailed
      explanation of the filing system ones is left to other
      advanced guides, but we explain what each routine does.

      The program in this module, B/osb09, uses OSRDRM, one of the
      undocumented routines, to print a list of the headers from
      the sideways ROMs in your machine.  It is the first self-
      contained routine in OSBITS so far, and will be useful to
      anyone without a 1770 DFS (which has one built in).


Part 10: Opcodes and Error Messages

      Most of the instructions available in a 6502 microprocessor
      have now been covered.  These instructions are known as
      opcodes, and the text file in this module lists them for
      reference.  It goes on to explain how to use the default
      error reporting routine which is common to many languages,
      including BASIC.  This routine makes error trapping simple. 
      After a BRK instruction is detected in your machine code,
      the micro will automatically enter the routine.  The BRK is
      followed by a byte which holds the error number, and then a
      string which will be printed as the error message.

      The assembler routine is a small one which illustrates error
      handling, something we will need in future modules.  You
      press a key, and if you have pressed a number (0-9), the
      routine loops, but if it was anything else, an error is
      generated and a message is printed out.  I have included a
      special bit of code that deals with an Escape in a different
      way to the standard Escape by printing a different message.


Part 11: Inputting Numbers

      The next five modules will cover two areas.  They are
      converting ASCII characters, representing numbers, into
      numbers in memory (input), and vice versa (output), and the
      arithmetical processes of multiplication and division. 
      Since inputting and multiplication are connected they will
      come first.

      Input to a micro is often in the form of strings or
      numbers from the keyboard.  Any numbers that are typed in
      will be in the form of strings, and must be converted into
      binary numbers in memory.  Input in complicated by the need
      to allow for any errors which could occur because of
      mistakes, or malice, when someone is entering the data.

      The text file explains how the program operates and explains
      why we wrote a new routine rather than using an available
      operating system call.  The program itself, B/osb10, inputs
      characters using OSRDCH, looking for a Carriage Return which
      terminates input, a Delete which removes the last character,
      and checking anything else against a list of valid
      characters (the numbers 0 to 9).  These are added to a
      string (of defined maximum length) and output to the screen.


Part 12: ASCII to Binary Conversion

      We get so used to entering numbers into a computer that we
      can forget that they are not in the right format.  The keys
      we press put the ASCII value of the particular digit we type
      into the micro rather than the number itself.  Some sort of
      conversion program is needed to take a string of ASCII
      characters that represent a number, and convert them into a
      binary number in memory on which the program can work.

      The program B/osb12 in this module uses a slightly modified
      version of the input subroutine from module 11 to enter a
      string representing a signed decimal number.  This is then
      converted into a four-byte binary integer which is stored,
      and then printed in decimal and hex.  An important part of
      the program is the subroutine for multiplying the running
      total by 10.  This, and multiplication in general, is
      explained in the text file.  In the next module we will
      expand on this with a full multiplication routine.


Part 13: Multi-Byte Multiplication

      It is worth taking a detailed look at multiplication where
      the numbers being multiplied are both several bytes long.  I
      have called this multi-byte arithmetic, although it is often
      known as multi-precision arithmetic.

      The simplest algorithm with which to multiply two numbers is
      based on long multiplication, but you only need your 'one
      times table' for binary.  Rotate the multiplicand left as
      you rotate the multiplier right.  If the carried bit of the
      multiplier is set, add the rotated multiplicand to a current
      running total.  This will finally be the result.  The text
      explains the algorithm in detail.  We are in fact left with
      a problem in that two four byte numbers multiplied together
      can give an eight byte result!

      The program B/osb13 demonstrates the multiplication of two
      four-byte numbers.  Rather than the input routine we have been
      developing in previous modules, BASIC has been used this
      time for clarity.  A slightly modified version of the
      'rotate and conditionally add' algorithm is used to multiply
      together the two four byte numbers, and the result printed.
      The program also uses BASIC to check for a correct result
      which allows you to explore the limits of this program's
      validity.


Part 14: Binary to ASCII Conversion

      This module brings us around to division, and I'll introduce
      it by way of a routine to take a 4 byte number in memory and
      print out it's value as a decimal number in ASCII.

      Unlike input, we have no error conditions to worry about
      since there are only four bytes (the routine can be expanded
      as required), and the number can be either positive or 2's
      complement negative.  For a negative number a sign flag is
      set, and the number subtracted from zero before printing.

      To convert a number in memory into a string, you have to
      find out how many units, 10s, 100s etc. there are.  First
      divide by 10, the remainder is the number of units.  Then
      divide the quotient by 10, the remainder is the number of
      10s ... and so on.  Adding 48 to a number between 0 and 9
      gives its ASCII equivalent.

      The use of division in a conversion program of this type
      provides an introduction to binary division.  This will be
      followed up in the next module by a general routine for
      division.


Part 15: Multi-byte Division

      This module contains a simple multi-byte division routine
      which works almost exactly like the long division example
      given last time.  The only difference is that this time
      the divisor can be 32 bits long.

      Machine code division is similar to decimal long division. 
      The dividend is rotated out left until a number larger than
      the divisor has been formed.  The divisor is then subtracted
      from this.  More bits are rotated in and the process is
      repeated.  For a rotation with a subtraction, a 1 is
      appended to the result, otherwise a 0 is added.  Generally,
      negative numbers do not produce a correct result with this
      algorithm.

      The text file in this module shows how binary division is
      carried out and explains the algorithm used in this program. 
      The problems of keeping track of errors, such as division by
      zero are also discussed.

      The program in this module takes two numbers entered by the
      user, and divides the first by the second.  The quotient and
      remainder are then printed out.


Part 16: Vectors

      When a BBC OS routine is called, the first thing that
      routine does is jump down a vector.  This means that if you
      call address &FFF1, for example, the code there will be JMP
      (vector). This means a jump to the number held in the
      address 'vector'.  By changing that number, which will be in
      RAM, you can modify the way that the routine operates.

      The text file with this module gives details of the vectors
      used by the OS for indirecting its routines.  Every OS
      routine, including OSBYTE and OSCLI, can be intercepted and
      modified.  The program intercepts the vector through which
      characters and commands go to the screen, called the Write
      Character Vector.  This provides a print out of every VDU
      command that passes to the VDU drivers.

      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 prevent
      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.  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.  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 *CODE is used, but
      both are explained.


Part 17: Events

      Certain things that happen in the BBC Micro, or to devices
      connected to it, can interrupt the processor and take over
      briefly.  One type of interrupt provided by the BBC OS is
      called an Event, and by trapping these events the user can
      make things happen whenever the screen flyback starts, when
      a key is pushed, or when a timer reaches zero for example.

      The text file with this module explains Events and shows how
      they are trapped using the Event Vector.  The program uses
      one of these events to trigger a click from the computer so
      that the noise occurs whenever a character enters the input
      buffer, which effectively is when a key is pressed.

      Events are a specially packaged form of interrupt, and the
      next module deals with the subject in more detail.


Part 18: Interrupts I  -  Mouse driver

      An interrupt is a signal from a piece of hardware which
      forces the microprocessor to temporarily stop what it is
      doing and react to the requirements of the hardware.

      The BBC OS sets up the micro in a known way before passing
      execution down the interrupt vectors.  You can intercept
      these vectors to process the interrupt either to modify the
      OS action or add a new feature.

      The text file with this module explains Interrupts and shows
      how you trap them with the two IRQ vectors.  One of the
      hardware devices that can generate an interrupt is the User
      VIA which is connected to the user port.  The program uses
      the interrupts from the user port to detect the movement of
      a mouse.  Once the movement of the mouse has been detected,
      the program plots a pointer to the screen which can be moved
      with the mouse.


Part 19: Interrupts II  -  Palette Switching using Timers

      As a sequel to the last module, we now look at the timers
      contained in the system and user VIAs.  With these timers it
      is possible to time an action to microsecond accuracy.  The
      timers are set up by poking bytes into their registers which
      lie in the part of memory known as Sheila (Page &FE).  These
      timers are only one of the functions available from the VIAs.

      The text file with this module explains how to set up the
      timers in the VIA.  The program then uses one of the timers
      to generate a series of interrupts during each video frame. 
      At each interrupt the actual colour of COLOUR 1 is modified
      using an OSWORD call.  In this way a series of horizontal
      bands of colour can be generated even in a two-colour mode. 
      The program demonstrates this by printing lines of 80 column
      text in different colours in Mode 3.


Part 20: Real Numbers  -  Fixed Point Arithmetic

      Fixed point maths represents a number with a fractional part
      by working with the number multiplied by a constant.  In
      this way 1.23 is represented by 123 if the constant is 100. 
      By calculating with a number times a constant, you can
      calculate with real numbers using integer maths as long as
      you handle the constant correctly.

      The text file with this module explains how fixed point
      numbering can be used to calculate.  There are simple ways
      of handling addition, subtraction, multiplication and
      division.  The program in this module uses BASIC integers to
      illustrate a simple fixed point system based on a factor of
      10000.  It shows how such a system can often be faster than
      BASIC's built-in floating point arithmetic, although the
      BASIC routines are more accurate.


Part 21: Real Numbers  -  Fixed Point Mandelbrot Set

      The last module introduced the idea of splitting up a word
      (in that case it was 4 bytes as used by BASIC integers) such
      that the lower few bytes were in fact representing
      fractional parts of 1.  This module exploits that idea to
      perform some pretty hairy computation in order to plot a
      crude diagram showing the Mandelbrot Set.

      The Mandelbrot Set graphic shows the way the formula
      z = z^2 + c   behaves when z and c are complex numbers.  The
      calculation of the set involves many multiplications at each
      pixel on the screen and so takes a long time.  Using a fixed
      point system from machine code should be much faster than
      carrying out the calculation from BASIC.

      The Mandelbrot Set is explained in this module's text file. 
      We also set up a fixed point system using a factor of 65536
      and working with four-byte numbers.  The program uses this
      fixed point system, a modified version of the four-byte
      multiplication routine in Module 13, to plot the Mandelbrot
      set in about a quarter of the time it takes from BASIC. 
      With a 6502 second processor it takes about 23 minutes.


Part 22: Floating Point Arithmetic

      In the last module we used a fixed point arithmetic system
      for calculations.  The result was relatively fast but was
      slightly inaccurate since very small numbers were not
      represented as well as they could have been.

      You will remember that we converted from a real number to a
      fixed point number by multiplying by a constant factor.  The
      next logical step is to make the factor variable and keep
      track of what it is.  For example, 123.4 could be 
      represented as 1.234 * 10^2.  This is the scientific
      notation used in BBC BASIC, but the power of ten is written
      as E2 (in this case), and is called the EXPONENT.

      The text file in this module explains how this notation can
      be extended to binary numbers, and how the addition and
      subtraction procedures described for integer numbers need to
      be modified for floating point.

      The program takes a pair of numbers you enter and calculates
      the sum and difference of them using modified versions of
      the multi-byte arithmetical routines introduced earlier in
      the series.  The input of the floating point numbers is done
      using a pseudo OPT function defined at the end of the
      program.  It relies on us knowing where BASIC will store the
      first variable beginning with a ` sign (pound).  We can use
      this knowledge to both put and retrieve BBC BASIC format
      floating point numbers.


Part 23: Floating Point Arithmetic II

      Having achieved addition and subtraction in the last module,
      we now go on to multiplication and division.  The general
      rule for multiplication is that you multiply the mantissae
      and add the exponents while for division you divide the
      mantissae and subtract the exponents.

      The program in this module works on this basis, but it does
      highlight a few problems.  The text describes the program
      section by section, and briefly discusses the problems found
      whilst writing it.  It also explains how Basic sets up a
      parameter block at &600 for any parameters that are passed
      with the CALL command.


Part 24: Sideways ROMs

      One of the more unusual and powerful parts of the BBC Micro
      is the use of sideways ROMs.  They are called sideways
      because several of them can exist, side by side, in the same
      address space in the memory map.  The space between &8000
      and &BFFF in the micro's memory is given over to these
      sideways ROMs which can hold a language (like BASIC or a
      word processor), or can be service ROMs that contain utility
      programs.

      The operating system can select which one out of a possible
      sixteen is actually in the memory map at any particular
      moment by writing to a four bit register at &FE30.  Since
      the process of selecting one is known as 'paging it into the
      memory map', these ROMS are sometimes known as paged ROMs. 
      On an unexpanded BBC B there are four sockets on the main
      printed circuit board, but many people have added extra
      sockets to bring the total up to 16.

      T/OSB24 explains the principles behind formatting sideways
      ROMS, and briefly lists the service calls that pass through
      Them.  The paged memory can be RAM as well as ROM, the OS
      doesn't care which.  With sideways RAM you can load in what
      is called a 'ROM Image' from disc, and the RAM will then
      behave as if it was a sideways ROM.  The program B/OSB24
      produces a ROM image which can be loaded into sideways RAM
      and modified.  You can then experiment with your own ROM and
      investigate the service calls sent by the OS.  (Requires
      BASIC-2 or later)


Part 25: Legal and Illegal Code

      You often read about programming techniques with the BBC
      Micro family that Acorn describe as 'illegal'.  The concept
      of legality in the BBC Micro relates to using the OS in a
      certain way.  The classic example is writing to the screen. 
      You can either use PLOT commands, from machine code or from
      a high level language like BASIC, or you can actually 'poke'
      numbers into the screen memory directly to light up
      individual pixels.

      The advantage of illegal code is that it usually works
      faster, and so is often used in arcade games.  Code that is
      illegal, and pokes the screen memory directly for example,
      cannot be guaranteed to run on any machine.  Legally written
      code 'future-proofs' your program against differences
      between the OS in your machine and that in others.  Future-
      proofing your machine code in this way is the strongest
      argument for legal code and, in all cases except arcade
      games, is pretty unchallengeable.

      The program in this module writes directly to the screen in
      an illegal way to demonstrate the extra speed this provides. 
      It also shows the extra complications in the code caused by
      the non-linear screen addressing in the BBC Micro.  By
      trying to run this code in a second processor, or in a
      machine with shadow RAM, you would soon find that it would
      not work.


Part 26: Editing Your Source Code

      Bringing up the rear in this series is a brief discussion
      about editing source code.  Despite having reasonable
      facilities for line editing, one of the problems of working
      with large bodies of code on the BBC Micro is that you often
      wish you could edit it like you would text on a word
      processor; moving blocks about and replacing strings.

      There are BASIC program editors available,  and with the BBC
      Master micro you have the 'EDIT' facility to let you do just
      this.  It de-tokenises the BASIC file you are working on and
      puts it in memory ready for the EDIT process.  When you exit
      from EDIT, the edited text is put back into memory, with
      line numbers added, as a BASIC program.

      If you have a word processor and a disc drive, you can
      easily carry out this kind of operation.  Many of the
      assembler modules of OSbits were edited using VIEW in this
      way.  As the text file in this module explains, after
      modifying your text, you save it in an ASCII file, and
      finally *EXEC it back into your computer where you can run
      it.

      The program with this module is a text file version of a
      program in BASIC and assembler which 'unplugs' any sideways
      ROM in software to stop clashes over workspace or commands.



                         ----- oOo -----
00000000  20 20 20 20 20 20 4f 53  42 49 54 53 20 2d 20 41  |      OSBITS - A|
00000010  6e 20 45 78 70 6c 6f 72  61 74 69 6f 6e 20 6f 66  |n Exploration of|
00000020  20 74 68 65 20 42 42 43  20 4d 69 63 72 6f 20 61  | the BBC Micro a|
00000030  74 20 4d 61 63 68 69 6e  65 20 4c 65 76 65 6c 0d  |t Machine Level.|
00000040  0d 20 20 20 20 20 20 62  79 20 50 72 6f 67 72 61  |.      by Progra|
00000050  6d 6d 65 72 0d 0d 20 20  20 20 20 20 2e 2e 2e 2e  |mmer..      ....|
00000060  2e 2e 2e 2e 2e 2e 2e 2e  2e 2e 2e 2e 2e 2e 2e 2e  |................|
*
00000090  2e 2e 2e 2e 2e 0d 0d 0d  0d 20 20 20 20 20 20 20  |.........       |
000000a0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000000b0  20 20 20 20 20 49 20 4e  20 44 20 45 20 58 0d 20  |     I N D E X. |
000000c0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000000d0  20 20 20 20 20 20 20 20  20 20 20 3d 3d 3d 3d 3d  |           =====|
000000e0  3d 3d 3d 3d 0d 0d 0d 20  20 20 20 20 20 50 61 72  |====...      Par|
000000f0  74 20 30 3a 20 20 54 68  65 20 48 69 73 74 6f 72  |t 0:  The Histor|
00000100  79 20 4f 66 20 43 6f 6d  70 75 74 69 6e 67 0d 20  |y Of Computing. |
00000110  20 20 20 20 20 50 61 72  74 20 31 3a 20 20 54 68  |     Part 1:  Th|
00000120  65 20 42 42 43 20 41 73  73 65 6d 62 6c 65 72 0d  |e BBC Assembler.|
00000130  20 20 20 20 20 20 50 61  72 74 20 32 3a 20 20 43  |      Part 2:  C|
00000140  6f 75 6e 74 69 6e 67 20  54 77 6f 20 42 79 20 54  |ounting Two By T|
00000150  77 6f 0d 20 20 20 20 20  20 50 61 72 74 20 33 3a  |wo.      Part 3:|
00000160  20 20 54 68 65 20 52 65  67 69 73 74 65 72 73 20  |  The Registers |
00000170  61 6e 64 20 46 6c 61 67  73 0d 20 20 20 20 20 20  |and Flags.      |
00000180  50 61 72 74 20 34 3a 20  20 4d 65 6d 6f 72 79 0d  |Part 4:  Memory.|
00000190  20 20 20 20 20 20 50 61  72 74 20 35 3a 20 20 4f  |      Part 5:  O|
000001a0  70 65 72 61 74 69 6e 67  20 53 79 73 74 65 6d 20  |perating System |
000001b0  43 61 6c 6c 73 20 28 49  29 20 2d 20 4f 53 42 59  |Calls (I) - OSBY|
000001c0  54 45 20 61 6e 64 20 4f  53 57 4f 52 44 0d 20 20  |TE and OSWORD.  |
000001d0  20 20 20 20 50 61 72 74  20 36 3a 20 20 52 6f 74  |    Part 6:  Rot|
000001e0  61 74 69 6e 67 20 61 6e  64 20 53 68 69 66 74 69  |ating and Shifti|
000001f0  6e 67 0d 20 20 20 20 20  20 50 61 72 74 20 37 3a  |ng.      Part 7:|
00000200  20 20 4f 70 65 72 61 74  69 6e 67 20 53 79 73 74  |  Operating Syst|
00000210  65 6d 20 43 61 6c 6c 73  20 28 49 49 29 20 2d 20  |em Calls (II) - |
00000220  49 2f 30 0d 20 20 20 20  20 20 50 61 72 74 20 38  |I/0.      Part 8|
00000230  3a 20 20 4c 6f 67 69 63  61 6c 20 4f 70 65 72 61  |:  Logical Opera|
00000240  74 6f 72 73 0d 20 20 20  20 20 20 50 61 72 74 20  |tors.      Part |
00000250  39 3a 20 20 4f 70 65 72  61 74 69 6e 67 20 53 79  |9:  Operating Sy|
00000260  73 74 65 6d 20 43 61 6c  6c 73 20 28 49 49 49 29  |stem Calls (III)|
00000270  0d 20 20 20 20 20 20 50  61 72 74 20 31 30 3a 20  |.      Part 10: |
00000280  4f 70 63 6f 64 65 73 20  61 6e 64 20 45 72 72 6f  |Opcodes and Erro|
00000290  72 20 4d 65 73 73 61 67  65 73 0d 20 20 20 20 20  |r Messages.     |
000002a0  20 50 61 72 74 20 31 31  3a 20 49 6e 70 75 74 74  | Part 11: Inputt|
000002b0  69 6e 67 20 4e 75 6d 62  65 72 73 0d 20 20 20 20  |ing Numbers.    |
000002c0  20 20 50 61 72 74 20 31  32 3a 20 41 53 43 49 49  |  Part 12: ASCII|
000002d0  20 74 6f 20 42 69 6e 61  72 79 20 43 6f 6e 76 65  | to Binary Conve|
000002e0  72 73 69 6f 6e 0d 20 20  20 20 20 20 50 61 72 74  |rsion.      Part|
000002f0  20 31 33 3a 20 4d 75 6c  74 69 2d 42 79 74 65 20  | 13: Multi-Byte |
00000300  4d 75 6c 74 69 70 6c 69  63 61 74 69 6f 6e 0d 20  |Multiplication. |
00000310  20 20 20 20 20 50 61 72  74 20 31 34 3a 20 42 69  |     Part 14: Bi|
00000320  6e 61 72 79 20 74 6f 20  41 53 43 49 49 20 43 6f  |nary to ASCII Co|
00000330  6e 76 65 72 73 69 6f 6e  0d 20 20 20 20 20 20 50  |nversion.      P|
00000340  61 72 74 20 31 35 3a 20  4d 75 6c 74 69 2d 62 79  |art 15: Multi-by|
00000350  74 65 20 44 69 76 69 73  69 6f 6e 0d 20 20 20 20  |te Division.    |
00000360  20 20 50 61 72 74 20 31  36 3a 20 56 65 63 74 6f  |  Part 16: Vecto|
00000370  72 73 0d 20 20 20 20 20  20 50 61 72 74 20 31 37  |rs.      Part 17|
00000380  3a 20 45 76 65 6e 74 73  0d 20 20 20 20 20 20 50  |: Events.      P|
00000390  61 72 74 20 31 38 3a 20  49 6e 74 65 72 72 75 70  |art 18: Interrup|
000003a0  74 73 20 49 20 20 20 2d  20 20 4d 6f 75 73 65 20  |ts I   -  Mouse |
000003b0  64 72 69 76 65 72 0d 20  20 20 20 20 20 50 61 72  |driver.      Par|
000003c0  74 20 31 39 3a 20 49 6e  74 65 72 72 75 70 74 73  |t 19: Interrupts|
000003d0  20 49 49 20 20 2d 20 20  50 61 6c 65 74 74 65 20  | II  -  Palette |
000003e0  53 77 69 74 63 68 69 6e  67 20 75 73 69 6e 67 20  |Switching using |
000003f0  54 69 6d 65 72 73 0d 20  20 20 20 20 20 50 61 72  |Timers.      Par|
00000400  74 20 32 30 3a 20 52 65  61 6c 20 4e 75 6d 62 65  |t 20: Real Numbe|
00000410  72 73 20 20 2d 20 20 46  69 78 65 64 20 50 6f 69  |rs  -  Fixed Poi|
00000420  6e 74 20 41 72 69 74 68  6d 65 74 69 63 0d 20 20  |nt Arithmetic.  |
00000430  20 20 20 20 50 61 72 74  20 32 31 3a 20 52 65 61  |    Part 21: Rea|
00000440  6c 20 4e 75 6d 62 65 72  73 20 20 2d 20 20 46 69  |l Numbers  -  Fi|
00000450  78 65 64 20 50 6f 69 6e  74 20 4d 61 6e 64 65 6c  |xed Point Mandel|
00000460  62 72 6f 74 20 53 65 74  0d 20 20 20 20 20 20 50  |brot Set.      P|
00000470  61 72 74 20 32 32 3a 20  46 6c 6f 61 74 69 6e 67  |art 22: Floating|
00000480  20 50 6f 69 6e 74 20 41  72 69 74 68 6d 65 74 69  | Point Arithmeti|
00000490  63 0d 20 20 20 20 20 20  50 61 72 74 20 32 33 3a  |c.      Part 23:|
000004a0  20 46 6c 6f 61 74 69 6e  67 20 50 6f 69 6e 74 20  | Floating Point |
000004b0  41 72 69 74 68 6d 65 74  69 63 20 49 49 0d 20 20  |Arithmetic II.  |
000004c0  20 20 20 20 50 61 72 74  20 32 34 3a 20 53 69 64  |    Part 24: Sid|
000004d0  65 77 61 79 73 20 52 4f  4d 73 0d 20 20 20 20 20  |eways ROMs.     |
000004e0  20 50 61 72 74 20 32 35  3a 20 4c 65 67 61 6c 20  | Part 25: Legal |
000004f0  61 6e 64 20 49 6c 6c 65  67 61 6c 20 43 6f 64 65  |and Illegal Code|
00000500  0d 20 20 20 20 20 20 50  61 72 74 20 32 36 3a 20  |.      Part 26: |
00000510  45 64 69 74 69 6e 67 20  59 6f 75 72 20 53 6f 75  |Editing Your Sou|
00000520  72 63 65 20 43 6f 64 65  0d 0d 0d 0d 0d 0d 20 20  |rce Code......  |
00000530  20 20 20 20 4f 53 42 49  54 53 20 69 73 20 61 20  |    OSBITS is a |
00000540  73 65 72 69 65 73 20 6f  66 20 32 36 20 6d 6f 64  |series of 26 mod|
00000550  75 6c 65 73 20 70 72 6f  76 69 64 69 6e 67 20 61  |ules providing a|
00000560  6e 20 69 6e 74 72 6f 64  75 63 74 69 6f 6e 0d 74  |n introduction.t|
00000570  6f 20 6d 61 63 68 69 6e  65 20 63 6f 64 65 20 70  |o machine code p|
00000580  72 6f 67 72 61 6d 6d 69  6e 67 20 6f 6e 20 74 68  |rogramming on th|
00000590  65 20 42 42 43 20 6d 69  63 72 6f 2e 0d 0d 20 20  |e BBC micro...  |
000005a0  20 20 20 20 54 68 65 20  63 6f 75 72 73 65 20 72  |    The course r|
000005b0  65 66 65 72 73 20 74 6f  20 74 68 65 20 42 42 43  |efers to the BBC|
000005c0  20 6d 69 63 72 6f 27 73  20 36 35 30 32 20 61 73  | micro's 6502 as|
000005d0  73 65 6d 62 6c 65 72 2c  20 62 75 74 20 74 68 65  |sembler, but the|
000005e0  0d 70 72 69 6e 63 69 70  6c 65 73 20 69 6e 76 6f  |.principles invo|
000005f0  6c 76 65 64 20 61 70 70  6c 79 20 74 6f 20 61 20  |lved apply to a |
00000600  77 69 64 65 20 72 61 6e  67 65 20 6f 66 20 63 6f  |wide range of co|
00000610  6d 70 75 74 65 72 73 2e  0d 0d 20 20 20 20 20 20  |mputers...      |
00000620  54 6f 20 68 65 6c 70 20  69 64 65 6e 74 69 66 69  |To help identifi|
00000630  63 61 74 69 6f 6e 2c 20  74 65 78 74 20 66 69 6c  |cation, text fil|
00000640  65 73 20 61 72 65 20 6e  61 6d 65 64 20 54 2f 4f  |es are named T/O|
00000650  53 42 2e 2e 2e 20 61 6e  64 0d 61 73 73 6f 63 69  |SB... and.associ|
00000660  61 74 65 64 20 70 72 6f  67 72 61 6d 73 20 61 72  |ated programs ar|
00000670  65 20 42 2f 4f 53 42 2e  2e 2e 0d 0d 54 48 45 20  |e B/OSB.....THE |
00000680  48 49 53 54 4f 52 59 20  4f 46 20 43 4f 4d 50 55  |HISTORY OF COMPU|
00000690  54 49 4e 47 0d 0d 20 20  20 20 20 20 41 20 70 72  |TING..      A pr|
000006a0  65 66 61 63 65 20 74 6f  20 61 6e 20 65 78 70 6c  |eface to an expl|
000006b0  6f 72 61 74 69 6f 6e 20  6f 66 20 74 68 65 20 42  |oration of the B|
000006c0  42 43 20 4d 69 63 72 6f  20 61 74 20 4d 61 63 68  |BC Micro at Mach|
000006d0  69 6e 65 0d 20 20 20 20  20 20 6c 65 76 65 6c 2e  |ine.      level.|
000006e0  20 20 20 41 20 62 69 74  20 6f 66 20 6c 69 67 68  |   A bit of ligh|
000006f0  74 20 72 65 6c 69 65 66  20 74 6f 20 73 74 61 72  |t relief to star|
00000700  74 20 77 69 74 68 20 2d  20 61 20 74 65 78 74 20  |t with - a text |
00000710  6f 6e 6c 79 0d 20 20 20  20 20 20 6d 6f 64 75 6c  |only.      modul|
00000720  65 20 77 69 74 68 20 73  6f 6d 65 20 68 69 73 74  |e with some hist|
00000730  6f 72 69 63 61 6c 20 62  61 63 6b 67 72 6f 75 6e  |orical backgroun|
00000740  64 20 74 6f 20 63 6f 6d  70 75 74 65 72 73 20 61  |d to computers a|
00000750  6e 64 0d 20 20 20 20 20  20 63 6f 6d 70 75 74 69  |nd.      computi|
00000760  6e 67 2e 0d 0d 20 20 20  20 20 20 54 68 69 73 20  |ng...      This |
00000770  66 69 6c 65 20 62 72 69  65 66 6c 79 20 74 65 6c  |file briefly tel|
00000780  6c 73 20 74 68 65 20 73  74 6f 72 79 20 6f 66 20  |ls the story of |
00000790  74 68 65 20 64 65 76 65  6c 6f 70 6d 65 6e 74 20  |the development |
000007a0  6f 66 0d 20 20 20 20 20  20 63 6f 6d 70 75 74 65  |of.      compute|
000007b0  72 73 2e 20 20 49 74 20  73 68 6f 77 73 20 74 68  |rs.  It shows th|
000007c0  61 74 2c 20 61 6c 74 68  6f 75 67 68 20 74 68 65  |at, although the|
000007d0  20 68 6f 6d 65 20 6d 69  63 72 6f 20 68 61 73 20  | home micro has |
000007e0  6f 6e 6c 79 0d 20 20 20  20 20 20 62 65 65 6e 20  |only.      been |
000007f0  61 72 6f 75 6e 64 20 66  6f 72 20 74 68 65 20 6c  |around for the l|
00000800  61 73 74 20 66 69 76 65  20 79 65 61 72 73 20 6f  |ast five years o|
00000810  72 20 73 6f 2c 20 74 68  65 20 73 74 6f 72 79 20  |r so, the story |
00000820  6f 66 0d 20 20 20 20 20  20 63 6f 6d 70 75 74 69  |of.      computi|
00000830  6e 67 20 67 6f 65 73 20  62 61 63 6b 20 63 65 6e  |ng goes back cen|
00000840  74 75 72 69 65 73 2e 0d  0d 0d 50 61 72 74 20 31  |turies....Part 1|
00000850  3a 20 54 68 65 20 42 42  43 20 41 73 73 65 6d 62  |: The BBC Assemb|
00000860  6c 65 72 2e 0d 0d 20 20  20 20 20 20 42 42 43 20  |ler...      BBC |
00000870  42 61 73 69 63 20 69 6e  63 6c 75 64 65 73 20 61  |Basic includes a|
00000880  6e 20 61 73 73 65 6d 62  6c 65 72 20 66 6f 72 20  |n assembler for |
00000890  74 68 65 20 36 35 30 32  20 6d 69 63 72 6f 70 72  |the 6502 micropr|
000008a0  6f 63 65 73 73 6f 72 0d  20 20 20 20 20 20 77 68  |ocessor.      wh|
000008b0  69 63 68 20 74 68 65 20  42 42 43 20 4d 69 63 72  |ich the BBC Micr|
000008c0  6f 20 63 6f 6e 74 61 69  6e 73 2e 20 20 54 68 69  |o contains.  Thi|
000008d0  73 20 61 73 73 65 6d 62  6c 65 72 20 74 61 6b 65  |s assembler take|
000008e0  73 20 79 6f 75 72 0d 20  20 20 20 20 20 61 73 73  |s your.      ass|
000008f0  65 6d 62 6c 79 20 6c 61  6e 67 75 61 67 65 20 70  |embly language p|
00000900  72 6f 67 72 61 6d 20 61  6e 64 20 63 6f 6e 76 65  |rogram and conve|
00000910  72 74 73 20 69 74 20 69  6e 74 6f 20 6d 61 63 68  |rts it into mach|
00000920  69 6e 65 20 63 6f 64 65  2e 20 0d 20 20 20 20 20  |ine code. .     |
00000930  20 54 68 69 73 20 63 6f  64 65 20 69 73 20 74 68  | This code is th|
00000940  65 20 27 6e 61 74 75 72  61 6c 27 20 6c 61 6e 67  |e 'natural' lang|
00000950  75 61 67 65 20 6f 66 20  74 68 65 20 6d 69 63 72  |uage of the micr|
00000960  6f 2c 20 61 6e 64 20 62  79 0d 20 20 20 20 20 20  |o, and by.      |
00000970  75 73 69 6e 67 20 69 74  20 79 6f 75 20 77 69 6c  |using it you wil|
00000980  6c 20 67 65 74 20 61 20  66 61 73 74 65 72 20 61  |l get a faster a|
00000990  6e 64 20 73 6d 61 6c 6c  65 72 20 70 72 6f 67 72  |nd smaller progr|
000009a0  61 6d 20 61 6e 64 20 77  69 6c 6c 0d 20 20 20 20  |am and will.    |
000009b0  20 20 61 6c 73 6f 20 62  65 20 61 62 6c 65 20 74  |  also be able t|
000009c0  6f 20 64 6f 20 74 68 69  6e 67 73 20 74 68 61 74  |o do things that|
000009d0  20 61 72 65 20 69 6d 70  6f 73 73 69 62 6c 65 20  | are impossible |
000009e0  66 72 6f 6d 20 42 41 53  49 43 2e 0d 0d 20 20 20  |from BASIC...   |
000009f0  20 20 20 54 68 65 20 74  65 78 74 20 66 69 6c 65  |   The text file|
00000a00  20 64 65 73 63 72 69 62  65 73 20 74 68 65 20 6f  | describes the o|
00000a10  70 65 72 61 74 69 6f 6e  20 6f 66 20 74 68 65 20  |peration of the |
00000a20  42 42 43 20 61 73 73 65  6d 62 6c 65 72 2c 0d 20  |BBC assembler,. |
00000a30  20 20 20 20 20 61 6e 64  20 73 68 6f 77 73 20 79  |     and shows y|
00000a40  6f 75 20 68 6f 77 20 74  6f 20 73 65 74 20 69 74  |ou how to set it|
00000a50  20 75 70 20 69 6e 20 79  6f 75 72 20 70 72 6f 67  | up in your prog|
00000a60  72 61 6d 73 2e 20 20 54  68 65 0d 20 20 20 20 20  |rams.  The.     |
00000a70  20 61 73 73 65 6d 62 6c  65 72 20 69 73 20 70 61  | assembler is pa|
00000a80  72 74 20 6f 66 20 42 42  43 20 42 41 53 49 43 2c  |rt of BBC BASIC,|
00000a90  20 61 6e 64 20 74 68 69  73 20 6d 6f 64 75 6c 65  | and this module|
00000aa0  20 61 6c 73 6f 20 73 68  6f 77 73 0d 20 20 20 20  | also shows.    |
00000ab0  20 20 79 6f 75 20 68 6f  77 20 74 6f 20 65 6e 6c  |  you how to enl|
00000ac0  69 73 74 20 73 6f 6d 65  20 68 65 6c 70 20 66 72  |ist some help fr|
00000ad0  6f 6d 20 42 41 53 49 43  20 77 69 74 68 20 79 6f  |om BASIC with yo|
00000ae0  75 72 20 6d 61 63 68 69  6e 65 0d 20 20 20 20 20  |ur machine.     |
00000af0  20 63 6f 64 65 20 70 72  6f 67 72 61 6d 6d 69 6e  | code programmin|
00000b00  67 2e 0d 0d 20 20 20 20  20 20 54 68 65 20 70 72  |g...      The pr|
00000b10  6f 67 72 61 6d 20 42 2f  6f 73 62 30 31 20 69 73  |ogram B/osb01 is|
00000b20  20 61 20 73 69 6d 70 6c  65 20 65 78 61 6d 70 6c  | a simple exampl|
00000b30  65 20 6f 66 20 61 6e 20  61 73 73 65 6d 62 6c 79  |e of an assembly|
00000b40  0d 20 20 20 20 20 20 6c  61 6e 67 75 61 67 65 20  |.      language |
00000b50  70 72 6f 67 72 61 6d 20  77 68 69 63 68 20 70 72  |program which pr|
00000b60  69 6e 74 73 20 61 20 6d  65 73 73 61 67 65 20 6f  |ints a message o|
00000b70  6e 20 74 68 65 20 73 63  72 65 65 6e 2c 20 61 0d  |n the screen, a.|
00000b80  20 20 20 20 20 20 73 6f  72 74 20 6f 66 20 63 6f  |      sort of co|
00000b90  6e 66 69 64 65 6e 63 65  20 74 65 73 74 2e 0d 0d  |nfidence test...|
00000ba0  0d 50 61 72 74 20 32 3a  20 43 6f 75 6e 74 69 6e  |.Part 2: Countin|
00000bb0  67 20 54 77 6f 20 42 79  20 54 77 6f 0d 0d 20 20  |g Two By Two..  |
00000bc0  20 20 20 20 54 68 65 20  42 42 43 20 4d 69 63 72  |    The BBC Micr|
00000bd0  6f 20 68 61 6e 64 6c 65  73 20 69 74 73 20 6e 75  |o handles its nu|
00000be0  6d 62 65 72 73 20 69 6e  20 67 72 6f 75 70 73 20  |mbers in groups |
00000bf0  6f 66 20 65 69 67 68 74  20 62 69 6e 61 72 79 0d  |of eight binary.|
00000c00  20 20 20 20 20 20 64 69  67 69 74 73 20 63 61 6c  |      digits cal|
00000c10  6c 65 64 20 62 69 74 73  2c 20 77 68 69 63 68 20  |led bits, which |
00000c20  74 6f 67 65 74 68 65 72  20 61 72 65 20 63 61 6c  |together are cal|
00000c30  6c 65 64 20 61 20 62 79  74 65 2e 20 20 45 61 63  |led a byte.  Eac|
00000c40  68 0d 20 20 20 20 20 20  6f 66 20 74 68 65 20 62  |h.      of the b|
00000c50  69 74 73 20 69 73 20 65  69 74 68 65 72 20 73 65  |its is either se|
00000c60  74 20 74 6f 20 31 2c 20  6f 72 20 63 6c 65 61 72  |t to 1, or clear|
00000c70  65 64 20 74 6f 20 30 2e  20 20 57 69 74 68 20 61  |ed to 0.  With a|
00000c80  0d 20 20 20 20 20 20 62  79 74 65 20 79 6f 75 20  |.      byte you |
00000c90  63 61 6e 20 72 65 70 72  65 73 65 6e 74 20 61 6e  |can represent an|
00000ca0  79 20 6e 75 6d 62 65 72  20 62 65 74 77 65 65 6e  |y number between|
00000cb0  20 30 20 61 6e 64 20 32  35 35 2e 20 20 41 6c 6c  | 0 and 255.  All|
00000cc0  0d 20 20 20 20 20 20 74  68 65 20 63 61 6c 63 75  |.      the calcu|
00000cd0  6c 61 74 69 6e 67 20 77  69 74 68 69 6e 20 74 68  |lating within th|
00000ce0  65 20 63 6f 6d 70 75 74  65 72 20 69 73 20 64 6f  |e computer is do|
00000cf0  6e 65 20 62 79 20 6d 61  6e 69 70 75 6c 61 74 69  |ne by manipulati|
00000d00  6e 67 0d 20 20 20 20 20  20 74 68 65 73 65 20 62  |ng.      these b|
00000d10  79 74 65 73 2c 20 65 69  74 68 65 72 20 73 69 6e  |ytes, either sin|
00000d20  67 6c 79 20 6f 72 20 69  6e 20 67 72 6f 75 70 73  |gly or in groups|
00000d30  2e 20 20 42 79 20 67 72  6f 75 70 69 6e 67 20 62  |.  By grouping b|
00000d40  79 74 65 73 0d 20 20 20  20 20 20 69 6e 74 6f 20  |ytes.      into |
00000d50  27 77 6f 72 64 73 27 20  79 6f 75 20 63 61 6e 20  |'words' you can |
00000d60  77 6f 72 6b 20 77 69 74  68 20 6c 61 72 67 65 72  |work with larger|
00000d70  20 6e 75 6d 62 65 72 73  2e 0d 0d 20 20 20 20 20  | numbers...     |
00000d80  20 54 68 65 20 74 65 78  74 20 66 69 6c 65 20 64  | The text file d|
00000d90  69 73 63 75 73 73 65 73  20 62 69 6e 61 72 79 20  |iscusses binary |
00000da0  6e 75 6d 62 65 72 73 2c  20 61 6e 64 20 64 65 73  |numbers, and des|
00000db0  63 72 69 62 65 73 20 68  6f 77 20 74 6f 0d 20 20  |cribes how to.  |
00000dc0  20 20 20 20 61 64 64 20  61 6e 64 20 73 75 62 74  |    add and subt|
00000dd0  72 61 63 74 20 74 68 65  6d 2e 20 20 54 68 69 73  |ract them.  This|
00000de0  20 72 61 69 73 65 73 20  74 68 65 20 69 6d 70 6f  | raises the impo|
00000df0  72 74 61 6e 74 20 63 6f  6e 63 65 70 74 20 6f 66  |rtant concept of|
00000e00  0d 20 20 20 20 20 20 27  63 61 72 72 79 69 6e 67  |.      'carrying|
00000e10  27 20 61 20 62 69 74 20  6f 6e 20 66 72 6f 6d 20  |' a bit on from |
00000e20  61 6e 20 61 64 64 69 74  69 6f 6e 2c 20 6f 72 20  |an addition, or |
00000e30  27 62 6f 72 72 6f 77 69  6e 67 27 20 64 75 72 69  |'borrowing' duri|
00000e40  6e 67 0d 20 20 20 20 20  20 73 75 62 74 72 61 63  |ng.      subtrac|
00000e50  74 69 6f 6e 2c 20 6a 75  73 74 20 61 73 20 69 6e  |tion, just as in|
00000e60  20 64 65 63 69 6d 61 6c  20 61 72 69 74 68 6d 65  | decimal arithme|
00000e70  74 69 63 2e 0d 0d 20 20  20 20 20 20 54 68 65 20  |tic...      The |
00000e80  70 72 6f 67 72 61 6d 20  69 6e 20 74 68 69 73 20  |program in this |
00000e90  6d 6f 64 75 6c 65 20 6d  61 6b 65 73 20 75 73 65  |module makes use|
00000ea0  20 6f 66 20 63 61 72 72  79 20 74 6f 20 61 64 64  | of carry to add|
00000eb0  20 61 6e 64 0d 20 20 20  20 20 20 73 75 62 74 72  | and.      subtr|
00000ec0  61 63 74 20 74 77 6f 20  34 2d 62 79 74 65 20 6e  |act two 4-byte n|
00000ed0  75 6d 62 65 72 73 2c 20  61 6e 64 20 74 6f 20 63  |umbers, and to c|
00000ee0  6f 6d 70 61 72 65 20 74  68 65 20 61 6e 73 77 65  |ompare the answe|
00000ef0  72 20 66 72 6f 6d 0d 20  20 20 20 20 20 74 68 65  |r from.      the|
00000f00  20 6d 61 63 68 69 6e 65  20 63 6f 64 65 20 77 69  | machine code wi|
00000f10  74 68 20 74 68 65 20 61  6e 73 77 65 72 20 66 72  |th the answer fr|
00000f20  6f 6d 20 42 41 53 49 43  2e 0d 0d 0d 50 61 72 74  |om BASIC....Part|
00000f30  20 33 3a 20 54 68 65 20  52 65 67 69 73 74 65 72  | 3: The Register|
00000f40  73 20 61 6e 64 20 46 6c  61 67 73 0d 0d 20 20 20  |s and Flags..   |
00000f50  20 20 20 4d 6f 73 74 20  6f 66 20 74 68 65 20 69  |   Most of the i|
00000f60  6e 73 74 72 75 63 74 69  6f 6e 73 20 63 61 72 72  |nstructions carr|
00000f70  69 65 64 20 6f 75 74 20  62 79 20 74 68 65 20 6d  |ied out by the m|
00000f80  69 63 72 6f 70 72 6f 63  65 73 73 6f 72 0d 20 20  |icroprocessor.  |
00000f90  20 20 20 20 73 65 74 20  6f 72 20 63 6c 65 61 72  |    set or clear|
00000fa0  20 69 74 73 20 66 6c 61  67 73 2e 20 20 54 68 65  | its flags.  The|
00000fb0  20 63 61 72 72 79 20 66  6c 61 67 20 77 65 20 75  | carry flag we u|
00000fc0  73 65 64 20 69 6e 20 61  64 64 69 74 69 6f 6e 0d  |sed in addition.|
00000fd0  20 20 20 20 20 20 61 6e  64 20 73 75 62 74 72 61  |      and subtra|
00000fe0  63 74 69 6f 6e 20 69 73  20 73 75 63 68 20 61 20  |ction is such a |
00000ff0  66 6c 61 67 2e 20 20 54  68 65 20 74 65 78 74 20  |flag.  The text |
00001000  66 69 6c 65 20 6c 6f 6f  6b 73 20 61 74 20 74 68  |file looks at th|
00001010  65 0d 20 20 20 20 20 20  72 65 67 69 73 74 65 72  |e.      register|
00001020  73 20 61 6e 64 20 66 6c  61 67 73 20 6f 66 20 74  |s and flags of t|
00001030  68 65 20 6d 69 63 72 6f  2c 20 61 6e 64 20 73 68  |he micro, and sh|
00001040  6f 77 73 20 68 6f 77 20  74 6f 20 6c 6f 61 64 20  |ows how to load |
00001050  61 6e 64 0d 20 20 20 20  20 20 73 61 76 65 20 61  |and.      save a|
00001060  20 62 79 74 65 2e 20 20  54 68 65 20 65 66 66 65  | byte.  The effe|
00001070  63 74 20 6f 66 20 61 6e  20 6f 70 65 72 61 74 69  |ct of an operati|
00001080  6f 6e 20 6f 6e 20 74 68  65 20 66 6c 61 67 73 20  |on on the flags |
00001090  6c 65 61 64 73 0d 20 20  20 20 20 20 74 6f 20 64  |leads.      to d|
000010a0  65 63 69 73 69 6f 6e 20  6d 61 6b 69 6e 67 20 77  |ecision making w|
000010b0  69 74 68 20 6a 75 6d 70  73 20 61 6e 64 20 62 72  |ith jumps and br|
000010c0  61 6e 63 68 65 73 20 61  6e 64 20 63 61 6c 6c 73  |anches and calls|
000010d0  20 74 6f 0d 20 20 20 20  20 20 73 75 62 72 6f 75  | to.      subrou|
000010e0  74 69 6e 65 73 2e 0d 0d  20 20 20 20 20 20 49 6e  |tines...      In|
000010f0  20 74 68 65 20 70 72 6f  67 72 61 6d 20 42 2f 6f  | the program B/o|
00001100  73 62 30 33 20 69 73 20  61 20 72 6f 75 74 69 6e  |sb03 is a routin|
00001110  65 20 74 68 61 74 20 64  65 74 65 63 74 73 20 77  |e that detects w|
00001120  68 65 74 68 65 72 20 61  0d 20 20 20 20 20 20 6b  |hether a.      k|
00001130  65 79 20 70 72 65 73 73  65 64 20 69 73 20 61 6e  |ey pressed is an|
00001140  20 75 70 70 65 72 20 6f  72 20 6c 6f 77 65 72 20  | upper or lower |
00001150  63 61 73 65 20 6c 65 74  74 65 72 2c 20 61 20 6e  |case letter, a n|
00001160  75 6d 62 65 72 2c 0d 20  20 20 20 20 20 70 75 6e  |umber,.      pun|
00001170  63 74 75 61 74 69 6f 6e  2c 20 6f 72 20 61 20 63  |ctuation, or a c|
00001180  6f 6e 74 72 6f 6c 20 63  6f 64 65 2c 20 61 6e 64  |ontrol code, and|
00001190  20 70 72 69 6e 74 73 20  6f 75 74 20 61 20 6d 65  | prints out a me|
000011a0  73 73 61 67 65 0d 20 20  20 20 20 20 61 63 63 6f  |ssage.      acco|
000011b0  72 64 69 6e 67 6c 79 2e  0d 0d 0d 50 61 72 74 20  |rdingly....Part |
000011c0  34 3a 20 4d 65 6d 6f 72  79 0d 0d 20 20 20 20 20  |4: Memory..     |
000011d0  20 55 6e 6c 69 6b 65 20  42 41 53 49 43 2c 20 69  | Unlike BASIC, i|
000011e0  74 20 69 73 20 75 70 20  74 6f 20 79 6f 75 20 77  |t is up to you w|
000011f0  68 65 72 65 20 79 6f 75  20 70 75 74 20 79 6f 75  |here you put you|
00001200  72 20 6d 61 63 68 69 6e  65 0d 20 20 20 20 20 20  |r machine.      |
00001210  63 6f 64 65 2e 20 20 54  68 69 73 20 6d 65 61 6e  |code.  This mean|
00001220  73 20 79 6f 75 20 68 61  76 65 20 74 6f 20 6b 6e  |s you have to kn|
00001230  6f 77 20 61 20 62 69 74  20 61 62 6f 75 74 20 68  |ow a bit about h|
00001240  6f 77 20 74 68 65 20 42  42 43 0d 20 20 20 20 20  |ow the BBC.     |
00001250  20 4d 69 63 72 6f 20 75  73 65 73 20 69 74 73 20  | Micro uses its |
00001260  6d 65 6d 6f 72 79 2e 20  20 49 6e 69 74 69 61 6c  |memory.  Initial|
00001270  6c 79 20 79 6f 75 20 63  61 6e 20 65 6e 6c 69 73  |ly you can enlis|
00001280  74 20 74 68 65 20 68 65  6c 70 20 6f 66 0d 20 20  |t the help of.  |
00001290  20 20 20 20 74 68 65 20  42 41 53 49 43 20 44 49  |    the BASIC DI|
000012a0  4d 65 6e 73 69 6f 6e 20  73 74 61 74 65 6d 65 6e  |Mension statemen|
000012b0  74 2c 20 62 75 74 20 65  76 65 6e 74 75 61 6c 6c  |t, but eventuall|
000012c0  79 20 79 6f 75 20 77 69  6c 6c 20 62 65 20 6f 6e  |y you will be on|
000012d0  0d 20 20 20 20 20 20 79  6f 75 72 20 6f 77 6e 2e  |.      your own.|
000012e0  0d 0d 20 20 20 20 20 20  54 68 69 73 20 77 65 65  |..      This wee|
000012f0  6b 27 73 20 74 65 78 74  20 66 69 6c 65 20 73 68  |k's text file sh|
00001300  6f 77 73 20 68 6f 77 20  74 68 65 20 6d 65 6d 6f  |ows how the memo|
00001310  72 79 20 6f 66 20 74 68  65 20 6d 69 63 72 6f 20  |ry of the micro |
00001320  69 73 0d 20 20 20 20 20  20 6c 61 69 64 20 6f 75  |is.      laid ou|
00001330  74 20 61 6e 64 20 75 73  65 64 2e 20 20 57 69 74  |t and used.  Wit|
00001340  68 20 74 68 69 73 20 62  61 63 6b 67 72 6f 75 6e  |h this backgroun|
00001350  64 20 79 6f 75 20 73 68  6f 75 6c 64 20 66 69 6e  |d you should fin|
00001360  64 20 69 74 0d 20 20 20  20 20 20 65 61 73 79 20  |d it.      easy |
00001370  74 6f 20 70 6f 73 69 74  69 6f 6e 20 79 6f 75 72  |to position your|
00001380  20 6d 61 63 68 69 6e 65  20 63 6f 64 65 20 70 72  | machine code pr|
00001390  6f 67 72 61 6d 73 20 77  68 65 72 65 20 74 68 65  |ograms where the|
000013a0  79 20 77 69 6c 6c 0d 20  20 20 20 20 20 62 65 20  |y will.      be |
000013b0  6d 6f 73 74 20 75 73 65  66 75 6c 20 61 6e 64 20  |most useful and |
000013c0  74 72 6f 75 62 6c 65 20  66 72 65 65 2e 20 20 4f  |trouble free.  O|
000013d0  66 74 65 6e 20 69 74 20  69 73 20 61 6c 73 6f 20  |ften it is also |
000013e0  6e 65 63 65 73 73 61 72  79 0d 20 20 20 20 20 20  |necessary.      |
000013f0  74 6f 20 70 6f 73 69 74  69 6f 6e 20 76 61 72 69  |to position vari|
00001400  61 62 6c 65 73 20 61 6e  64 20 74 68 65 20 6c 69  |ables and the li|
00001410  6b 65 20 69 6e 20 6d 65  6d 6f 72 79 20 77 69 74  |ke in memory wit|
00001420  68 69 6e 20 61 0d 20 20  20 20 20 20 70 72 6f 67  |hin a.      prog|
00001430  72 61 6d 2e 20 54 68 69  73 20 69 73 20 6d 6f 72  |ram. This is mor|
00001440  65 20 64 69 66 66 69 63  75 6c 74 20 69 6e 20 42  |e difficult in B|
00001450  41 53 49 43 20 31 20 74  68 61 6e 20 69 6e 20 6c  |ASIC 1 than in l|
00001460  61 74 65 72 0d 20 20 20  20 20 20 42 41 53 49 43  |ater.      BASIC|
00001470  73 2c 20 61 6e 64 20 74  68 65 20 72 6f 75 74 69  |s, and the routi|
00001480  6e 65 73 20 64 65 6d 6f  6e 73 74 72 61 74 65 64  |nes demonstrated|
00001490  20 69 6e 20 42 2f 6f 73  62 30 34 20 61 72 65 0d  | in B/osb04 are.|
000014a0  20 20 20 20 20 20 65 78  70 6c 61 69 6e 65 64 2e  |      explained.|
000014b0  0d 0d 20 20 20 20 20 20  54 68 65 20 70 72 6f 67  |..      The prog|
000014c0  72 61 6d 20 42 2f 6f 73  62 30 34 20 63 6f 6e 73  |ram B/osb04 cons|
000014d0  69 73 74 73 20 6f 66 20  61 20 73 65 74 20 6f 66  |ists of a set of|
000014e0  20 42 41 53 49 43 20 66  75 6e 63 74 69 6f 6e 73  | BASIC functions|
000014f0  0d 20 20 20 20 20 20 77  68 69 63 68 20 63 61 6e  |.      which can|
00001500  20 62 65 20 75 73 65 64  20 69 6e 20 42 41 53 49  | be used in BASI|
00001510  43 20 31 20 74 6f 20 70  6f 73 69 74 69 6f 6e 20  |C 1 to position |
00001520  76 61 72 69 61 62 6c 65  73 20 69 6e 20 61 0d 20  |variables in a. |
00001530  20 20 20 20 20 6d 61 63  68 69 6e 65 20 63 6f 64  |     machine cod|
00001540  65 20 70 72 6f 67 72 61  6d 2c 20 68 65 6e 63 65  |e program, hence|
00001550  20 6d 69 6d 69 63 6b 69  6e 67 20 74 68 65 20 61  | mimicking the a|
00001560  63 74 69 6f 6e 20 6f 66  20 45 51 55 20 69 6e 0d  |ction of EQU in.|
00001570  20 20 20 20 20 20 6c 61  74 65 72 20 42 41 53 49  |      later BASI|
00001580  43 73 2e 20 20 41 6c 73  6f 20 69 6e 63 6c 75 64  |Cs.  Also includ|
00001590  65 64 20 61 72 65 20 61  20 63 6f 75 70 6c 65 20  |ed are a couple |
000015a0  6f 66 20 65 78 74 72 61  0d 20 20 20 20 20 20 70  |of extra.      p|
000015b0  73 65 75 64 6f 2d 6f 70  65 72 61 74 69 76 65 73  |seudo-operatives|
000015c0  20 45 51 55 4d 20 61 6e  64 20 45 51 55 46 2c 20  | EQUM and EQUF, |
000015d0  77 68 69 63 68 20 72 65  73 70 65 63 74 69 76 65  |which respective|
000015e0  6c 79 20 66 69 6c 6c 20  61 0d 20 20 20 20 20 20  |ly fill a.      |
000015f0  62 6c 6f 63 6b 20 6f 66  20 6d 65 6d 6f 72 79 20  |block of memory |
00001600  77 69 74 68 20 61 20 73  70 65 63 69 66 69 65 64  |with a specified|
00001610  20 62 79 74 65 2c 20 61  6e 64 20 63 6f 6e 76 65  | byte, and conve|
00001620  72 74 20 61 20 6e 75 6d  62 65 72 0d 20 20 20 20  |rt a number.    |
00001630  20 20 74 6f 20 42 41 53  49 43 27 73 20 66 6c 6f  |  to BASIC's flo|
00001640  61 74 69 6e 67 20 70 6f  69 6e 74 20 66 6f 72 6d  |ating point form|
00001650  61 74 2c 20 73 74 6f 72  69 6e 67 20 69 74 20 69  |at, storing it i|
00001660  6e 20 6d 65 6d 6f 72 79  2e 0d 0d 0d 50 61 72 74  |n memory....Part|
00001670  20 35 3a 20 4f 70 65 72  61 74 69 6e 67 20 53 79  | 5: Operating Sy|
00001680  73 74 65 6d 20 43 61 6c  6c 73 20 28 49 29 20 2d  |stem Calls (I) -|
00001690  20 4f 53 42 59 54 45 20  61 6e 64 20 4f 53 57 4f  | OSBYTE and OSWO|
000016a0  52 44 0d 0d 20 20 20 20  20 20 4f 70 65 72 61 74  |RD..      Operat|
000016b0  69 6e 67 20 53 79 73 74  65 6d 20 72 6f 75 74 69  |ing System routi|
000016c0  6e 65 73 2c 20 77 68 69  63 68 20 79 6f 75 20 63  |nes, which you c|
000016d0  61 6c 6c 20 61 73 20 73  75 62 72 6f 75 74 69 6e  |all as subroutin|
000016e0  65 73 2c 0d 20 20 20 20  20 20 6d 61 6b 65 20 6c  |es,.      make l|
000016f0  69 67 68 74 20 77 6f 72  6b 20 6f 66 20 74 61 73  |ight work of tas|
00001700  6b 73 20 74 68 61 74 20  63 6f 75 6c 64 20 6f 74  |ks that could ot|
00001710  68 65 72 77 69 73 65 20  62 65 20 76 65 72 79 0d  |herwise be very.|
00001720  20 20 20 20 20 20 64 69  66 66 69 63 75 6c 74 2e  |      difficult.|
00001730  20 20 54 68 65 79 20 61  6c 73 6f 20 68 65 6c 70  |  They also help|
00001740  20 70 72 65 73 65 72 76  65 20 74 68 65 20 63 6f  | preserve the co|
00001750  6d 70 61 74 69 62 69 6c  69 74 79 20 6f 66 0d 20  |mpatibility of. |
00001760  20 20 20 20 20 73 6f 66  74 77 61 72 65 20 77 69  |     software wi|
00001770  74 68 20 64 69 66 66 65  72 65 6e 74 20 76 65 72  |th different ver|
00001780  73 69 6f 6e 73 20 6f 66  20 74 68 65 20 4f 70 65  |sions of the Ope|
00001790  72 61 74 69 6e 67 20 53  79 73 74 65 6d 2e 20 0d  |rating System. .|
000017a0  20 20 20 20 20 20 54 68  65 20 74 65 78 74 20 66  |      The text f|
000017b0  69 6c 65 20 77 69 74 68  20 74 68 69 73 20 6d 6f  |ile with this mo|
000017c0  64 75 6c 65 20 73 68 6f  77 73 20 68 6f 77 20 74  |dule shows how t|
000017d0  6f 20 73 65 74 20 75 70  20 4f 53 42 59 54 45 0d  |o set up OSBYTE.|
000017e0  20 20 20 20 20 20 61 6e  64 20 4f 53 57 4f 52 44  |      and OSWORD|
000017f0  20 72 6f 75 74 69 6e 65  73 20 61 6e 64 20 67 69  | routines and gi|
00001800  76 65 73 20 65 78 61 6d  70 6c 65 73 20 6f 66 20  |ves examples of |
00001810  77 68 61 74 20 74 68 65  79 20 63 61 6e 20 64 6f  |what they can do|
00001820  2e 0d 0d 20 20 20 20 20  20 42 2f 6f 73 62 30 35  |...      B/osb05|
00001830  20 69 73 20 61 20 73 6d  61 6c 6c 20 70 72 6f 67  | is a small prog|
00001840  72 61 6d 20 77 68 69 63  68 20 75 73 65 73 20 61  |ram which uses a|
00001850  6e 20 4f 53 42 59 54 45  20 63 61 6c 6c 2c 20 6e  |n OSBYTE call, n|
00001860  75 6d 62 65 72 0d 20 20  20 20 20 20 31 32 31 2c  |umber.      121,|
00001870  20 74 68 61 74 20 73 63  61 6e 73 20 74 68 65 20  | that scans the |
00001880  6b 65 79 62 6f 61 72 64  20 61 6e 64 20 72 65 74  |keyboard and ret|
00001890  75 72 6e 73 20 61 20 6e  75 6d 62 65 72 0d 20 20  |urns a number.  |
000018a0  20 20 20 20 63 6f 72 72  65 73 70 6f 6e 64 69 6e  |    correspondin|
000018b0  67 20 74 6f 20 74 68 65  20 6b 65 79 20 70 72 65  |g to the key pre|
000018c0  73 73 65 64 20 64 6f 77  6e 20 61 74 20 74 68 65  |ssed down at the|
000018d0  20 74 69 6d 65 2e 20 20  54 68 69 73 20 69 73 0d  | time.  This is.|
000018e0  20 20 20 20 20 20 74 68  65 6e 20 75 73 65 64 20  |      then used |
000018f0  61 73 20 61 20 70 61 72  61 6d 65 74 65 72 20 69  |as a parameter i|
00001900  6e 20 61 6e 20 4f 53 57  4f 52 44 20 63 61 6c 6c  |n an OSWORD call|
00001910  20 77 68 69 63 68 20 70  6c 61 79 73 20 61 20 6e  | which plays a n|
00001920  6f 74 65 0d 20 20 20 20  20 20 6f 6e 20 74 68 65  |ote.      on the|
00001930  20 73 6f 75 6e 64 20 63  68 69 70 2c 20 74 68 65  | sound chip, the|
00001940  20 70 69 74 63 68 20 64  65 70 65 6e 64 69 6e 67  | pitch depending|
00001950  20 6f 6e 20 77 68 69 63  68 20 6b 65 79 20 69 73  | on which key is|
00001960  0d 20 20 20 20 20 20 70  72 65 73 73 65 64 2e 0d  |.      pressed..|
00001970  0d 0d 50 61 72 74 20 36  3a 20 52 6f 74 61 74 69  |..Part 6: Rotati|
00001980  6e 67 20 61 6e 64 20 53  68 69 66 74 69 6e 67 0d  |ng and Shifting.|
00001990  0d 20 20 20 20 20 20 54  68 65 72 65 20 61 72 65  |.      There are|
000019a0  20 69 6e 73 74 72 75 63  74 69 6f 6e 73 20 69 6e  | instructions in|
000019b0  20 74 68 65 20 36 35 30  32 20 73 65 74 20 74 6f  | the 6502 set to|
000019c0  20 65 6e 61 62 6c 65 20  79 6f 75 20 74 6f 20 6d  | enable you to m|
000019d0  6f 76 65 0d 20 20 20 20  20 20 61 6c 6c 20 74 68  |ove.      all th|
000019e0  65 20 62 69 74 73 20 6f  66 20 61 20 62 79 74 65  |e bits of a byte|
000019f0  20 75 70 20 6f 72 20 64  6f 77 6e 20 6f 6e 65 2c  | up or down one,|
00001a00  20 65 66 66 65 63 74 69  76 65 6c 79 0d 20 20 20  | effectively.   |
00001a10  20 20 20 6d 75 6c 74 69  70 6c 79 69 6e 67 20 6f  |   multiplying o|
00001a20  72 20 64 69 76 69 64 69  6e 67 20 74 68 65 20 62  |r dividing the b|
00001a30  79 74 65 20 62 79 20 32  2e 20 20 54 68 65 20 62  |yte by 2.  The b|
00001a40  69 74 20 74 68 61 74 20  77 6f 75 6c 64 0d 20 20  |it that would.  |
00001a50  20 20 20 20 27 66 61 6c  6c 20 6f 66 66 20 74 68  |    'fall off th|
00001a60  65 20 65 6e 64 27 20 67  6f 65 73 20 69 6e 74 6f  |e end' goes into|
00001a70  20 74 68 65 20 43 61 72  72 79 20 66 6c 61 67 2e  | the Carry flag.|
00001a80  20 20 4f 6e 65 20 70 61  69 72 20 6f 66 0d 20 20  |  One pair of.  |
00001a90  20 20 20 20 73 75 63 68  20 63 6f 6d 6d 61 6e 64  |    such command|
00001aa0  73 20 70 75 74 20 7a 65  72 6f 20 69 6e 20 74 68  |s put zero in th|
00001ab0  65 20 76 61 63 61 74 65  64 20 62 69 74 2c 20 77  |e vacated bit, w|
00001ac0  68 69 6c 65 20 74 68 65  20 6f 74 68 65 72 0d 20  |hile the other. |
00001ad0  20 20 20 20 20 70 61 69  72 20 70 75 74 20 74 68  |     pair put th|
00001ae0  65 20 6f 6c 64 20 43 61  72 72 79 20 76 61 6c 75  |e old Carry valu|
00001af0  65 20 69 6e 2e 0d 0d 20  20 20 20 20 20 54 68 69  |e in...      Thi|
00001b00  73 20 6d 6f 64 75 6c 65  20 67 69 76 65 73 20 64  |s module gives d|
00001b10  65 74 61 69 6c 73 20 6f  66 20 74 68 65 20 66 6f  |etails of the fo|
00001b20  75 72 20 62 69 74 2d 73  68 69 66 74 69 6e 67 0d  |ur bit-shifting.|
00001b30  20 20 20 20 20 20 69 6e  73 74 72 75 63 74 69 6f  |      instructio|
00001b40  6e 73 2c 20 61 6e 64 20  61 6c 73 6f 20 64 69 73  |ns, and also dis|
00001b50  63 75 73 73 65 73 20 74  65 6d 70 6f 72 61 72 79  |cusses temporary|
00001b60  20 73 74 6f 72 61 67 65  20 6f 66 0d 20 20 20 20  | storage of.    |
00001b70  20 20 76 61 72 69 61 62  6c 65 73 20 64 75 72 69  |  variables duri|
00001b80  6e 67 20 61 20 70 72 6f  67 72 61 6d 20 75 73 69  |ng a program usi|
00001b90  6e 67 20 62 6f 74 68 20  6d 65 6d 6f 72 79 20 61  |ng both memory a|
00001ba0  6e 64 20 74 68 65 20 73  74 61 63 6b 2e 20 0d 20  |nd the stack. . |
00001bb0  20 20 20 20 20 49 74 20  73 68 6f 77 73 20 61 20  |     It shows a |
00001bc0  66 75 72 74 68 65 72 20  6d 65 74 68 6f 64 20 6f  |further method o|
00001bd0  66 20 65 61 73 69 6c 79  20 6d 61 6b 69 6e 67 20  |f easily making |
00001be0  73 70 61 63 65 20 66 6f  72 20 61 0d 20 20 20 20  |space for a.    |
00001bf0  20 20 76 61 72 69 61 62  6c 65 20 69 6e 74 6f 20  |  variable into |
00001c00  6d 65 6d 6f 72 79 2e 0d  0d 20 20 20 20 20 20 54  |memory...      T|
00001c10  68 65 20 70 72 6f 67 72  61 6d 20 42 2f 6f 73 62  |he program B/osb|
00001c20  30 36 20 74 61 6b 65 73  20 61 20 62 79 74 65 20  |06 takes a byte |
00001c30  74 68 61 74 20 79 6f 75  20 74 79 70 65 20 69 6e  |that you type in|
00001c40  20 62 79 0d 20 20 20 20  20 20 70 72 65 73 73 69  | by.      pressi|
00001c50  6e 67 20 61 20 6b 65 79  2c 20 61 6e 64 20 75 73  |ng a key, and us|
00001c60  69 6e 67 20 74 68 65 20  62 69 74 20 73 68 69 66  |ing the bit shif|
00001c70  74 69 6e 67 20 69 6e 73  74 72 75 63 74 69 6f 6e  |ting instruction|
00001c80  73 2c 0d 20 20 20 20 20  20 70 72 69 6e 74 73 20  |s,.      prints |
00001c90  69 74 73 20 76 61 6c 75  65 20 6f 75 74 20 69 6e  |its value out in|
00001ca0  20 74 68 72 65 65 20 77  61 79 73 20 2d 20 62 69  | three ways - bi|
00001cb0  6e 61 72 79 2c 20 68 65  78 61 64 65 63 69 6d 61  |nary, hexadecima|
00001cc0  6c 20 61 6e 64 0d 20 20  20 20 20 20 64 65 63 69  |l and.      deci|
00001cd0  6d 61 6c 2e 0d 0d 0d 50  61 72 74 20 37 3a 20 4f  |mal....Part 7: O|
00001ce0  70 65 72 61 74 69 6e 67  20 53 79 73 74 65 6d 20  |perating System |
00001cf0  43 61 6c 6c 73 20 28 49  49 29 20 2d 20 49 2f 30  |Calls (II) - I/0|
00001d00  0d 0d 20 20 20 20 20 20  54 68 69 73 20 73 65 63  |..      This sec|
00001d10  6f 6e 64 20 6c 6f 6f 6b  20 61 74 20 4f 70 65 72  |ond look at Oper|
00001d20  61 74 69 6e 67 20 53 79  73 74 65 6d 20 72 6f 75  |ating System rou|
00001d30  74 69 6e 65 73 20 64 65  61 6c 73 20 77 69 74 68  |tines deals with|
00001d40  0d 20 20 20 20 20 20 74  68 6f 73 65 20 72 65 6c  |.      those rel|
00001d50  61 74 69 6e 67 20 74 6f  20 69 6e 70 75 74 20 61  |ating to input a|
00001d60  6e 64 20 6f 75 74 70 75  74 2e 20 20 20 49 74 27  |nd output.   It'|
00001d70  73 20 6f 6e 65 20 6f 66  20 74 68 65 0d 20 20 20  |s one of the.   |
00001d80  20 20 20 62 65 61 75 74  69 65 73 20 6f 66 20 74  |   beauties of t|
00001d90  68 65 20 42 42 43 20 4d  69 63 72 6f 27 73 20 4f  |he BBC Micro's O|
00001da0  53 20 74 68 61 74 20 74  68 65 20 72 6f 75 74 69  |S that the routi|
00001db0  6e 65 73 20 66 6f 72 20  69 6e 70 75 74 0d 20 20  |nes for input.  |
00001dc0  20 20 20 20 61 6e 64 20  6f 75 74 70 75 74 20 28  |    and output (|
00001dd0  49 2f 4f 29 20 61 72 65  20 69 6e 64 65 70 65 6e  |I/O) are indepen|
00001de0  64 65 6e 74 20 6f 66 20  74 68 65 20 73 6f 75 72  |dent of the sour|
00001df0  63 65 20 6f 72 0d 20 20  20 20 20 20 64 65 73 74  |ce or.      dest|
00001e00  69 6e 61 74 69 6f 6e 20  6f 66 20 74 68 61 74 20  |ination of that |
00001e10  49 2f 4f 2e 20 20 54 68  65 20 73 65 6c 65 63 74  |I/O.  The select|
00001e20  69 6f 6e 20 6f 66 20 73  6f 75 72 63 65 20 61 6e  |ion of source an|
00001e30  64 0d 20 20 20 20 20 20  64 65 73 74 69 6e 61 74  |d.      destinat|
00001e40  69 6f 6e 20 28 6b 6e 6f  77 6e 20 61 73 20 74 68  |ion (known as th|
00001e50  65 20 69 6e 70 75 74 20  61 6e 64 20 6f 75 74 70  |e input and outp|
00001e60  75 74 20 73 74 72 65 61  6d 29 20 61 72 65 20 74  |ut stream) are t|
00001e70  68 65 0d 20 20 20 20 20  20 70 72 6f 76 69 6e 63  |he.      provinc|
00001e80  65 20 6f 66 20 73 6f 6d  65 20 6f 66 20 74 68 65  |e of some of the|
00001e90  20 4f 53 42 59 54 45 20  63 61 6c 6c 73 2e 0d 0d  | OSBYTE calls...|
00001ea0  20 20 20 20 20 20 42 2f  6f 73 62 30 37 20 73 65  |      B/osb07 se|
00001eb0  74 73 20 75 70 20 74 68  65 20 72 6f 75 74 69 6e  |ts up the routin|
00001ec0  65 20 77 68 69 63 68 20  77 69 6c 6c 20 70 72 69  |e which will pri|
00001ed0  6e 74 20 6f 75 74 20 61  20 73 74 72 69 6e 67 0d  |nt out a string.|
00001ee0  20 20 20 20 20 20 70 72  6f 70 6f 72 74 69 6f 6e  |      proportion|
00001ef0  61 6c 6c 79 20 73 70 61  63 65 64 2e 20 20 54 6f  |ally spaced.  To|
00001f00  20 75 73 65 20 69 74 20  79 6f 75 20 6d 75 73 74  | use it you must|
00001f10  20 62 65 20 69 6e 20 4d  6f 64 65 20 31 20 6f 72  | be in Mode 1 or|
00001f20  0d 20 20 20 20 20 20 4d  6f 64 65 20 34 2c 20 61  |.      Mode 4, a|
00001f30  6e 64 20 64 65 66 69 6e  65 20 61 20 73 74 72 69  |nd define a stri|
00001f40  6e 67 20 76 61 72 69 61  62 6c 65 20 74 6f 20 62  |ng variable to b|
00001f50  65 20 79 6f 75 72 20 72  65 71 75 69 72 65 64 0d  |e your required.|
00001f60  20 20 20 20 20 20 73 74  72 69 6e 67 2e 20 20 54  |      string.  T|
00001f70  68 65 20 67 72 61 70 68  69 63 73 20 63 75 72 73  |he graphics curs|
00001f80  6f 72 20 6d 75 73 74 20  62 65 20 70 6f 73 69 74  |or must be posit|
00001f90  69 6f 6e 65 64 20 77 68  65 72 65 20 79 6f 75 0d  |ioned where you.|
00001fa0  20 20 20 20 20 20 77 61  6e 74 20 74 68 65 20 70  |      want the p|
00001fb0  72 69 6e 74 69 6e 67 20  74 6f 20 73 74 61 72 74  |rinting to start|
00001fc0  20 62 79 20 75 73 69 6e  67 20 4d 4f 56 45 2e 0d  | by using MOVE..|
00001fd0  0d 0d 50 61 72 74 20 38  3a 20 4c 6f 67 69 63 61  |..Part 8: Logica|
00001fe0  6c 20 4f 70 65 72 61 74  6f 72 73 0d 0d 20 20 20  |l Operators..   |
00001ff0  20 20 20 57 65 27 72 65  20 62 61 63 6b 20 74 6f  |   We're back to|
00002000  20 63 6f 6d 70 61 72 69  73 6f 6e 73 20 69 6e 20  | comparisons in |
00002010  74 68 69 73 20 6d 6f 64  75 6c 65 2e 20 20 41 6c  |this module.  Al|
00002020  72 65 61 64 79 20 79 6f  75 20 68 61 76 65 0d 20  |ready you have. |
00002030  20 20 20 20 20 63 6f 6d  65 20 61 63 72 6f 73 73  |     come across|
00002040  20 62 72 61 6e 63 68 69  6e 67 20 6f 70 65 72 61  | branching opera|
00002050  74 69 6f 6e 73 20 63 61  72 72 69 65 64 20 6f 75  |tions carried ou|
00002060  74 20 63 6f 6e 64 69 74  69 6f 6e 61 6c 6c 79 0d  |t conditionally.|
00002070  20 20 20 20 20 20 6f 6e  20 74 68 65 20 73 65 74  |      on the set|
00002080  74 69 6e 67 20 6f 66 20  63 65 72 74 61 69 6e 20  |ting of certain |
00002090  66 6c 61 67 73 20 69 6e  20 74 68 65 20 70 72 6f  |flags in the pro|
000020a0  63 65 73 73 6f 72 20 73  74 61 74 75 73 0d 20 20  |cessor status.  |
000020b0  20 20 20 20 72 65 67 69  73 74 65 72 3b 20 6d 6e  |    register; mn|
000020c0  65 6d 6f 6e 69 63 73 20  6c 69 6b 65 20 42 4e 45  |emonics like BNE|
000020d0  2c 20 42 45 51 2c 20 61  6e 64 20 42 4d 49 2e 20  |, BEQ, and BMI. |
000020e0  20 4c 6f 67 69 63 61 6c  0d 20 20 20 20 20 20 6f  | Logical.      o|
000020f0  70 65 72 61 74 6f 72 73  20 65 6e 61 62 6c 65 20  |perators enable |
00002100  75 73 20 74 6f 20 63 6f  6d 70 61 72 65 20 74 68  |us to compare th|
00002110  65 20 62 69 74 73 20 6f  66 20 6f 6e 65 20 62 79  |e bits of one by|
00002120  74 65 20 77 69 74 68 20  74 68 65 0d 20 20 20 20  |te with the.    |
00002130  20 20 62 69 74 73 20 6f  66 20 61 6e 6f 74 68 65  |  bits of anothe|
00002140  72 2c 20 61 6e 64 20 65  73 73 65 6e 74 69 61 6c  |r, and essential|
00002150  6c 79 20 74 68 65 72 65  20 61 72 65 20 74 68 72  |ly there are thr|
00002160  65 65 20 74 79 70 65 73  20 6f 66 0d 20 20 20 20  |ee types of.    |
00002170  20 20 63 6f 6d 70 61 72  69 73 6f 6e 2e 20 20 54  |  comparison.  T|
00002180  68 69 73 20 6d 6f 64 75  6c 65 20 65 78 70 6c 61  |his module expla|
00002190  69 6e 73 20 74 68 65 20  6c 6f 67 69 63 61 6c 20  |ins the logical |
000021a0  6f 70 65 72 61 74 6f 72  73 20 41 4e 44 2c 0d 20  |operators AND,. |
000021b0  20 20 20 20 20 4f 52 41  2c 20 61 6e 64 20 45 4f  |     ORA, and EO|
000021c0  52 2c 20 61 6e 64 20 61  6c 73 6f 20 42 49 54 20  |R, and also BIT |
000021d0  77 68 69 63 68 20 69 73  20 73 69 6d 69 6c 61 72  |which is similar|
000021e0  20 74 6f 20 41 4e 44 2e  20 20 54 68 65 73 65 0d  | to AND.  These.|
000021f0  20 20 20 20 20 20 69 6e  73 74 72 75 63 74 69 6f  |      instructio|
00002200  6e 73 20 63 61 6e 20 62  65 20 75 73 65 64 20 74  |ns can be used t|
00002210  6f 20 61 66 66 65 63 74  20 69 6e 64 69 76 69 64  |o affect individ|
00002220  75 61 6c 20 62 69 74 73  20 6f 66 20 61 20 0d 20  |ual bits of a . |
00002230  20 20 20 20 20 62 79 74  65 2e 0d 0d 20 20 20 20  |     byte...    |
00002240  20 20 49 74 27 73 20 61  20 73 69 6d 70 6c 65 20  |  It's a simple |
00002250  6c 69 74 74 6c 65 20 70  69 65 63 65 20 6f 66 20  |little piece of |
00002260  63 6f 64 65 20 69 6e 20  74 68 69 73 20 6d 6f 64  |code in this mod|
00002270  75 6c 65 2e 20 20 54 68  65 0d 20 20 20 20 20 20  |ule.  The.      |
00002280  41 53 43 49 49 20 63 6f  64 65 73 20 61 72 65 20  |ASCII codes are |
00002290  61 72 72 61 6e 67 65 64  20 73 75 63 68 20 74 68  |arranged such th|
000022a0  61 74 20 74 68 65 20 63  6f 64 65 20 66 6f 72 20  |at the code for |
000022b0  61 20 6c 65 74 74 65 72  2c 0d 20 20 20 20 20 20  |a letter,.      |
000022c0  77 68 65 6e 20 41 4e 44  65 64 20 77 69 74 68 20  |when ANDed with |
000022d0  26 44 46 2c 20 77 69 6c  6c 20 61 6c 77 61 79 73  |&DF, will always|
000022e0  20 70 72 6f 64 75 63 65  20 74 68 65 20 63 6f 64  | produce the cod|
000022f0  65 20 66 6f 72 20 75 70  70 65 72 0d 20 20 20 20  |e for upper.    |
00002300  20 20 63 61 73 65 2c 20  61 6e 64 20 42 2f 6f 73  |  case, and B/os|
00002310  62 30 38 20 64 6f 65 73  20 73 69 6d 70 6c 79 20  |b08 does simply |
00002320  74 68 61 74 2e 20 20 48  6f 77 65 76 65 72 2c 20  |that.  However, |
00002330  62 65 69 6e 67 20 73 69  6d 70 6c 65 0d 20 20 20  |being simple.   |
00002340  20 20 20 69 74 20 64 6f  65 73 20 6e 6f 74 20 70  |   it does not p|
00002350  72 6f 64 75 63 65 20 61  20 73 61 74 69 73 66 61  |roduce a satisfa|
00002360  63 74 6f 72 79 20 72 65  73 75 6c 74 20 66 6f 72  |ctory result for|
00002370  20 61 6c 6c 20 74 68 65  20 6f 74 68 65 72 0d 20  | all the other. |
00002380  20 20 20 20 20 6b 65 79  73 20 6f 6e 20 74 68 65  |     keys on the|
00002390  20 6b 65 79 62 6f 61 72  64 2e 20 20 54 68 69 73  | keyboard.  This|
000023a0  20 61 70 70 72 6f 61 63  68 20 69 73 20 6f 6e 65  | approach is one|
000023b0  20 6f 66 20 74 68 65 20  77 61 79 73 20 74 6f 0d  | of the ways to.|
000023c0  20 20 20 20 20 20 6c 65  67 69 73 6c 61 74 65 20  |      legislate |
000023d0  61 67 61 69 6e 73 74 20  70 65 6f 70 6c 65 20 77  |against people w|
000023e0  68 6f 20 74 75 72 6e 20  6f 66 66 20 28 6f 72 20  |ho turn off (or |
000023f0  6f 6e 29 20 74 68 65 20  43 41 50 53 20 4c 4f 43  |on) the CAPS LOC|
00002400  4b 0d 20 20 20 20 20 20  6f 6e 20 74 68 65 69 72  |K.      on their|
00002410  20 6d 69 63 72 6f 20 77  68 65 6e 20 79 6f 75 20  | micro when you |
00002420  65 78 70 65 63 74 20 69  74 20 74 68 65 20 6f 74  |expect it the ot|
00002430  68 65 72 20 77 61 79 20  61 72 6f 75 6e 64 2e 0d  |her way around..|
00002440  0d 0d 50 61 72 74 20 39  3a 20 4f 70 65 72 61 74  |..Part 9: Operat|
00002450  69 6e 67 20 53 79 73 74  65 6d 20 43 61 6c 6c 73  |ing System Calls|
00002460  20 28 49 49 49 29 0d 0d  20 20 20 20 20 20 54 68  | (III)..      Th|
00002470  65 72 65 20 61 72 65 20  6d 61 6e 79 20 6d 6f 72  |ere are many mor|
00002480  65 20 4f 53 20 72 6f 75  74 69 6e 65 73 20 62 65  |e OS routines be|
00002490  73 69 64 65 73 20 74 68  6f 73 65 20 6d 65 6e 74  |sides those ment|
000024a0  69 6f 6e 65 64 20 69 6e  0d 20 20 20 20 20 20 65  |ioned in.      e|
000024b0  61 72 6c 69 65 72 20 6d  6f 64 75 6c 65 73 2e 20  |arlier modules. |
000024c0  20 53 6f 6d 65 20 6f 66  20 74 68 65 6d 2c 20 6c  | Some of them, l|
000024d0  69 6b 65 20 4f 53 46 49  4c 45 20 61 72 65 20 75  |ike OSFILE are u|
000024e0  73 65 64 20 74 6f 0d 20  20 20 20 20 20 6f 70 65  |sed to.      ope|
000024f0  72 61 74 65 20 74 68 65  20 66 69 6c 69 6e 67 20  |rate the filing |
00002500  73 79 73 74 65 6d 73 2e  20 20 4f 6e 65 2c 20 4f  |systems.  One, O|
00002510  53 43 4c 49 2c 20 67 69  76 65 73 20 61 63 63 65  |SCLI, gives acce|
00002520  73 73 20 74 6f 20 74 68  65 0d 20 20 20 20 20 20  |ss to the.      |
00002530  22 43 6f 6d 6d 61 6e 64  2d 4c 69 6e 65 20 49 6e  |"Command-Line In|
00002540  74 65 72 70 72 65 74 65  72 22 20 6f 66 20 74 68  |terpreter" of th|
00002550  65 20 6d 69 63 72 6f 2e  20 20 54 68 65 72 65 20  |e micro.  There |
00002560  69 73 20 61 6c 73 6f 20  61 0d 20 20 20 20 20 20  |is also a.      |
00002570  67 72 6f 75 70 20 6f 66  20 72 6f 75 74 69 6e 65  |group of routine|
00002580  73 20 77 68 69 63 68 20  41 63 6f 72 6e 20 68 61  |s which Acorn ha|
00002590  76 65 20 6c 65 66 74 20  75 6e 64 6f 63 75 6d 65  |ve left undocume|
000025a0  6e 74 65 64 2c 20 62 75  74 0d 20 20 20 20 20 20  |nted, but.      |
000025b0  61 6e 79 20 75 73 65 20  6f 66 20 74 68 65 73 65  |any use of these|
000025c0  20 6d 75 73 74 20 62 65  20 63 61 75 74 69 6f 75  | must be cautiou|
000025d0  73 2e 0d 0d 20 20 20 20  20 20 54 68 69 73 20 6d  |s...      This m|
000025e0  6f 64 75 6c 65 20 6c 69  73 74 73 20 74 68 65 20  |odule lists the |
000025f0  66 69 6e 61 6c 20 73 65  74 20 6f 66 20 74 68 65  |final set of the|
00002600  73 65 20 6f 70 65 72 61  74 69 6e 67 20 73 79 73  |se operating sys|
00002610  74 65 6d 0d 20 20 20 20  20 20 72 6f 75 74 69 6e  |tem.      routin|
00002620  65 73 2c 20 74 6f 67 65  74 68 65 72 20 77 69 74  |es, together wit|
00002630  68 20 74 68 65 69 72 20  63 61 6c 6c 20 61 6e 64  |h their call and|
00002640  20 76 65 63 74 6f 72 20  61 64 64 72 65 73 73 65  | vector addresse|
00002650  73 2e 0d 20 20 20 20 20  20 28 56 65 63 74 6f 72  |s..      (Vector|
00002660  73 20 77 69 6c 6c 20 62  65 20 64 65 73 63 72 69  |s will be descri|
00002670  62 65 64 20 69 6e 20 61  20 6c 61 74 65 72 20 6d  |bed in a later m|
00002680  6f 64 75 6c 65 2e 29 20  20 44 65 74 61 69 6c 65  |odule.)  Detaile|
00002690  64 0d 20 20 20 20 20 20  65 78 70 6c 61 6e 61 74  |d.      explanat|
000026a0  69 6f 6e 20 6f 66 20 74  68 65 20 66 69 6c 69 6e  |ion of the filin|
000026b0  67 20 73 79 73 74 65 6d  20 6f 6e 65 73 20 69 73  |g system ones is|
000026c0  20 6c 65 66 74 20 74 6f  20 6f 74 68 65 72 0d 20  | left to other. |
000026d0  20 20 20 20 20 61 64 76  61 6e 63 65 64 20 67 75  |     advanced gu|
000026e0  69 64 65 73 2c 20 62 75  74 20 77 65 20 65 78 70  |ides, but we exp|
000026f0  6c 61 69 6e 20 77 68 61  74 20 65 61 63 68 20 72  |lain what each r|
00002700  6f 75 74 69 6e 65 20 64  6f 65 73 2e 0d 0d 20 20  |outine does...  |
00002710  20 20 20 20 54 68 65 20  70 72 6f 67 72 61 6d 20  |    The program |
00002720  69 6e 20 74 68 69 73 20  6d 6f 64 75 6c 65 2c 20  |in this module, |
00002730  42 2f 6f 73 62 30 39 2c  20 75 73 65 73 20 4f 53  |B/osb09, uses OS|
00002740  52 44 52 4d 2c 20 6f 6e  65 20 6f 66 20 74 68 65  |RDRM, one of the|
00002750  0d 20 20 20 20 20 20 75  6e 64 6f 63 75 6d 65 6e  |.      undocumen|
00002760  74 65 64 20 72 6f 75 74  69 6e 65 73 2c 20 74 6f  |ted routines, to|
00002770  20 70 72 69 6e 74 20 61  20 6c 69 73 74 20 6f 66  | print a list of|
00002780  20 74 68 65 20 68 65 61  64 65 72 73 20 66 72 6f  | the headers fro|
00002790  6d 0d 20 20 20 20 20 20  74 68 65 20 73 69 64 65  |m.      the side|
000027a0  77 61 79 73 20 52 4f 4d  73 20 69 6e 20 79 6f 75  |ways ROMs in you|
000027b0  72 20 6d 61 63 68 69 6e  65 2e 20 20 49 74 20 69  |r machine.  It i|
000027c0  73 20 74 68 65 20 66 69  72 73 74 20 73 65 6c 66  |s the first self|
000027d0  2d 0d 20 20 20 20 20 20  63 6f 6e 74 61 69 6e 65  |-.      containe|
000027e0  64 20 72 6f 75 74 69 6e  65 20 69 6e 20 4f 53 42  |d routine in OSB|
000027f0  49 54 53 20 73 6f 20 66  61 72 2c 20 61 6e 64 20  |ITS so far, and |
00002800  77 69 6c 6c 20 62 65 20  75 73 65 66 75 6c 20 74  |will be useful t|
00002810  6f 0d 20 20 20 20 20 20  61 6e 79 6f 6e 65 20 77  |o.      anyone w|
00002820  69 74 68 6f 75 74 20 61  20 31 37 37 30 20 44 46  |ithout a 1770 DF|
00002830  53 20 28 77 68 69 63 68  20 68 61 73 20 6f 6e 65  |S (which has one|
00002840  20 62 75 69 6c 74 20 69  6e 29 2e 0d 0d 0d 50 61  | built in)....Pa|
00002850  72 74 20 31 30 3a 20 4f  70 63 6f 64 65 73 20 61  |rt 10: Opcodes a|
00002860  6e 64 20 45 72 72 6f 72  20 4d 65 73 73 61 67 65  |nd Error Message|
00002870  73 0d 0d 20 20 20 20 20  20 4d 6f 73 74 20 6f 66  |s..      Most of|
00002880  20 74 68 65 20 69 6e 73  74 72 75 63 74 69 6f 6e  | the instruction|
00002890  73 20 61 76 61 69 6c 61  62 6c 65 20 69 6e 20 61  |s available in a|
000028a0  20 36 35 30 32 20 6d 69  63 72 6f 70 72 6f 63 65  | 6502 microproce|
000028b0  73 73 6f 72 0d 20 20 20  20 20 20 68 61 76 65 20  |ssor.      have |
000028c0  6e 6f 77 20 62 65 65 6e  20 63 6f 76 65 72 65 64  |now been covered|
000028d0  2e 20 20 54 68 65 73 65  20 69 6e 73 74 72 75 63  |.  These instruc|
000028e0  74 69 6f 6e 73 20 61 72  65 20 6b 6e 6f 77 6e 20  |tions are known |
000028f0  61 73 0d 20 20 20 20 20  20 6f 70 63 6f 64 65 73  |as.      opcodes|
00002900  2c 20 61 6e 64 20 74 68  65 20 74 65 78 74 20 66  |, and the text f|
00002910  69 6c 65 20 69 6e 20 74  68 69 73 20 6d 6f 64 75  |ile in this modu|
00002920  6c 65 20 6c 69 73 74 73  20 74 68 65 6d 20 66 6f  |le lists them fo|
00002930  72 0d 20 20 20 20 20 20  72 65 66 65 72 65 6e 63  |r.      referenc|
00002940  65 2e 20 20 49 74 20 67  6f 65 73 20 6f 6e 20 74  |e.  It goes on t|
00002950  6f 20 65 78 70 6c 61 69  6e 20 68 6f 77 20 74 6f  |o explain how to|
00002960  20 75 73 65 20 74 68 65  20 64 65 66 61 75 6c 74  | use the default|
00002970  0d 20 20 20 20 20 20 65  72 72 6f 72 20 72 65 70  |.      error rep|
00002980  6f 72 74 69 6e 67 20 72  6f 75 74 69 6e 65 20 77  |orting routine w|
00002990  68 69 63 68 20 69 73 20  63 6f 6d 6d 6f 6e 20 74  |hich is common t|
000029a0  6f 20 6d 61 6e 79 20 6c  61 6e 67 75 61 67 65 73  |o many languages|
000029b0  2c 0d 20 20 20 20 20 20  69 6e 63 6c 75 64 69 6e  |,.      includin|
000029c0  67 20 42 41 53 49 43 2e  20 20 54 68 69 73 20 72  |g BASIC.  This r|
000029d0  6f 75 74 69 6e 65 20 6d  61 6b 65 73 20 65 72 72  |outine makes err|
000029e0  6f 72 20 74 72 61 70 70  69 6e 67 20 73 69 6d 70  |or trapping simp|
000029f0  6c 65 2e 20 0d 20 20 20  20 20 20 41 66 74 65 72  |le. .      After|
00002a00  20 61 20 42 52 4b 20 69  6e 73 74 72 75 63 74 69  | a BRK instructi|
00002a10  6f 6e 20 69 73 20 64 65  74 65 63 74 65 64 20 69  |on is detected i|
00002a20  6e 20 79 6f 75 72 20 6d  61 63 68 69 6e 65 20 63  |n your machine c|
00002a30  6f 64 65 2c 0d 20 20 20  20 20 20 74 68 65 20 6d  |ode,.      the m|
00002a40  69 63 72 6f 20 77 69 6c  6c 20 61 75 74 6f 6d 61  |icro will automa|
00002a50  74 69 63 61 6c 6c 79 20  65 6e 74 65 72 20 74 68  |tically enter th|
00002a60  65 20 72 6f 75 74 69 6e  65 2e 20 20 54 68 65 20  |e routine.  The |
00002a70  42 52 4b 20 69 73 0d 20  20 20 20 20 20 66 6f 6c  |BRK is.      fol|
00002a80  6c 6f 77 65 64 20 62 79  20 61 20 62 79 74 65 20  |lowed by a byte |
00002a90  77 68 69 63 68 20 68 6f  6c 64 73 20 74 68 65 20  |which holds the |
00002aa0  65 72 72 6f 72 20 6e 75  6d 62 65 72 2c 20 61 6e  |error number, an|
00002ab0  64 20 74 68 65 6e 20 61  0d 20 20 20 20 20 20 73  |d then a.      s|
00002ac0  74 72 69 6e 67 20 77 68  69 63 68 20 77 69 6c 6c  |tring which will|
00002ad0  20 62 65 20 70 72 69 6e  74 65 64 20 61 73 20 74  | be printed as t|
00002ae0  68 65 20 65 72 72 6f 72  20 6d 65 73 73 61 67 65  |he error message|
00002af0  2e 0d 0d 20 20 20 20 20  20 54 68 65 20 61 73 73  |...      The ass|
00002b00  65 6d 62 6c 65 72 20 72  6f 75 74 69 6e 65 20 69  |embler routine i|
00002b10  73 20 61 20 73 6d 61 6c  6c 20 6f 6e 65 20 77 68  |s a small one wh|
00002b20  69 63 68 20 69 6c 6c 75  73 74 72 61 74 65 73 20  |ich illustrates |
00002b30  65 72 72 6f 72 0d 20 20  20 20 20 20 68 61 6e 64  |error.      hand|
00002b40  6c 69 6e 67 2c 20 73 6f  6d 65 74 68 69 6e 67 20  |ling, something |
00002b50  77 65 20 77 69 6c 6c 20  6e 65 65 64 20 69 6e 20  |we will need in |
00002b60  66 75 74 75 72 65 20 6d  6f 64 75 6c 65 73 2e 20  |future modules. |
00002b70  20 59 6f 75 0d 20 20 20  20 20 20 70 72 65 73 73  | You.      press|
00002b80  20 61 20 6b 65 79 2c 20  61 6e 64 20 69 66 20 79  | a key, and if y|
00002b90  6f 75 20 68 61 76 65 20  70 72 65 73 73 65 64 20  |ou have pressed |
00002ba0  61 20 6e 75 6d 62 65 72  20 28 30 2d 39 29 2c 20  |a number (0-9), |
00002bb0  74 68 65 0d 20 20 20 20  20 20 72 6f 75 74 69 6e  |the.      routin|
00002bc0  65 20 6c 6f 6f 70 73 2c  20 62 75 74 20 69 66 20  |e loops, but if |
00002bd0  69 74 20 77 61 73 20 61  6e 79 74 68 69 6e 67 20  |it was anything |
00002be0  65 6c 73 65 2c 20 61 6e  20 65 72 72 6f 72 20 69  |else, an error i|
00002bf0  73 0d 20 20 20 20 20 20  67 65 6e 65 72 61 74 65  |s.      generate|
00002c00  64 20 61 6e 64 20 61 20  6d 65 73 73 61 67 65 20  |d and a message |
00002c10  69 73 20 70 72 69 6e 74  65 64 20 6f 75 74 2e 20  |is printed out. |
00002c20  20 49 20 68 61 76 65 20  69 6e 63 6c 75 64 65 64  | I have included|
00002c30  20 61 0d 20 20 20 20 20  20 73 70 65 63 69 61 6c  | a.      special|
00002c40  20 62 69 74 20 6f 66 20  63 6f 64 65 20 74 68 61  | bit of code tha|
00002c50  74 20 64 65 61 6c 73 20  77 69 74 68 20 61 6e 20  |t deals with an |
00002c60  45 73 63 61 70 65 20 69  6e 20 61 20 64 69 66 66  |Escape in a diff|
00002c70  65 72 65 6e 74 0d 20 20  20 20 20 20 77 61 79 20  |erent.      way |
00002c80  74 6f 20 74 68 65 20 73  74 61 6e 64 61 72 64 20  |to the standard |
00002c90  45 73 63 61 70 65 20 62  79 20 70 72 69 6e 74 69  |Escape by printi|
00002ca0  6e 67 20 61 20 64 69 66  66 65 72 65 6e 74 20 6d  |ng a different m|
00002cb0  65 73 73 61 67 65 2e 0d  0d 0d 50 61 72 74 20 31  |essage....Part 1|
00002cc0  31 3a 20 49 6e 70 75 74  74 69 6e 67 20 4e 75 6d  |1: Inputting Num|
00002cd0  62 65 72 73 0d 0d 20 20  20 20 20 20 54 68 65 20  |bers..      The |
00002ce0  6e 65 78 74 20 66 69 76  65 20 6d 6f 64 75 6c 65  |next five module|
00002cf0  73 20 77 69 6c 6c 20 63  6f 76 65 72 20 74 77 6f  |s will cover two|
00002d00  20 61 72 65 61 73 2e 20  20 54 68 65 79 20 61 72  | areas.  They ar|
00002d10  65 0d 20 20 20 20 20 20  63 6f 6e 76 65 72 74 69  |e.      converti|
00002d20  6e 67 20 41 53 43 49 49  20 63 68 61 72 61 63 74  |ng ASCII charact|
00002d30  65 72 73 2c 20 72 65 70  72 65 73 65 6e 74 69 6e  |ers, representin|
00002d40  67 20 6e 75 6d 62 65 72  73 2c 20 69 6e 74 6f 0d  |g numbers, into.|
00002d50  20 20 20 20 20 20 6e 75  6d 62 65 72 73 20 69 6e  |      numbers in|
00002d60  20 6d 65 6d 6f 72 79 20  28 69 6e 70 75 74 29 2c  | memory (input),|
00002d70  20 61 6e 64 20 76 69 63  65 20 76 65 72 73 61 20  | and vice versa |
00002d80  28 6f 75 74 70 75 74 29  2c 20 61 6e 64 20 74 68  |(output), and th|
00002d90  65 0d 20 20 20 20 20 20  61 72 69 74 68 6d 65 74  |e.      arithmet|
00002da0  69 63 61 6c 20 70 72 6f  63 65 73 73 65 73 20 6f  |ical processes o|
00002db0  66 20 6d 75 6c 74 69 70  6c 69 63 61 74 69 6f 6e  |f multiplication|
00002dc0  20 61 6e 64 20 64 69 76  69 73 69 6f 6e 2e 20 0d  | and division. .|
00002dd0  20 20 20 20 20 20 53 69  6e 63 65 20 69 6e 70 75  |      Since inpu|
00002de0  74 74 69 6e 67 20 61 6e  64 20 6d 75 6c 74 69 70  |tting and multip|
00002df0  6c 69 63 61 74 69 6f 6e  20 61 72 65 20 63 6f 6e  |lication are con|
00002e00  6e 65 63 74 65 64 20 74  68 65 79 20 77 69 6c 6c  |nected they will|
00002e10  0d 20 20 20 20 20 20 63  6f 6d 65 20 66 69 72 73  |.      come firs|
00002e20  74 2e 0d 0d 20 20 20 20  20 20 49 6e 70 75 74 20  |t...      Input |
00002e30  74 6f 20 61 20 6d 69 63  72 6f 20 69 73 20 6f 66  |to a micro is of|
00002e40  74 65 6e 20 69 6e 20 74  68 65 20 66 6f 72 6d 20  |ten in the form |
00002e50  6f 66 20 73 74 72 69 6e  67 73 20 6f 72 0d 20 20  |of strings or.  |
00002e60  20 20 20 20 6e 75 6d 62  65 72 73 20 66 72 6f 6d  |    numbers from|
00002e70  20 74 68 65 20 6b 65 79  62 6f 61 72 64 2e 20 20  | the keyboard.  |
00002e80  41 6e 79 20 6e 75 6d 62  65 72 73 20 74 68 61 74  |Any numbers that|
00002e90  20 61 72 65 20 74 79 70  65 64 20 69 6e 0d 20 20  | are typed in.  |
00002ea0  20 20 20 20 77 69 6c 6c  20 62 65 20 69 6e 20 74  |    will be in t|
00002eb0  68 65 20 66 6f 72 6d 20  6f 66 20 73 74 72 69 6e  |he form of strin|
00002ec0  67 73 2c 20 61 6e 64 20  6d 75 73 74 20 62 65 20  |gs, and must be |
00002ed0  63 6f 6e 76 65 72 74 65  64 20 69 6e 74 6f 0d 20  |converted into. |
00002ee0  20 20 20 20 20 62 69 6e  61 72 79 20 6e 75 6d 62  |     binary numb|
00002ef0  65 72 73 20 69 6e 20 6d  65 6d 6f 72 79 2e 20 20  |ers in memory.  |
00002f00  49 6e 70 75 74 20 69 6e  20 63 6f 6d 70 6c 69 63  |Input in complic|
00002f10  61 74 65 64 20 62 79 20  74 68 65 20 6e 65 65 64  |ated by the need|
00002f20  0d 20 20 20 20 20 20 74  6f 20 61 6c 6c 6f 77 20  |.      to allow |
00002f30  66 6f 72 20 61 6e 79 20  65 72 72 6f 72 73 20 77  |for any errors w|
00002f40  68 69 63 68 20 63 6f 75  6c 64 20 6f 63 63 75 72  |hich could occur|
00002f50  20 62 65 63 61 75 73 65  20 6f 66 0d 20 20 20 20  | because of.    |
00002f60  20 20 6d 69 73 74 61 6b  65 73 2c 20 6f 72 20 6d  |  mistakes, or m|
00002f70  61 6c 69 63 65 2c 20 77  68 65 6e 20 73 6f 6d 65  |alice, when some|
00002f80  6f 6e 65 20 69 73 20 65  6e 74 65 72 69 6e 67 20  |one is entering |
00002f90  74 68 65 20 64 61 74 61  2e 0d 0d 20 20 20 20 20  |the data...     |
00002fa0  20 54 68 65 20 74 65 78  74 20 66 69 6c 65 20 65  | The text file e|
00002fb0  78 70 6c 61 69 6e 73 20  68 6f 77 20 74 68 65 20  |xplains how the |
00002fc0  70 72 6f 67 72 61 6d 20  6f 70 65 72 61 74 65 73  |program operates|
00002fd0  20 61 6e 64 20 65 78 70  6c 61 69 6e 73 0d 20 20  | and explains.  |
00002fe0  20 20 20 20 77 68 79 20  77 65 20 77 72 6f 74 65  |    why we wrote|
00002ff0  20 61 20 6e 65 77 20 72  6f 75 74 69 6e 65 20 72  | a new routine r|
00003000  61 74 68 65 72 20 74 68  61 6e 20 75 73 69 6e 67  |ather than using|
00003010  20 61 6e 20 61 76 61 69  6c 61 62 6c 65 0d 20 20  | an available.  |
00003020  20 20 20 20 6f 70 65 72  61 74 69 6e 67 20 73 79  |    operating sy|
00003030  73 74 65 6d 20 63 61 6c  6c 2e 20 20 54 68 65 20  |stem call.  The |
00003040  70 72 6f 67 72 61 6d 20  69 74 73 65 6c 66 2c 20  |program itself, |
00003050  42 2f 6f 73 62 31 30 2c  20 69 6e 70 75 74 73 0d  |B/osb10, inputs.|
00003060  20 20 20 20 20 20 63 68  61 72 61 63 74 65 72 73  |      characters|
00003070  20 75 73 69 6e 67 20 4f  53 52 44 43 48 2c 20 6c  | using OSRDCH, l|
00003080  6f 6f 6b 69 6e 67 20 66  6f 72 20 61 20 43 61 72  |ooking for a Car|
00003090  72 69 61 67 65 20 52 65  74 75 72 6e 20 77 68 69  |riage Return whi|
000030a0  63 68 0d 20 20 20 20 20  20 74 65 72 6d 69 6e 61  |ch.      termina|
000030b0  74 65 73 20 69 6e 70 75  74 2c 20 61 20 44 65 6c  |tes input, a Del|
000030c0  65 74 65 20 77 68 69 63  68 20 72 65 6d 6f 76 65  |ete which remove|
000030d0  73 20 74 68 65 20 6c 61  73 74 20 63 68 61 72 61  |s the last chara|
000030e0  63 74 65 72 2c 0d 20 20  20 20 20 20 61 6e 64 20  |cter,.      and |
000030f0  63 68 65 63 6b 69 6e 67  20 61 6e 79 74 68 69 6e  |checking anythin|
00003100  67 20 65 6c 73 65 20 61  67 61 69 6e 73 74 20 61  |g else against a|
00003110  20 6c 69 73 74 20 6f 66  20 76 61 6c 69 64 0d 20  | list of valid. |
00003120  20 20 20 20 20 63 68 61  72 61 63 74 65 72 73 20  |     characters |
00003130  28 74 68 65 20 6e 75 6d  62 65 72 73 20 30 20 74  |(the numbers 0 t|
00003140  6f 20 39 29 2e 20 20 54  68 65 73 65 20 61 72 65  |o 9).  These are|
00003150  20 61 64 64 65 64 20 74  6f 20 61 0d 20 20 20 20  | added to a.    |
00003160  20 20 73 74 72 69 6e 67  20 28 6f 66 20 64 65 66  |  string (of def|
00003170  69 6e 65 64 20 6d 61 78  69 6d 75 6d 20 6c 65 6e  |ined maximum len|
00003180  67 74 68 29 20 61 6e 64  20 6f 75 74 70 75 74 20  |gth) and output |
00003190  74 6f 20 74 68 65 20 73  63 72 65 65 6e 2e 0d 0d  |to the screen...|
000031a0  0d 50 61 72 74 20 31 32  3a 20 41 53 43 49 49 20  |.Part 12: ASCII |
000031b0  74 6f 20 42 69 6e 61 72  79 20 43 6f 6e 76 65 72  |to Binary Conver|
000031c0  73 69 6f 6e 0d 0d 20 20  20 20 20 20 57 65 20 67  |sion..      We g|
000031d0  65 74 20 73 6f 20 75 73  65 64 20 74 6f 20 65 6e  |et so used to en|
000031e0  74 65 72 69 6e 67 20 6e  75 6d 62 65 72 73 20 69  |tering numbers i|
000031f0  6e 74 6f 20 61 20 63 6f  6d 70 75 74 65 72 20 74  |nto a computer t|
00003200  68 61 74 20 77 65 0d 20  20 20 20 20 20 63 61 6e  |hat we.      can|
00003210  20 66 6f 72 67 65 74 20  74 68 61 74 20 74 68 65  | forget that the|
00003220  79 20 61 72 65 20 6e 6f  74 20 69 6e 20 74 68 65  |y are not in the|
00003230  20 72 69 67 68 74 20 66  6f 72 6d 61 74 2e 20 20  | right format.  |
00003240  54 68 65 20 6b 65 79 73  0d 20 20 20 20 20 20 77  |The keys.      w|
00003250  65 20 70 72 65 73 73 20  70 75 74 20 74 68 65 20  |e press put the |
00003260  41 53 43 49 49 20 76 61  6c 75 65 20 6f 66 20 74  |ASCII value of t|
00003270  68 65 20 70 61 72 74 69  63 75 6c 61 72 20 64 69  |he particular di|
00003280  67 69 74 20 77 65 20 74  79 70 65 0d 20 20 20 20  |git we type.    |
00003290  20 20 69 6e 74 6f 20 74  68 65 20 6d 69 63 72 6f  |  into the micro|
000032a0  20 72 61 74 68 65 72 20  74 68 61 6e 20 74 68 65  | rather than the|
000032b0  20 6e 75 6d 62 65 72 20  69 74 73 65 6c 66 2e 20  | number itself. |
000032c0  20 53 6f 6d 65 20 73 6f  72 74 20 6f 66 0d 20 20  | Some sort of.  |
000032d0  20 20 20 20 63 6f 6e 76  65 72 73 69 6f 6e 20 70  |    conversion p|
000032e0  72 6f 67 72 61 6d 20 69  73 20 6e 65 65 64 65 64  |rogram is needed|
000032f0  20 74 6f 20 74 61 6b 65  20 61 20 73 74 72 69 6e  | to take a strin|
00003300  67 20 6f 66 20 41 53 43  49 49 0d 20 20 20 20 20  |g of ASCII.     |
00003310  20 63 68 61 72 61 63 74  65 72 73 20 74 68 61 74  | characters that|
00003320  20 72 65 70 72 65 73 65  6e 74 20 61 20 6e 75 6d  | represent a num|
00003330  62 65 72 2c 20 61 6e 64  20 63 6f 6e 76 65 72 74  |ber, and convert|
00003340  20 74 68 65 6d 20 69 6e  74 6f 20 61 0d 20 20 20  | them into a.   |
00003350  20 20 20 62 69 6e 61 72  79 20 6e 75 6d 62 65 72  |   binary number|
00003360  20 69 6e 20 6d 65 6d 6f  72 79 20 6f 6e 20 77 68  | in memory on wh|
00003370  69 63 68 20 74 68 65 20  70 72 6f 67 72 61 6d 20  |ich the program |
00003380  63 61 6e 20 77 6f 72 6b  2e 0d 0d 20 20 20 20 20  |can work...     |
00003390  20 54 68 65 20 70 72 6f  67 72 61 6d 20 42 2f 6f  | The program B/o|
000033a0  73 62 31 32 20 69 6e 20  74 68 69 73 20 6d 6f 64  |sb12 in this mod|
000033b0  75 6c 65 20 75 73 65 73  20 61 20 73 6c 69 67 68  |ule uses a sligh|
000033c0  74 6c 79 20 6d 6f 64 69  66 69 65 64 0d 20 20 20  |tly modified.   |
000033d0  20 20 20 76 65 72 73 69  6f 6e 20 6f 66 20 74 68  |   version of th|
000033e0  65 20 69 6e 70 75 74 20  73 75 62 72 6f 75 74 69  |e input subrouti|
000033f0  6e 65 20 66 72 6f 6d 20  6d 6f 64 75 6c 65 20 31  |ne from module 1|
00003400  31 20 74 6f 20 65 6e 74  65 72 20 61 0d 20 20 20  |1 to enter a.   |
00003410  20 20 20 73 74 72 69 6e  67 20 72 65 70 72 65 73  |   string repres|
00003420  65 6e 74 69 6e 67 20 61  20 73 69 67 6e 65 64 20  |enting a signed |
00003430  64 65 63 69 6d 61 6c 20  6e 75 6d 62 65 72 2e 20  |decimal number. |
00003440  20 54 68 69 73 20 69 73  20 74 68 65 6e 0d 20 20  | This is then.  |
00003450  20 20 20 20 63 6f 6e 76  65 72 74 65 64 20 69 6e  |    converted in|
00003460  74 6f 20 61 20 66 6f 75  72 2d 62 79 74 65 20 62  |to a four-byte b|
00003470  69 6e 61 72 79 20 69 6e  74 65 67 65 72 20 77 68  |inary integer wh|
00003480  69 63 68 20 69 73 20 73  74 6f 72 65 64 2c 0d 20  |ich is stored,. |
00003490  20 20 20 20 20 61 6e 64  20 74 68 65 6e 20 70 72  |     and then pr|
000034a0  69 6e 74 65 64 20 69 6e  20 64 65 63 69 6d 61 6c  |inted in decimal|
000034b0  20 61 6e 64 20 68 65 78  2e 20 20 41 6e 20 69 6d  | and hex.  An im|
000034c0  70 6f 72 74 61 6e 74 20  70 61 72 74 20 6f 66 0d  |portant part of.|
000034d0  20 20 20 20 20 20 74 68  65 20 70 72 6f 67 72 61  |      the progra|
000034e0  6d 20 69 73 20 74 68 65  20 73 75 62 72 6f 75 74  |m is the subrout|
000034f0  69 6e 65 20 66 6f 72 20  6d 75 6c 74 69 70 6c 79  |ine for multiply|
00003500  69 6e 67 20 74 68 65 20  72 75 6e 6e 69 6e 67 0d  |ing the running.|
00003510  20 20 20 20 20 20 74 6f  74 61 6c 20 62 79 20 31  |      total by 1|
00003520  30 2e 20 20 54 68 69 73  2c 20 61 6e 64 20 6d 75  |0.  This, and mu|
00003530  6c 74 69 70 6c 69 63 61  74 69 6f 6e 20 69 6e 20  |ltiplication in |
00003540  67 65 6e 65 72 61 6c 2c  20 69 73 0d 20 20 20 20  |general, is.    |
00003550  20 20 65 78 70 6c 61 69  6e 65 64 20 69 6e 20 74  |  explained in t|
00003560  68 65 20 74 65 78 74 20  66 69 6c 65 2e 20 20 49  |he text file.  I|
00003570  6e 20 74 68 65 20 6e 65  78 74 20 6d 6f 64 75 6c  |n the next modul|
00003580  65 20 77 65 20 77 69 6c  6c 0d 20 20 20 20 20 20  |e we will.      |
00003590  65 78 70 61 6e 64 20 6f  6e 20 74 68 69 73 20 77  |expand on this w|
000035a0  69 74 68 20 61 20 66 75  6c 6c 20 6d 75 6c 74 69  |ith a full multi|
000035b0  70 6c 69 63 61 74 69 6f  6e 20 72 6f 75 74 69 6e  |plication routin|
000035c0  65 2e 0d 0d 0d 50 61 72  74 20 31 33 3a 20 4d 75  |e....Part 13: Mu|
000035d0  6c 74 69 2d 42 79 74 65  20 4d 75 6c 74 69 70 6c  |lti-Byte Multipl|
000035e0  69 63 61 74 69 6f 6e 0d  0d 20 20 20 20 20 20 49  |ication..      I|
000035f0  74 20 69 73 20 77 6f 72  74 68 20 74 61 6b 69 6e  |t is worth takin|
00003600  67 20 61 20 64 65 74 61  69 6c 65 64 20 6c 6f 6f  |g a detailed loo|
00003610  6b 20 61 74 20 6d 75 6c  74 69 70 6c 69 63 61 74  |k at multiplicat|
00003620  69 6f 6e 20 77 68 65 72  65 0d 20 20 20 20 20 20  |ion where.      |
00003630  74 68 65 20 6e 75 6d 62  65 72 73 20 62 65 69 6e  |the numbers bein|
00003640  67 20 6d 75 6c 74 69 70  6c 69 65 64 20 61 72 65  |g multiplied are|
00003650  20 62 6f 74 68 20 73 65  76 65 72 61 6c 20 62 79  | both several by|
00003660  74 65 73 20 6c 6f 6e 67  2e 20 20 49 0d 20 20 20  |tes long.  I.   |
00003670  20 20 20 68 61 76 65 20  63 61 6c 6c 65 64 20 74  |   have called t|
00003680  68 69 73 20 6d 75 6c 74  69 2d 62 79 74 65 20 61  |his multi-byte a|
00003690  72 69 74 68 6d 65 74 69  63 2c 20 61 6c 74 68 6f  |rithmetic, altho|
000036a0  75 67 68 20 69 74 20 69  73 20 6f 66 74 65 6e 0d  |ugh it is often.|
000036b0  20 20 20 20 20 20 6b 6e  6f 77 6e 20 61 73 20 6d  |      known as m|
000036c0  75 6c 74 69 2d 70 72 65  63 69 73 69 6f 6e 20 61  |ulti-precision a|
000036d0  72 69 74 68 6d 65 74 69  63 2e 0d 0d 20 20 20 20  |rithmetic...    |
000036e0  20 20 54 68 65 20 73 69  6d 70 6c 65 73 74 20 61  |  The simplest a|
000036f0  6c 67 6f 72 69 74 68 6d  20 77 69 74 68 20 77 68  |lgorithm with wh|
00003700  69 63 68 20 74 6f 20 6d  75 6c 74 69 70 6c 79 20  |ich to multiply |
00003710  74 77 6f 20 6e 75 6d 62  65 72 73 20 69 73 0d 20  |two numbers is. |
00003720  20 20 20 20 20 62 61 73  65 64 20 6f 6e 20 6c 6f  |     based on lo|
00003730  6e 67 20 6d 75 6c 74 69  70 6c 69 63 61 74 69 6f  |ng multiplicatio|
00003740  6e 2c 20 62 75 74 20 79  6f 75 20 6f 6e 6c 79 20  |n, but you only |
00003750  6e 65 65 64 20 79 6f 75  72 20 27 6f 6e 65 0d 20  |need your 'one. |
00003760  20 20 20 20 20 74 69 6d  65 73 20 74 61 62 6c 65  |     times table|
00003770  27 20 66 6f 72 20 62 69  6e 61 72 79 2e 20 20 52  |' for binary.  R|
00003780  6f 74 61 74 65 20 74 68  65 20 6d 75 6c 74 69 70  |otate the multip|
00003790  6c 69 63 61 6e 64 20 6c  65 66 74 20 61 73 0d 20  |licand left as. |
000037a0  20 20 20 20 20 79 6f 75  20 72 6f 74 61 74 65 20  |     you rotate |
000037b0  74 68 65 20 6d 75 6c 74  69 70 6c 69 65 72 20 72  |the multiplier r|
000037c0  69 67 68 74 2e 20 20 49  66 20 74 68 65 20 63 61  |ight.  If the ca|
000037d0  72 72 69 65 64 20 62 69  74 20 6f 66 20 74 68 65  |rried bit of the|
000037e0  0d 20 20 20 20 20 20 6d  75 6c 74 69 70 6c 69 65  |.      multiplie|
000037f0  72 20 69 73 20 73 65 74  2c 20 61 64 64 20 74 68  |r is set, add th|
00003800  65 20 72 6f 74 61 74 65  64 20 6d 75 6c 74 69 70  |e rotated multip|
00003810  6c 69 63 61 6e 64 20 74  6f 20 61 20 63 75 72 72  |licand to a curr|
00003820  65 6e 74 0d 20 20 20 20  20 20 72 75 6e 6e 69 6e  |ent.      runnin|
00003830  67 20 74 6f 74 61 6c 2e  20 20 54 68 69 73 20 77  |g total.  This w|
00003840  69 6c 6c 20 66 69 6e 61  6c 6c 79 20 62 65 20 74  |ill finally be t|
00003850  68 65 20 72 65 73 75 6c  74 2e 20 20 54 68 65 20  |he result.  The |
00003860  74 65 78 74 0d 20 20 20  20 20 20 65 78 70 6c 61  |text.      expla|
00003870  69 6e 73 20 74 68 65 20  61 6c 67 6f 72 69 74 68  |ins the algorith|
00003880  6d 20 69 6e 20 64 65 74  61 69 6c 2e 20 20 57 65  |m in detail.  We|
00003890  20 61 72 65 20 69 6e 20  66 61 63 74 20 6c 65 66  | are in fact lef|
000038a0  74 20 77 69 74 68 0d 20  20 20 20 20 20 61 20 70  |t with.      a p|
000038b0  72 6f 62 6c 65 6d 20 69  6e 20 74 68 61 74 20 74  |roblem in that t|
000038c0  77 6f 20 66 6f 75 72 20  62 79 74 65 20 6e 75 6d  |wo four byte num|
000038d0  62 65 72 73 20 6d 75 6c  74 69 70 6c 69 65 64 20  |bers multiplied |
000038e0  74 6f 67 65 74 68 65 72  0d 20 20 20 20 20 20 63  |together.      c|
000038f0  61 6e 20 67 69 76 65 20  61 6e 20 65 69 67 68 74  |an give an eight|
00003900  20 62 79 74 65 20 72 65  73 75 6c 74 21 0d 0d 20  | byte result!.. |
00003910  20 20 20 20 20 54 68 65  20 70 72 6f 67 72 61 6d  |     The program|
00003920  20 42 2f 6f 73 62 31 33  20 64 65 6d 6f 6e 73 74  | B/osb13 demonst|
00003930  72 61 74 65 73 20 74 68  65 20 6d 75 6c 74 69 70  |rates the multip|
00003940  6c 69 63 61 74 69 6f 6e  20 6f 66 20 74 77 6f 0d  |lication of two.|
00003950  20 20 20 20 20 20 66 6f  75 72 2d 62 79 74 65 20  |      four-byte |
00003960  6e 75 6d 62 65 72 73 2e  20 20 52 61 74 68 65 72  |numbers.  Rather|
00003970  20 74 68 61 6e 20 74 68  65 20 69 6e 70 75 74 20  | than the input |
00003980  72 6f 75 74 69 6e 65 20  77 65 20 68 61 76 65 20  |routine we have |
00003990  62 65 65 6e 0d 20 20 20  20 20 20 64 65 76 65 6c  |been.      devel|
000039a0  6f 70 69 6e 67 20 69 6e  20 70 72 65 76 69 6f 75  |oping in previou|
000039b0  73 20 6d 6f 64 75 6c 65  73 2c 20 42 41 53 49 43  |s modules, BASIC|
000039c0  20 68 61 73 20 62 65 65  6e 20 75 73 65 64 20 74  | has been used t|
000039d0  68 69 73 0d 20 20 20 20  20 20 74 69 6d 65 20 66  |his.      time f|
000039e0  6f 72 20 63 6c 61 72 69  74 79 2e 20 20 41 20 73  |or clarity.  A s|
000039f0  6c 69 67 68 74 6c 79 20  6d 6f 64 69 66 69 65 64  |lightly modified|
00003a00  20 76 65 72 73 69 6f 6e  20 6f 66 20 74 68 65 0d  | version of the.|
00003a10  20 20 20 20 20 20 27 72  6f 74 61 74 65 20 61 6e  |      'rotate an|
00003a20  64 20 63 6f 6e 64 69 74  69 6f 6e 61 6c 6c 79 20  |d conditionally |
00003a30  61 64 64 27 20 61 6c 67  6f 72 69 74 68 6d 20 69  |add' algorithm i|
00003a40  73 20 75 73 65 64 20 74  6f 20 6d 75 6c 74 69 70  |s used to multip|
00003a50  6c 79 0d 20 20 20 20 20  20 74 6f 67 65 74 68 65  |ly.      togethe|
00003a60  72 20 74 68 65 20 74 77  6f 20 66 6f 75 72 20 62  |r the two four b|
00003a70  79 74 65 20 6e 75 6d 62  65 72 73 2c 20 61 6e 64  |yte numbers, and|
00003a80  20 74 68 65 20 72 65 73  75 6c 74 20 70 72 69 6e  | the result prin|
00003a90  74 65 64 2e 0d 20 20 20  20 20 20 54 68 65 20 70  |ted..      The p|
00003aa0  72 6f 67 72 61 6d 20 61  6c 73 6f 20 75 73 65 73  |rogram also uses|
00003ab0  20 42 41 53 49 43 20 74  6f 20 63 68 65 63 6b 20  | BASIC to check |
00003ac0  66 6f 72 20 61 20 63 6f  72 72 65 63 74 20 72 65  |for a correct re|
00003ad0  73 75 6c 74 0d 20 20 20  20 20 20 77 68 69 63 68  |sult.      which|
00003ae0  20 61 6c 6c 6f 77 73 20  79 6f 75 20 74 6f 20 65  | allows you to e|
00003af0  78 70 6c 6f 72 65 20 74  68 65 20 6c 69 6d 69 74  |xplore the limit|
00003b00  73 20 6f 66 20 74 68 69  73 20 70 72 6f 67 72 61  |s of this progra|
00003b10  6d 27 73 0d 20 20 20 20  20 20 76 61 6c 69 64 69  |m's.      validi|
00003b20  74 79 2e 0d 0d 0d 50 61  72 74 20 31 34 3a 20 42  |ty....Part 14: B|
00003b30  69 6e 61 72 79 20 74 6f  20 41 53 43 49 49 20 43  |inary to ASCII C|
00003b40  6f 6e 76 65 72 73 69 6f  6e 0d 0d 20 20 20 20 20  |onversion..     |
00003b50  20 54 68 69 73 20 6d 6f  64 75 6c 65 20 62 72 69  | This module bri|
00003b60  6e 67 73 20 75 73 20 61  72 6f 75 6e 64 20 74 6f  |ngs us around to|
00003b70  20 64 69 76 69 73 69 6f  6e 2c 20 61 6e 64 20 49  | division, and I|
00003b80  27 6c 6c 20 69 6e 74 72  6f 64 75 63 65 0d 20 20  |'ll introduce.  |
00003b90  20 20 20 20 69 74 20 62  79 20 77 61 79 20 6f 66  |    it by way of|
00003ba0  20 61 20 72 6f 75 74 69  6e 65 20 74 6f 20 74 61  | a routine to ta|
00003bb0  6b 65 20 61 20 34 20 62  79 74 65 20 6e 75 6d 62  |ke a 4 byte numb|
00003bc0  65 72 20 69 6e 20 6d 65  6d 6f 72 79 20 61 6e 64  |er in memory and|
00003bd0  0d 20 20 20 20 20 20 70  72 69 6e 74 20 6f 75 74  |.      print out|
00003be0  20 69 74 27 73 20 76 61  6c 75 65 20 61 73 20 61  | it's value as a|
00003bf0  20 64 65 63 69 6d 61 6c  20 6e 75 6d 62 65 72 20  | decimal number |
00003c00  69 6e 20 41 53 43 49 49  2e 0d 0d 20 20 20 20 20  |in ASCII...     |
00003c10  20 55 6e 6c 69 6b 65 20  69 6e 70 75 74 2c 20 77  | Unlike input, w|
00003c20  65 20 68 61 76 65 20 6e  6f 20 65 72 72 6f 72 20  |e have no error |
00003c30  63 6f 6e 64 69 74 69 6f  6e 73 20 74 6f 20 77 6f  |conditions to wo|
00003c40  72 72 79 20 61 62 6f 75  74 0d 20 20 20 20 20 20  |rry about.      |
00003c50  73 69 6e 63 65 20 74 68  65 72 65 20 61 72 65 20  |since there are |
00003c60  6f 6e 6c 79 20 66 6f 75  72 20 62 79 74 65 73 20  |only four bytes |
00003c70  28 74 68 65 20 72 6f 75  74 69 6e 65 20 63 61 6e  |(the routine can|
00003c80  20 62 65 20 65 78 70 61  6e 64 65 64 0d 20 20 20  | be expanded.   |
00003c90  20 20 20 61 73 20 72 65  71 75 69 72 65 64 29 2c  |   as required),|
00003ca0  20 61 6e 64 20 74 68 65  20 6e 75 6d 62 65 72 20  | and the number |
00003cb0  63 61 6e 20 62 65 20 65  69 74 68 65 72 20 70 6f  |can be either po|
00003cc0  73 69 74 69 76 65 20 6f  72 20 32 27 73 0d 20 20  |sitive or 2's.  |
00003cd0  20 20 20 20 63 6f 6d 70  6c 65 6d 65 6e 74 20 6e  |    complement n|
00003ce0  65 67 61 74 69 76 65 2e  20 20 46 6f 72 20 61 20  |egative.  For a |
00003cf0  6e 65 67 61 74 69 76 65  20 6e 75 6d 62 65 72 20  |negative number |
00003d00  61 20 73 69 67 6e 20 66  6c 61 67 20 69 73 0d 20  |a sign flag is. |
00003d10  20 20 20 20 20 73 65 74  2c 20 61 6e 64 20 74 68  |     set, and th|
00003d20  65 20 6e 75 6d 62 65 72  20 73 75 62 74 72 61 63  |e number subtrac|
00003d30  74 65 64 20 66 72 6f 6d  20 7a 65 72 6f 20 62 65  |ted from zero be|
00003d40  66 6f 72 65 20 70 72 69  6e 74 69 6e 67 2e 0d 0d  |fore printing...|
00003d50  20 20 20 20 20 20 54 6f  20 63 6f 6e 76 65 72 74  |      To convert|
00003d60  20 61 20 6e 75 6d 62 65  72 20 69 6e 20 6d 65 6d  | a number in mem|
00003d70  6f 72 79 20 69 6e 74 6f  20 61 20 73 74 72 69 6e  |ory into a strin|
00003d80  67 2c 20 79 6f 75 20 68  61 76 65 20 74 6f 0d 20  |g, you have to. |
00003d90  20 20 20 20 20 66 69 6e  64 20 6f 75 74 20 68 6f  |     find out ho|
00003da0  77 20 6d 61 6e 79 20 75  6e 69 74 73 2c 20 31 30  |w many units, 10|
00003db0  73 2c 20 31 30 30 73 20  65 74 63 2e 20 74 68 65  |s, 100s etc. the|
00003dc0  72 65 20 61 72 65 2e 20  20 46 69 72 73 74 0d 20  |re are.  First. |
00003dd0  20 20 20 20 20 64 69 76  69 64 65 20 62 79 20 31  |     divide by 1|
00003de0  30 2c 20 74 68 65 20 72  65 6d 61 69 6e 64 65 72  |0, the remainder|
00003df0  20 69 73 20 74 68 65 20  6e 75 6d 62 65 72 20 6f  | is the number o|
00003e00  66 20 75 6e 69 74 73 2e  20 20 54 68 65 6e 0d 20  |f units.  Then. |
00003e10  20 20 20 20 20 64 69 76  69 64 65 20 74 68 65 20  |     divide the |
00003e20  71 75 6f 74 69 65 6e 74  20 62 79 20 31 30 2c 20  |quotient by 10, |
00003e30  74 68 65 20 72 65 6d 61  69 6e 64 65 72 20 69 73  |the remainder is|
00003e40  20 74 68 65 20 6e 75 6d  62 65 72 20 6f 66 0d 20  | the number of. |
00003e50  20 20 20 20 20 31 30 73  20 2e 2e 2e 20 61 6e 64  |     10s ... and|
00003e60  20 73 6f 20 6f 6e 2e 20  20 41 64 64 69 6e 67 20  | so on.  Adding |
00003e70  34 38 20 74 6f 20 61 20  6e 75 6d 62 65 72 20 62  |48 to a number b|
00003e80  65 74 77 65 65 6e 20 30  20 61 6e 64 20 39 0d 20  |etween 0 and 9. |
00003e90  20 20 20 20 20 67 69 76  65 73 20 69 74 73 20 41  |     gives its A|
00003ea0  53 43 49 49 20 65 71 75  69 76 61 6c 65 6e 74 2e  |SCII equivalent.|
00003eb0  0d 0d 20 20 20 20 20 20  54 68 65 20 75 73 65 20  |..      The use |
00003ec0  6f 66 20 64 69 76 69 73  69 6f 6e 20 69 6e 20 61  |of division in a|
00003ed0  20 63 6f 6e 76 65 72 73  69 6f 6e 20 70 72 6f 67  | conversion prog|
00003ee0  72 61 6d 20 6f 66 20 74  68 69 73 20 74 79 70 65  |ram of this type|
00003ef0  0d 20 20 20 20 20 20 70  72 6f 76 69 64 65 73 20  |.      provides |
00003f00  61 6e 20 69 6e 74 72 6f  64 75 63 74 69 6f 6e 20  |an introduction |
00003f10  74 6f 20 62 69 6e 61 72  79 20 64 69 76 69 73 69  |to binary divisi|
00003f20  6f 6e 2e 20 20 54 68 69  73 20 77 69 6c 6c 20 62  |on.  This will b|
00003f30  65 0d 20 20 20 20 20 20  66 6f 6c 6c 6f 77 65 64  |e.      followed|
00003f40  20 75 70 20 69 6e 20 74  68 65 20 6e 65 78 74 20  | up in the next |
00003f50  6d 6f 64 75 6c 65 20 62  79 20 61 20 67 65 6e 65  |module by a gene|
00003f60  72 61 6c 20 72 6f 75 74  69 6e 65 20 66 6f 72 0d  |ral routine for.|
00003f70  20 20 20 20 20 20 64 69  76 69 73 69 6f 6e 2e 0d  |      division..|
00003f80  0d 0d 50 61 72 74 20 31  35 3a 20 4d 75 6c 74 69  |..Part 15: Multi|
00003f90  2d 62 79 74 65 20 44 69  76 69 73 69 6f 6e 0d 0d  |-byte Division..|
00003fa0  20 20 20 20 20 20 54 68  69 73 20 6d 6f 64 75 6c  |      This modul|
00003fb0  65 20 63 6f 6e 74 61 69  6e 73 20 61 20 73 69 6d  |e contains a sim|
00003fc0  70 6c 65 20 6d 75 6c 74  69 2d 62 79 74 65 20 64  |ple multi-byte d|
00003fd0  69 76 69 73 69 6f 6e 20  72 6f 75 74 69 6e 65 0d  |ivision routine.|
00003fe0  20 20 20 20 20 20 77 68  69 63 68 20 77 6f 72 6b  |      which work|
00003ff0  73 20 61 6c 6d 6f 73 74  20 65 78 61 63 74 6c 79  |s almost exactly|
00004000  20 6c 69 6b 65 20 74 68  65 20 6c 6f 6e 67 20 64  | like the long d|
00004010  69 76 69 73 69 6f 6e 20  65 78 61 6d 70 6c 65 0d  |ivision example.|
00004020  20 20 20 20 20 20 67 69  76 65 6e 20 6c 61 73 74  |      given last|
00004030  20 74 69 6d 65 2e 20 20  54 68 65 20 6f 6e 6c 79  | time.  The only|
00004040  20 64 69 66 66 65 72 65  6e 63 65 20 69 73 20 74  | difference is t|
00004050  68 61 74 20 74 68 69 73  20 74 69 6d 65 0d 20 20  |hat this time.  |
00004060  20 20 20 20 74 68 65 20  64 69 76 69 73 6f 72 20  |    the divisor |
00004070  63 61 6e 20 62 65 20 33  32 20 62 69 74 73 20 6c  |can be 32 bits l|
00004080  6f 6e 67 2e 0d 0d 20 20  20 20 20 20 4d 61 63 68  |ong...      Mach|
00004090  69 6e 65 20 63 6f 64 65  20 64 69 76 69 73 69 6f  |ine code divisio|
000040a0  6e 20 69 73 20 73 69 6d  69 6c 61 72 20 74 6f 20  |n is similar to |
000040b0  64 65 63 69 6d 61 6c 20  6c 6f 6e 67 20 64 69 76  |decimal long div|
000040c0  69 73 69 6f 6e 2e 20 0d  20 20 20 20 20 20 54 68  |ision. .      Th|
000040d0  65 20 64 69 76 69 64 65  6e 64 20 69 73 20 72 6f  |e dividend is ro|
000040e0  74 61 74 65 64 20 6f 75  74 20 6c 65 66 74 20 75  |tated out left u|
000040f0  6e 74 69 6c 20 61 20 6e  75 6d 62 65 72 20 6c 61  |ntil a number la|
00004100  72 67 65 72 20 74 68 61  6e 0d 20 20 20 20 20 20  |rger than.      |
00004110  74 68 65 20 64 69 76 69  73 6f 72 20 68 61 73 20  |the divisor has |
00004120  62 65 65 6e 20 66 6f 72  6d 65 64 2e 20 20 54 68  |been formed.  Th|
00004130  65 20 64 69 76 69 73 6f  72 20 69 73 20 74 68 65  |e divisor is the|
00004140  6e 20 73 75 62 74 72 61  63 74 65 64 0d 20 20 20  |n subtracted.   |
00004150  20 20 20 66 72 6f 6d 20  74 68 69 73 2e 20 20 4d  |   from this.  M|
00004160  6f 72 65 20 62 69 74 73  20 61 72 65 20 72 6f 74  |ore bits are rot|
00004170  61 74 65 64 20 69 6e 20  61 6e 64 20 74 68 65 20  |ated in and the |
00004180  70 72 6f 63 65 73 73 20  69 73 0d 20 20 20 20 20  |process is.     |
00004190  20 72 65 70 65 61 74 65  64 2e 20 20 46 6f 72 20  | repeated.  For |
000041a0  61 20 72 6f 74 61 74 69  6f 6e 20 77 69 74 68 20  |a rotation with |
000041b0  61 20 73 75 62 74 72 61  63 74 69 6f 6e 2c 20 61  |a subtraction, a|
000041c0  20 31 20 69 73 0d 20 20  20 20 20 20 61 70 70 65  | 1 is.      appe|
000041d0  6e 64 65 64 20 74 6f 20  74 68 65 20 72 65 73 75  |nded to the resu|
000041e0  6c 74 2c 20 6f 74 68 65  72 77 69 73 65 20 61 20  |lt, otherwise a |
000041f0  30 20 69 73 20 61 64 64  65 64 2e 20 20 47 65 6e  |0 is added.  Gen|
00004200  65 72 61 6c 6c 79 2c 0d  20 20 20 20 20 20 6e 65  |erally,.      ne|
00004210  67 61 74 69 76 65 20 6e  75 6d 62 65 72 73 20 64  |gative numbers d|
00004220  6f 20 6e 6f 74 20 70 72  6f 64 75 63 65 20 61 20  |o not produce a |
00004230  63 6f 72 72 65 63 74 20  72 65 73 75 6c 74 20 77  |correct result w|
00004240  69 74 68 20 74 68 69 73  0d 20 20 20 20 20 20 61  |ith this.      a|
00004250  6c 67 6f 72 69 74 68 6d  2e 0d 0d 20 20 20 20 20  |lgorithm...     |
00004260  20 54 68 65 20 74 65 78  74 20 66 69 6c 65 20 69  | The text file i|
00004270  6e 20 74 68 69 73 20 6d  6f 64 75 6c 65 20 73 68  |n this module sh|
00004280  6f 77 73 20 68 6f 77 20  62 69 6e 61 72 79 20 64  |ows how binary d|
00004290  69 76 69 73 69 6f 6e 20  69 73 0d 20 20 20 20 20  |ivision is.     |
000042a0  20 63 61 72 72 69 65 64  20 6f 75 74 20 61 6e 64  | carried out and|
000042b0  20 65 78 70 6c 61 69 6e  73 20 74 68 65 20 61 6c  | explains the al|
000042c0  67 6f 72 69 74 68 6d 20  75 73 65 64 20 69 6e 20  |gorithm used in |
000042d0  74 68 69 73 20 70 72 6f  67 72 61 6d 2e 20 0d 20  |this program. . |
000042e0  20 20 20 20 20 54 68 65  20 70 72 6f 62 6c 65 6d  |     The problem|
000042f0  73 20 6f 66 20 6b 65 65  70 69 6e 67 20 74 72 61  |s of keeping tra|
00004300  63 6b 20 6f 66 20 65 72  72 6f 72 73 2c 20 73 75  |ck of errors, su|
00004310  63 68 20 61 73 20 64 69  76 69 73 69 6f 6e 20 62  |ch as division b|
00004320  79 0d 20 20 20 20 20 20  7a 65 72 6f 20 61 72 65  |y.      zero are|
00004330  20 61 6c 73 6f 20 64 69  73 63 75 73 73 65 64 2e  | also discussed.|
00004340  0d 0d 20 20 20 20 20 20  54 68 65 20 70 72 6f 67  |..      The prog|
00004350  72 61 6d 20 69 6e 20 74  68 69 73 20 6d 6f 64 75  |ram in this modu|
00004360  6c 65 20 74 61 6b 65 73  20 74 77 6f 20 6e 75 6d  |le takes two num|
00004370  62 65 72 73 20 65 6e 74  65 72 65 64 20 62 79 20  |bers entered by |
00004380  74 68 65 0d 20 20 20 20  20 20 75 73 65 72 2c 20  |the.      user, |
00004390  61 6e 64 20 64 69 76 69  64 65 73 20 74 68 65 20  |and divides the |
000043a0  66 69 72 73 74 20 62 79  20 74 68 65 20 73 65 63  |first by the sec|
000043b0  6f 6e 64 2e 20 20 54 68  65 20 71 75 6f 74 69 65  |ond.  The quotie|
000043c0  6e 74 20 61 6e 64 0d 20  20 20 20 20 20 72 65 6d  |nt and.      rem|
000043d0  61 69 6e 64 65 72 20 61  72 65 20 74 68 65 6e 20  |ainder are then |
000043e0  70 72 69 6e 74 65 64 20  6f 75 74 2e 0d 0d 0d 50  |printed out....P|
000043f0  61 72 74 20 31 36 3a 20  56 65 63 74 6f 72 73 0d  |art 16: Vectors.|
00004400  0d 20 20 20 20 20 20 57  68 65 6e 20 61 20 42 42  |.      When a BB|
00004410  43 20 4f 53 20 72 6f 75  74 69 6e 65 20 69 73 20  |C OS routine is |
00004420  63 61 6c 6c 65 64 2c 20  74 68 65 20 66 69 72 73  |called, the firs|
00004430  74 20 74 68 69 6e 67 20  74 68 61 74 0d 20 20 20  |t thing that.   |
00004440  20 20 20 72 6f 75 74 69  6e 65 20 64 6f 65 73 20  |   routine does |
00004450  69 73 20 6a 75 6d 70 20  64 6f 77 6e 20 61 20 76  |is jump down a v|
00004460  65 63 74 6f 72 2e 20 20  54 68 69 73 20 6d 65 61  |ector.  This mea|
00004470  6e 73 20 74 68 61 74 20  69 66 20 79 6f 75 0d 20  |ns that if you. |
00004480  20 20 20 20 20 63 61 6c  6c 20 61 64 64 72 65 73  |     call addres|
00004490  73 20 26 46 46 46 31 2c  20 66 6f 72 20 65 78 61  |s &FFF1, for exa|
000044a0  6d 70 6c 65 2c 20 74 68  65 20 63 6f 64 65 20 74  |mple, the code t|
000044b0  68 65 72 65 20 77 69 6c  6c 20 62 65 20 4a 4d 50  |here will be JMP|
000044c0  0d 20 20 20 20 20 20 28  76 65 63 74 6f 72 29 2e  |.      (vector).|
000044d0  20 54 68 69 73 20 6d 65  61 6e 73 20 61 20 6a 75  | This means a ju|
000044e0  6d 70 20 74 6f 20 74 68  65 20 6e 75 6d 62 65 72  |mp to the number|
000044f0  20 68 65 6c 64 20 69 6e  20 74 68 65 0d 20 20 20  | held in the.   |
00004500  20 20 20 61 64 64 72 65  73 73 20 27 76 65 63 74  |   address 'vect|
00004510  6f 72 27 2e 20 20 42 79  20 63 68 61 6e 67 69 6e  |or'.  By changin|
00004520  67 20 74 68 61 74 20 6e  75 6d 62 65 72 2c 20 77  |g that number, w|
00004530  68 69 63 68 20 77 69 6c  6c 20 62 65 20 69 6e 0d  |hich will be in.|
00004540  20 20 20 20 20 20 52 41  4d 2c 20 79 6f 75 20 63  |      RAM, you c|
00004550  61 6e 20 6d 6f 64 69 66  79 20 74 68 65 20 77 61  |an modify the wa|
00004560  79 20 74 68 61 74 20 74  68 65 20 72 6f 75 74 69  |y that the routi|
00004570  6e 65 20 6f 70 65 72 61  74 65 73 2e 0d 0d 20 20  |ne operates...  |
00004580  20 20 20 20 54 68 65 20  74 65 78 74 20 66 69 6c  |    The text fil|
00004590  65 20 77 69 74 68 20 74  68 69 73 20 6d 6f 64 75  |e with this modu|
000045a0  6c 65 20 67 69 76 65 73  20 64 65 74 61 69 6c 73  |le gives details|
000045b0  20 6f 66 20 74 68 65 20  76 65 63 74 6f 72 73 0d  | of the vectors.|
000045c0  20 20 20 20 20 20 75 73  65 64 20 62 79 20 74 68  |      used by th|
000045d0  65 20 4f 53 20 66 6f 72  20 69 6e 64 69 72 65 63  |e OS for indirec|
000045e0  74 69 6e 67 20 69 74 73  20 72 6f 75 74 69 6e 65  |ting its routine|
000045f0  73 2e 20 20 45 76 65 72  79 20 4f 53 0d 20 20 20  |s.  Every OS.   |
00004600  20 20 20 72 6f 75 74 69  6e 65 2c 20 69 6e 63 6c  |   routine, incl|
00004610  75 64 69 6e 67 20 4f 53  42 59 54 45 20 61 6e 64  |uding OSBYTE and|
00004620  20 4f 53 43 4c 49 2c 20  63 61 6e 20 62 65 20 69  | OSCLI, can be i|
00004630  6e 74 65 72 63 65 70 74  65 64 20 61 6e 64 0d 20  |ntercepted and. |
00004640  20 20 20 20 20 6d 6f 64  69 66 69 65 64 2e 20 20  |     modified.  |
00004650  54 68 65 20 70 72 6f 67  72 61 6d 20 69 6e 74 65  |The program inte|
00004660  72 63 65 70 74 73 20 74  68 65 20 76 65 63 74 6f  |rcepts the vecto|
00004670  72 20 74 68 72 6f 75 67  68 20 77 68 69 63 68 0d  |r through which.|
00004680  20 20 20 20 20 20 63 68  61 72 61 63 74 65 72 73  |      characters|
00004690  20 61 6e 64 20 63 6f 6d  6d 61 6e 64 73 20 67 6f  | and commands go|
000046a0  20 74 6f 20 74 68 65 20  73 63 72 65 65 6e 2c 20  | to the screen, |
000046b0  63 61 6c 6c 65 64 20 74  68 65 20 57 72 69 74 65  |called the Write|
000046c0  0d 20 20 20 20 20 20 43  68 61 72 61 63 74 65 72  |.      Character|
000046d0  20 56 65 63 74 6f 72 2e  20 20 54 68 69 73 20 70  | Vector.  This p|
000046e0  72 6f 76 69 64 65 73 20  61 20 70 72 69 6e 74 20  |rovides a print |
000046f0  6f 75 74 20 6f 66 20 65  76 65 72 79 20 56 44 55  |out of every VDU|
00004700  0d 20 20 20 20 20 20 63  6f 6d 6d 61 6e 64 20 74  |.      command t|
00004710  68 61 74 20 70 61 73 73  65 73 20 74 6f 20 74 68  |hat passes to th|
00004720  65 20 56 44 55 20 64 72  69 76 65 72 73 2e 0d 0d  |e VDU drivers...|
00004730  20 20 20 20 20 20 42 2f  6f 73 62 31 36 20 64 65  |      B/osb16 de|
00004740  61 6c 73 20 77 69 74 68  20 74 68 72 65 65 20 69  |als with three i|
00004750  73 73 75 65 73 20 72 61  69 73 65 64 20 62 79 20  |ssues raised by |
00004760  69 6e 74 65 72 63 65 70  74 69 6e 67 0d 20 20 20  |intercepting.   |
00004770  20 20 20 76 65 63 74 6f  72 73 2e 20 20 46 69 72  |   vectors.  Fir|
00004780  73 74 6c 79 20 74 68 65  20 4f 53 20 69 73 20 76  |stly the OS is v|
00004790  75 6c 6e 65 72 61 62 6c  65 20 64 75 72 69 6e 67  |ulnerable during|
000047a0  20 74 68 65 20 63 68 61  6e 67 69 6e 67 0d 20 20  | the changing.  |
000047b0  20 20 20 20 6f 66 20 61  20 76 65 63 74 6f 72 2e  |    of a vector.|
000047c0  20 20 41 6e 20 69 6e 74  65 72 72 75 70 74 20 63  |  An interrupt c|
000047d0  6f 75 6c 64 20 6f 63 63  75 72 20 77 68 65 6e 20  |ould occur when |
000047e0  6f 6e 65 20 6f 66 20 74  68 65 20 74 77 6f 0d 20  |one of the two. |
000047f0  20 20 20 20 20 62 79 74  65 73 20 68 61 73 20 62  |     bytes has b|
00004800  65 65 6e 20 63 68 61 6e  67 65 64 20 62 75 74 20  |een changed but |
00004810  62 65 66 6f 72 65 20 74  68 65 20 6f 74 68 65 72  |before the other|
00004820  2e 20 20 54 6f 20 70 72  65 76 65 6e 74 0d 20 20  |.  To prevent.  |
00004830  20 20 20 20 74 68 69 73  2c 20 74 68 65 20 69 6e  |    this, the in|
00004840  74 65 72 72 75 70 74 20  66 6c 61 67 20 69 73 20  |terrupt flag is |
00004850  73 65 74 20 77 68 69 63  68 20 73 74 6f 70 73 20  |set which stops |
00004860  6d 61 73 6b 61 62 6c 65  0d 20 20 20 20 20 20 69  |maskable.      i|
00004870  6e 74 65 72 72 75 70 74  73 20 6f 63 63 75 72 72  |nterrupts occurr|
00004880  69 6e 67 2e 20 20 54 68  69 73 20 77 69 6c 6c 20  |ing.  This will |
00004890  62 65 20 65 78 70 6c 61  69 6e 65 64 20 6d 6f 72  |be explained mor|
000048a0  65 20 69 6e 20 74 68 65  0d 20 20 20 20 20 20 49  |e in the.      I|
000048b0  6e 74 65 72 72 75 70 74  73 20 6d 6f 64 75 6c 65  |nterrupts module|
000048c0  2e 20 20 53 65 63 6f 6e  64 6c 79 20 77 65 20 6d  |.  Secondly we m|
000048d0  75 73 74 20 6d 61 6b 65  20 73 75 72 65 20 74 68  |ust make sure th|
000048e0  65 20 76 65 63 74 6f 72  0d 20 20 20 20 20 20 63  |e vector.      c|
000048f0  68 61 6e 67 69 6e 67 20  72 6f 75 74 69 6e 65 20  |hanging routine |
00004900  69 73 20 65 78 65 63 75  74 65 64 20 6f 6e 6c 79  |is executed only|
00004910  20 6f 6e 63 65 2e 20 20  46 69 6e 61 6c 6c 79 20  | once.  Finally |
00004920  77 65 20 68 61 76 65 20  74 6f 0d 20 20 20 20 20  |we have to.     |
00004930  20 70 75 74 20 74 68 65  20 72 6f 75 74 69 6e 65  | put the routine|
00004940  20 69 6e 20 74 68 65 20  49 2f 4f 20 70 72 6f 63  | in the I/O proc|
00004950  65 73 73 6f 72 20 74 6f  20 62 65 20 73 75 72 65  |essor to be sure|
00004960  20 69 74 20 77 69 6c 6c  20 77 6f 72 6b 0d 20 20  | it will work.  |
00004970  20 20 20 20 66 6f 72 20  61 6c 6c 20 63 61 73 65  |    for all case|
00004980  73 20 61 6e 64 20 61 6c  6c 20 74 79 70 65 73 20  |s and all types |
00004990  6f 66 20 73 65 63 6f 6e  64 20 70 72 6f 63 65 73  |of second proces|
000049a0  73 6f 72 2e 20 20 48 61  76 69 6e 67 0d 20 20 20  |sor.  Having.   |
000049b0  20 20 20 64 6f 6e 65 20  74 68 69 73 20 69 74 20  |   done this it |
000049c0  69 73 20 6f 62 76 69 6f  75 73 6c 79 20 67 6f 69  |is obviously goi|
000049d0  6e 67 20 74 6f 20 62 65  20 6d 6f 72 65 20 64 69  |ng to be more di|
000049e0  66 66 69 63 75 6c 74 20  74 6f 0d 20 20 20 20 20  |fficult to.     |
000049f0  20 73 77 69 74 63 68 20  74 68 65 20 69 6e 74 65  | switch the inte|
00004a00  72 63 65 70 74 20 72 6f  75 74 69 6e 65 20 6f 6e  |rcept routine on|
00004a10  20 61 6e 64 20 6f 66 66  2c 20 62 75 74 20 66 6f  | and off, but fo|
00004a20  72 74 75 6e 61 74 65 6c  79 0d 20 20 20 20 20 20  |rtunately.      |
00004a30  74 68 65 72 65 20 69 73  20 61 6e 20 4f 53 20 66  |there is an OS f|
00004a40  75 6e 63 74 69 6f 6e 20  77 65 20 63 61 6e 20 75  |unction we can u|
00004a50  73 65 2e 0d 0d 20 20 20  20 20 20 54 68 65 72 65  |se...      There|
00004a60  20 61 72 65 20 74 77 6f  20 6c 69 74 74 6c 65 20  | are two little |
00004a70  6b 6e 6f 77 6e 20 62 75  69 6c 74 20 69 6e 20 2a  |known built in *|
00004a80  20 63 6f 6d 6d 61 6e 64  73 2c 20 2a 43 4f 44 45  | commands, *CODE|
00004a90  20 61 6e 64 0d 20 20 20  20 20 20 2a 4c 49 4e 45  | and.      *LINE|
00004aa0  2e 20 20 57 68 65 6e 20  65 69 74 68 65 72 20 69  |.  When either i|
00004ab0  73 20 65 78 65 63 75 74  65 64 20 69 6e 20 77 68  |s executed in wh|
00004ac0  69 63 68 65 76 65 72 20  70 72 6f 63 65 73 73 6f  |ichever processo|
00004ad0  72 20 69 6e 0d 20 20 20  20 20 20 79 6f 75 72 20  |r in.      your |
00004ae0  63 6f 6d 70 75 74 65 72  2c 20 74 68 65 20 49 2f  |computer, the I/|
00004af0  4f 20 70 72 6f 63 65 73  73 6f 72 20 6a 75 6d 70  |O processor jump|
00004b00  73 20 74 6f 20 74 68 65  20 63 6f 6e 74 65 6e 74  |s to the content|
00004b10  73 20 6f 66 0d 20 20 20  20 20 20 74 68 65 20 55  |s of.      the U|
00004b20  73 65 72 20 56 65 63 74  6f 72 20 61 74 20 26 32  |ser Vector at &2|
00004b30  30 30 2e 20 20 49 6e 20  74 68 69 73 20 6d 6f 64  |00.  In this mod|
00004b40  75 6c 65 20 2a 43 4f 44  45 20 69 73 20 75 73 65  |ule *CODE is use|
00004b50  64 2c 20 62 75 74 0d 20  20 20 20 20 20 62 6f 74  |d, but.      bot|
00004b60  68 20 61 72 65 20 65 78  70 6c 61 69 6e 65 64 2e  |h are explained.|
00004b70  0d 0d 0d 50 61 72 74 20  31 37 3a 20 45 76 65 6e  |...Part 17: Even|
00004b80  74 73 0d 0d 20 20 20 20  20 20 43 65 72 74 61 69  |ts..      Certai|
00004b90  6e 20 74 68 69 6e 67 73  20 74 68 61 74 20 68 61  |n things that ha|
00004ba0  70 70 65 6e 20 69 6e 20  74 68 65 20 42 42 43 20  |ppen in the BBC |
00004bb0  4d 69 63 72 6f 2c 20 6f  72 20 74 6f 20 64 65 76  |Micro, or to dev|
00004bc0  69 63 65 73 0d 20 20 20  20 20 20 63 6f 6e 6e 65  |ices.      conne|
00004bd0  63 74 65 64 20 74 6f 20  69 74 2c 20 63 61 6e 20  |cted to it, can |
00004be0  69 6e 74 65 72 72 75 70  74 20 74 68 65 20 70 72  |interrupt the pr|
00004bf0  6f 63 65 73 73 6f 72 20  61 6e 64 20 74 61 6b 65  |ocessor and take|
00004c00  20 6f 76 65 72 0d 20 20  20 20 20 20 62 72 69 65  | over.      brie|
00004c10  66 6c 79 2e 20 20 4f 6e  65 20 74 79 70 65 20 6f  |fly.  One type o|
00004c20  66 20 69 6e 74 65 72 72  75 70 74 20 70 72 6f 76  |f interrupt prov|
00004c30  69 64 65 64 20 62 79 20  74 68 65 20 42 42 43 20  |ided by the BBC |
00004c40  4f 53 20 69 73 0d 20 20  20 20 20 20 63 61 6c 6c  |OS is.      call|
00004c50  65 64 20 61 6e 20 45 76  65 6e 74 2c 20 61 6e 64  |ed an Event, and|
00004c60  20 62 79 20 74 72 61 70  70 69 6e 67 20 74 68 65  | by trapping the|
00004c70  73 65 20 65 76 65 6e 74  73 20 74 68 65 20 75 73  |se events the us|
00004c80  65 72 20 63 61 6e 0d 20  20 20 20 20 20 6d 61 6b  |er can.      mak|
00004c90  65 20 74 68 69 6e 67 73  20 68 61 70 70 65 6e 20  |e things happen |
00004ca0  77 68 65 6e 65 76 65 72  20 74 68 65 20 73 63 72  |whenever the scr|
00004cb0  65 65 6e 20 66 6c 79 62  61 63 6b 20 73 74 61 72  |een flyback star|
00004cc0  74 73 2c 20 77 68 65 6e  0d 20 20 20 20 20 20 61  |ts, when.      a|
00004cd0  20 6b 65 79 20 69 73 20  70 75 73 68 65 64 2c 20  | key is pushed, |
00004ce0  6f 72 20 77 68 65 6e 20  61 20 74 69 6d 65 72 20  |or when a timer |
00004cf0  72 65 61 63 68 65 73 20  7a 65 72 6f 20 66 6f 72  |reaches zero for|
00004d00  20 65 78 61 6d 70 6c 65  2e 0d 0d 20 20 20 20 20  | example...     |
00004d10  20 54 68 65 20 74 65 78  74 20 66 69 6c 65 20 77  | The text file w|
00004d20  69 74 68 20 74 68 69 73  20 6d 6f 64 75 6c 65 20  |ith this module |
00004d30  65 78 70 6c 61 69 6e 73  20 45 76 65 6e 74 73 20  |explains Events |
00004d40  61 6e 64 20 73 68 6f 77  73 20 68 6f 77 0d 20 20  |and shows how.  |
00004d50  20 20 20 20 74 68 65 79  20 61 72 65 20 74 72 61  |    they are tra|
00004d60  70 70 65 64 20 75 73 69  6e 67 20 74 68 65 20 45  |pped using the E|
00004d70  76 65 6e 74 20 56 65 63  74 6f 72 2e 20 20 54 68  |vent Vector.  Th|
00004d80  65 20 70 72 6f 67 72 61  6d 20 75 73 65 73 0d 20  |e program uses. |
00004d90  20 20 20 20 20 6f 6e 65  20 6f 66 20 74 68 65 73  |     one of thes|
00004da0  65 20 65 76 65 6e 74 73  20 74 6f 20 74 72 69 67  |e events to trig|
00004db0  67 65 72 20 61 20 63 6c  69 63 6b 20 66 72 6f 6d  |ger a click from|
00004dc0  20 74 68 65 20 63 6f 6d  70 75 74 65 72 20 73 6f  | the computer so|
00004dd0  0d 20 20 20 20 20 20 74  68 61 74 20 74 68 65 20  |.      that the |
00004de0  6e 6f 69 73 65 20 6f 63  63 75 72 73 20 77 68 65  |noise occurs whe|
00004df0  6e 65 76 65 72 20 61 20  63 68 61 72 61 63 74 65  |never a characte|
00004e00  72 20 65 6e 74 65 72 73  20 74 68 65 20 69 6e 70  |r enters the inp|
00004e10  75 74 0d 20 20 20 20 20  20 62 75 66 66 65 72 2c  |ut.      buffer,|
00004e20  20 77 68 69 63 68 20 65  66 66 65 63 74 69 76 65  | which effective|
00004e30  6c 79 20 69 73 20 77 68  65 6e 20 61 20 6b 65 79  |ly is when a key|
00004e40  20 69 73 20 70 72 65 73  73 65 64 2e 0d 0d 20 20  | is pressed...  |
00004e50  20 20 20 20 45 76 65 6e  74 73 20 61 72 65 20 61  |    Events are a|
00004e60  20 73 70 65 63 69 61 6c  6c 79 20 70 61 63 6b 61  | specially packa|
00004e70  67 65 64 20 66 6f 72 6d  20 6f 66 20 69 6e 74 65  |ged form of inte|
00004e80  72 72 75 70 74 2c 20 61  6e 64 20 74 68 65 0d 20  |rrupt, and the. |
00004e90  20 20 20 20 20 6e 65 78  74 20 6d 6f 64 75 6c 65  |     next module|
00004ea0  20 64 65 61 6c 73 20 77  69 74 68 20 74 68 65 20  | deals with the |
00004eb0  73 75 62 6a 65 63 74 20  69 6e 20 6d 6f 72 65 20  |subject in more |
00004ec0  64 65 74 61 69 6c 2e 0d  0d 0d 50 61 72 74 20 31  |detail....Part 1|
00004ed0  38 3a 20 49 6e 74 65 72  72 75 70 74 73 20 49 20  |8: Interrupts I |
00004ee0  20 2d 20 20 4d 6f 75 73  65 20 64 72 69 76 65 72  | -  Mouse driver|
00004ef0  0d 0d 20 20 20 20 20 20  41 6e 20 69 6e 74 65 72  |..      An inter|
00004f00  72 75 70 74 20 69 73 20  61 20 73 69 67 6e 61 6c  |rupt is a signal|
00004f10  20 66 72 6f 6d 20 61 20  70 69 65 63 65 20 6f 66  | from a piece of|
00004f20  20 68 61 72 64 77 61 72  65 20 77 68 69 63 68 0d  | hardware which.|
00004f30  20 20 20 20 20 20 66 6f  72 63 65 73 20 74 68 65  |      forces the|
00004f40  20 6d 69 63 72 6f 70 72  6f 63 65 73 73 6f 72 20  | microprocessor |
00004f50  74 6f 20 74 65 6d 70 6f  72 61 72 69 6c 79 20 73  |to temporarily s|
00004f60  74 6f 70 20 77 68 61 74  20 69 74 20 69 73 0d 20  |top what it is. |
00004f70  20 20 20 20 20 64 6f 69  6e 67 20 61 6e 64 20 72  |     doing and r|
00004f80  65 61 63 74 20 74 6f 20  74 68 65 20 72 65 71 75  |eact to the requ|
00004f90  69 72 65 6d 65 6e 74 73  20 6f 66 20 74 68 65 20  |irements of the |
00004fa0  68 61 72 64 77 61 72 65  2e 0d 0d 20 20 20 20 20  |hardware...     |
00004fb0  20 54 68 65 20 42 42 43  20 4f 53 20 73 65 74 73  | The BBC OS sets|
00004fc0  20 75 70 20 74 68 65 20  6d 69 63 72 6f 20 69 6e  | up the micro in|
00004fd0  20 61 20 6b 6e 6f 77 6e  20 77 61 79 20 62 65 66  | a known way bef|
00004fe0  6f 72 65 20 70 61 73 73  69 6e 67 0d 20 20 20 20  |ore passing.    |
00004ff0  20 20 65 78 65 63 75 74  69 6f 6e 20 64 6f 77 6e  |  execution down|
00005000  20 74 68 65 20 69 6e 74  65 72 72 75 70 74 20 76  | the interrupt v|
00005010  65 63 74 6f 72 73 2e 20  20 59 6f 75 20 63 61 6e  |ectors.  You can|
00005020  20 69 6e 74 65 72 63 65  70 74 0d 20 20 20 20 20  | intercept.     |
00005030  20 74 68 65 73 65 20 76  65 63 74 6f 72 73 20 74  | these vectors t|
00005040  6f 20 70 72 6f 63 65 73  73 20 74 68 65 20 69 6e  |o process the in|
00005050  74 65 72 72 75 70 74 20  65 69 74 68 65 72 20 74  |terrupt either t|
00005060  6f 20 6d 6f 64 69 66 79  20 74 68 65 0d 20 20 20  |o modify the.   |
00005070  20 20 20 4f 53 20 61 63  74 69 6f 6e 20 6f 72 20  |   OS action or |
00005080  61 64 64 20 61 20 6e 65  77 20 66 65 61 74 75 72  |add a new featur|
00005090  65 2e 0d 0d 20 20 20 20  20 20 54 68 65 20 74 65  |e...      The te|
000050a0  78 74 20 66 69 6c 65 20  77 69 74 68 20 74 68 69  |xt file with thi|
000050b0  73 20 6d 6f 64 75 6c 65  20 65 78 70 6c 61 69 6e  |s module explain|
000050c0  73 20 49 6e 74 65 72 72  75 70 74 73 20 61 6e 64  |s Interrupts and|
000050d0  20 73 68 6f 77 73 0d 20  20 20 20 20 20 68 6f 77  | shows.      how|
000050e0  20 79 6f 75 20 74 72 61  70 20 74 68 65 6d 20 77  | you trap them w|
000050f0  69 74 68 20 74 68 65 20  74 77 6f 20 49 52 51 20  |ith the two IRQ |
00005100  76 65 63 74 6f 72 73 2e  20 20 4f 6e 65 20 6f 66  |vectors.  One of|
00005110  20 74 68 65 0d 20 20 20  20 20 20 68 61 72 64 77  | the.      hardw|
00005120  61 72 65 20 64 65 76 69  63 65 73 20 74 68 61 74  |are devices that|
00005130  20 63 61 6e 20 67 65 6e  65 72 61 74 65 20 61 6e  | can generate an|
00005140  20 69 6e 74 65 72 72 75  70 74 20 69 73 20 74 68  | interrupt is th|
00005150  65 20 55 73 65 72 0d 20  20 20 20 20 20 56 49 41  |e User.      VIA|
00005160  20 77 68 69 63 68 20 69  73 20 63 6f 6e 6e 65 63  | which is connec|
00005170  74 65 64 20 74 6f 20 74  68 65 20 75 73 65 72 20  |ted to the user |
00005180  70 6f 72 74 2e 20 20 54  68 65 20 70 72 6f 67 72  |port.  The progr|
00005190  61 6d 20 75 73 65 73 0d  20 20 20 20 20 20 74 68  |am uses.      th|
000051a0  65 20 69 6e 74 65 72 72  75 70 74 73 20 66 72 6f  |e interrupts fro|
000051b0  6d 20 74 68 65 20 75 73  65 72 20 70 6f 72 74 20  |m the user port |
000051c0  74 6f 20 64 65 74 65 63  74 20 74 68 65 20 6d 6f  |to detect the mo|
000051d0  76 65 6d 65 6e 74 20 6f  66 0d 20 20 20 20 20 20  |vement of.      |
000051e0  61 20 6d 6f 75 73 65 2e  20 20 4f 6e 63 65 20 74  |a mouse.  Once t|
000051f0  68 65 20 6d 6f 76 65 6d  65 6e 74 20 6f 66 20 74  |he movement of t|
00005200  68 65 20 6d 6f 75 73 65  20 68 61 73 20 62 65 65  |he mouse has bee|
00005210  6e 20 64 65 74 65 63 74  65 64 2c 0d 20 20 20 20  |n detected,.    |
00005220  20 20 74 68 65 20 70 72  6f 67 72 61 6d 20 70 6c  |  the program pl|
00005230  6f 74 73 20 61 20 70 6f  69 6e 74 65 72 20 74 6f  |ots a pointer to|
00005240  20 74 68 65 20 73 63 72  65 65 6e 20 77 68 69 63  | the screen whic|
00005250  68 20 63 61 6e 20 62 65  20 6d 6f 76 65 64 0d 20  |h can be moved. |
00005260  20 20 20 20 20 77 69 74  68 20 74 68 65 20 6d 6f  |     with the mo|
00005270  75 73 65 2e 0d 0d 0d 50  61 72 74 20 31 39 3a 20  |use....Part 19: |
00005280  49 6e 74 65 72 72 75 70  74 73 20 49 49 20 20 2d  |Interrupts II  -|
00005290  20 20 50 61 6c 65 74 74  65 20 53 77 69 74 63 68  |  Palette Switch|
000052a0  69 6e 67 20 75 73 69 6e  67 20 54 69 6d 65 72 73  |ing using Timers|
000052b0  0d 0d 20 20 20 20 20 20  41 73 20 61 20 73 65 71  |..      As a seq|
000052c0  75 65 6c 20 74 6f 20 74  68 65 20 6c 61 73 74 20  |uel to the last |
000052d0  6d 6f 64 75 6c 65 2c 20  77 65 20 6e 6f 77 20 6c  |module, we now l|
000052e0  6f 6f 6b 20 61 74 20 74  68 65 20 74 69 6d 65 72  |ook at the timer|
000052f0  73 0d 20 20 20 20 20 20  63 6f 6e 74 61 69 6e 65  |s.      containe|
00005300  64 20 69 6e 20 74 68 65  20 73 79 73 74 65 6d 20  |d in the system |
00005310  61 6e 64 20 75 73 65 72  20 56 49 41 73 2e 20 20  |and user VIAs.  |
00005320  57 69 74 68 20 74 68 65  73 65 20 74 69 6d 65 72  |With these timer|
00005330  73 20 69 74 0d 20 20 20  20 20 20 69 73 20 70 6f  |s it.      is po|
00005340  73 73 69 62 6c 65 20 74  6f 20 74 69 6d 65 20 61  |ssible to time a|
00005350  6e 20 61 63 74 69 6f 6e  20 74 6f 20 6d 69 63 72  |n action to micr|
00005360  6f 73 65 63 6f 6e 64 20  61 63 63 75 72 61 63 79  |osecond accuracy|
00005370  2e 20 20 54 68 65 0d 20  20 20 20 20 20 74 69 6d  |.  The.      tim|
00005380  65 72 73 20 61 72 65 20  73 65 74 20 75 70 20 62  |ers are set up b|
00005390  79 20 70 6f 6b 69 6e 67  20 62 79 74 65 73 20 69  |y poking bytes i|
000053a0  6e 74 6f 20 74 68 65 69  72 20 72 65 67 69 73 74  |nto their regist|
000053b0  65 72 73 20 77 68 69 63  68 0d 20 20 20 20 20 20  |ers which.      |
000053c0  6c 69 65 20 69 6e 20 74  68 65 20 70 61 72 74 20  |lie in the part |
000053d0  6f 66 20 6d 65 6d 6f 72  79 20 6b 6e 6f 77 6e 20  |of memory known |
000053e0  61 73 20 53 68 65 69 6c  61 20 28 50 61 67 65 20  |as Sheila (Page |
000053f0  26 46 45 29 2e 20 20 54  68 65 73 65 0d 20 20 20  |&FE).  These.   |
00005400  20 20 20 74 69 6d 65 72  73 20 61 72 65 20 6f 6e  |   timers are on|
00005410  6c 79 20 6f 6e 65 20 6f  66 20 74 68 65 20 66 75  |ly one of the fu|
00005420  6e 63 74 69 6f 6e 73 20  61 76 61 69 6c 61 62 6c  |nctions availabl|
00005430  65 20 66 72 6f 6d 20 74  68 65 20 56 49 41 73 2e  |e from the VIAs.|
00005440  0d 0d 20 20 20 20 20 20  54 68 65 20 74 65 78 74  |..      The text|
00005450  20 66 69 6c 65 20 77 69  74 68 20 74 68 69 73 20  | file with this |
00005460  6d 6f 64 75 6c 65 20 65  78 70 6c 61 69 6e 73 20  |module explains |
00005470  68 6f 77 20 74 6f 20 73  65 74 20 75 70 20 74 68  |how to set up th|
00005480  65 0d 20 20 20 20 20 20  74 69 6d 65 72 73 20 69  |e.      timers i|
00005490  6e 20 74 68 65 20 56 49  41 2e 20 20 54 68 65 20  |n the VIA.  The |
000054a0  70 72 6f 67 72 61 6d 20  74 68 65 6e 20 75 73 65  |program then use|
000054b0  73 20 6f 6e 65 20 6f 66  20 74 68 65 20 74 69 6d  |s one of the tim|
000054c0  65 72 73 0d 20 20 20 20  20 20 74 6f 20 67 65 6e  |ers.      to gen|
000054d0  65 72 61 74 65 20 61 20  73 65 72 69 65 73 20 6f  |erate a series o|
000054e0  66 20 69 6e 74 65 72 72  75 70 74 73 20 64 75 72  |f interrupts dur|
000054f0  69 6e 67 20 65 61 63 68  20 76 69 64 65 6f 20 66  |ing each video f|
00005500  72 61 6d 65 2e 20 0d 20  20 20 20 20 20 41 74 20  |rame. .      At |
00005510  65 61 63 68 20 69 6e 74  65 72 72 75 70 74 20 74  |each interrupt t|
00005520  68 65 20 61 63 74 75 61  6c 20 63 6f 6c 6f 75 72  |he actual colour|
00005530  20 6f 66 20 43 4f 4c 4f  55 52 20 31 20 69 73 20  | of COLOUR 1 is |
00005540  6d 6f 64 69 66 69 65 64  0d 20 20 20 20 20 20 75  |modified.      u|
00005550  73 69 6e 67 20 61 6e 20  4f 53 57 4f 52 44 20 63  |sing an OSWORD c|
00005560  61 6c 6c 2e 20 20 49 6e  20 74 68 69 73 20 77 61  |all.  In this wa|
00005570  79 20 61 20 73 65 72 69  65 73 20 6f 66 20 68 6f  |y a series of ho|
00005580  72 69 7a 6f 6e 74 61 6c  0d 20 20 20 20 20 20 62  |rizontal.      b|
00005590  61 6e 64 73 20 6f 66 20  63 6f 6c 6f 75 72 20 63  |ands of colour c|
000055a0  61 6e 20 62 65 20 67 65  6e 65 72 61 74 65 64 20  |an be generated |
000055b0  65 76 65 6e 20 69 6e 20  61 20 74 77 6f 2d 63 6f  |even in a two-co|
000055c0  6c 6f 75 72 20 6d 6f 64  65 2e 20 0d 20 20 20 20  |lour mode. .    |
000055d0  20 20 54 68 65 20 70 72  6f 67 72 61 6d 20 64 65  |  The program de|
000055e0  6d 6f 6e 73 74 72 61 74  65 73 20 74 68 69 73 20  |monstrates this |
000055f0  62 79 20 70 72 69 6e 74  69 6e 67 20 6c 69 6e 65  |by printing line|
00005600  73 20 6f 66 20 38 30 20  63 6f 6c 75 6d 6e 0d 20  |s of 80 column. |
00005610  20 20 20 20 20 74 65 78  74 20 69 6e 20 64 69 66  |     text in dif|
00005620  66 65 72 65 6e 74 20 63  6f 6c 6f 75 72 73 20 69  |ferent colours i|
00005630  6e 20 4d 6f 64 65 20 33  2e 0d 0d 0d 50 61 72 74  |n Mode 3....Part|
00005640  20 32 30 3a 20 52 65 61  6c 20 4e 75 6d 62 65 72  | 20: Real Number|
00005650  73 20 20 2d 20 20 46 69  78 65 64 20 50 6f 69 6e  |s  -  Fixed Poin|
00005660  74 20 41 72 69 74 68 6d  65 74 69 63 0d 0d 20 20  |t Arithmetic..  |
00005670  20 20 20 20 46 69 78 65  64 20 70 6f 69 6e 74 20  |    Fixed point |
00005680  6d 61 74 68 73 20 72 65  70 72 65 73 65 6e 74 73  |maths represents|
00005690  20 61 20 6e 75 6d 62 65  72 20 77 69 74 68 20 61  | a number with a|
000056a0  20 66 72 61 63 74 69 6f  6e 61 6c 20 70 61 72 74  | fractional part|
000056b0  0d 20 20 20 20 20 20 62  79 20 77 6f 72 6b 69 6e  |.      by workin|
000056c0  67 20 77 69 74 68 20 74  68 65 20 6e 75 6d 62 65  |g with the numbe|
000056d0  72 20 6d 75 6c 74 69 70  6c 69 65 64 20 62 79 20  |r multiplied by |
000056e0  61 20 63 6f 6e 73 74 61  6e 74 2e 20 20 49 6e 0d  |a constant.  In.|
000056f0  20 20 20 20 20 20 74 68  69 73 20 77 61 79 20 31  |      this way 1|
00005700  2e 32 33 20 69 73 20 72  65 70 72 65 73 65 6e 74  |.23 is represent|
00005710  65 64 20 62 79 20 31 32  33 20 69 66 20 74 68 65  |ed by 123 if the|
00005720  20 63 6f 6e 73 74 61 6e  74 20 69 73 20 31 30 30  | constant is 100|
00005730  2e 20 0d 20 20 20 20 20  20 42 79 20 63 61 6c 63  |. .      By calc|
00005740  75 6c 61 74 69 6e 67 20  77 69 74 68 20 61 20 6e  |ulating with a n|
00005750  75 6d 62 65 72 20 74 69  6d 65 73 20 61 20 63 6f  |umber times a co|
00005760  6e 73 74 61 6e 74 2c 20  79 6f 75 20 63 61 6e 0d  |nstant, you can.|
00005770  20 20 20 20 20 20 63 61  6c 63 75 6c 61 74 65 20  |      calculate |
00005780  77 69 74 68 20 72 65 61  6c 20 6e 75 6d 62 65 72  |with real number|
00005790  73 20 75 73 69 6e 67 20  69 6e 74 65 67 65 72 20  |s using integer |
000057a0  6d 61 74 68 73 20 61 73  20 6c 6f 6e 67 20 61 73  |maths as long as|
000057b0  0d 20 20 20 20 20 20 79  6f 75 20 68 61 6e 64 6c  |.      you handl|
000057c0  65 20 74 68 65 20 63 6f  6e 73 74 61 6e 74 20 63  |e the constant c|
000057d0  6f 72 72 65 63 74 6c 79  2e 0d 0d 20 20 20 20 20  |orrectly...     |
000057e0  20 54 68 65 20 74 65 78  74 20 66 69 6c 65 20 77  | The text file w|
000057f0  69 74 68 20 74 68 69 73  20 6d 6f 64 75 6c 65 20  |ith this module |
00005800  65 78 70 6c 61 69 6e 73  20 68 6f 77 20 66 69 78  |explains how fix|
00005810  65 64 20 70 6f 69 6e 74  0d 20 20 20 20 20 20 6e  |ed point.      n|
00005820  75 6d 62 65 72 69 6e 67  20 63 61 6e 20 62 65 20  |umbering can be |
00005830  75 73 65 64 20 74 6f 20  63 61 6c 63 75 6c 61 74  |used to calculat|
00005840  65 2e 20 20 54 68 65 72  65 20 61 72 65 20 73 69  |e.  There are si|
00005850  6d 70 6c 65 20 77 61 79  73 0d 20 20 20 20 20 20  |mple ways.      |
00005860  6f 66 20 68 61 6e 64 6c  69 6e 67 20 61 64 64 69  |of handling addi|
00005870  74 69 6f 6e 2c 20 73 75  62 74 72 61 63 74 69 6f  |tion, subtractio|
00005880  6e 2c 20 6d 75 6c 74 69  70 6c 69 63 61 74 69 6f  |n, multiplicatio|
00005890  6e 20 61 6e 64 0d 20 20  20 20 20 20 64 69 76 69  |n and.      divi|
000058a0  73 69 6f 6e 2e 20 20 54  68 65 20 70 72 6f 67 72  |sion.  The progr|
000058b0  61 6d 20 69 6e 20 74 68  69 73 20 6d 6f 64 75 6c  |am in this modul|
000058c0  65 20 75 73 65 73 20 42  41 53 49 43 20 69 6e 74  |e uses BASIC int|
000058d0  65 67 65 72 73 20 74 6f  0d 20 20 20 20 20 20 69  |egers to.      i|
000058e0  6c 6c 75 73 74 72 61 74  65 20 61 20 73 69 6d 70  |llustrate a simp|
000058f0  6c 65 20 66 69 78 65 64  20 70 6f 69 6e 74 20 73  |le fixed point s|
00005900  79 73 74 65 6d 20 62 61  73 65 64 20 6f 6e 20 61  |ystem based on a|
00005910  20 66 61 63 74 6f 72 20  6f 66 0d 20 20 20 20 20  | factor of.     |
00005920  20 31 30 30 30 30 2e 20  20 49 74 20 73 68 6f 77  | 10000.  It show|
00005930  73 20 68 6f 77 20 73 75  63 68 20 61 20 73 79 73  |s how such a sys|
00005940  74 65 6d 20 63 61 6e 20  6f 66 74 65 6e 20 62 65  |tem can often be|
00005950  20 66 61 73 74 65 72 20  74 68 61 6e 0d 20 20 20  | faster than.   |
00005960  20 20 20 42 41 53 49 43  27 73 20 62 75 69 6c 74  |   BASIC's built|
00005970  2d 69 6e 20 66 6c 6f 61  74 69 6e 67 20 70 6f 69  |-in floating poi|
00005980  6e 74 20 61 72 69 74 68  6d 65 74 69 63 2c 20 61  |nt arithmetic, a|
00005990  6c 74 68 6f 75 67 68 20  74 68 65 0d 20 20 20 20  |lthough the.    |
000059a0  20 20 42 41 53 49 43 20  72 6f 75 74 69 6e 65 73  |  BASIC routines|
000059b0  20 61 72 65 20 6d 6f 72  65 20 61 63 63 75 72 61  | are more accura|
000059c0  74 65 2e 0d 0d 0d 50 61  72 74 20 32 31 3a 20 52  |te....Part 21: R|
000059d0  65 61 6c 20 4e 75 6d 62  65 72 73 20 20 2d 20 20  |eal Numbers  -  |
000059e0  46 69 78 65 64 20 50 6f  69 6e 74 20 4d 61 6e 64  |Fixed Point Mand|
000059f0  65 6c 62 72 6f 74 20 53  65 74 0d 0d 20 20 20 20  |elbrot Set..    |
00005a00  20 20 54 68 65 20 6c 61  73 74 20 6d 6f 64 75 6c  |  The last modul|
00005a10  65 20 69 6e 74 72 6f 64  75 63 65 64 20 74 68 65  |e introduced the|
00005a20  20 69 64 65 61 20 6f 66  20 73 70 6c 69 74 74 69  | idea of splitti|
00005a30  6e 67 20 75 70 20 61 20  77 6f 72 64 0d 20 20 20  |ng up a word.   |
00005a40  20 20 20 28 69 6e 20 74  68 61 74 20 63 61 73 65  |   (in that case|
00005a50  20 69 74 20 77 61 73 20  34 20 62 79 74 65 73 20  | it was 4 bytes |
00005a60  61 73 20 75 73 65 64 20  62 79 20 42 41 53 49 43  |as used by BASIC|
00005a70  20 69 6e 74 65 67 65 72  73 29 20 73 75 63 68 0d  | integers) such.|
00005a80  20 20 20 20 20 20 74 68  61 74 20 74 68 65 20 6c  |      that the l|
00005a90  6f 77 65 72 20 66 65 77  20 62 79 74 65 73 20 77  |ower few bytes w|
00005aa0  65 72 65 20 69 6e 20 66  61 63 74 20 72 65 70 72  |ere in fact repr|
00005ab0  65 73 65 6e 74 69 6e 67  0d 20 20 20 20 20 20 66  |esenting.      f|
00005ac0  72 61 63 74 69 6f 6e 61  6c 20 70 61 72 74 73 20  |ractional parts |
00005ad0  6f 66 20 31 2e 20 20 54  68 69 73 20 6d 6f 64 75  |of 1.  This modu|
00005ae0  6c 65 20 65 78 70 6c 6f  69 74 73 20 74 68 61 74  |le exploits that|
00005af0  20 69 64 65 61 20 74 6f  0d 20 20 20 20 20 20 70  | idea to.      p|
00005b00  65 72 66 6f 72 6d 20 73  6f 6d 65 20 70 72 65 74  |erform some pret|
00005b10  74 79 20 68 61 69 72 79  20 63 6f 6d 70 75 74 61  |ty hairy computa|
00005b20  74 69 6f 6e 20 69 6e 20  6f 72 64 65 72 20 74 6f  |tion in order to|
00005b30  20 70 6c 6f 74 20 61 0d  20 20 20 20 20 20 63 72  | plot a.      cr|
00005b40  75 64 65 20 64 69 61 67  72 61 6d 20 73 68 6f 77  |ude diagram show|
00005b50  69 6e 67 20 74 68 65 20  4d 61 6e 64 65 6c 62 72  |ing the Mandelbr|
00005b60  6f 74 20 53 65 74 2e 0d  0d 20 20 20 20 20 20 54  |ot Set...      T|
00005b70  68 65 20 4d 61 6e 64 65  6c 62 72 6f 74 20 53 65  |he Mandelbrot Se|
00005b80  74 20 67 72 61 70 68 69  63 20 73 68 6f 77 73 20  |t graphic shows |
00005b90  74 68 65 20 77 61 79 20  74 68 65 20 66 6f 72 6d  |the way the form|
00005ba0  75 6c 61 0d 20 20 20 20  20 20 7a 20 3d 20 7a 5e  |ula.      z = z^|
00005bb0  32 20 2b 20 63 20 20 20  62 65 68 61 76 65 73 20  |2 + c   behaves |
00005bc0  77 68 65 6e 20 7a 20 61  6e 64 20 63 20 61 72 65  |when z and c are|
00005bd0  20 63 6f 6d 70 6c 65 78  20 6e 75 6d 62 65 72 73  | complex numbers|
00005be0  2e 20 20 54 68 65 0d 20  20 20 20 20 20 63 61 6c  |.  The.      cal|
00005bf0  63 75 6c 61 74 69 6f 6e  20 6f 66 20 74 68 65 20  |culation of the |
00005c00  73 65 74 20 69 6e 76 6f  6c 76 65 73 20 6d 61 6e  |set involves man|
00005c10  79 20 6d 75 6c 74 69 70  6c 69 63 61 74 69 6f 6e  |y multiplication|
00005c20  73 20 61 74 20 65 61 63  68 0d 20 20 20 20 20 20  |s at each.      |
00005c30  70 69 78 65 6c 20 6f 6e  20 74 68 65 20 73 63 72  |pixel on the scr|
00005c40  65 65 6e 20 61 6e 64 20  73 6f 20 74 61 6b 65 73  |een and so takes|
00005c50  20 61 20 6c 6f 6e 67 20  74 69 6d 65 2e 20 20 55  | a long time.  U|
00005c60  73 69 6e 67 20 61 20 66  69 78 65 64 0d 20 20 20  |sing a fixed.   |
00005c70  20 20 20 70 6f 69 6e 74  20 73 79 73 74 65 6d 20  |   point system |
00005c80  66 72 6f 6d 20 6d 61 63  68 69 6e 65 20 63 6f 64  |from machine cod|
00005c90  65 20 73 68 6f 75 6c 64  20 62 65 20 6d 75 63 68  |e should be much|
00005ca0  20 66 61 73 74 65 72 20  74 68 61 6e 0d 20 20 20  | faster than.   |
00005cb0  20 20 20 63 61 72 72 79  69 6e 67 20 6f 75 74 20  |   carrying out |
00005cc0  74 68 65 20 63 61 6c 63  75 6c 61 74 69 6f 6e 20  |the calculation |
00005cd0  66 72 6f 6d 20 42 41 53  49 43 2e 0d 0d 20 20 20  |from BASIC...   |
00005ce0  20 20 20 54 68 65 20 4d  61 6e 64 65 6c 62 72 6f  |   The Mandelbro|
00005cf0  74 20 53 65 74 20 69 73  20 65 78 70 6c 61 69 6e  |t Set is explain|
00005d00  65 64 20 69 6e 20 74 68  69 73 20 6d 6f 64 75 6c  |ed in this modul|
00005d10  65 27 73 20 74 65 78 74  20 66 69 6c 65 2e 20 0d  |e's text file. .|
00005d20  20 20 20 20 20 20 57 65  20 61 6c 73 6f 20 73 65  |      We also se|
00005d30  74 20 75 70 20 61 20 66  69 78 65 64 20 70 6f 69  |t up a fixed poi|
00005d40  6e 74 20 73 79 73 74 65  6d 20 75 73 69 6e 67 20  |nt system using |
00005d50  61 20 66 61 63 74 6f 72  20 6f 66 20 36 35 35 33  |a factor of 6553|
00005d60  36 0d 20 20 20 20 20 20  61 6e 64 20 77 6f 72 6b  |6.      and work|
00005d70  69 6e 67 20 77 69 74 68  20 66 6f 75 72 2d 62 79  |ing with four-by|
00005d80  74 65 20 6e 75 6d 62 65  72 73 2e 20 20 54 68 65  |te numbers.  The|
00005d90  20 70 72 6f 67 72 61 6d  20 75 73 65 73 20 74 68  | program uses th|
00005da0  69 73 0d 20 20 20 20 20  20 66 69 78 65 64 20 70  |is.      fixed p|
00005db0  6f 69 6e 74 20 73 79 73  74 65 6d 2c 20 61 20 6d  |oint system, a m|
00005dc0  6f 64 69 66 69 65 64 20  76 65 72 73 69 6f 6e 20  |odified version |
00005dd0  6f 66 20 74 68 65 20 66  6f 75 72 2d 62 79 74 65  |of the four-byte|
00005de0  0d 20 20 20 20 20 20 6d  75 6c 74 69 70 6c 69 63  |.      multiplic|
00005df0  61 74 69 6f 6e 20 72 6f  75 74 69 6e 65 20 69 6e  |ation routine in|
00005e00  20 4d 6f 64 75 6c 65 20  31 33 2c 20 74 6f 20 70  | Module 13, to p|
00005e10  6c 6f 74 20 74 68 65 20  4d 61 6e 64 65 6c 62 72  |lot the Mandelbr|
00005e20  6f 74 0d 20 20 20 20 20  20 73 65 74 20 69 6e 20  |ot.      set in |
00005e30  61 62 6f 75 74 20 61 20  71 75 61 72 74 65 72 20  |about a quarter |
00005e40  6f 66 20 74 68 65 20 74  69 6d 65 20 69 74 20 74  |of the time it t|
00005e50  61 6b 65 73 20 66 72 6f  6d 20 42 41 53 49 43 2e  |akes from BASIC.|
00005e60  20 0d 20 20 20 20 20 20  57 69 74 68 20 61 20 36  | .      With a 6|
00005e70  35 30 32 20 73 65 63 6f  6e 64 20 70 72 6f 63 65  |502 second proce|
00005e80  73 73 6f 72 20 69 74 20  74 61 6b 65 73 20 61 62  |ssor it takes ab|
00005e90  6f 75 74 20 32 33 20 6d  69 6e 75 74 65 73 2e 0d  |out 23 minutes..|
00005ea0  0d 0d 50 61 72 74 20 32  32 3a 20 46 6c 6f 61 74  |..Part 22: Float|
00005eb0  69 6e 67 20 50 6f 69 6e  74 20 41 72 69 74 68 6d  |ing Point Arithm|
00005ec0  65 74 69 63 0d 0d 20 20  20 20 20 20 49 6e 20 74  |etic..      In t|
00005ed0  68 65 20 6c 61 73 74 20  6d 6f 64 75 6c 65 20 77  |he last module w|
00005ee0  65 20 75 73 65 64 20 61  20 66 69 78 65 64 20 70  |e used a fixed p|
00005ef0  6f 69 6e 74 20 61 72 69  74 68 6d 65 74 69 63 20  |oint arithmetic |
00005f00  73 79 73 74 65 6d 0d 20  20 20 20 20 20 66 6f 72  |system.      for|
00005f10  20 63 61 6c 63 75 6c 61  74 69 6f 6e 73 2e 20 20  | calculations.  |
00005f20  54 68 65 20 72 65 73 75  6c 74 20 77 61 73 20 72  |The result was r|
00005f30  65 6c 61 74 69 76 65 6c  79 20 66 61 73 74 20 62  |elatively fast b|
00005f40  75 74 20 77 61 73 0d 20  20 20 20 20 20 73 6c 69  |ut was.      sli|
00005f50  67 68 74 6c 79 20 69 6e  61 63 63 75 72 61 74 65  |ghtly inaccurate|
00005f60  20 73 69 6e 63 65 20 76  65 72 79 20 73 6d 61 6c  | since very smal|
00005f70  6c 20 6e 75 6d 62 65 72  73 20 77 65 72 65 20 6e  |l numbers were n|
00005f80  6f 74 0d 20 20 20 20 20  20 72 65 70 72 65 73 65  |ot.      represe|
00005f90  6e 74 65 64 20 61 73 20  77 65 6c 6c 20 61 73 20  |nted as well as |
00005fa0  74 68 65 79 20 63 6f 75  6c 64 20 68 61 76 65 20  |they could have |
00005fb0  62 65 65 6e 2e 0d 0d 20  20 20 20 20 20 59 6f 75  |been...      You|
00005fc0  20 77 69 6c 6c 20 72 65  6d 65 6d 62 65 72 20 74  | will remember t|
00005fd0  68 61 74 20 77 65 20 63  6f 6e 76 65 72 74 65 64  |hat we converted|
00005fe0  20 66 72 6f 6d 20 61 20  72 65 61 6c 20 6e 75 6d  | from a real num|
00005ff0  62 65 72 20 74 6f 20 61  0d 20 20 20 20 20 20 66  |ber to a.      f|
00006000  69 78 65 64 20 70 6f 69  6e 74 20 6e 75 6d 62 65  |ixed point numbe|
00006010  72 20 62 79 20 6d 75 6c  74 69 70 6c 79 69 6e 67  |r by multiplying|
00006020  20 62 79 20 61 20 63 6f  6e 73 74 61 6e 74 20 66  | by a constant f|
00006030  61 63 74 6f 72 2e 20 20  54 68 65 0d 20 20 20 20  |actor.  The.    |
00006040  20 20 6e 65 78 74 20 6c  6f 67 69 63 61 6c 20 73  |  next logical s|
00006050  74 65 70 20 69 73 20 74  6f 20 6d 61 6b 65 20 74  |tep is to make t|
00006060  68 65 20 66 61 63 74 6f  72 20 76 61 72 69 61 62  |he factor variab|
00006070  6c 65 20 61 6e 64 20 6b  65 65 70 0d 20 20 20 20  |le and keep.    |
00006080  20 20 74 72 61 63 6b 20  6f 66 20 77 68 61 74 20  |  track of what |
00006090  69 74 20 69 73 2e 20 20  46 6f 72 20 65 78 61 6d  |it is.  For exam|
000060a0  70 6c 65 2c 20 31 32 33  2e 34 20 63 6f 75 6c 64  |ple, 123.4 could|
000060b0  20 62 65 20 0d 20 20 20  20 20 20 72 65 70 72 65  | be .      repre|
000060c0  73 65 6e 74 65 64 20 61  73 20 31 2e 32 33 34 20  |sented as 1.234 |
000060d0  2a 20 31 30 5e 32 2e 20  20 54 68 69 73 20 69 73  |* 10^2.  This is|
000060e0  20 74 68 65 20 73 63 69  65 6e 74 69 66 69 63 0d  | the scientific.|
000060f0  20 20 20 20 20 20 6e 6f  74 61 74 69 6f 6e 20 75  |      notation u|
00006100  73 65 64 20 69 6e 20 42  42 43 20 42 41 53 49 43  |sed in BBC BASIC|
00006110  2c 20 62 75 74 20 74 68  65 20 70 6f 77 65 72 20  |, but the power |
00006120  6f 66 20 74 65 6e 20 69  73 20 77 72 69 74 74 65  |of ten is writte|
00006130  6e 0d 20 20 20 20 20 20  61 73 20 45 32 20 28 69  |n.      as E2 (i|
00006140  6e 20 74 68 69 73 20 63  61 73 65 29 2c 20 61 6e  |n this case), an|
00006150  64 20 69 73 20 63 61 6c  6c 65 64 20 74 68 65 20  |d is called the |
00006160  45 58 50 4f 4e 45 4e 54  2e 0d 0d 20 20 20 20 20  |EXPONENT...     |
00006170  20 54 68 65 20 74 65 78  74 20 66 69 6c 65 20 69  | The text file i|
00006180  6e 20 74 68 69 73 20 6d  6f 64 75 6c 65 20 65 78  |n this module ex|
00006190  70 6c 61 69 6e 73 20 68  6f 77 20 74 68 69 73 20  |plains how this |
000061a0  6e 6f 74 61 74 69 6f 6e  20 63 61 6e 0d 20 20 20  |notation can.   |
000061b0  20 20 20 62 65 20 65 78  74 65 6e 64 65 64 20 74  |   be extended t|
000061c0  6f 20 62 69 6e 61 72 79  20 6e 75 6d 62 65 72 73  |o binary numbers|
000061d0  2c 20 61 6e 64 20 68 6f  77 20 74 68 65 20 61 64  |, and how the ad|
000061e0  64 69 74 69 6f 6e 20 61  6e 64 0d 20 20 20 20 20  |dition and.     |
000061f0  20 73 75 62 74 72 61 63  74 69 6f 6e 20 70 72 6f  | subtraction pro|
00006200  63 65 64 75 72 65 73 20  64 65 73 63 72 69 62 65  |cedures describe|
00006210  64 20 66 6f 72 20 69 6e  74 65 67 65 72 20 6e 75  |d for integer nu|
00006220  6d 62 65 72 73 20 6e 65  65 64 20 74 6f 0d 20 20  |mbers need to.  |
00006230  20 20 20 20 62 65 20 6d  6f 64 69 66 69 65 64 20  |    be modified |
00006240  66 6f 72 20 66 6c 6f 61  74 69 6e 67 20 70 6f 69  |for floating poi|
00006250  6e 74 2e 0d 0d 20 20 20  20 20 20 54 68 65 20 70  |nt...      The p|
00006260  72 6f 67 72 61 6d 20 74  61 6b 65 73 20 61 20 70  |rogram takes a p|
00006270  61 69 72 20 6f 66 20 6e  75 6d 62 65 72 73 20 79  |air of numbers y|
00006280  6f 75 20 65 6e 74 65 72  20 61 6e 64 20 63 61 6c  |ou enter and cal|
00006290  63 75 6c 61 74 65 73 0d  20 20 20 20 20 20 74 68  |culates.      th|
000062a0  65 20 73 75 6d 20 61 6e  64 20 64 69 66 66 65 72  |e sum and differ|
000062b0  65 6e 63 65 20 6f 66 20  74 68 65 6d 20 75 73 69  |ence of them usi|
000062c0  6e 67 20 6d 6f 64 69 66  69 65 64 20 76 65 72 73  |ng modified vers|
000062d0  69 6f 6e 73 20 6f 66 0d  20 20 20 20 20 20 74 68  |ions of.      th|
000062e0  65 20 6d 75 6c 74 69 2d  62 79 74 65 20 61 72 69  |e multi-byte ari|
000062f0  74 68 6d 65 74 69 63 61  6c 20 72 6f 75 74 69 6e  |thmetical routin|
00006300  65 73 20 69 6e 74 72 6f  64 75 63 65 64 20 65 61  |es introduced ea|
00006310  72 6c 69 65 72 20 69 6e  0d 20 20 20 20 20 20 74  |rlier in.      t|
00006320  68 65 20 73 65 72 69 65  73 2e 20 20 54 68 65 20  |he series.  The |
00006330  69 6e 70 75 74 20 6f 66  20 74 68 65 20 66 6c 6f  |input of the flo|
00006340  61 74 69 6e 67 20 70 6f  69 6e 74 20 6e 75 6d 62  |ating point numb|
00006350  65 72 73 20 69 73 20 64  6f 6e 65 0d 20 20 20 20  |ers is done.    |
00006360  20 20 75 73 69 6e 67 20  61 20 70 73 65 75 64 6f  |  using a pseudo|
00006370  20 4f 50 54 20 66 75 6e  63 74 69 6f 6e 20 64 65  | OPT function de|
00006380  66 69 6e 65 64 20 61 74  20 74 68 65 20 65 6e 64  |fined at the end|
00006390  20 6f 66 20 74 68 65 0d  20 20 20 20 20 20 70 72  | of the.      pr|
000063a0  6f 67 72 61 6d 2e 20 20  49 74 20 72 65 6c 69 65  |ogram.  It relie|
000063b0  73 20 6f 6e 20 75 73 20  6b 6e 6f 77 69 6e 67 20  |s on us knowing |
000063c0  77 68 65 72 65 20 42 41  53 49 43 20 77 69 6c 6c  |where BASIC will|
000063d0  20 73 74 6f 72 65 20 74  68 65 0d 20 20 20 20 20  | store the.     |
000063e0  20 66 69 72 73 74 20 76  61 72 69 61 62 6c 65 20  | first variable |
000063f0  62 65 67 69 6e 6e 69 6e  67 20 77 69 74 68 20 61  |beginning with a|
00006400  20 60 20 73 69 67 6e 20  28 70 6f 75 6e 64 29 2e  | ` sign (pound).|
00006410  20 20 57 65 20 63 61 6e  20 75 73 65 0d 20 20 20  |  We can use.   |
00006420  20 20 20 74 68 69 73 20  6b 6e 6f 77 6c 65 64 67  |   this knowledg|
00006430  65 20 74 6f 20 62 6f 74  68 20 70 75 74 20 61 6e  |e to both put an|
00006440  64 20 72 65 74 72 69 65  76 65 20 42 42 43 20 42  |d retrieve BBC B|
00006450  41 53 49 43 20 66 6f 72  6d 61 74 0d 20 20 20 20  |ASIC format.    |
00006460  20 20 66 6c 6f 61 74 69  6e 67 20 70 6f 69 6e 74  |  floating point|
00006470  20 6e 75 6d 62 65 72 73  2e 0d 0d 0d 50 61 72 74  | numbers....Part|
00006480  20 32 33 3a 20 46 6c 6f  61 74 69 6e 67 20 50 6f  | 23: Floating Po|
00006490  69 6e 74 20 41 72 69 74  68 6d 65 74 69 63 20 49  |int Arithmetic I|
000064a0  49 0d 0d 20 20 20 20 20  20 48 61 76 69 6e 67 20  |I..      Having |
000064b0  61 63 68 69 65 76 65 64  20 61 64 64 69 74 69 6f  |achieved additio|
000064c0  6e 20 61 6e 64 20 73 75  62 74 72 61 63 74 69 6f  |n and subtractio|
000064d0  6e 20 69 6e 20 74 68 65  20 6c 61 73 74 20 6d 6f  |n in the last mo|
000064e0  64 75 6c 65 2c 0d 20 20  20 20 20 20 77 65 20 6e  |dule,.      we n|
000064f0  6f 77 20 67 6f 20 6f 6e  20 74 6f 20 6d 75 6c 74  |ow go on to mult|
00006500  69 70 6c 69 63 61 74 69  6f 6e 20 61 6e 64 20 64  |iplication and d|
00006510  69 76 69 73 69 6f 6e 2e  20 20 54 68 65 20 67 65  |ivision.  The ge|
00006520  6e 65 72 61 6c 0d 20 20  20 20 20 20 72 75 6c 65  |neral.      rule|
00006530  20 66 6f 72 20 6d 75 6c  74 69 70 6c 69 63 61 74  | for multiplicat|
00006540  69 6f 6e 20 69 73 20 74  68 61 74 20 79 6f 75 20  |ion is that you |
00006550  6d 75 6c 74 69 70 6c 79  20 74 68 65 20 6d 61 6e  |multiply the man|
00006560  74 69 73 73 61 65 0d 20  20 20 20 20 20 61 6e 64  |tissae.      and|
00006570  20 61 64 64 20 74 68 65  20 65 78 70 6f 6e 65 6e  | add the exponen|
00006580  74 73 20 77 68 69 6c 65  20 66 6f 72 20 64 69 76  |ts while for div|
00006590  69 73 69 6f 6e 20 79 6f  75 20 64 69 76 69 64 65  |ision you divide|
000065a0  20 74 68 65 0d 20 20 20  20 20 20 6d 61 6e 74 69  | the.      manti|
000065b0  73 73 61 65 20 61 6e 64  20 73 75 62 74 72 61 63  |ssae and subtrac|
000065c0  74 20 74 68 65 20 65 78  70 6f 6e 65 6e 74 73 2e  |t the exponents.|
000065d0  0d 0d 20 20 20 20 20 20  54 68 65 20 70 72 6f 67  |..      The prog|
000065e0  72 61 6d 20 69 6e 20 74  68 69 73 20 6d 6f 64 75  |ram in this modu|
000065f0  6c 65 20 77 6f 72 6b 73  20 6f 6e 20 74 68 69 73  |le works on this|
00006600  20 62 61 73 69 73 2c 20  62 75 74 20 69 74 20 64  | basis, but it d|
00006610  6f 65 73 0d 20 20 20 20  20 20 68 69 67 68 6c 69  |oes.      highli|
00006620  67 68 74 20 61 20 66 65  77 20 70 72 6f 62 6c 65  |ght a few proble|
00006630  6d 73 2e 20 20 54 68 65  20 74 65 78 74 20 64 65  |ms.  The text de|
00006640  73 63 72 69 62 65 73 20  74 68 65 20 70 72 6f 67  |scribes the prog|
00006650  72 61 6d 0d 20 20 20 20  20 20 73 65 63 74 69 6f  |ram.      sectio|
00006660  6e 20 62 79 20 73 65 63  74 69 6f 6e 2c 20 61 6e  |n by section, an|
00006670  64 20 62 72 69 65 66 6c  79 20 64 69 73 63 75 73  |d briefly discus|
00006680  73 65 73 20 74 68 65 20  70 72 6f 62 6c 65 6d 73  |ses the problems|
00006690  20 66 6f 75 6e 64 0d 20  20 20 20 20 20 77 68 69  | found.      whi|
000066a0  6c 73 74 20 77 72 69 74  69 6e 67 20 69 74 2e 20  |lst writing it. |
000066b0  20 49 74 20 61 6c 73 6f  20 65 78 70 6c 61 69 6e  | It also explain|
000066c0  73 20 68 6f 77 20 42 61  73 69 63 20 73 65 74 73  |s how Basic sets|
000066d0  20 75 70 20 61 0d 20 20  20 20 20 20 70 61 72 61  | up a.      para|
000066e0  6d 65 74 65 72 20 62 6c  6f 63 6b 20 61 74 20 26  |meter block at &|
000066f0  36 30 30 20 66 6f 72 20  61 6e 79 20 70 61 72 61  |600 for any para|
00006700  6d 65 74 65 72 73 20 74  68 61 74 20 61 72 65 20  |meters that are |
00006710  70 61 73 73 65 64 0d 20  20 20 20 20 20 77 69 74  |passed.      wit|
00006720  68 20 74 68 65 20 43 41  4c 4c 20 63 6f 6d 6d 61  |h the CALL comma|
00006730  6e 64 2e 0d 0d 0d 50 61  72 74 20 32 34 3a 20 53  |nd....Part 24: S|
00006740  69 64 65 77 61 79 73 20  52 4f 4d 73 0d 0d 20 20  |ideways ROMs..  |
00006750  20 20 20 20 4f 6e 65 20  6f 66 20 74 68 65 20 6d  |    One of the m|
00006760  6f 72 65 20 75 6e 75 73  75 61 6c 20 61 6e 64 20  |ore unusual and |
00006770  70 6f 77 65 72 66 75 6c  20 70 61 72 74 73 20 6f  |powerful parts o|
00006780  66 20 74 68 65 20 42 42  43 20 4d 69 63 72 6f 0d  |f the BBC Micro.|
00006790  20 20 20 20 20 20 69 73  20 74 68 65 20 75 73 65  |      is the use|
000067a0  20 6f 66 20 73 69 64 65  77 61 79 73 20 52 4f 4d  | of sideways ROM|
000067b0  73 2e 20 20 54 68 65 79  20 61 72 65 20 63 61 6c  |s.  They are cal|
000067c0  6c 65 64 20 73 69 64 65  77 61 79 73 0d 20 20 20  |led sideways.   |
000067d0  20 20 20 62 65 63 61 75  73 65 20 73 65 76 65 72  |   because sever|
000067e0  61 6c 20 6f 66 20 74 68  65 6d 20 63 61 6e 20 65  |al of them can e|
000067f0  78 69 73 74 2c 20 73 69  64 65 20 62 79 20 73 69  |xist, side by si|
00006800  64 65 2c 20 69 6e 20 74  68 65 20 73 61 6d 65 0d  |de, in the same.|
00006810  20 20 20 20 20 20 61 64  64 72 65 73 73 20 73 70  |      address sp|
00006820  61 63 65 20 69 6e 20 74  68 65 20 6d 65 6d 6f 72  |ace in the memor|
00006830  79 20 6d 61 70 2e 20 20  54 68 65 20 73 70 61 63  |y map.  The spac|
00006840  65 20 62 65 74 77 65 65  6e 20 26 38 30 30 30 0d  |e between &8000.|
00006850  20 20 20 20 20 20 61 6e  64 20 26 42 46 46 46 20  |      and &BFFF |
00006860  69 6e 20 74 68 65 20 6d  69 63 72 6f 27 73 20 6d  |in the micro's m|
00006870  65 6d 6f 72 79 20 69 73  20 67 69 76 65 6e 20 6f  |emory is given o|
00006880  76 65 72 20 74 6f 20 74  68 65 73 65 0d 20 20 20  |ver to these.   |
00006890  20 20 20 73 69 64 65 77  61 79 73 20 52 4f 4d 73  |   sideways ROMs|
000068a0  20 77 68 69 63 68 20 63  61 6e 20 68 6f 6c 64 20  | which can hold |
000068b0  61 20 6c 61 6e 67 75 61  67 65 20 28 6c 69 6b 65  |a language (like|
000068c0  20 42 41 53 49 43 20 6f  72 20 61 0d 20 20 20 20  | BASIC or a.    |
000068d0  20 20 77 6f 72 64 20 70  72 6f 63 65 73 73 6f 72  |  word processor|
000068e0  29 2c 20 6f 72 20 63 61  6e 20 62 65 20 73 65 72  |), or can be ser|
000068f0  76 69 63 65 20 52 4f 4d  73 20 74 68 61 74 20 63  |vice ROMs that c|
00006900  6f 6e 74 61 69 6e 20 75  74 69 6c 69 74 79 0d 20  |ontain utility. |
00006910  20 20 20 20 20 70 72 6f  67 72 61 6d 73 2e 0d 0d  |     programs...|
00006920  20 20 20 20 20 20 54 68  65 20 6f 70 65 72 61 74  |      The operat|
00006930  69 6e 67 20 73 79 73 74  65 6d 20 63 61 6e 20 73  |ing system can s|
00006940  65 6c 65 63 74 20 77 68  69 63 68 20 6f 6e 65 20  |elect which one |
00006950  6f 75 74 20 6f 66 20 61  20 70 6f 73 73 69 62 6c  |out of a possibl|
00006960  65 0d 20 20 20 20 20 20  73 69 78 74 65 65 6e 20  |e.      sixteen |
00006970  69 73 20 61 63 74 75 61  6c 6c 79 20 69 6e 20 74  |is actually in t|
00006980  68 65 20 6d 65 6d 6f 72  79 20 6d 61 70 20 61 74  |he memory map at|
00006990  20 61 6e 79 20 70 61 72  74 69 63 75 6c 61 72 0d  | any particular.|
000069a0  20 20 20 20 20 20 6d 6f  6d 65 6e 74 20 62 79 20  |      moment by |
000069b0  77 72 69 74 69 6e 67 20  74 6f 20 61 20 66 6f 75  |writing to a fou|
000069c0  72 20 62 69 74 20 72 65  67 69 73 74 65 72 20 61  |r bit register a|
000069d0  74 20 26 46 45 33 30 2e  20 20 53 69 6e 63 65 0d  |t &FE30.  Since.|
000069e0  20 20 20 20 20 20 74 68  65 20 70 72 6f 63 65 73  |      the proces|
000069f0  73 20 6f 66 20 73 65 6c  65 63 74 69 6e 67 20 6f  |s of selecting o|
00006a00  6e 65 20 69 73 20 6b 6e  6f 77 6e 20 61 73 20 27  |ne is known as '|
00006a10  70 61 67 69 6e 67 20 69  74 20 69 6e 74 6f 20 74  |paging it into t|
00006a20  68 65 0d 20 20 20 20 20  20 6d 65 6d 6f 72 79 20  |he.      memory |
00006a30  6d 61 70 27 2c 20 74 68  65 73 65 20 52 4f 4d 53  |map', these ROMS|
00006a40  20 61 72 65 20 73 6f 6d  65 74 69 6d 65 73 20 6b  | are sometimes k|
00006a50  6e 6f 77 6e 20 61 73 20  70 61 67 65 64 20 52 4f  |nown as paged RO|
00006a60  4d 73 2e 20 0d 20 20 20  20 20 20 4f 6e 20 61 6e  |Ms. .      On an|
00006a70  20 75 6e 65 78 70 61 6e  64 65 64 20 42 42 43 20  | unexpanded BBC |
00006a80  42 20 74 68 65 72 65 20  61 72 65 20 66 6f 75 72  |B there are four|
00006a90  20 73 6f 63 6b 65 74 73  20 6f 6e 20 74 68 65 20  | sockets on the |
00006aa0  6d 61 69 6e 0d 20 20 20  20 20 20 70 72 69 6e 74  |main.      print|
00006ab0  65 64 20 63 69 72 63 75  69 74 20 62 6f 61 72 64  |ed circuit board|
00006ac0  2c 20 62 75 74 20 6d 61  6e 79 20 70 65 6f 70 6c  |, but many peopl|
00006ad0  65 20 68 61 76 65 20 61  64 64 65 64 20 65 78 74  |e have added ext|
00006ae0  72 61 0d 20 20 20 20 20  20 73 6f 63 6b 65 74 73  |ra.      sockets|
00006af0  20 74 6f 20 62 72 69 6e  67 20 74 68 65 20 74 6f  | to bring the to|
00006b00  74 61 6c 20 75 70 20 74  6f 20 31 36 2e 0d 0d 20  |tal up to 16... |
00006b10  20 20 20 20 20 54 2f 4f  53 42 32 34 20 65 78 70  |     T/OSB24 exp|
00006b20  6c 61 69 6e 73 20 74 68  65 20 70 72 69 6e 63 69  |lains the princi|
00006b30  70 6c 65 73 20 62 65 68  69 6e 64 20 66 6f 72 6d  |ples behind form|
00006b40  61 74 74 69 6e 67 20 73  69 64 65 77 61 79 73 0d  |atting sideways.|
00006b50  20 20 20 20 20 20 52 4f  4d 53 2c 20 61 6e 64 20  |      ROMS, and |
00006b60  62 72 69 65 66 6c 79 20  6c 69 73 74 73 20 74 68  |briefly lists th|
00006b70  65 20 73 65 72 76 69 63  65 20 63 61 6c 6c 73 20  |e service calls |
00006b80  74 68 61 74 20 70 61 73  73 20 74 68 72 6f 75 67  |that pass throug|
00006b90  68 0d 20 20 20 20 20 20  54 68 65 6d 2e 20 20 54  |h.      Them.  T|
00006ba0  68 65 20 70 61 67 65 64  20 6d 65 6d 6f 72 79 20  |he paged memory |
00006bb0  63 61 6e 20 62 65 20 52  41 4d 20 61 73 20 77 65  |can be RAM as we|
00006bc0  6c 6c 20 61 73 20 52 4f  4d 2c 20 74 68 65 20 4f  |ll as ROM, the O|
00006bd0  53 0d 20 20 20 20 20 20  64 6f 65 73 6e 27 74 20  |S.      doesn't |
00006be0  63 61 72 65 20 77 68 69  63 68 2e 20 20 57 69 74  |care which.  Wit|
00006bf0  68 20 73 69 64 65 77 61  79 73 20 52 41 4d 20 79  |h sideways RAM y|
00006c00  6f 75 20 63 61 6e 20 6c  6f 61 64 20 69 6e 20 77  |ou can load in w|
00006c10  68 61 74 0d 20 20 20 20  20 20 69 73 20 63 61 6c  |hat.      is cal|
00006c20  6c 65 64 20 61 20 27 52  4f 4d 20 49 6d 61 67 65  |led a 'ROM Image|
00006c30  27 20 66 72 6f 6d 20 64  69 73 63 2c 20 61 6e 64  |' from disc, and|
00006c40  20 74 68 65 20 52 41 4d  20 77 69 6c 6c 20 74 68  | the RAM will th|
00006c50  65 6e 0d 20 20 20 20 20  20 62 65 68 61 76 65 20  |en.      behave |
00006c60  61 73 20 69 66 20 69 74  20 77 61 73 20 61 20 73  |as if it was a s|
00006c70  69 64 65 77 61 79 73 20  52 4f 4d 2e 20 20 54 68  |ideways ROM.  Th|
00006c80  65 20 70 72 6f 67 72 61  6d 20 42 2f 4f 53 42 32  |e program B/OSB2|
00006c90  34 0d 20 20 20 20 20 20  70 72 6f 64 75 63 65 73  |4.      produces|
00006ca0  20 61 20 52 4f 4d 20 69  6d 61 67 65 20 77 68 69  | a ROM image whi|
00006cb0  63 68 20 63 61 6e 20 62  65 20 6c 6f 61 64 65 64  |ch can be loaded|
00006cc0  20 69 6e 74 6f 20 73 69  64 65 77 61 79 73 20 52  | into sideways R|
00006cd0  41 4d 0d 20 20 20 20 20  20 61 6e 64 20 6d 6f 64  |AM.      and mod|
00006ce0  69 66 69 65 64 2e 20 20  59 6f 75 20 63 61 6e 20  |ified.  You can |
00006cf0  74 68 65 6e 20 65 78 70  65 72 69 6d 65 6e 74 20  |then experiment |
00006d00  77 69 74 68 20 79 6f 75  72 20 6f 77 6e 20 52 4f  |with your own RO|
00006d10  4d 20 61 6e 64 0d 20 20  20 20 20 20 69 6e 76 65  |M and.      inve|
00006d20  73 74 69 67 61 74 65 20  74 68 65 20 73 65 72 76  |stigate the serv|
00006d30  69 63 65 20 63 61 6c 6c  73 20 73 65 6e 74 20 62  |ice calls sent b|
00006d40  79 20 74 68 65 20 4f 53  2e 20 20 28 52 65 71 75  |y the OS.  (Requ|
00006d50  69 72 65 73 0d 20 20 20  20 20 20 42 41 53 49 43  |ires.      BASIC|
00006d60  2d 32 20 6f 72 20 6c 61  74 65 72 29 0d 0d 0d 50  |-2 or later)...P|
00006d70  61 72 74 20 32 35 3a 20  4c 65 67 61 6c 20 61 6e  |art 25: Legal an|
00006d80  64 20 49 6c 6c 65 67 61  6c 20 43 6f 64 65 0d 0d  |d Illegal Code..|
00006d90  20 20 20 20 20 20 59 6f  75 20 6f 66 74 65 6e 20  |      You often |
00006da0  72 65 61 64 20 61 62 6f  75 74 20 70 72 6f 67 72  |read about progr|
00006db0  61 6d 6d 69 6e 67 20 74  65 63 68 6e 69 71 75 65  |amming technique|
00006dc0  73 20 77 69 74 68 20 74  68 65 20 42 42 43 0d 20  |s with the BBC. |
00006dd0  20 20 20 20 20 4d 69 63  72 6f 20 66 61 6d 69 6c  |     Micro famil|
00006de0  79 20 74 68 61 74 20 41  63 6f 72 6e 20 64 65 73  |y that Acorn des|
00006df0  63 72 69 62 65 20 61 73  20 27 69 6c 6c 65 67 61  |cribe as 'illega|
00006e00  6c 27 2e 20 20 54 68 65  20 63 6f 6e 63 65 70 74  |l'.  The concept|
00006e10  0d 20 20 20 20 20 20 6f  66 20 6c 65 67 61 6c 69  |.      of legali|
00006e20  74 79 20 69 6e 20 74 68  65 20 42 42 43 20 4d 69  |ty in the BBC Mi|
00006e30  63 72 6f 20 72 65 6c 61  74 65 73 20 74 6f 20 75  |cro relates to u|
00006e40  73 69 6e 67 20 74 68 65  20 4f 53 20 69 6e 20 61  |sing the OS in a|
00006e50  0d 20 20 20 20 20 20 63  65 72 74 61 69 6e 20 77  |.      certain w|
00006e60  61 79 2e 20 20 54 68 65  20 63 6c 61 73 73 69 63  |ay.  The classic|
00006e70  20 65 78 61 6d 70 6c 65  20 69 73 20 77 72 69 74  | example is writ|
00006e80  69 6e 67 20 74 6f 20 74  68 65 20 73 63 72 65 65  |ing to the scree|
00006e90  6e 2e 20 0d 20 20 20 20  20 20 59 6f 75 20 63 61  |n. .      You ca|
00006ea0  6e 20 65 69 74 68 65 72  20 75 73 65 20 50 4c 4f  |n either use PLO|
00006eb0  54 20 63 6f 6d 6d 61 6e  64 73 2c 20 66 72 6f 6d  |T commands, from|
00006ec0  20 6d 61 63 68 69 6e 65  20 63 6f 64 65 20 6f 72  | machine code or|
00006ed0  20 66 72 6f 6d 0d 20 20  20 20 20 20 61 20 68 69  | from.      a hi|
00006ee0  67 68 20 6c 65 76 65 6c  20 6c 61 6e 67 75 61 67  |gh level languag|
00006ef0  65 20 6c 69 6b 65 20 42  41 53 49 43 2c 20 6f 72  |e like BASIC, or|
00006f00  20 79 6f 75 20 63 61 6e  20 61 63 74 75 61 6c 6c  | you can actuall|
00006f10  79 20 27 70 6f 6b 65 27  0d 20 20 20 20 20 20 6e  |y 'poke'.      n|
00006f20  75 6d 62 65 72 73 20 69  6e 74 6f 20 74 68 65 20  |umbers into the |
00006f30  73 63 72 65 65 6e 20 6d  65 6d 6f 72 79 20 64 69  |screen memory di|
00006f40  72 65 63 74 6c 79 20 74  6f 20 6c 69 67 68 74 20  |rectly to light |
00006f50  75 70 0d 20 20 20 20 20  20 69 6e 64 69 76 69 64  |up.      individ|
00006f60  75 61 6c 20 70 69 78 65  6c 73 2e 0d 0d 20 20 20  |ual pixels...   |
00006f70  20 20 20 54 68 65 20 61  64 76 61 6e 74 61 67 65  |   The advantage|
00006f80  20 6f 66 20 69 6c 6c 65  67 61 6c 20 63 6f 64 65  | of illegal code|
00006f90  20 69 73 20 74 68 61 74  20 69 74 20 75 73 75 61  | is that it usua|
00006fa0  6c 6c 79 20 77 6f 72 6b  73 0d 20 20 20 20 20 20  |lly works.      |
00006fb0  66 61 73 74 65 72 2c 20  61 6e 64 20 73 6f 20 69  |faster, and so i|
00006fc0  73 20 6f 66 74 65 6e 20  75 73 65 64 20 69 6e 20  |s often used in |
00006fd0  61 72 63 61 64 65 20 67  61 6d 65 73 2e 20 20 43  |arcade games.  C|
00006fe0  6f 64 65 20 74 68 61 74  20 69 73 0d 20 20 20 20  |ode that is.    |
00006ff0  20 20 69 6c 6c 65 67 61  6c 2c 20 61 6e 64 20 70  |  illegal, and p|
00007000  6f 6b 65 73 20 74 68 65  20 73 63 72 65 65 6e 20  |okes the screen |
00007010  6d 65 6d 6f 72 79 20 64  69 72 65 63 74 6c 79 20  |memory directly |
00007020  66 6f 72 20 65 78 61 6d  70 6c 65 2c 0d 20 20 20  |for example,.   |
00007030  20 20 20 63 61 6e 6e 6f  74 20 62 65 20 67 75 61  |   cannot be gua|
00007040  72 61 6e 74 65 65 64 20  74 6f 20 72 75 6e 20 6f  |ranteed to run o|
00007050  6e 20 61 6e 79 20 6d 61  63 68 69 6e 65 2e 20 20  |n any machine.  |
00007060  4c 65 67 61 6c 6c 79 20  77 72 69 74 74 65 6e 0d  |Legally written.|
00007070  20 20 20 20 20 20 63 6f  64 65 20 27 66 75 74 75  |      code 'futu|
00007080  72 65 2d 70 72 6f 6f 66  73 27 20 79 6f 75 72 20  |re-proofs' your |
00007090  70 72 6f 67 72 61 6d 20  61 67 61 69 6e 73 74 20  |program against |
000070a0  64 69 66 66 65 72 65 6e  63 65 73 0d 20 20 20 20  |differences.    |
000070b0  20 20 62 65 74 77 65 65  6e 20 74 68 65 20 4f 53  |  between the OS|
000070c0  20 69 6e 20 79 6f 75 72  20 6d 61 63 68 69 6e 65  | in your machine|
000070d0  20 61 6e 64 20 74 68 61  74 20 69 6e 20 6f 74 68  | and that in oth|
000070e0  65 72 73 2e 20 20 46 75  74 75 72 65 2d 0d 20 20  |ers.  Future-.  |
000070f0  20 20 20 20 70 72 6f 6f  66 69 6e 67 20 79 6f 75  |    proofing you|
00007100  72 20 6d 61 63 68 69 6e  65 20 63 6f 64 65 20 69  |r machine code i|
00007110  6e 20 74 68 69 73 20 77  61 79 20 69 73 20 74 68  |n this way is th|
00007120  65 20 73 74 72 6f 6e 67  65 73 74 0d 20 20 20 20  |e strongest.    |
00007130  20 20 61 72 67 75 6d 65  6e 74 20 66 6f 72 20 6c  |  argument for l|
00007140  65 67 61 6c 20 63 6f 64  65 20 61 6e 64 2c 20 69  |egal code and, i|
00007150  6e 20 61 6c 6c 20 63 61  73 65 73 20 65 78 63 65  |n all cases exce|
00007160  70 74 20 61 72 63 61 64  65 0d 20 20 20 20 20 20  |pt arcade.      |
00007170  67 61 6d 65 73 2c 20 69  73 20 70 72 65 74 74 79  |games, is pretty|
00007180  20 75 6e 63 68 61 6c 6c  65 6e 67 65 61 62 6c 65  | unchallengeable|
00007190  2e 0d 0d 20 20 20 20 20  20 54 68 65 20 70 72 6f  |...      The pro|
000071a0  67 72 61 6d 20 69 6e 20  74 68 69 73 20 6d 6f 64  |gram in this mod|
000071b0  75 6c 65 20 77 72 69 74  65 73 20 64 69 72 65 63  |ule writes direc|
000071c0  74 6c 79 20 74 6f 20 74  68 65 20 73 63 72 65 65  |tly to the scree|
000071d0  6e 20 69 6e 0d 20 20 20  20 20 20 61 6e 20 69 6c  |n in.      an il|
000071e0  6c 65 67 61 6c 20 77 61  79 20 74 6f 20 64 65 6d  |legal way to dem|
000071f0  6f 6e 73 74 72 61 74 65  20 74 68 65 20 65 78 74  |onstrate the ext|
00007200  72 61 20 73 70 65 65 64  20 74 68 69 73 20 70 72  |ra speed this pr|
00007210  6f 76 69 64 65 73 2e 20  0d 20 20 20 20 20 20 49  |ovides. .      I|
00007220  74 20 61 6c 73 6f 20 73  68 6f 77 73 20 74 68 65  |t also shows the|
00007230  20 65 78 74 72 61 20 63  6f 6d 70 6c 69 63 61 74  | extra complicat|
00007240  69 6f 6e 73 20 69 6e 20  74 68 65 20 63 6f 64 65  |ions in the code|
00007250  20 63 61 75 73 65 64 20  62 79 0d 20 20 20 20 20  | caused by.     |
00007260  20 74 68 65 20 6e 6f 6e  2d 6c 69 6e 65 61 72 20  | the non-linear |
00007270  73 63 72 65 65 6e 20 61  64 64 72 65 73 73 69 6e  |screen addressin|
00007280  67 20 69 6e 20 74 68 65  20 42 42 43 20 4d 69 63  |g in the BBC Mic|
00007290  72 6f 2e 20 20 42 79 0d  20 20 20 20 20 20 74 72  |ro.  By.      tr|
000072a0  79 69 6e 67 20 74 6f 20  72 75 6e 20 74 68 69 73  |ying to run this|
000072b0  20 63 6f 64 65 20 69 6e  20 61 20 73 65 63 6f 6e  | code in a secon|
000072c0  64 20 70 72 6f 63 65 73  73 6f 72 2c 20 6f 72 20  |d processor, or |
000072d0  69 6e 20 61 0d 20 20 20  20 20 20 6d 61 63 68 69  |in a.      machi|
000072e0  6e 65 20 77 69 74 68 20  73 68 61 64 6f 77 20 52  |ne with shadow R|
000072f0  41 4d 2c 20 79 6f 75 20  77 6f 75 6c 64 20 73 6f  |AM, you would so|
00007300  6f 6e 20 66 69 6e 64 20  74 68 61 74 20 69 74 20  |on find that it |
00007310  77 6f 75 6c 64 0d 20 20  20 20 20 20 6e 6f 74 20  |would.      not |
00007320  77 6f 72 6b 2e 0d 0d 0d  50 61 72 74 20 32 36 3a  |work....Part 26:|
00007330  20 45 64 69 74 69 6e 67  20 59 6f 75 72 20 53 6f  | Editing Your So|
00007340  75 72 63 65 20 43 6f 64  65 0d 0d 20 20 20 20 20  |urce Code..     |
00007350  20 42 72 69 6e 67 69 6e  67 20 75 70 20 74 68 65  | Bringing up the|
00007360  20 72 65 61 72 20 69 6e  20 74 68 69 73 20 73 65  | rear in this se|
00007370  72 69 65 73 20 69 73 20  61 20 62 72 69 65 66 20  |ries is a brief |
00007380  64 69 73 63 75 73 73 69  6f 6e 0d 20 20 20 20 20  |discussion.     |
00007390  20 61 62 6f 75 74 20 65  64 69 74 69 6e 67 20 73  | about editing s|
000073a0  6f 75 72 63 65 20 63 6f  64 65 2e 20 20 44 65 73  |ource code.  Des|
000073b0  70 69 74 65 20 68 61 76  69 6e 67 20 72 65 61 73  |pite having reas|
000073c0  6f 6e 61 62 6c 65 0d 20  20 20 20 20 20 66 61 63  |onable.      fac|
000073d0  69 6c 69 74 69 65 73 20  66 6f 72 20 6c 69 6e 65  |ilities for line|
000073e0  20 65 64 69 74 69 6e 67  2c 20 6f 6e 65 20 6f 66  | editing, one of|
000073f0  20 74 68 65 20 70 72 6f  62 6c 65 6d 73 20 6f 66  | the problems of|
00007400  20 77 6f 72 6b 69 6e 67  0d 20 20 20 20 20 20 77  | working.      w|
00007410  69 74 68 20 6c 61 72 67  65 20 62 6f 64 69 65 73  |ith large bodies|
00007420  20 6f 66 20 63 6f 64 65  20 6f 6e 20 74 68 65 20  | of code on the |
00007430  42 42 43 20 4d 69 63 72  6f 20 69 73 20 74 68 61  |BBC Micro is tha|
00007440  74 20 79 6f 75 20 6f 66  74 65 6e 0d 20 20 20 20  |t you often.    |
00007450  20 20 77 69 73 68 20 79  6f 75 20 63 6f 75 6c 64  |  wish you could|
00007460  20 65 64 69 74 20 69 74  20 6c 69 6b 65 20 79 6f  | edit it like yo|
00007470  75 20 77 6f 75 6c 64 20  74 65 78 74 20 6f 6e 20  |u would text on |
00007480  61 20 77 6f 72 64 0d 20  20 20 20 20 20 70 72 6f  |a word.      pro|
00007490  63 65 73 73 6f 72 3b 20  6d 6f 76 69 6e 67 20 62  |cessor; moving b|
000074a0  6c 6f 63 6b 73 20 61 62  6f 75 74 20 61 6e 64 20  |locks about and |
000074b0  72 65 70 6c 61 63 69 6e  67 20 73 74 72 69 6e 67  |replacing string|
000074c0  73 2e 0d 0d 20 20 20 20  20 20 54 68 65 72 65 20  |s...      There |
000074d0  61 72 65 20 42 41 53 49  43 20 70 72 6f 67 72 61  |are BASIC progra|
000074e0  6d 20 65 64 69 74 6f 72  73 20 61 76 61 69 6c 61  |m editors availa|
000074f0  62 6c 65 2c 20 20 61 6e  64 20 77 69 74 68 20 74  |ble,  and with t|
00007500  68 65 20 42 42 43 0d 20  20 20 20 20 20 4d 61 73  |he BBC.      Mas|
00007510  74 65 72 20 6d 69 63 72  6f 20 79 6f 75 20 68 61  |ter micro you ha|
00007520  76 65 20 74 68 65 20 27  45 44 49 54 27 20 66 61  |ve the 'EDIT' fa|
00007530  63 69 6c 69 74 79 20 74  6f 20 6c 65 74 20 79 6f  |cility to let yo|
00007540  75 20 64 6f 20 6a 75 73  74 0d 20 20 20 20 20 20  |u do just.      |
00007550  74 68 69 73 2e 20 20 49  74 20 64 65 2d 74 6f 6b  |this.  It de-tok|
00007560  65 6e 69 73 65 73 20 74  68 65 20 42 41 53 49 43  |enises the BASIC|
00007570  20 66 69 6c 65 20 79 6f  75 20 61 72 65 20 77 6f  | file you are wo|
00007580  72 6b 69 6e 67 20 6f 6e  20 61 6e 64 0d 20 20 20  |rking on and.   |
00007590  20 20 20 70 75 74 73 20  69 74 20 69 6e 20 6d 65  |   puts it in me|
000075a0  6d 6f 72 79 20 72 65 61  64 79 20 66 6f 72 20 74  |mory ready for t|
000075b0  68 65 20 45 44 49 54 20  70 72 6f 63 65 73 73 2e  |he EDIT process.|
000075c0  20 20 57 68 65 6e 20 79  6f 75 20 65 78 69 74 0d  |  When you exit.|
000075d0  20 20 20 20 20 20 66 72  6f 6d 20 45 44 49 54 2c  |      from EDIT,|
000075e0  20 74 68 65 20 65 64 69  74 65 64 20 74 65 78 74  | the edited text|
000075f0  20 69 73 20 70 75 74 20  62 61 63 6b 20 69 6e 74  | is put back int|
00007600  6f 20 6d 65 6d 6f 72 79  2c 20 77 69 74 68 0d 20  |o memory, with. |
00007610  20 20 20 20 20 6c 69 6e  65 20 6e 75 6d 62 65 72  |     line number|
00007620  73 20 61 64 64 65 64 2c  20 61 73 20 61 20 42 41  |s added, as a BA|
00007630  53 49 43 20 70 72 6f 67  72 61 6d 2e 0d 0d 20 20  |SIC program...  |
00007640  20 20 20 20 49 66 20 79  6f 75 20 68 61 76 65 20  |    If you have |
00007650  61 20 77 6f 72 64 20 70  72 6f 63 65 73 73 6f 72  |a word processor|
00007660  20 61 6e 64 20 61 20 64  69 73 63 20 64 72 69 76  | and a disc driv|
00007670  65 2c 20 79 6f 75 20 63  61 6e 0d 20 20 20 20 20  |e, you can.     |
00007680  20 65 61 73 69 6c 79 20  63 61 72 72 79 20 6f 75  | easily carry ou|
00007690  74 20 74 68 69 73 20 6b  69 6e 64 20 6f 66 20 6f  |t this kind of o|
000076a0  70 65 72 61 74 69 6f 6e  2e 20 20 4d 61 6e 79 20  |peration.  Many |
000076b0  6f 66 20 74 68 65 0d 20  20 20 20 20 20 61 73 73  |of the.      ass|
000076c0  65 6d 62 6c 65 72 20 6d  6f 64 75 6c 65 73 20 6f  |embler modules o|
000076d0  66 20 4f 53 62 69 74 73  20 77 65 72 65 20 65 64  |f OSbits were ed|
000076e0  69 74 65 64 20 75 73 69  6e 67 20 56 49 45 57 20  |ited using VIEW |
000076f0  69 6e 20 74 68 69 73 0d  20 20 20 20 20 20 77 61  |in this.      wa|
00007700  79 2e 20 20 41 73 20 74  68 65 20 74 65 78 74 20  |y.  As the text |
00007710  66 69 6c 65 20 69 6e 20  74 68 69 73 20 6d 6f 64  |file in this mod|
00007720  75 6c 65 20 65 78 70 6c  61 69 6e 73 2c 20 61 66  |ule explains, af|
00007730  74 65 72 0d 20 20 20 20  20 20 6d 6f 64 69 66 79  |ter.      modify|
00007740  69 6e 67 20 79 6f 75 72  20 74 65 78 74 2c 20 79  |ing your text, y|
00007750  6f 75 20 73 61 76 65 20  69 74 20 69 6e 20 61 6e  |ou save it in an|
00007760  20 41 53 43 49 49 20 66  69 6c 65 2c 20 61 6e 64  | ASCII file, and|
00007770  0d 20 20 20 20 20 20 66  69 6e 61 6c 6c 79 20 2a  |.      finally *|
00007780  45 58 45 43 20 69 74 20  62 61 63 6b 20 69 6e 74  |EXEC it back int|
00007790  6f 20 79 6f 75 72 20 63  6f 6d 70 75 74 65 72 20  |o your computer |
000077a0  77 68 65 72 65 20 79 6f  75 20 63 61 6e 20 72 75  |where you can ru|
000077b0  6e 0d 20 20 20 20 20 20  69 74 2e 0d 0d 20 20 20  |n.      it...   |
000077c0  20 20 20 54 68 65 20 70  72 6f 67 72 61 6d 20 77  |   The program w|
000077d0  69 74 68 20 74 68 69 73  20 6d 6f 64 75 6c 65 20  |ith this module |
000077e0  69 73 20 61 20 74 65 78  74 20 66 69 6c 65 20 76  |is a text file v|
000077f0  65 72 73 69 6f 6e 20 6f  66 20 61 0d 20 20 20 20  |ersion of a.    |
00007800  20 20 70 72 6f 67 72 61  6d 20 69 6e 20 42 41 53  |  program in BAS|
00007810  49 43 20 61 6e 64 20 61  73 73 65 6d 62 6c 65 72  |IC and assembler|
00007820  20 77 68 69 63 68 20 27  75 6e 70 6c 75 67 73 27  | which 'unplugs'|
00007830  20 61 6e 79 20 73 69 64  65 77 61 79 73 0d 20 20  | any sideways.  |
00007840  20 20 20 20 52 4f 4d 20  69 6e 20 73 6f 66 74 77  |    ROM in softw|
00007850  61 72 65 20 74 6f 20 73  74 6f 70 20 63 6c 61 73  |are to stop clas|
00007860  68 65 73 20 6f 76 65 72  20 77 6f 72 6b 73 70 61  |hes over workspa|
00007870  63 65 20 6f 72 20 63 6f  6d 6d 61 6e 64 73 2e 0d  |ce or commands..|
00007880  0d 0d 0d 20 20 20 20 20  20 20 20 20 20 20 20 20  |...             |
00007890  20 20 20 20 20 20 20 20  20 20 20 20 2d 2d 2d 2d  |            ----|
000078a0  2d 20 6f 4f 6f 20 2d 2d  2d 2d 2d 0d              |- oOo -----.|
000078ac
11_10_87/T\INDEX.m0
11_10_87/T\INDEX.m1
11_10_87/T\INDEX.m2
11_10_87/T\INDEX.m4
11_10_87/T\INDEX.m5