Home » CEEFAX disks » telesoftware3.adl » 13_11_87/T\OSB04

13_11_87/T\OSB04

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 » telesoftware3.adl
Filename: 13_11_87/T\OSB04
Read OK:
File size: 3438 bytes
Load address: 0000
Exec address: 0000
File contents
OSBITS - An Exploration of the BBC Micro at Machine Level

By Programmer

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


Part 4: Memory


In this module we'll look at how the BBC Micro's memory is
used.  The way it is laid out is called a memory map.

But first a short note about pages:

In the micro a block of 256 bytes of memory is called a
page.  It's easier in hexadecimal since 256 = &100.  You can
see, I hope, that when you refer to page X you mean the
memory from &X00 to &XFF.  PAGE in BASIC is so called
because it sets the page at which your BASIC program's
workspace starts.  This is &E00 on a Master or a B without a
disc filing system and &1900 on a B with a DFS.

The bottom 256 bytes of memory, from &00 to &FF is called
ZERO PAGE (X is 0) and the 6502 needs it for some
operations.  It is useful because the memory location, being
less that 256, can be held in a byte which speeds up
processing.

The 6502 microprocessor and its variants, use 16 bits for
their addressing.  The program counter is therefore two
bytes in size which means that any address from 0 to 65535
(&00 to &FFFF) can be accessed directly.

In the BBC Micro (using BASIC) the memory is divided up like
this:

    FFFF            
            The operating system lives here
    C000
    ------------------------------------------
    BFFF
            The current language, e.g. BASIC
            lives here
    8000
    ------------------------------------------
    7FFF
            This memory is used by the screen
            and how much is used depends on 
            the mode being used
    HIMEM
    ------------------------------------------
            This memory is used by your BASIC
            program
    PAGE
   -------------------------------------------        
            This memory is used by the BASIC
            interpreter, the operating system
            and the filing systems
    0000

The memory from &0000 to &7FFF is Random Access Memory, or
RAM, and you can write into it as well as read from it.  The
memory from &8000 to &FFFF is Read Only Memory, or ROM, and
you cannot write to it.  You can try, but nothing will
happen.  (N.B. in a 6502 second processor things are
different.  The operating system is absent and all memory is
RAM so you can cause havoc by writing between &8000 and
&FFFF.)

The chart shows the memory map for a Model B.  On a B+ or
Master there is extra memory available at the same address
as the screen memory.  This gives both main RAM and 'shadow
RAM' available between &3000 and &7FFF.  The idea is that
the operating system tells if you are writing to the screen
(i.e. are Printing or Drawing etc) and if so uses the shadow
RAM.  Pure memory work, like a BASIC program itself, goes
into the main RAM.  In this way you have access to all the
user RAM even in MODE 2.  Shadow RAM can also exist
elsewhere on these machines, particularly the Master, but
the 'Shadow Screen' area is the most important.  Add-on
Shadow Screen boards are available for the BBC B.

So-called Sideways RAM occupies the same memory as the
language (&8000 to &BFFF) and we'll deal with this in a
later file.

As I've said before, BASIC takes care of you. Compared to
machine code it's a nanny and once you move over to
assembler you are the babes in the memory map.  You have to
decide where you want to put your code.  The assembler will
put it where you say you want it to go.  This can lead to
three common mistakes.

    1: Loading code over your source code
    2: Loading code over workspace
    3: Loading code into screen memory

If you are working in the second processor you can also load
code over your language.

There are two ways around this problem.  Firstly you can
learn where you can safely put your code.  Secondly you can
let BASIC put it somewhere safe for you.

In most of my code examples so far I have used the BASIC DIM
statement to allocate a chunk of memory into which I
assembled some code.  Initially this is the best way of
going about things.  If you think you will need 256 bytes of
space then put

                  DIM code% 256

at the top of your source code. If eventually you actually
use more than 256 bytes then the most likely thing is you
will over-write the space in which BASIC stores variables
and a 'no such variable' error will be generated during the
second pass of the assembler.  This is not a fatal error,
i.e. you can recover simply by increasing the memory you
reserve and running the assembly again.

The BBC Micro is designed primarily for use with BASIC and
so you have to think carefully before choosing memory for
your own machine code routines.  Early versions of the user
guide said that page D (&D00 to &DFF) was available for user
machine code but this was later revised.  In fact in a
machine with discs this is the NMI workspace.  NMI means Non
Maskable Interrupt, we'll come onto interrupts later, and
you can take it from me that you don't mess with the NMI
workspace or your disc drives cease to function .... or
worse.

There are two types of places to put machine code.  Firstly
you can reserve memory safe from intrusion.  This is either
within your program workspace (by using DIM as above) or
below PAGE or above HIMEM.

PAGE is the pseudo variable that is normally set to the
lowest memory location that is not used by the operating
system or filing systems or utility ROMS as workspace and so
is free for BASIC programs.  On a completely unexpanded
machine it is at &E00 (it always lies at a page boundary)
and adding an Acorn DFS raises it to &1900.  The BBC ATS
raises it to &1A00 when the adapter is active.  To find your
default PAGE value press control/break and, in BASIC, enter
PRINT ~PAGE.  This will print out the value of PAGE in hex.

If you deliberately set it higher than the default for your
machine configuration then you can safely use the space
between.  For example, assume you want 256 bytes of space,
and PAGE is normally at &1900.  By typing PAGE=&1A00 you
stop BASIC (including your source code) getting at page &19
and you can then assemble your code there by setting P% to
&1900 at the start of each pass of your assembly.

HIMEM is the pseudo variable that is usually set to the
first byte that BASIC does not use, normally the first byte
of screen memory.  When using an unexpanded BBC Micro
without shadow RAM HIMEM takes a different value for each
screen Mode.  In Mode 3 it is &4000 so to reserve a page for
a program you could set HIMEM to &3F00 if you were using a
Mode 3 screen.

While developing a routine that does not have to be in a
particular memory space to work your best bet is probably to
use DIM to dynamically allocate space.  Errors while using
PAGE can overwrite your source and HIMEM moves with changes
in mode.  Also, as your code grows, so you can increase the
dimensioned memory with it.

The alternative approach (which does not work in a second
processor) is to use bits of the machines' work space that
you do not think will be used.  Here are some examples for a
Model B.

Page &B stores user defined key strings
Page &C stores user defined character definitions
Pages &9 and &A are workspace for the RS423, cassette and
(in Page &9) sound envelope storage and speech processing

On a Model B with discs you can use space between &1100 and
&1900 although beware of some flags stored in page &17. Use
of this workspace only affects random access filing system
operations with several files open.

As you can probably guess none of this space is guaranteed
safe in all circumstances.  Probably the only way to
guarantee safety is to put your code into a sideways ROM
since these ROMS have special privileges and can reserve
workspace.

In a 6502 second processor running ordinary BASIC, not Hi
BASIC, you have space above the language which you could use
lying between &8000 and &F7FF.  Above this are the second
processor OS and TUBE buffers.  (See 2nd Processor User
Guide.)

And when you have generated your code you may wish to save
it and run it from disc or tape independently.  By looking
at your assembler listing you will see that the first memory
location listed on the left is where you defined the code to
start.  The final location given by the assembly listing is
the end of your code.  Let's assume you have assembled some
code to start at, say, &1200 (by putting code%=&1200 and
P%=code% at the front of your program) and that the
assembler listing tells you it ends at &12B5.

To save this code to disc you would type

*SAVE atitle 1200 12B6

That is you save it in a file called atitle (or whatever)
and the memory block saved is from &1200 to &12B5.  Note
that the end point is one byte after the final byte shown in
your listing.  An alternative form uses length rather than
start and end so it would be

*SAVE atitle 1200 +B5

If you wanted to execute this directly from disc you could
then either enter

*LOAD atitle  followed by  CALL &1200

or

*atitle

If you wanted to make sure the code would always run in the
main micro even when you had a second processor up and
running then you could operate in one of two ways.  Firstly,
if your code had been assembled in the main (I/O) processor
you would type

*SAVE atitle FFFF1200 +B5

The four leading Fs tell the filing system that you mean the
I/O processor if there is a choice.  Or secondly, whether
you are in the I/O or second processor you could type

*SAVE atitle 1200 +B5 FFFF1200 FFFF1200

The two extra chunks of numbers tell the filing system to
set the load and execution address of your code to 1200 in
the I/O processor.

There are occasions when you have to execute code in the I/O
processor, for example when using interrupts, but I'll come
onto those in a later module.  In the meantime try out
saving and running some code, for instance the code in the
first module that prints out a 'Hello World' message.  Note
here though that you will have to check where the end of
that code is because of the string tagged onto the end,
which is important.

While we're on the subject of memory I will mention a
machine code monitor.  This is a program that enables you to
debug your code (at least) by stepping through it a command
at a time and seeing how the registers and memory are
affected.  If you are interested in programming in machine
code then you should consider buying one.  It would take me
too long to write one to include in this course, and in any
case I doubt if I could write one as good as, say, the BBC
Soft rom called Monitor written by Graham Bartram.  This is
the one I use but there are numerous types available,
usually as roms which you can plug into your machine.  The
advertising pages of magazines like Acorn User, Micro User,
A and B Computing and BEEBUG will show you the choice
available.


Finally this week a few words on the EQU pseudo operatives
in the BASIC2 (and later) assemblers.

In last week's file I used a rather crude method to put
variables and strings into memory.  It involved leaving the
assembler, using BASIC indirection operators (? ! and $) to
put the variable in place at the program counter value P%,
and re-entering the assembler.

While BASIC1 does not have the facility, later ones permit
you to equate a section of memory to a byte, a word, a
double word or a string.  Like this:

    .one        EQUB &12
    .two        EQUW &1234
    .three      EQUD &12345678
    .four       EQUS "ONE TWO THREE" + CHR$(13)

Here, a word means 2 bytes and a double word means 4 bytes.

In each case the number or string concerned is assembled at
the label.  This is a very neat way of putting values into
your code.  You can also use it to reserve a block of
memory.  For example the byte held at 'one' could change as
this location is used to store a variable in your code.

Incidentally you tell which BASIC you have by pressing BREAK
and then typing REPORT.  If the message (C) Acorn 1981
appears then you have BASIC1.

The program in this week's telesoftware transmission B/osb04
is an assembler shell to illustrate how to mimic the action
of EQUB etc with BASIC1.  I have also added a couple of
extra pseudo-operatives EQUM and EQUF.  They work in the
same way as the techniques used last week but, by working
through a function, are more elegant to use.

Obviously to use these pseudo-operatives you need to have
the relevant functions at the end of your program.

FNEQUM(X%,Y%) takes the byte Y% and puts X% of it in the
locations after, and including, the labelled location.  This
is useful for reserving blocks of memory for tables, or for
parameters when using OSWORD calls.

FNEQUF(N) converts N into the BBC Micro format for floating
point numbers and stores it at the labelled location.  It
does this by relying on the way BASIC stores its variables.
We know that the variable ` (pound sign) is stored at the
location held in locations &4C0 and &4C1.  This is only true
if no other variables starting with ` are defined, but this
is unlikely.  Many users do not realise you can start a
variable with ` anyway.  In order to verify the function the
shell program prints out the value of ` using PROCfp.

I plan to investigate floating point numbers later in this
series.  Next week I shall start to discuss the BBC Micro's
operating system calls.  Once we've gained access to them
they will provide us with easy access to some very powerful
and helpful things.
00000000  4f 53 42 49 54 53 20 2d  20 41 6e 20 45 78 70 6c  |OSBITS - An Expl|
00000010  6f 72 61 74 69 6f 6e 20  6f 66 20 74 68 65 20 42  |oration of the B|
00000020  42 43 20 4d 69 63 72 6f  20 61 74 20 4d 61 63 68  |BC Micro at Mach|
00000030  69 6e 65 20 4c 65 76 65  6c 0d 0d 42 79 20 50 72  |ine Level..By Pr|
00000040  6f 67 72 61 6d 6d 65 72  0d 0d 2e 2e 2e 2e 2e 2e  |ogrammer........|
00000050  2e 2e 2e 2e 2e 2e 2e 2e  2e 2e 2e 2e 2e 2e 2e 2e  |................|
*
00000080  2e 2e 2e 2e 2e 0d 0d 0d  50 61 72 74 20 34 3a 20  |........Part 4: |
00000090  4d 65 6d 6f 72 79 0d 0d  0d 49 6e 20 74 68 69 73  |Memory...In this|
000000a0  20 6d 6f 64 75 6c 65 20  77 65 27 6c 6c 20 6c 6f  | module we'll lo|
000000b0  6f 6b 20 61 74 20 68 6f  77 20 74 68 65 20 42 42  |ok at how the BB|
000000c0  43 20 4d 69 63 72 6f 27  73 20 6d 65 6d 6f 72 79  |C Micro's memory|
000000d0  20 69 73 0d 75 73 65 64  2e 20 20 54 68 65 20 77  | is.used.  The w|
000000e0  61 79 20 69 74 20 69 73  20 6c 61 69 64 20 6f 75  |ay it is laid ou|
000000f0  74 20 69 73 20 63 61 6c  6c 65 64 20 61 20 6d 65  |t is called a me|
00000100  6d 6f 72 79 20 6d 61 70  2e 0d 0d 42 75 74 20 66  |mory map...But f|
00000110  69 72 73 74 20 61 20 73  68 6f 72 74 20 6e 6f 74  |irst a short not|
00000120  65 20 61 62 6f 75 74 20  70 61 67 65 73 3a 0d 0d  |e about pages:..|
00000130  49 6e 20 74 68 65 20 6d  69 63 72 6f 20 61 20 62  |In the micro a b|
00000140  6c 6f 63 6b 20 6f 66 20  32 35 36 20 62 79 74 65  |lock of 256 byte|
00000150  73 20 6f 66 20 6d 65 6d  6f 72 79 20 69 73 20 63  |s of memory is c|
00000160  61 6c 6c 65 64 20 61 0d  70 61 67 65 2e 20 20 49  |alled a.page.  I|
00000170  74 27 73 20 65 61 73 69  65 72 20 69 6e 20 68 65  |t's easier in he|
00000180  78 61 64 65 63 69 6d 61  6c 20 73 69 6e 63 65 20  |xadecimal since |
00000190  32 35 36 20 3d 20 26 31  30 30 2e 20 20 59 6f 75  |256 = &100.  You|
000001a0  20 63 61 6e 0d 73 65 65  2c 20 49 20 68 6f 70 65  | can.see, I hope|
000001b0  2c 20 74 68 61 74 20 77  68 65 6e 20 79 6f 75 20  |, that when you |
000001c0  72 65 66 65 72 20 74 6f  20 70 61 67 65 20 58 20  |refer to page X |
000001d0  79 6f 75 20 6d 65 61 6e  20 74 68 65 0d 6d 65 6d  |you mean the.mem|
000001e0  6f 72 79 20 66 72 6f 6d  20 26 58 30 30 20 74 6f  |ory from &X00 to|
000001f0  20 26 58 46 46 2e 20 20  50 41 47 45 20 69 6e 20  | &XFF.  PAGE in |
00000200  42 41 53 49 43 20 69 73  20 73 6f 20 63 61 6c 6c  |BASIC is so call|
00000210  65 64 0d 62 65 63 61 75  73 65 20 69 74 20 73 65  |ed.because it se|
00000220  74 73 20 74 68 65 20 70  61 67 65 20 61 74 20 77  |ts the page at w|
00000230  68 69 63 68 20 79 6f 75  72 20 42 41 53 49 43 20  |hich your BASIC |
00000240  70 72 6f 67 72 61 6d 27  73 0d 77 6f 72 6b 73 70  |program's.worksp|
00000250  61 63 65 20 73 74 61 72  74 73 2e 20 20 54 68 69  |ace starts.  Thi|
00000260  73 20 69 73 20 26 45 30  30 20 6f 6e 20 61 20 4d  |s is &E00 on a M|
00000270  61 73 74 65 72 20 6f 72  20 61 20 42 20 77 69 74  |aster or a B wit|
00000280  68 6f 75 74 20 61 0d 64  69 73 63 20 66 69 6c 69  |hout a.disc fili|
00000290  6e 67 20 73 79 73 74 65  6d 20 61 6e 64 20 26 31  |ng system and &1|
000002a0  39 30 30 20 6f 6e 20 61  20 42 20 77 69 74 68 20  |900 on a B with |
000002b0  61 20 44 46 53 2e 0d 0d  54 68 65 20 62 6f 74 74  |a DFS...The bott|
000002c0  6f 6d 20 32 35 36 20 62  79 74 65 73 20 6f 66 20  |om 256 bytes of |
000002d0  6d 65 6d 6f 72 79 2c 20  66 72 6f 6d 20 26 30 30  |memory, from &00|
000002e0  20 74 6f 20 26 46 46 20  69 73 20 63 61 6c 6c 65  | to &FF is calle|
000002f0  64 0d 5a 45 52 4f 20 50  41 47 45 20 28 58 20 69  |d.ZERO PAGE (X i|
00000300  73 20 30 29 20 61 6e 64  20 74 68 65 20 36 35 30  |s 0) and the 650|
00000310  32 20 6e 65 65 64 73 20  69 74 20 66 6f 72 20 73  |2 needs it for s|
00000320  6f 6d 65 0d 6f 70 65 72  61 74 69 6f 6e 73 2e 20  |ome.operations. |
00000330  20 49 74 20 69 73 20 75  73 65 66 75 6c 20 62 65  | It is useful be|
00000340  63 61 75 73 65 20 74 68  65 20 6d 65 6d 6f 72 79  |cause the memory|
00000350  20 6c 6f 63 61 74 69 6f  6e 2c 20 62 65 69 6e 67  | location, being|
00000360  0d 6c 65 73 73 20 74 68  61 74 20 32 35 36 2c 20  |.less that 256, |
00000370  63 61 6e 20 62 65 20 68  65 6c 64 20 69 6e 20 61  |can be held in a|
00000380  20 62 79 74 65 20 77 68  69 63 68 20 73 70 65 65  | byte which spee|
00000390  64 73 20 75 70 0d 70 72  6f 63 65 73 73 69 6e 67  |ds up.processing|
000003a0  2e 0d 0d 54 68 65 20 36  35 30 32 20 6d 69 63 72  |...The 6502 micr|
000003b0  6f 70 72 6f 63 65 73 73  6f 72 20 61 6e 64 20 69  |oprocessor and i|
000003c0  74 73 20 76 61 72 69 61  6e 74 73 2c 20 75 73 65  |ts variants, use|
000003d0  20 31 36 20 62 69 74 73  20 66 6f 72 0d 74 68 65  | 16 bits for.the|
000003e0  69 72 20 61 64 64 72 65  73 73 69 6e 67 2e 20 20  |ir addressing.  |
000003f0  54 68 65 20 70 72 6f 67  72 61 6d 20 63 6f 75 6e  |The program coun|
00000400  74 65 72 20 69 73 20 74  68 65 72 65 66 6f 72 65  |ter is therefore|
00000410  20 74 77 6f 0d 62 79 74  65 73 20 69 6e 20 73 69  | two.bytes in si|
00000420  7a 65 20 77 68 69 63 68  20 6d 65 61 6e 73 20 74  |ze which means t|
00000430  68 61 74 20 61 6e 79 20  61 64 64 72 65 73 73 20  |hat any address |
00000440  66 72 6f 6d 20 30 20 74  6f 20 36 35 35 33 35 0d  |from 0 to 65535.|
00000450  28 26 30 30 20 74 6f 20  26 46 46 46 46 29 20 63  |(&00 to &FFFF) c|
00000460  61 6e 20 62 65 20 61 63  63 65 73 73 65 64 20 64  |an be accessed d|
00000470  69 72 65 63 74 6c 79 2e  0d 0d 49 6e 20 74 68 65  |irectly...In the|
00000480  20 42 42 43 20 4d 69 63  72 6f 20 28 75 73 69 6e  | BBC Micro (usin|
00000490  67 20 42 41 53 49 43 29  20 74 68 65 20 6d 65 6d  |g BASIC) the mem|
000004a0  6f 72 79 20 69 73 20 64  69 76 69 64 65 64 20 75  |ory is divided u|
000004b0  70 20 6c 69 6b 65 0d 74  68 69 73 3a 0d 0d 20 20  |p like.this:..  |
000004c0  20 20 46 46 46 46 20 20  20 20 20 20 20 20 20 20  |  FFFF          |
000004d0  20 20 0d 20 20 20 20 20  20 20 20 20 20 20 20 54  |  .            T|
000004e0  68 65 20 6f 70 65 72 61  74 69 6e 67 20 73 79 73  |he operating sys|
000004f0  74 65 6d 20 6c 69 76 65  73 20 68 65 72 65 0d 20  |tem lives here. |
00000500  20 20 20 43 30 30 30 0d  20 20 20 20 2d 2d 2d 2d  |   C000.    ----|
00000510  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000530  2d 2d 2d 2d 2d 2d 0d 20  20 20 20 42 46 46 46 0d  |------.    BFFF.|
00000540  20 20 20 20 20 20 20 20  20 20 20 20 54 68 65 20  |            The |
00000550  63 75 72 72 65 6e 74 20  6c 61 6e 67 75 61 67 65  |current language|
00000560  2c 20 65 2e 67 2e 20 42  41 53 49 43 0d 20 20 20  |, e.g. BASIC.   |
00000570  20 20 20 20 20 20 20 20  20 6c 69 76 65 73 20 68  |         lives h|
00000580  65 72 65 0d 20 20 20 20  38 30 30 30 0d 20 20 20  |ere.    8000.   |
00000590  20 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  | ---------------|
000005a0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
000005b0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 0d 20 20 20 20  |-----------.    |
000005c0  37 46 46 46 0d 20 20 20  20 20 20 20 20 20 20 20  |7FFF.           |
000005d0  20 54 68 69 73 20 6d 65  6d 6f 72 79 20 69 73 20  | This memory is |
000005e0  75 73 65 64 20 62 79 20  74 68 65 20 73 63 72 65  |used by the scre|
000005f0  65 6e 0d 20 20 20 20 20  20 20 20 20 20 20 20 61  |en.            a|
00000600  6e 64 20 68 6f 77 20 6d  75 63 68 20 69 73 20 75  |nd how much is u|
00000610  73 65 64 20 64 65 70 65  6e 64 73 20 6f 6e 20 0d  |sed depends on .|
00000620  20 20 20 20 20 20 20 20  20 20 20 20 74 68 65 20  |            the |
00000630  6d 6f 64 65 20 62 65 69  6e 67 20 75 73 65 64 0d  |mode being used.|
00000640  20 20 20 20 48 49 4d 45  4d 0d 20 20 20 20 2d 2d  |    HIMEM.    --|
00000650  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000670  2d 2d 2d 2d 2d 2d 2d 2d  0d 20 20 20 20 20 20 20  |--------.       |
00000680  20 20 20 20 20 54 68 69  73 20 6d 65 6d 6f 72 79  |     This memory|
00000690  20 69 73 20 75 73 65 64  20 62 79 20 79 6f 75 72  | is used by your|
000006a0  20 42 41 53 49 43 0d 20  20 20 20 20 20 20 20 20  | BASIC.         |
000006b0  20 20 20 70 72 6f 67 72  61 6d 0d 20 20 20 20 50  |   program.    P|
000006c0  41 47 45 0d 20 20 20 2d  2d 2d 2d 2d 2d 2d 2d 2d  |AGE.   ---------|
000006d0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
000006f0  2d 2d 20 20 20 20 20 20  20 20 0d 20 20 20 20 20  |--        .     |
00000700  20 20 20 20 20 20 20 54  68 69 73 20 6d 65 6d 6f  |       This memo|
00000710  72 79 20 69 73 20 75 73  65 64 20 62 79 20 74 68  |ry is used by th|
00000720  65 20 42 41 53 49 43 0d  20 20 20 20 20 20 20 20  |e BASIC.        |
00000730  20 20 20 20 69 6e 74 65  72 70 72 65 74 65 72 2c  |    interpreter,|
00000740  20 74 68 65 20 6f 70 65  72 61 74 69 6e 67 20 73  | the operating s|
00000750  79 73 74 65 6d 0d 20 20  20 20 20 20 20 20 20 20  |ystem.          |
00000760  20 20 61 6e 64 20 74 68  65 20 66 69 6c 69 6e 67  |  and the filing|
00000770  20 73 79 73 74 65 6d 73  0d 20 20 20 20 30 30 30  | systems.    000|
00000780  30 0d 0d 54 68 65 20 6d  65 6d 6f 72 79 20 66 72  |0..The memory fr|
00000790  6f 6d 20 26 30 30 30 30  20 74 6f 20 26 37 46 46  |om &0000 to &7FF|
000007a0  46 20 69 73 20 52 61 6e  64 6f 6d 20 41 63 63 65  |F is Random Acce|
000007b0  73 73 20 4d 65 6d 6f 72  79 2c 20 6f 72 0d 52 41  |ss Memory, or.RA|
000007c0  4d 2c 20 61 6e 64 20 79  6f 75 20 63 61 6e 20 77  |M, and you can w|
000007d0  72 69 74 65 20 69 6e 74  6f 20 69 74 20 61 73 20  |rite into it as |
000007e0  77 65 6c 6c 20 61 73 20  72 65 61 64 20 66 72 6f  |well as read fro|
000007f0  6d 20 69 74 2e 20 20 54  68 65 0d 6d 65 6d 6f 72  |m it.  The.memor|
00000800  79 20 66 72 6f 6d 20 26  38 30 30 30 20 74 6f 20  |y from &8000 to |
00000810  26 46 46 46 46 20 69 73  20 52 65 61 64 20 4f 6e  |&FFFF is Read On|
00000820  6c 79 20 4d 65 6d 6f 72  79 2c 20 6f 72 20 52 4f  |ly Memory, or RO|
00000830  4d 2c 20 61 6e 64 0d 79  6f 75 20 63 61 6e 6e 6f  |M, and.you canno|
00000840  74 20 77 72 69 74 65 20  74 6f 20 69 74 2e 20 20  |t write to it.  |
00000850  59 6f 75 20 63 61 6e 20  74 72 79 2c 20 62 75 74  |You can try, but|
00000860  20 6e 6f 74 68 69 6e 67  20 77 69 6c 6c 0d 68 61  | nothing will.ha|
00000870  70 70 65 6e 2e 20 20 28  4e 2e 42 2e 20 69 6e 20  |ppen.  (N.B. in |
00000880  61 20 36 35 30 32 20 73  65 63 6f 6e 64 20 70 72  |a 6502 second pr|
00000890  6f 63 65 73 73 6f 72 20  74 68 69 6e 67 73 20 61  |ocessor things a|
000008a0  72 65 0d 64 69 66 66 65  72 65 6e 74 2e 20 20 54  |re.different.  T|
000008b0  68 65 20 6f 70 65 72 61  74 69 6e 67 20 73 79 73  |he operating sys|
000008c0  74 65 6d 20 69 73 20 61  62 73 65 6e 74 20 61 6e  |tem is absent an|
000008d0  64 20 61 6c 6c 20 6d 65  6d 6f 72 79 20 69 73 0d  |d all memory is.|
000008e0  52 41 4d 20 73 6f 20 79  6f 75 20 63 61 6e 20 63  |RAM so you can c|
000008f0  61 75 73 65 20 68 61 76  6f 63 20 62 79 20 77 72  |ause havoc by wr|
00000900  69 74 69 6e 67 20 62 65  74 77 65 65 6e 20 26 38  |iting between &8|
00000910  30 30 30 20 61 6e 64 0d  26 46 46 46 46 2e 29 0d  |000 and.&FFFF.).|
00000920  0d 54 68 65 20 63 68 61  72 74 20 73 68 6f 77 73  |.The chart shows|
00000930  20 74 68 65 20 6d 65 6d  6f 72 79 20 6d 61 70 20  | the memory map |
00000940  66 6f 72 20 61 20 4d 6f  64 65 6c 20 42 2e 20 20  |for a Model B.  |
00000950  4f 6e 20 61 20 42 2b 20  6f 72 0d 4d 61 73 74 65  |On a B+ or.Maste|
00000960  72 20 74 68 65 72 65 20  69 73 20 65 78 74 72 61  |r there is extra|
00000970  20 6d 65 6d 6f 72 79 20  61 76 61 69 6c 61 62 6c  | memory availabl|
00000980  65 20 61 74 20 74 68 65  20 73 61 6d 65 20 61 64  |e at the same ad|
00000990  64 72 65 73 73 0d 61 73  20 74 68 65 20 73 63 72  |dress.as the scr|
000009a0  65 65 6e 20 6d 65 6d 6f  72 79 2e 20 20 54 68 69  |een memory.  Thi|
000009b0  73 20 67 69 76 65 73 20  62 6f 74 68 20 6d 61 69  |s gives both mai|
000009c0  6e 20 52 41 4d 20 61 6e  64 20 27 73 68 61 64 6f  |n RAM and 'shado|
000009d0  77 0d 52 41 4d 27 20 61  76 61 69 6c 61 62 6c 65  |w.RAM' available|
000009e0  20 62 65 74 77 65 65 6e  20 26 33 30 30 30 20 61  | between &3000 a|
000009f0  6e 64 20 26 37 46 46 46  2e 20 20 54 68 65 20 69  |nd &7FFF.  The i|
00000a00  64 65 61 20 69 73 20 74  68 61 74 0d 74 68 65 20  |dea is that.the |
00000a10  6f 70 65 72 61 74 69 6e  67 20 73 79 73 74 65 6d  |operating system|
00000a20  20 74 65 6c 6c 73 20 69  66 20 79 6f 75 20 61 72  | tells if you ar|
00000a30  65 20 77 72 69 74 69 6e  67 20 74 6f 20 74 68 65  |e writing to the|
00000a40  20 73 63 72 65 65 6e 0d  28 69 2e 65 2e 20 61 72  | screen.(i.e. ar|
00000a50  65 20 50 72 69 6e 74 69  6e 67 20 6f 72 20 44 72  |e Printing or Dr|
00000a60  61 77 69 6e 67 20 65 74  63 29 20 61 6e 64 20 69  |awing etc) and i|
00000a70  66 20 73 6f 20 75 73 65  73 20 74 68 65 20 73 68  |f so uses the sh|
00000a80  61 64 6f 77 0d 52 41 4d  2e 20 20 50 75 72 65 20  |adow.RAM.  Pure |
00000a90  6d 65 6d 6f 72 79 20 77  6f 72 6b 2c 20 6c 69 6b  |memory work, lik|
00000aa0  65 20 61 20 42 41 53 49  43 20 70 72 6f 67 72 61  |e a BASIC progra|
00000ab0  6d 20 69 74 73 65 6c 66  2c 20 67 6f 65 73 0d 69  |m itself, goes.i|
00000ac0  6e 74 6f 20 74 68 65 20  6d 61 69 6e 20 52 41 4d  |nto the main RAM|
00000ad0  2e 20 20 49 6e 20 74 68  69 73 20 77 61 79 20 79  |.  In this way y|
00000ae0  6f 75 20 68 61 76 65 20  61 63 63 65 73 73 20 74  |ou have access t|
00000af0  6f 20 61 6c 6c 20 74 68  65 0d 75 73 65 72 20 52  |o all the.user R|
00000b00  41 4d 20 65 76 65 6e 20  69 6e 20 4d 4f 44 45 20  |AM even in MODE |
00000b10  32 2e 20 20 53 68 61 64  6f 77 20 52 41 4d 20 63  |2.  Shadow RAM c|
00000b20  61 6e 20 61 6c 73 6f 20  65 78 69 73 74 0d 65 6c  |an also exist.el|
00000b30  73 65 77 68 65 72 65 20  6f 6e 20 74 68 65 73 65  |sewhere on these|
00000b40  20 6d 61 63 68 69 6e 65  73 2c 20 70 61 72 74 69  | machines, parti|
00000b50  63 75 6c 61 72 6c 79 20  74 68 65 20 4d 61 73 74  |cularly the Mast|
00000b60  65 72 2c 20 62 75 74 0d  74 68 65 20 27 53 68 61  |er, but.the 'Sha|
00000b70  64 6f 77 20 53 63 72 65  65 6e 27 20 61 72 65 61  |dow Screen' area|
00000b80  20 69 73 20 74 68 65 20  6d 6f 73 74 20 69 6d 70  | is the most imp|
00000b90  6f 72 74 61 6e 74 2e 20  20 41 64 64 2d 6f 6e 0d  |ortant.  Add-on.|
00000ba0  53 68 61 64 6f 77 20 53  63 72 65 65 6e 20 62 6f  |Shadow Screen bo|
00000bb0  61 72 64 73 20 61 72 65  20 61 76 61 69 6c 61 62  |ards are availab|
00000bc0  6c 65 20 66 6f 72 20 74  68 65 20 42 42 43 20 42  |le for the BBC B|
00000bd0  2e 0d 0d 53 6f 2d 63 61  6c 6c 65 64 20 53 69 64  |...So-called Sid|
00000be0  65 77 61 79 73 20 52 41  4d 20 6f 63 63 75 70 69  |eways RAM occupi|
00000bf0  65 73 20 74 68 65 20 73  61 6d 65 20 6d 65 6d 6f  |es the same memo|
00000c00  72 79 20 61 73 20 74 68  65 0d 6c 61 6e 67 75 61  |ry as the.langua|
00000c10  67 65 20 28 26 38 30 30  30 20 74 6f 20 26 42 46  |ge (&8000 to &BF|
00000c20  46 46 29 20 61 6e 64 20  77 65 27 6c 6c 20 64 65  |FF) and we'll de|
00000c30  61 6c 20 77 69 74 68 20  74 68 69 73 20 69 6e 20  |al with this in |
00000c40  61 0d 6c 61 74 65 72 20  66 69 6c 65 2e 0d 0d 41  |a.later file...A|
00000c50  73 20 49 27 76 65 20 73  61 69 64 20 62 65 66 6f  |s I've said befo|
00000c60  72 65 2c 20 42 41 53 49  43 20 74 61 6b 65 73 20  |re, BASIC takes |
00000c70  63 61 72 65 20 6f 66 20  79 6f 75 2e 20 43 6f 6d  |care of you. Com|
00000c80  70 61 72 65 64 20 74 6f  0d 6d 61 63 68 69 6e 65  |pared to.machine|
00000c90  20 63 6f 64 65 20 69 74  27 73 20 61 20 6e 61 6e  | code it's a nan|
00000ca0  6e 79 20 61 6e 64 20 6f  6e 63 65 20 79 6f 75 20  |ny and once you |
00000cb0  6d 6f 76 65 20 6f 76 65  72 20 74 6f 0d 61 73 73  |move over to.ass|
00000cc0  65 6d 62 6c 65 72 20 79  6f 75 20 61 72 65 20 74  |embler you are t|
00000cd0  68 65 20 62 61 62 65 73  20 69 6e 20 74 68 65 20  |he babes in the |
00000ce0  6d 65 6d 6f 72 79 20 6d  61 70 2e 20 20 59 6f 75  |memory map.  You|
00000cf0  20 68 61 76 65 20 74 6f  0d 64 65 63 69 64 65 20  | have to.decide |
00000d00  77 68 65 72 65 20 79 6f  75 20 77 61 6e 74 20 74  |where you want t|
00000d10  6f 20 70 75 74 20 79 6f  75 72 20 63 6f 64 65 2e  |o put your code.|
00000d20  20 20 54 68 65 20 61 73  73 65 6d 62 6c 65 72 20  |  The assembler |
00000d30  77 69 6c 6c 0d 70 75 74  20 69 74 20 77 68 65 72  |will.put it wher|
00000d40  65 20 79 6f 75 20 73 61  79 20 79 6f 75 20 77 61  |e you say you wa|
00000d50  6e 74 20 69 74 20 74 6f  20 67 6f 2e 20 20 54 68  |nt it to go.  Th|
00000d60  69 73 20 63 61 6e 20 6c  65 61 64 20 74 6f 0d 74  |is can lead to.t|
00000d70  68 72 65 65 20 63 6f 6d  6d 6f 6e 20 6d 69 73 74  |hree common mist|
00000d80  61 6b 65 73 2e 0d 0d 20  20 20 20 31 3a 20 4c 6f  |akes...    1: Lo|
00000d90  61 64 69 6e 67 20 63 6f  64 65 20 6f 76 65 72 20  |ading code over |
00000da0  79 6f 75 72 20 73 6f 75  72 63 65 20 63 6f 64 65  |your source code|
00000db0  0d 20 20 20 20 32 3a 20  4c 6f 61 64 69 6e 67 20  |.    2: Loading |
00000dc0  63 6f 64 65 20 6f 76 65  72 20 77 6f 72 6b 73 70  |code over worksp|
00000dd0  61 63 65 0d 20 20 20 20  33 3a 20 4c 6f 61 64 69  |ace.    3: Loadi|
00000de0  6e 67 20 63 6f 64 65 20  69 6e 74 6f 20 73 63 72  |ng code into scr|
00000df0  65 65 6e 20 6d 65 6d 6f  72 79 0d 0d 49 66 20 79  |een memory..If y|
00000e00  6f 75 20 61 72 65 20 77  6f 72 6b 69 6e 67 20 69  |ou are working i|
00000e10  6e 20 74 68 65 20 73 65  63 6f 6e 64 20 70 72 6f  |n the second pro|
00000e20  63 65 73 73 6f 72 20 79  6f 75 20 63 61 6e 20 61  |cessor you can a|
00000e30  6c 73 6f 20 6c 6f 61 64  0d 63 6f 64 65 20 6f 76  |lso load.code ov|
00000e40  65 72 20 79 6f 75 72 20  6c 61 6e 67 75 61 67 65  |er your language|
00000e50  2e 0d 0d 54 68 65 72 65  20 61 72 65 20 74 77 6f  |...There are two|
00000e60  20 77 61 79 73 20 61 72  6f 75 6e 64 20 74 68 69  | ways around thi|
00000e70  73 20 70 72 6f 62 6c 65  6d 2e 20 20 46 69 72 73  |s problem.  Firs|
00000e80  74 6c 79 20 79 6f 75 20  63 61 6e 0d 6c 65 61 72  |tly you can.lear|
00000e90  6e 20 77 68 65 72 65 20  79 6f 75 20 63 61 6e 20  |n where you can |
00000ea0  73 61 66 65 6c 79 20 70  75 74 20 79 6f 75 72 20  |safely put your |
00000eb0  63 6f 64 65 2e 20 20 53  65 63 6f 6e 64 6c 79 20  |code.  Secondly |
00000ec0  79 6f 75 20 63 61 6e 0d  6c 65 74 20 42 41 53 49  |you can.let BASI|
00000ed0  43 20 70 75 74 20 69 74  20 73 6f 6d 65 77 68 65  |C put it somewhe|
00000ee0  72 65 20 73 61 66 65 20  66 6f 72 20 79 6f 75 2e  |re safe for you.|
00000ef0  0d 0d 49 6e 20 6d 6f 73  74 20 6f 66 20 6d 79 20  |..In most of my |
00000f00  63 6f 64 65 20 65 78 61  6d 70 6c 65 73 20 73 6f  |code examples so|
00000f10  20 66 61 72 20 49 20 68  61 76 65 20 75 73 65 64  | far I have used|
00000f20  20 74 68 65 20 42 41 53  49 43 20 44 49 4d 0d 73  | the BASIC DIM.s|
00000f30  74 61 74 65 6d 65 6e 74  20 74 6f 20 61 6c 6c 6f  |tatement to allo|
00000f40  63 61 74 65 20 61 20 63  68 75 6e 6b 20 6f 66 20  |cate a chunk of |
00000f50  6d 65 6d 6f 72 79 20 69  6e 74 6f 20 77 68 69 63  |memory into whic|
00000f60  68 20 49 0d 61 73 73 65  6d 62 6c 65 64 20 73 6f  |h I.assembled so|
00000f70  6d 65 20 63 6f 64 65 2e  20 20 49 6e 69 74 69 61  |me code.  Initia|
00000f80  6c 6c 79 20 74 68 69 73  20 69 73 20 74 68 65 20  |lly this is the |
00000f90  62 65 73 74 20 77 61 79  20 6f 66 0d 67 6f 69 6e  |best way of.goin|
00000fa0  67 20 61 62 6f 75 74 20  74 68 69 6e 67 73 2e 20  |g about things. |
00000fb0  20 49 66 20 79 6f 75 20  74 68 69 6e 6b 20 79 6f  | If you think yo|
00000fc0  75 20 77 69 6c 6c 20 6e  65 65 64 20 32 35 36 20  |u will need 256 |
00000fd0  62 79 74 65 73 20 6f 66  0d 73 70 61 63 65 20 74  |bytes of.space t|
00000fe0  68 65 6e 20 70 75 74 0d  0d 20 20 20 20 20 20 20  |hen put..       |
00000ff0  20 20 20 20 20 20 20 20  20 20 20 44 49 4d 20 63  |           DIM c|
00001000  6f 64 65 25 20 32 35 36  0d 0d 61 74 20 74 68 65  |ode% 256..at the|
00001010  20 74 6f 70 20 6f 66 20  79 6f 75 72 20 73 6f 75  | top of your sou|
00001020  72 63 65 20 63 6f 64 65  2e 20 49 66 20 65 76 65  |rce code. If eve|
00001030  6e 74 75 61 6c 6c 79 20  79 6f 75 20 61 63 74 75  |ntually you actu|
00001040  61 6c 6c 79 0d 75 73 65  20 6d 6f 72 65 20 74 68  |ally.use more th|
00001050  61 6e 20 32 35 36 20 62  79 74 65 73 20 74 68 65  |an 256 bytes the|
00001060  6e 20 74 68 65 20 6d 6f  73 74 20 6c 69 6b 65 6c  |n the most likel|
00001070  79 20 74 68 69 6e 67 20  69 73 20 79 6f 75 0d 77  |y thing is you.w|
00001080  69 6c 6c 20 6f 76 65 72  2d 77 72 69 74 65 20 74  |ill over-write t|
00001090  68 65 20 73 70 61 63 65  20 69 6e 20 77 68 69 63  |he space in whic|
000010a0  68 20 42 41 53 49 43 20  73 74 6f 72 65 73 20 76  |h BASIC stores v|
000010b0  61 72 69 61 62 6c 65 73  0d 61 6e 64 20 61 20 27  |ariables.and a '|
000010c0  6e 6f 20 73 75 63 68 20  76 61 72 69 61 62 6c 65  |no such variable|
000010d0  27 20 65 72 72 6f 72 20  77 69 6c 6c 20 62 65 20  |' error will be |
000010e0  67 65 6e 65 72 61 74 65  64 20 64 75 72 69 6e 67  |generated during|
000010f0  20 74 68 65 0d 73 65 63  6f 6e 64 20 70 61 73 73  | the.second pass|
00001100  20 6f 66 20 74 68 65 20  61 73 73 65 6d 62 6c 65  | of the assemble|
00001110  72 2e 20 20 54 68 69 73  20 69 73 20 6e 6f 74 20  |r.  This is not |
00001120  61 20 66 61 74 61 6c 20  65 72 72 6f 72 2c 0d 69  |a fatal error,.i|
00001130  2e 65 2e 20 79 6f 75 20  63 61 6e 20 72 65 63 6f  |.e. you can reco|
00001140  76 65 72 20 73 69 6d 70  6c 79 20 62 79 20 69 6e  |ver simply by in|
00001150  63 72 65 61 73 69 6e 67  20 74 68 65 20 6d 65 6d  |creasing the mem|
00001160  6f 72 79 20 79 6f 75 0d  72 65 73 65 72 76 65 20  |ory you.reserve |
00001170  61 6e 64 20 72 75 6e 6e  69 6e 67 20 74 68 65 20  |and running the |
00001180  61 73 73 65 6d 62 6c 79  20 61 67 61 69 6e 2e 0d  |assembly again..|
00001190  0d 54 68 65 20 42 42 43  20 4d 69 63 72 6f 20 69  |.The BBC Micro i|
000011a0  73 20 64 65 73 69 67 6e  65 64 20 70 72 69 6d 61  |s designed prima|
000011b0  72 69 6c 79 20 66 6f 72  20 75 73 65 20 77 69 74  |rily for use wit|
000011c0  68 20 42 41 53 49 43 20  61 6e 64 0d 73 6f 20 79  |h BASIC and.so y|
000011d0  6f 75 20 68 61 76 65 20  74 6f 20 74 68 69 6e 6b  |ou have to think|
000011e0  20 63 61 72 65 66 75 6c  6c 79 20 62 65 66 6f 72  | carefully befor|
000011f0  65 20 63 68 6f 6f 73 69  6e 67 20 6d 65 6d 6f 72  |e choosing memor|
00001200  79 20 66 6f 72 0d 79 6f  75 72 20 6f 77 6e 20 6d  |y for.your own m|
00001210  61 63 68 69 6e 65 20 63  6f 64 65 20 72 6f 75 74  |achine code rout|
00001220  69 6e 65 73 2e 20 20 45  61 72 6c 79 20 76 65 72  |ines.  Early ver|
00001230  73 69 6f 6e 73 20 6f 66  20 74 68 65 20 75 73 65  |sions of the use|
00001240  72 0d 67 75 69 64 65 20  73 61 69 64 20 74 68 61  |r.guide said tha|
00001250  74 20 70 61 67 65 20 44  20 28 26 44 30 30 20 74  |t page D (&D00 t|
00001260  6f 20 26 44 46 46 29 20  77 61 73 20 61 76 61 69  |o &DFF) was avai|
00001270  6c 61 62 6c 65 20 66 6f  72 20 75 73 65 72 0d 6d  |lable for user.m|
00001280  61 63 68 69 6e 65 20 63  6f 64 65 20 62 75 74 20  |achine code but |
00001290  74 68 69 73 20 77 61 73  20 6c 61 74 65 72 20 72  |this was later r|
000012a0  65 76 69 73 65 64 2e 20  20 49 6e 20 66 61 63 74  |evised.  In fact|
000012b0  20 69 6e 20 61 0d 6d 61  63 68 69 6e 65 20 77 69  | in a.machine wi|
000012c0  74 68 20 64 69 73 63 73  20 74 68 69 73 20 69 73  |th discs this is|
000012d0  20 74 68 65 20 4e 4d 49  20 77 6f 72 6b 73 70 61  | the NMI workspa|
000012e0  63 65 2e 20 20 4e 4d 49  20 6d 65 61 6e 73 20 4e  |ce.  NMI means N|
000012f0  6f 6e 0d 4d 61 73 6b 61  62 6c 65 20 49 6e 74 65  |on.Maskable Inte|
00001300  72 72 75 70 74 2c 20 77  65 27 6c 6c 20 63 6f 6d  |rrupt, we'll com|
00001310  65 20 6f 6e 74 6f 20 69  6e 74 65 72 72 75 70 74  |e onto interrupt|
00001320  73 20 6c 61 74 65 72 2c  20 61 6e 64 0d 79 6f 75  |s later, and.you|
00001330  20 63 61 6e 20 74 61 6b  65 20 69 74 20 66 72 6f  | can take it fro|
00001340  6d 20 6d 65 20 74 68 61  74 20 79 6f 75 20 64 6f  |m me that you do|
00001350  6e 27 74 20 6d 65 73 73  20 77 69 74 68 20 74 68  |n't mess with th|
00001360  65 20 4e 4d 49 0d 77 6f  72 6b 73 70 61 63 65 20  |e NMI.workspace |
00001370  6f 72 20 79 6f 75 72 20  64 69 73 63 20 64 72 69  |or your disc dri|
00001380  76 65 73 20 63 65 61 73  65 20 74 6f 20 66 75 6e  |ves cease to fun|
00001390  63 74 69 6f 6e 20 2e 2e  2e 2e 20 6f 72 0d 77 6f  |ction .... or.wo|
000013a0  72 73 65 2e 0d 0d 54 68  65 72 65 20 61 72 65 20  |rse...There are |
000013b0  74 77 6f 20 74 79 70 65  73 20 6f 66 20 70 6c 61  |two types of pla|
000013c0  63 65 73 20 74 6f 20 70  75 74 20 6d 61 63 68 69  |ces to put machi|
000013d0  6e 65 20 63 6f 64 65 2e  20 20 46 69 72 73 74 6c  |ne code.  Firstl|
000013e0  79 0d 79 6f 75 20 63 61  6e 20 72 65 73 65 72 76  |y.you can reserv|
000013f0  65 20 6d 65 6d 6f 72 79  20 73 61 66 65 20 66 72  |e memory safe fr|
00001400  6f 6d 20 69 6e 74 72 75  73 69 6f 6e 2e 20 20 54  |om intrusion.  T|
00001410  68 69 73 20 69 73 20 65  69 74 68 65 72 0d 77 69  |his is either.wi|
00001420  74 68 69 6e 20 79 6f 75  72 20 70 72 6f 67 72 61  |thin your progra|
00001430  6d 20 77 6f 72 6b 73 70  61 63 65 20 28 62 79 20  |m workspace (by |
00001440  75 73 69 6e 67 20 44 49  4d 20 61 73 20 61 62 6f  |using DIM as abo|
00001450  76 65 29 20 6f 72 0d 62  65 6c 6f 77 20 50 41 47  |ve) or.below PAG|
00001460  45 20 6f 72 20 61 62 6f  76 65 20 48 49 4d 45 4d  |E or above HIMEM|
00001470  2e 0d 0d 50 41 47 45 20  69 73 20 74 68 65 20 70  |...PAGE is the p|
00001480  73 65 75 64 6f 20 76 61  72 69 61 62 6c 65 20 74  |seudo variable t|
00001490  68 61 74 20 69 73 20 6e  6f 72 6d 61 6c 6c 79 20  |hat is normally |
000014a0  73 65 74 20 74 6f 20 74  68 65 0d 6c 6f 77 65 73  |set to the.lowes|
000014b0  74 20 6d 65 6d 6f 72 79  20 6c 6f 63 61 74 69 6f  |t memory locatio|
000014c0  6e 20 74 68 61 74 20 69  73 20 6e 6f 74 20 75 73  |n that is not us|
000014d0  65 64 20 62 79 20 74 68  65 20 6f 70 65 72 61 74  |ed by the operat|
000014e0  69 6e 67 0d 73 79 73 74  65 6d 20 6f 72 20 66 69  |ing.system or fi|
000014f0  6c 69 6e 67 20 73 79 73  74 65 6d 73 20 6f 72 20  |ling systems or |
00001500  75 74 69 6c 69 74 79 20  52 4f 4d 53 20 61 73 20  |utility ROMS as |
00001510  77 6f 72 6b 73 70 61 63  65 20 61 6e 64 20 73 6f  |workspace and so|
00001520  0d 69 73 20 66 72 65 65  20 66 6f 72 20 42 41 53  |.is free for BAS|
00001530  49 43 20 70 72 6f 67 72  61 6d 73 2e 20 20 4f 6e  |IC programs.  On|
00001540  20 61 20 63 6f 6d 70 6c  65 74 65 6c 79 20 75 6e  | a completely un|
00001550  65 78 70 61 6e 64 65 64  0d 6d 61 63 68 69 6e 65  |expanded.machine|
00001560  20 69 74 20 69 73 20 61  74 20 26 45 30 30 20 28  | it is at &E00 (|
00001570  69 74 20 61 6c 77 61 79  73 20 6c 69 65 73 20 61  |it always lies a|
00001580  74 20 61 20 70 61 67 65  20 62 6f 75 6e 64 61 72  |t a page boundar|
00001590  79 29 0d 61 6e 64 20 61  64 64 69 6e 67 20 61 6e  |y).and adding an|
000015a0  20 41 63 6f 72 6e 20 44  46 53 20 72 61 69 73 65  | Acorn DFS raise|
000015b0  73 20 69 74 20 74 6f 20  26 31 39 30 30 2e 20 20  |s it to &1900.  |
000015c0  54 68 65 20 42 42 43 20  41 54 53 0d 72 61 69 73  |The BBC ATS.rais|
000015d0  65 73 20 69 74 20 74 6f  20 26 31 41 30 30 20 77  |es it to &1A00 w|
000015e0  68 65 6e 20 74 68 65 20  61 64 61 70 74 65 72 20  |hen the adapter |
000015f0  69 73 20 61 63 74 69 76  65 2e 20 20 54 6f 20 66  |is active.  To f|
00001600  69 6e 64 20 79 6f 75 72  0d 64 65 66 61 75 6c 74  |ind your.default|
00001610  20 50 41 47 45 20 76 61  6c 75 65 20 70 72 65 73  | PAGE value pres|
00001620  73 20 63 6f 6e 74 72 6f  6c 2f 62 72 65 61 6b 20  |s control/break |
00001630  61 6e 64 2c 20 69 6e 20  42 41 53 49 43 2c 20 65  |and, in BASIC, e|
00001640  6e 74 65 72 0d 50 52 49  4e 54 20 7e 50 41 47 45  |nter.PRINT ~PAGE|
00001650  2e 20 20 54 68 69 73 20  77 69 6c 6c 20 70 72 69  |.  This will pri|
00001660  6e 74 20 6f 75 74 20 74  68 65 20 76 61 6c 75 65  |nt out the value|
00001670  20 6f 66 20 50 41 47 45  20 69 6e 20 68 65 78 2e  | of PAGE in hex.|
00001680  0d 0d 49 66 20 79 6f 75  20 64 65 6c 69 62 65 72  |..If you deliber|
00001690  61 74 65 6c 79 20 73 65  74 20 69 74 20 68 69 67  |ately set it hig|
000016a0  68 65 72 20 74 68 61 6e  20 74 68 65 20 64 65 66  |her than the def|
000016b0  61 75 6c 74 20 66 6f 72  20 79 6f 75 72 0d 6d 61  |ault for your.ma|
000016c0  63 68 69 6e 65 20 63 6f  6e 66 69 67 75 72 61 74  |chine configurat|
000016d0  69 6f 6e 20 74 68 65 6e  20 79 6f 75 20 63 61 6e  |ion then you can|
000016e0  20 73 61 66 65 6c 79 20  75 73 65 20 74 68 65 20  | safely use the |
000016f0  73 70 61 63 65 0d 62 65  74 77 65 65 6e 2e 20 20  |space.between.  |
00001700  46 6f 72 20 65 78 61 6d  70 6c 65 2c 20 61 73 73  |For example, ass|
00001710  75 6d 65 20 79 6f 75 20  77 61 6e 74 20 32 35 36  |ume you want 256|
00001720  20 62 79 74 65 73 20 6f  66 20 73 70 61 63 65 2c  | bytes of space,|
00001730  0d 61 6e 64 20 50 41 47  45 20 69 73 20 6e 6f 72  |.and PAGE is nor|
00001740  6d 61 6c 6c 79 20 61 74  20 26 31 39 30 30 2e 20  |mally at &1900. |
00001750  20 42 79 20 74 79 70 69  6e 67 20 50 41 47 45 3d  | By typing PAGE=|
00001760  26 31 41 30 30 20 79 6f  75 0d 73 74 6f 70 20 42  |&1A00 you.stop B|
00001770  41 53 49 43 20 28 69 6e  63 6c 75 64 69 6e 67 20  |ASIC (including |
00001780  79 6f 75 72 20 73 6f 75  72 63 65 20 63 6f 64 65  |your source code|
00001790  29 20 67 65 74 74 69 6e  67 20 61 74 20 70 61 67  |) getting at pag|
000017a0  65 20 26 31 39 0d 61 6e  64 20 79 6f 75 20 63 61  |e &19.and you ca|
000017b0  6e 20 74 68 65 6e 20 61  73 73 65 6d 62 6c 65 20  |n then assemble |
000017c0  79 6f 75 72 20 63 6f 64  65 20 74 68 65 72 65 20  |your code there |
000017d0  62 79 20 73 65 74 74 69  6e 67 20 50 25 20 74 6f  |by setting P% to|
000017e0  0d 26 31 39 30 30 20 61  74 20 74 68 65 20 73 74  |.&1900 at the st|
000017f0  61 72 74 20 6f 66 20 65  61 63 68 20 70 61 73 73  |art of each pass|
00001800  20 6f 66 20 79 6f 75 72  20 61 73 73 65 6d 62 6c  | of your assembl|
00001810  79 2e 0d 0d 48 49 4d 45  4d 20 69 73 20 74 68 65  |y...HIMEM is the|
00001820  20 70 73 65 75 64 6f 20  76 61 72 69 61 62 6c 65  | pseudo variable|
00001830  20 74 68 61 74 20 69 73  20 75 73 75 61 6c 6c 79  | that is usually|
00001840  20 73 65 74 20 74 6f 20  74 68 65 0d 66 69 72 73  | set to the.firs|
00001850  74 20 62 79 74 65 20 74  68 61 74 20 42 41 53 49  |t byte that BASI|
00001860  43 20 64 6f 65 73 20 6e  6f 74 20 75 73 65 2c 20  |C does not use, |
00001870  6e 6f 72 6d 61 6c 6c 79  20 74 68 65 20 66 69 72  |normally the fir|
00001880  73 74 20 62 79 74 65 0d  6f 66 20 73 63 72 65 65  |st byte.of scree|
00001890  6e 20 6d 65 6d 6f 72 79  2e 20 20 57 68 65 6e 20  |n memory.  When |
000018a0  75 73 69 6e 67 20 61 6e  20 75 6e 65 78 70 61 6e  |using an unexpan|
000018b0  64 65 64 20 42 42 43 20  4d 69 63 72 6f 0d 77 69  |ded BBC Micro.wi|
000018c0  74 68 6f 75 74 20 73 68  61 64 6f 77 20 52 41 4d  |thout shadow RAM|
000018d0  20 48 49 4d 45 4d 20 74  61 6b 65 73 20 61 20 64  | HIMEM takes a d|
000018e0  69 66 66 65 72 65 6e 74  20 76 61 6c 75 65 20 66  |ifferent value f|
000018f0  6f 72 20 65 61 63 68 0d  73 63 72 65 65 6e 20 4d  |or each.screen M|
00001900  6f 64 65 2e 20 20 49 6e  20 4d 6f 64 65 20 33 20  |ode.  In Mode 3 |
00001910  69 74 20 69 73 20 26 34  30 30 30 20 73 6f 20 74  |it is &4000 so t|
00001920  6f 20 72 65 73 65 72 76  65 20 61 20 70 61 67 65  |o reserve a page|
00001930  20 66 6f 72 0d 61 20 70  72 6f 67 72 61 6d 20 79  | for.a program y|
00001940  6f 75 20 63 6f 75 6c 64  20 73 65 74 20 48 49 4d  |ou could set HIM|
00001950  45 4d 20 74 6f 20 26 33  46 30 30 20 69 66 20 79  |EM to &3F00 if y|
00001960  6f 75 20 77 65 72 65 20  75 73 69 6e 67 20 61 0d  |ou were using a.|
00001970  4d 6f 64 65 20 33 20 73  63 72 65 65 6e 2e 0d 0d  |Mode 3 screen...|
00001980  57 68 69 6c 65 20 64 65  76 65 6c 6f 70 69 6e 67  |While developing|
00001990  20 61 20 72 6f 75 74 69  6e 65 20 74 68 61 74 20  | a routine that |
000019a0  64 6f 65 73 20 6e 6f 74  20 68 61 76 65 20 74 6f  |does not have to|
000019b0  20 62 65 20 69 6e 20 61  0d 70 61 72 74 69 63 75  | be in a.particu|
000019c0  6c 61 72 20 6d 65 6d 6f  72 79 20 73 70 61 63 65  |lar memory space|
000019d0  20 74 6f 20 77 6f 72 6b  20 79 6f 75 72 20 62 65  | to work your be|
000019e0  73 74 20 62 65 74 20 69  73 20 70 72 6f 62 61 62  |st bet is probab|
000019f0  6c 79 20 74 6f 0d 75 73  65 20 44 49 4d 20 74 6f  |ly to.use DIM to|
00001a00  20 64 79 6e 61 6d 69 63  61 6c 6c 79 20 61 6c 6c  | dynamically all|
00001a10  6f 63 61 74 65 20 73 70  61 63 65 2e 20 20 45 72  |ocate space.  Er|
00001a20  72 6f 72 73 20 77 68 69  6c 65 20 75 73 69 6e 67  |rors while using|
00001a30  0d 50 41 47 45 20 63 61  6e 20 6f 76 65 72 77 72  |.PAGE can overwr|
00001a40  69 74 65 20 79 6f 75 72  20 73 6f 75 72 63 65 20  |ite your source |
00001a50  61 6e 64 20 48 49 4d 45  4d 20 6d 6f 76 65 73 20  |and HIMEM moves |
00001a60  77 69 74 68 20 63 68 61  6e 67 65 73 0d 69 6e 20  |with changes.in |
00001a70  6d 6f 64 65 2e 20 20 41  6c 73 6f 2c 20 61 73 20  |mode.  Also, as |
00001a80  79 6f 75 72 20 63 6f 64  65 20 67 72 6f 77 73 2c  |your code grows,|
00001a90  20 73 6f 20 79 6f 75 20  63 61 6e 20 69 6e 63 72  | so you can incr|
00001aa0  65 61 73 65 20 74 68 65  0d 64 69 6d 65 6e 73 69  |ease the.dimensi|
00001ab0  6f 6e 65 64 20 6d 65 6d  6f 72 79 20 77 69 74 68  |oned memory with|
00001ac0  20 69 74 2e 0d 0d 54 68  65 20 61 6c 74 65 72 6e  | it...The altern|
00001ad0  61 74 69 76 65 20 61 70  70 72 6f 61 63 68 20 28  |ative approach (|
00001ae0  77 68 69 63 68 20 64 6f  65 73 20 6e 6f 74 20 77  |which does not w|
00001af0  6f 72 6b 20 69 6e 20 61  20 73 65 63 6f 6e 64 0d  |ork in a second.|
00001b00  70 72 6f 63 65 73 73 6f  72 29 20 69 73 20 74 6f  |processor) is to|
00001b10  20 75 73 65 20 62 69 74  73 20 6f 66 20 74 68 65  | use bits of the|
00001b20  20 6d 61 63 68 69 6e 65  73 27 20 77 6f 72 6b 20  | machines' work |
00001b30  73 70 61 63 65 20 74 68  61 74 0d 79 6f 75 20 64  |space that.you d|
00001b40  6f 20 6e 6f 74 20 74 68  69 6e 6b 20 77 69 6c 6c  |o not think will|
00001b50  20 62 65 20 75 73 65 64  2e 20 20 48 65 72 65 20  | be used.  Here |
00001b60  61 72 65 20 73 6f 6d 65  20 65 78 61 6d 70 6c 65  |are some example|
00001b70  73 20 66 6f 72 20 61 0d  4d 6f 64 65 6c 20 42 2e  |s for a.Model B.|
00001b80  0d 0d 50 61 67 65 20 26  42 20 73 74 6f 72 65 73  |..Page &B stores|
00001b90  20 75 73 65 72 20 64 65  66 69 6e 65 64 20 6b 65  | user defined ke|
00001ba0  79 20 73 74 72 69 6e 67  73 0d 50 61 67 65 20 26  |y strings.Page &|
00001bb0  43 20 73 74 6f 72 65 73  20 75 73 65 72 20 64 65  |C stores user de|
00001bc0  66 69 6e 65 64 20 63 68  61 72 61 63 74 65 72 20  |fined character |
00001bd0  64 65 66 69 6e 69 74 69  6f 6e 73 0d 50 61 67 65  |definitions.Page|
00001be0  73 20 26 39 20 61 6e 64  20 26 41 20 61 72 65 20  |s &9 and &A are |
00001bf0  77 6f 72 6b 73 70 61 63  65 20 66 6f 72 20 74 68  |workspace for th|
00001c00  65 20 52 53 34 32 33 2c  20 63 61 73 73 65 74 74  |e RS423, cassett|
00001c10  65 20 61 6e 64 0d 28 69  6e 20 50 61 67 65 20 26  |e and.(in Page &|
00001c20  39 29 20 73 6f 75 6e 64  20 65 6e 76 65 6c 6f 70  |9) sound envelop|
00001c30  65 20 73 74 6f 72 61 67  65 20 61 6e 64 20 73 70  |e storage and sp|
00001c40  65 65 63 68 20 70 72 6f  63 65 73 73 69 6e 67 0d  |eech processing.|
00001c50  0d 4f 6e 20 61 20 4d 6f  64 65 6c 20 42 20 77 69  |.On a Model B wi|
00001c60  74 68 20 64 69 73 63 73  20 79 6f 75 20 63 61 6e  |th discs you can|
00001c70  20 75 73 65 20 73 70 61  63 65 20 62 65 74 77 65  | use space betwe|
00001c80  65 6e 20 26 31 31 30 30  20 61 6e 64 0d 26 31 39  |en &1100 and.&19|
00001c90  30 30 20 61 6c 74 68 6f  75 67 68 20 62 65 77 61  |00 although bewa|
00001ca0  72 65 20 6f 66 20 73 6f  6d 65 20 66 6c 61 67 73  |re of some flags|
00001cb0  20 73 74 6f 72 65 64 20  69 6e 20 70 61 67 65 20  | stored in page |
00001cc0  26 31 37 2e 20 55 73 65  0d 6f 66 20 74 68 69 73  |&17. Use.of this|
00001cd0  20 77 6f 72 6b 73 70 61  63 65 20 6f 6e 6c 79 20  | workspace only |
00001ce0  61 66 66 65 63 74 73 20  72 61 6e 64 6f 6d 20 61  |affects random a|
00001cf0  63 63 65 73 73 20 66 69  6c 69 6e 67 20 73 79 73  |ccess filing sys|
00001d00  74 65 6d 0d 6f 70 65 72  61 74 69 6f 6e 73 20 77  |tem.operations w|
00001d10  69 74 68 20 73 65 76 65  72 61 6c 20 66 69 6c 65  |ith several file|
00001d20  73 20 6f 70 65 6e 2e 0d  0d 41 73 20 79 6f 75 20  |s open...As you |
00001d30  63 61 6e 20 70 72 6f 62  61 62 6c 79 20 67 75 65  |can probably gue|
00001d40  73 73 20 6e 6f 6e 65 20  6f 66 20 74 68 69 73 20  |ss none of this |
00001d50  73 70 61 63 65 20 69 73  20 67 75 61 72 61 6e 74  |space is guarant|
00001d60  65 65 64 0d 73 61 66 65  20 69 6e 20 61 6c 6c 20  |eed.safe in all |
00001d70  63 69 72 63 75 6d 73 74  61 6e 63 65 73 2e 20 20  |circumstances.  |
00001d80  50 72 6f 62 61 62 6c 79  20 74 68 65 20 6f 6e 6c  |Probably the onl|
00001d90  79 20 77 61 79 20 74 6f  0d 67 75 61 72 61 6e 74  |y way to.guarant|
00001da0  65 65 20 73 61 66 65 74  79 20 69 73 20 74 6f 20  |ee safety is to |
00001db0  70 75 74 20 79 6f 75 72  20 63 6f 64 65 20 69 6e  |put your code in|
00001dc0  74 6f 20 61 20 73 69 64  65 77 61 79 73 20 52 4f  |to a sideways RO|
00001dd0  4d 0d 73 69 6e 63 65 20  74 68 65 73 65 20 52 4f  |M.since these RO|
00001de0  4d 53 20 68 61 76 65 20  73 70 65 63 69 61 6c 20  |MS have special |
00001df0  70 72 69 76 69 6c 65 67  65 73 20 61 6e 64 20 63  |privileges and c|
00001e00  61 6e 20 72 65 73 65 72  76 65 0d 77 6f 72 6b 73  |an reserve.works|
00001e10  70 61 63 65 2e 0d 0d 49  6e 20 61 20 36 35 30 32  |pace...In a 6502|
00001e20  20 73 65 63 6f 6e 64 20  70 72 6f 63 65 73 73 6f  | second processo|
00001e30  72 20 72 75 6e 6e 69 6e  67 20 6f 72 64 69 6e 61  |r running ordina|
00001e40  72 79 20 42 41 53 49 43  2c 20 6e 6f 74 20 48 69  |ry BASIC, not Hi|
00001e50  0d 42 41 53 49 43 2c 20  79 6f 75 20 68 61 76 65  |.BASIC, you have|
00001e60  20 73 70 61 63 65 20 61  62 6f 76 65 20 74 68 65  | space above the|
00001e70  20 6c 61 6e 67 75 61 67  65 20 77 68 69 63 68 20  | language which |
00001e80  79 6f 75 20 63 6f 75 6c  64 20 75 73 65 0d 6c 79  |you could use.ly|
00001e90  69 6e 67 20 62 65 74 77  65 65 6e 20 26 38 30 30  |ing between &800|
00001ea0  30 20 61 6e 64 20 26 46  37 46 46 2e 20 20 41 62  |0 and &F7FF.  Ab|
00001eb0  6f 76 65 20 74 68 69 73  20 61 72 65 20 74 68 65  |ove this are the|
00001ec0  20 73 65 63 6f 6e 64 0d  70 72 6f 63 65 73 73 6f  | second.processo|
00001ed0  72 20 4f 53 20 61 6e 64  20 54 55 42 45 20 62 75  |r OS and TUBE bu|
00001ee0  66 66 65 72 73 2e 20 20  28 53 65 65 20 32 6e 64  |ffers.  (See 2nd|
00001ef0  20 50 72 6f 63 65 73 73  6f 72 20 55 73 65 72 0d  | Processor User.|
00001f00  47 75 69 64 65 2e 29 0d  0d 41 6e 64 20 77 68 65  |Guide.)..And whe|
00001f10  6e 20 79 6f 75 20 68 61  76 65 20 67 65 6e 65 72  |n you have gener|
00001f20  61 74 65 64 20 79 6f 75  72 20 63 6f 64 65 20 79  |ated your code y|
00001f30  6f 75 20 6d 61 79 20 77  69 73 68 20 74 6f 20 73  |ou may wish to s|
00001f40  61 76 65 0d 69 74 20 61  6e 64 20 72 75 6e 20 69  |ave.it and run i|
00001f50  74 20 66 72 6f 6d 20 64  69 73 63 20 6f 72 20 74  |t from disc or t|
00001f60  61 70 65 20 69 6e 64 65  70 65 6e 64 65 6e 74 6c  |ape independentl|
00001f70  79 2e 20 20 42 79 20 6c  6f 6f 6b 69 6e 67 0d 61  |y.  By looking.a|
00001f80  74 20 79 6f 75 72 20 61  73 73 65 6d 62 6c 65 72  |t your assembler|
00001f90  20 6c 69 73 74 69 6e 67  20 79 6f 75 20 77 69 6c  | listing you wil|
00001fa0  6c 20 73 65 65 20 74 68  61 74 20 74 68 65 20 66  |l see that the f|
00001fb0  69 72 73 74 20 6d 65 6d  6f 72 79 0d 6c 6f 63 61  |irst memory.loca|
00001fc0  74 69 6f 6e 20 6c 69 73  74 65 64 20 6f 6e 20 74  |tion listed on t|
00001fd0  68 65 20 6c 65 66 74 20  69 73 20 77 68 65 72 65  |he left is where|
00001fe0  20 79 6f 75 20 64 65 66  69 6e 65 64 20 74 68 65  | you defined the|
00001ff0  20 63 6f 64 65 20 74 6f  0d 73 74 61 72 74 2e 20  | code to.start. |
00002000  20 54 68 65 20 66 69 6e  61 6c 20 6c 6f 63 61 74  | The final locat|
00002010  69 6f 6e 20 67 69 76 65  6e 20 62 79 20 74 68 65  |ion given by the|
00002020  20 61 73 73 65 6d 62 6c  79 20 6c 69 73 74 69 6e  | assembly listin|
00002030  67 20 69 73 0d 74 68 65  20 65 6e 64 20 6f 66 20  |g is.the end of |
00002040  79 6f 75 72 20 63 6f 64  65 2e 20 20 4c 65 74 27  |your code.  Let'|
00002050  73 20 61 73 73 75 6d 65  20 79 6f 75 20 68 61 76  |s assume you hav|
00002060  65 20 61 73 73 65 6d 62  6c 65 64 20 73 6f 6d 65  |e assembled some|
00002070  0d 63 6f 64 65 20 74 6f  20 73 74 61 72 74 20 61  |.code to start a|
00002080  74 2c 20 73 61 79 2c 20  26 31 32 30 30 20 28 62  |t, say, &1200 (b|
00002090  79 20 70 75 74 74 69 6e  67 20 63 6f 64 65 25 3d  |y putting code%=|
000020a0  26 31 32 30 30 20 61 6e  64 0d 50 25 3d 63 6f 64  |&1200 and.P%=cod|
000020b0  65 25 20 61 74 20 74 68  65 20 66 72 6f 6e 74 20  |e% at the front |
000020c0  6f 66 20 79 6f 75 72 20  70 72 6f 67 72 61 6d 29  |of your program)|
000020d0  20 61 6e 64 20 74 68 61  74 20 74 68 65 0d 61 73  | and that the.as|
000020e0  73 65 6d 62 6c 65 72 20  6c 69 73 74 69 6e 67 20  |sembler listing |
000020f0  74 65 6c 6c 73 20 79 6f  75 20 69 74 20 65 6e 64  |tells you it end|
00002100  73 20 61 74 20 26 31 32  42 35 2e 0d 0d 54 6f 20  |s at &12B5...To |
00002110  73 61 76 65 20 74 68 69  73 20 63 6f 64 65 20 74  |save this code t|
00002120  6f 20 64 69 73 63 20 79  6f 75 20 77 6f 75 6c 64  |o disc you would|
00002130  20 74 79 70 65 0d 0d 2a  53 41 56 45 20 61 74 69  | type..*SAVE ati|
00002140  74 6c 65 20 31 32 30 30  20 31 32 42 36 0d 0d 54  |tle 1200 12B6..T|
00002150  68 61 74 20 69 73 20 79  6f 75 20 73 61 76 65 20  |hat is you save |
00002160  69 74 20 69 6e 20 61 20  66 69 6c 65 20 63 61 6c  |it in a file cal|
00002170  6c 65 64 20 61 74 69 74  6c 65 20 28 6f 72 20 77  |led atitle (or w|
00002180  68 61 74 65 76 65 72 29  0d 61 6e 64 20 74 68 65  |hatever).and the|
00002190  20 6d 65 6d 6f 72 79 20  62 6c 6f 63 6b 20 73 61  | memory block sa|
000021a0  76 65 64 20 69 73 20 66  72 6f 6d 20 26 31 32 30  |ved is from &120|
000021b0  30 20 74 6f 20 26 31 32  42 35 2e 20 20 4e 6f 74  |0 to &12B5.  Not|
000021c0  65 0d 74 68 61 74 20 74  68 65 20 65 6e 64 20 70  |e.that the end p|
000021d0  6f 69 6e 74 20 69 73 20  6f 6e 65 20 62 79 74 65  |oint is one byte|
000021e0  20 61 66 74 65 72 20 74  68 65 20 66 69 6e 61 6c  | after the final|
000021f0  20 62 79 74 65 20 73 68  6f 77 6e 20 69 6e 0d 79  | byte shown in.y|
00002200  6f 75 72 20 6c 69 73 74  69 6e 67 2e 20 20 41 6e  |our listing.  An|
00002210  20 61 6c 74 65 72 6e 61  74 69 76 65 20 66 6f 72  | alternative for|
00002220  6d 20 75 73 65 73 20 6c  65 6e 67 74 68 20 72 61  |m uses length ra|
00002230  74 68 65 72 20 74 68 61  6e 0d 73 74 61 72 74 20  |ther than.start |
00002240  61 6e 64 20 65 6e 64 20  73 6f 20 69 74 20 77 6f  |and end so it wo|
00002250  75 6c 64 20 62 65 0d 0d  2a 53 41 56 45 20 61 74  |uld be..*SAVE at|
00002260  69 74 6c 65 20 31 32 30  30 20 2b 42 35 0d 0d 49  |itle 1200 +B5..I|
00002270  66 20 79 6f 75 20 77 61  6e 74 65 64 20 74 6f 20  |f you wanted to |
00002280  65 78 65 63 75 74 65 20  74 68 69 73 20 64 69 72  |execute this dir|
00002290  65 63 74 6c 79 20 66 72  6f 6d 20 64 69 73 63 20  |ectly from disc |
000022a0  79 6f 75 20 63 6f 75 6c  64 0d 74 68 65 6e 20 65  |you could.then e|
000022b0  69 74 68 65 72 20 65 6e  74 65 72 0d 0d 2a 4c 4f  |ither enter..*LO|
000022c0  41 44 20 61 74 69 74 6c  65 20 20 66 6f 6c 6c 6f  |AD atitle  follo|
000022d0  77 65 64 20 62 79 20 20  43 41 4c 4c 20 26 31 32  |wed by  CALL &12|
000022e0  30 30 0d 0d 6f 72 0d 0d  2a 61 74 69 74 6c 65 0d  |00..or..*atitle.|
000022f0  0d 49 66 20 79 6f 75 20  77 61 6e 74 65 64 20 74  |.If you wanted t|
00002300  6f 20 6d 61 6b 65 20 73  75 72 65 20 74 68 65 20  |o make sure the |
00002310  63 6f 64 65 20 77 6f 75  6c 64 20 61 6c 77 61 79  |code would alway|
00002320  73 20 72 75 6e 20 69 6e  20 74 68 65 0d 6d 61 69  |s run in the.mai|
00002330  6e 20 6d 69 63 72 6f 20  65 76 65 6e 20 77 68 65  |n micro even whe|
00002340  6e 20 79 6f 75 20 68 61  64 20 61 20 73 65 63 6f  |n you had a seco|
00002350  6e 64 20 70 72 6f 63 65  73 73 6f 72 20 75 70 20  |nd processor up |
00002360  61 6e 64 0d 72 75 6e 6e  69 6e 67 20 74 68 65 6e  |and.running then|
00002370  20 79 6f 75 20 63 6f 75  6c 64 20 6f 70 65 72 61  | you could opera|
00002380  74 65 20 69 6e 20 6f 6e  65 20 6f 66 20 74 77 6f  |te in one of two|
00002390  20 77 61 79 73 2e 20 20  46 69 72 73 74 6c 79 2c  | ways.  Firstly,|
000023a0  0d 69 66 20 79 6f 75 72  20 63 6f 64 65 20 68 61  |.if your code ha|
000023b0  64 20 62 65 65 6e 20 61  73 73 65 6d 62 6c 65 64  |d been assembled|
000023c0  20 69 6e 20 74 68 65 20  6d 61 69 6e 20 28 49 2f  | in the main (I/|
000023d0  4f 29 20 70 72 6f 63 65  73 73 6f 72 0d 79 6f 75  |O) processor.you|
000023e0  20 77 6f 75 6c 64 20 74  79 70 65 0d 0d 2a 53 41  | would type..*SA|
000023f0  56 45 20 61 74 69 74 6c  65 20 46 46 46 46 31 32  |VE atitle FFFF12|
00002400  30 30 20 2b 42 35 0d 0d  54 68 65 20 66 6f 75 72  |00 +B5..The four|
00002410  20 6c 65 61 64 69 6e 67  20 46 73 20 74 65 6c 6c  | leading Fs tell|
00002420  20 74 68 65 20 66 69 6c  69 6e 67 20 73 79 73 74  | the filing syst|
00002430  65 6d 20 74 68 61 74 20  79 6f 75 20 6d 65 61 6e  |em that you mean|
00002440  20 74 68 65 0d 49 2f 4f  20 70 72 6f 63 65 73 73  | the.I/O process|
00002450  6f 72 20 69 66 20 74 68  65 72 65 20 69 73 20 61  |or if there is a|
00002460  20 63 68 6f 69 63 65 2e  20 20 4f 72 20 73 65 63  | choice.  Or sec|
00002470  6f 6e 64 6c 79 2c 20 77  68 65 74 68 65 72 0d 79  |ondly, whether.y|
00002480  6f 75 20 61 72 65 20 69  6e 20 74 68 65 20 49 2f  |ou are in the I/|
00002490  4f 20 6f 72 20 73 65 63  6f 6e 64 20 70 72 6f 63  |O or second proc|
000024a0  65 73 73 6f 72 20 79 6f  75 20 63 6f 75 6c 64 20  |essor you could |
000024b0  74 79 70 65 0d 0d 2a 53  41 56 45 20 61 74 69 74  |type..*SAVE atit|
000024c0  6c 65 20 31 32 30 30 20  2b 42 35 20 46 46 46 46  |le 1200 +B5 FFFF|
000024d0  31 32 30 30 20 46 46 46  46 31 32 30 30 0d 0d 54  |1200 FFFF1200..T|
000024e0  68 65 20 74 77 6f 20 65  78 74 72 61 20 63 68 75  |he two extra chu|
000024f0  6e 6b 73 20 6f 66 20 6e  75 6d 62 65 72 73 20 74  |nks of numbers t|
00002500  65 6c 6c 20 74 68 65 20  66 69 6c 69 6e 67 20 73  |ell the filing s|
00002510  79 73 74 65 6d 20 74 6f  0d 73 65 74 20 74 68 65  |ystem to.set the|
00002520  20 6c 6f 61 64 20 61 6e  64 20 65 78 65 63 75 74  | load and execut|
00002530  69 6f 6e 20 61 64 64 72  65 73 73 20 6f 66 20 79  |ion address of y|
00002540  6f 75 72 20 63 6f 64 65  20 74 6f 20 31 32 30 30  |our code to 1200|
00002550  20 69 6e 0d 74 68 65 20  49 2f 4f 20 70 72 6f 63  | in.the I/O proc|
00002560  65 73 73 6f 72 2e 0d 0d  54 68 65 72 65 20 61 72  |essor...There ar|
00002570  65 20 6f 63 63 61 73 69  6f 6e 73 20 77 68 65 6e  |e occasions when|
00002580  20 79 6f 75 20 68 61 76  65 20 74 6f 20 65 78 65  | you have to exe|
00002590  63 75 74 65 20 63 6f 64  65 20 69 6e 20 74 68 65  |cute code in the|
000025a0  20 49 2f 4f 0d 70 72 6f  63 65 73 73 6f 72 2c 20  | I/O.processor, |
000025b0  66 6f 72 20 65 78 61 6d  70 6c 65 20 77 68 65 6e  |for example when|
000025c0  20 75 73 69 6e 67 20 69  6e 74 65 72 72 75 70 74  | using interrupt|
000025d0  73 2c 20 62 75 74 20 49  27 6c 6c 20 63 6f 6d 65  |s, but I'll come|
000025e0  0d 6f 6e 74 6f 20 74 68  6f 73 65 20 69 6e 20 61  |.onto those in a|
000025f0  20 6c 61 74 65 72 20 6d  6f 64 75 6c 65 2e 20 20  | later module.  |
00002600  49 6e 20 74 68 65 20 6d  65 61 6e 74 69 6d 65 20  |In the meantime |
00002610  74 72 79 20 6f 75 74 0d  73 61 76 69 6e 67 20 61  |try out.saving a|
00002620  6e 64 20 72 75 6e 6e 69  6e 67 20 73 6f 6d 65 20  |nd running some |
00002630  63 6f 64 65 2c 20 66 6f  72 20 69 6e 73 74 61 6e  |code, for instan|
00002640  63 65 20 74 68 65 20 63  6f 64 65 20 69 6e 20 74  |ce the code in t|
00002650  68 65 0d 66 69 72 73 74  20 6d 6f 64 75 6c 65 20  |he.first module |
00002660  74 68 61 74 20 70 72 69  6e 74 73 20 6f 75 74 20  |that prints out |
00002670  61 20 27 48 65 6c 6c 6f  20 57 6f 72 6c 64 27 20  |a 'Hello World' |
00002680  6d 65 73 73 61 67 65 2e  20 20 4e 6f 74 65 0d 68  |message.  Note.h|
00002690  65 72 65 20 74 68 6f 75  67 68 20 74 68 61 74 20  |ere though that |
000026a0  79 6f 75 20 77 69 6c 6c  20 68 61 76 65 20 74 6f  |you will have to|
000026b0  20 63 68 65 63 6b 20 77  68 65 72 65 20 74 68 65  | check where the|
000026c0  20 65 6e 64 20 6f 66 0d  74 68 61 74 20 63 6f 64  | end of.that cod|
000026d0  65 20 69 73 20 62 65 63  61 75 73 65 20 6f 66 20  |e is because of |
000026e0  74 68 65 20 73 74 72 69  6e 67 20 74 61 67 67 65  |the string tagge|
000026f0  64 20 6f 6e 74 6f 20 74  68 65 20 65 6e 64 2c 0d  |d onto the end,.|
00002700  77 68 69 63 68 20 69 73  20 69 6d 70 6f 72 74 61  |which is importa|
00002710  6e 74 2e 0d 0d 57 68 69  6c 65 20 77 65 27 72 65  |nt...While we're|
00002720  20 6f 6e 20 74 68 65 20  73 75 62 6a 65 63 74 20  | on the subject |
00002730  6f 66 20 6d 65 6d 6f 72  79 20 49 20 77 69 6c 6c  |of memory I will|
00002740  20 6d 65 6e 74 69 6f 6e  20 61 0d 6d 61 63 68 69  | mention a.machi|
00002750  6e 65 20 63 6f 64 65 20  6d 6f 6e 69 74 6f 72 2e  |ne code monitor.|
00002760  20 20 54 68 69 73 20 69  73 20 61 20 70 72 6f 67  |  This is a prog|
00002770  72 61 6d 20 74 68 61 74  20 65 6e 61 62 6c 65 73  |ram that enables|
00002780  20 79 6f 75 20 74 6f 0d  64 65 62 75 67 20 79 6f  | you to.debug yo|
00002790  75 72 20 63 6f 64 65 20  28 61 74 20 6c 65 61 73  |ur code (at leas|
000027a0  74 29 20 62 79 20 73 74  65 70 70 69 6e 67 20 74  |t) by stepping t|
000027b0  68 72 6f 75 67 68 20 69  74 20 61 20 63 6f 6d 6d  |hrough it a comm|
000027c0  61 6e 64 0d 61 74 20 61  20 74 69 6d 65 20 61 6e  |and.at a time an|
000027d0  64 20 73 65 65 69 6e 67  20 68 6f 77 20 74 68 65  |d seeing how the|
000027e0  20 72 65 67 69 73 74 65  72 73 20 61 6e 64 20 6d  | registers and m|
000027f0  65 6d 6f 72 79 20 61 72  65 0d 61 66 66 65 63 74  |emory are.affect|
00002800  65 64 2e 20 20 49 66 20  79 6f 75 20 61 72 65 20  |ed.  If you are |
00002810  69 6e 74 65 72 65 73 74  65 64 20 69 6e 20 70 72  |interested in pr|
00002820  6f 67 72 61 6d 6d 69 6e  67 20 69 6e 20 6d 61 63  |ogramming in mac|
00002830  68 69 6e 65 0d 63 6f 64  65 20 74 68 65 6e 20 79  |hine.code then y|
00002840  6f 75 20 73 68 6f 75 6c  64 20 63 6f 6e 73 69 64  |ou should consid|
00002850  65 72 20 62 75 79 69 6e  67 20 6f 6e 65 2e 20 20  |er buying one.  |
00002860  49 74 20 77 6f 75 6c 64  20 74 61 6b 65 20 6d 65  |It would take me|
00002870  0d 74 6f 6f 20 6c 6f 6e  67 20 74 6f 20 77 72 69  |.too long to wri|
00002880  74 65 20 6f 6e 65 20 74  6f 20 69 6e 63 6c 75 64  |te one to includ|
00002890  65 20 69 6e 20 74 68 69  73 20 63 6f 75 72 73 65  |e in this course|
000028a0  2c 20 61 6e 64 20 69 6e  20 61 6e 79 0d 63 61 73  |, and in any.cas|
000028b0  65 20 49 20 64 6f 75 62  74 20 69 66 20 49 20 63  |e I doubt if I c|
000028c0  6f 75 6c 64 20 77 72 69  74 65 20 6f 6e 65 20 61  |ould write one a|
000028d0  73 20 67 6f 6f 64 20 61  73 2c 20 73 61 79 2c 20  |s good as, say, |
000028e0  74 68 65 20 42 42 43 0d  53 6f 66 74 20 72 6f 6d  |the BBC.Soft rom|
000028f0  20 63 61 6c 6c 65 64 20  4d 6f 6e 69 74 6f 72 20  | called Monitor |
00002900  77 72 69 74 74 65 6e 20  62 79 20 47 72 61 68 61  |written by Graha|
00002910  6d 20 42 61 72 74 72 61  6d 2e 20 20 54 68 69 73  |m Bartram.  This|
00002920  20 69 73 0d 74 68 65 20  6f 6e 65 20 49 20 75 73  | is.the one I us|
00002930  65 20 62 75 74 20 74 68  65 72 65 20 61 72 65 20  |e but there are |
00002940  6e 75 6d 65 72 6f 75 73  20 74 79 70 65 73 20 61  |numerous types a|
00002950  76 61 69 6c 61 62 6c 65  2c 0d 75 73 75 61 6c 6c  |vailable,.usuall|
00002960  79 20 61 73 20 72 6f 6d  73 20 77 68 69 63 68 20  |y as roms which |
00002970  79 6f 75 20 63 61 6e 20  70 6c 75 67 20 69 6e 74  |you can plug int|
00002980  6f 20 79 6f 75 72 20 6d  61 63 68 69 6e 65 2e 20  |o your machine. |
00002990  20 54 68 65 0d 61 64 76  65 72 74 69 73 69 6e 67  | The.advertising|
000029a0  20 70 61 67 65 73 20 6f  66 20 6d 61 67 61 7a 69  | pages of magazi|
000029b0  6e 65 73 20 6c 69 6b 65  20 41 63 6f 72 6e 20 55  |nes like Acorn U|
000029c0  73 65 72 2c 20 4d 69 63  72 6f 20 55 73 65 72 2c  |ser, Micro User,|
000029d0  0d 41 20 61 6e 64 20 42  20 43 6f 6d 70 75 74 69  |.A and B Computi|
000029e0  6e 67 20 61 6e 64 20 42  45 45 42 55 47 20 77 69  |ng and BEEBUG wi|
000029f0  6c 6c 20 73 68 6f 77 20  79 6f 75 20 74 68 65 20  |ll show you the |
00002a00  63 68 6f 69 63 65 0d 61  76 61 69 6c 61 62 6c 65  |choice.available|
00002a10  2e 0d 0d 0d 46 69 6e 61  6c 6c 79 20 74 68 69 73  |....Finally this|
00002a20  20 77 65 65 6b 20 61 20  66 65 77 20 77 6f 72 64  | week a few word|
00002a30  73 20 6f 6e 20 74 68 65  20 45 51 55 20 70 73 65  |s on the EQU pse|
00002a40  75 64 6f 20 6f 70 65 72  61 74 69 76 65 73 0d 69  |udo operatives.i|
00002a50  6e 20 74 68 65 20 42 41  53 49 43 32 20 28 61 6e  |n the BASIC2 (an|
00002a60  64 20 6c 61 74 65 72 29  20 61 73 73 65 6d 62 6c  |d later) assembl|
00002a70  65 72 73 2e 0d 0d 49 6e  20 6c 61 73 74 20 77 65  |ers...In last we|
00002a80  65 6b 27 73 20 66 69 6c  65 20 49 20 75 73 65 64  |ek's file I used|
00002a90  20 61 20 72 61 74 68 65  72 20 63 72 75 64 65 20  | a rather crude |
00002aa0  6d 65 74 68 6f 64 20 74  6f 20 70 75 74 0d 76 61  |method to put.va|
00002ab0  72 69 61 62 6c 65 73 20  61 6e 64 20 73 74 72 69  |riables and stri|
00002ac0  6e 67 73 20 69 6e 74 6f  20 6d 65 6d 6f 72 79 2e  |ngs into memory.|
00002ad0  20 20 49 74 20 69 6e 76  6f 6c 76 65 64 20 6c 65  |  It involved le|
00002ae0  61 76 69 6e 67 20 74 68  65 0d 61 73 73 65 6d 62  |aving the.assemb|
00002af0  6c 65 72 2c 20 75 73 69  6e 67 20 42 41 53 49 43  |ler, using BASIC|
00002b00  20 69 6e 64 69 72 65 63  74 69 6f 6e 20 6f 70 65  | indirection ope|
00002b10  72 61 74 6f 72 73 20 28  3f 20 21 20 61 6e 64 20  |rators (? ! and |
00002b20  24 29 20 74 6f 0d 70 75  74 20 74 68 65 20 76 61  |$) to.put the va|
00002b30  72 69 61 62 6c 65 20 69  6e 20 70 6c 61 63 65 20  |riable in place |
00002b40  61 74 20 74 68 65 20 70  72 6f 67 72 61 6d 20 63  |at the program c|
00002b50  6f 75 6e 74 65 72 20 76  61 6c 75 65 20 50 25 2c  |ounter value P%,|
00002b60  0d 61 6e 64 20 72 65 2d  65 6e 74 65 72 69 6e 67  |.and re-entering|
00002b70  20 74 68 65 20 61 73 73  65 6d 62 6c 65 72 2e 0d  | the assembler..|
00002b80  0d 57 68 69 6c 65 20 42  41 53 49 43 31 20 64 6f  |.While BASIC1 do|
00002b90  65 73 20 6e 6f 74 20 68  61 76 65 20 74 68 65 20  |es not have the |
00002ba0  66 61 63 69 6c 69 74 79  2c 20 6c 61 74 65 72 20  |facility, later |
00002bb0  6f 6e 65 73 20 70 65 72  6d 69 74 0d 79 6f 75 20  |ones permit.you |
00002bc0  74 6f 20 65 71 75 61 74  65 20 61 20 73 65 63 74  |to equate a sect|
00002bd0  69 6f 6e 20 6f 66 20 6d  65 6d 6f 72 79 20 74 6f  |ion of memory to|
00002be0  20 61 20 62 79 74 65 2c  20 61 20 77 6f 72 64 2c  | a byte, a word,|
00002bf0  20 61 0d 64 6f 75 62 6c  65 20 77 6f 72 64 20 6f  | a.double word o|
00002c00  72 20 61 20 73 74 72 69  6e 67 2e 20 20 4c 69 6b  |r a string.  Lik|
00002c10  65 20 74 68 69 73 3a 0d  0d 20 20 20 20 2e 6f 6e  |e this:..    .on|
00002c20  65 20 20 20 20 20 20 20  20 45 51 55 42 20 26 31  |e        EQUB &1|
00002c30  32 0d 20 20 20 20 2e 74  77 6f 20 20 20 20 20 20  |2.    .two      |
00002c40  20 20 45 51 55 57 20 26  31 32 33 34 0d 20 20 20  |  EQUW &1234.   |
00002c50  20 2e 74 68 72 65 65 20  20 20 20 20 20 45 51 55  | .three      EQU|
00002c60  44 20 26 31 32 33 34 35  36 37 38 0d 20 20 20 20  |D &12345678.    |
00002c70  2e 66 6f 75 72 20 20 20  20 20 20 20 45 51 55 53  |.four       EQUS|
00002c80  20 22 4f 4e 45 20 54 57  4f 20 54 48 52 45 45 22  | "ONE TWO THREE"|
00002c90  20 2b 20 43 48 52 24 28  31 33 29 0d 0d 48 65 72  | + CHR$(13)..Her|
00002ca0  65 2c 20 61 20 77 6f 72  64 20 6d 65 61 6e 73 20  |e, a word means |
00002cb0  32 20 62 79 74 65 73 20  61 6e 64 20 61 20 64 6f  |2 bytes and a do|
00002cc0  75 62 6c 65 20 77 6f 72  64 20 6d 65 61 6e 73 20  |uble word means |
00002cd0  34 20 62 79 74 65 73 2e  0d 0d 49 6e 20 65 61 63  |4 bytes...In eac|
00002ce0  68 20 63 61 73 65 20 74  68 65 20 6e 75 6d 62 65  |h case the numbe|
00002cf0  72 20 6f 72 20 73 74 72  69 6e 67 20 63 6f 6e 63  |r or string conc|
00002d00  65 72 6e 65 64 20 69 73  20 61 73 73 65 6d 62 6c  |erned is assembl|
00002d10  65 64 20 61 74 0d 74 68  65 20 6c 61 62 65 6c 2e  |ed at.the label.|
00002d20  20 20 54 68 69 73 20 69  73 20 61 20 76 65 72 79  |  This is a very|
00002d30  20 6e 65 61 74 20 77 61  79 20 6f 66 20 70 75 74  | neat way of put|
00002d40  74 69 6e 67 20 76 61 6c  75 65 73 20 69 6e 74 6f  |ting values into|
00002d50  0d 79 6f 75 72 20 63 6f  64 65 2e 20 20 59 6f 75  |.your code.  You|
00002d60  20 63 61 6e 20 61 6c 73  6f 20 75 73 65 20 69 74  | can also use it|
00002d70  20 74 6f 20 72 65 73 65  72 76 65 20 61 20 62 6c  | to reserve a bl|
00002d80  6f 63 6b 20 6f 66 0d 6d  65 6d 6f 72 79 2e 20 20  |ock of.memory.  |
00002d90  46 6f 72 20 65 78 61 6d  70 6c 65 20 74 68 65 20  |For example the |
00002da0  62 79 74 65 20 68 65 6c  64 20 61 74 20 27 6f 6e  |byte held at 'on|
00002db0  65 27 20 63 6f 75 6c 64  20 63 68 61 6e 67 65 20  |e' could change |
00002dc0  61 73 0d 74 68 69 73 20  6c 6f 63 61 74 69 6f 6e  |as.this location|
00002dd0  20 69 73 20 75 73 65 64  20 74 6f 20 73 74 6f 72  | is used to stor|
00002de0  65 20 61 20 76 61 72 69  61 62 6c 65 20 69 6e 20  |e a variable in |
00002df0  79 6f 75 72 20 63 6f 64  65 2e 0d 0d 49 6e 63 69  |your code...Inci|
00002e00  64 65 6e 74 61 6c 6c 79  20 79 6f 75 20 74 65 6c  |dentally you tel|
00002e10  6c 20 77 68 69 63 68 20  42 41 53 49 43 20 79 6f  |l which BASIC yo|
00002e20  75 20 68 61 76 65 20 62  79 20 70 72 65 73 73 69  |u have by pressi|
00002e30  6e 67 20 42 52 45 41 4b  0d 61 6e 64 20 74 68 65  |ng BREAK.and the|
00002e40  6e 20 74 79 70 69 6e 67  20 52 45 50 4f 52 54 2e  |n typing REPORT.|
00002e50  20 20 49 66 20 74 68 65  20 6d 65 73 73 61 67 65  |  If the message|
00002e60  20 28 43 29 20 41 63 6f  72 6e 20 31 39 38 31 0d  | (C) Acorn 1981.|
00002e70  61 70 70 65 61 72 73 20  74 68 65 6e 20 79 6f 75  |appears then you|
00002e80  20 68 61 76 65 20 42 41  53 49 43 31 2e 0d 0d 54  | have BASIC1...T|
00002e90  68 65 20 70 72 6f 67 72  61 6d 20 69 6e 20 74 68  |he program in th|
00002ea0  69 73 20 77 65 65 6b 27  73 20 74 65 6c 65 73 6f  |is week's teleso|
00002eb0  66 74 77 61 72 65 20 74  72 61 6e 73 6d 69 73 73  |ftware transmiss|
00002ec0  69 6f 6e 20 42 2f 6f 73  62 30 34 0d 69 73 20 61  |ion B/osb04.is a|
00002ed0  6e 20 61 73 73 65 6d 62  6c 65 72 20 73 68 65 6c  |n assembler shel|
00002ee0  6c 20 74 6f 20 69 6c 6c  75 73 74 72 61 74 65 20  |l to illustrate |
00002ef0  68 6f 77 20 74 6f 20 6d  69 6d 69 63 20 74 68 65  |how to mimic the|
00002f00  20 61 63 74 69 6f 6e 0d  6f 66 20 45 51 55 42 20  | action.of EQUB |
00002f10  65 74 63 20 77 69 74 68  20 42 41 53 49 43 31 2e  |etc with BASIC1.|
00002f20  20 20 49 20 68 61 76 65  20 61 6c 73 6f 20 61 64  |  I have also ad|
00002f30  64 65 64 20 61 20 63 6f  75 70 6c 65 20 6f 66 0d  |ded a couple of.|
00002f40  65 78 74 72 61 20 70 73  65 75 64 6f 2d 6f 70 65  |extra pseudo-ope|
00002f50  72 61 74 69 76 65 73 20  45 51 55 4d 20 61 6e 64  |ratives EQUM and|
00002f60  20 45 51 55 46 2e 20 20  54 68 65 79 20 77 6f 72  | EQUF.  They wor|
00002f70  6b 20 69 6e 20 74 68 65  0d 73 61 6d 65 20 77 61  |k in the.same wa|
00002f80  79 20 61 73 20 74 68 65  20 74 65 63 68 6e 69 71  |y as the techniq|
00002f90  75 65 73 20 75 73 65 64  20 6c 61 73 74 20 77 65  |ues used last we|
00002fa0  65 6b 20 62 75 74 2c 20  62 79 20 77 6f 72 6b 69  |ek but, by worki|
00002fb0  6e 67 0d 74 68 72 6f 75  67 68 20 61 20 66 75 6e  |ng.through a fun|
00002fc0  63 74 69 6f 6e 2c 20 61  72 65 20 6d 6f 72 65 20  |ction, are more |
00002fd0  65 6c 65 67 61 6e 74 20  74 6f 20 75 73 65 2e 0d  |elegant to use..|
00002fe0  0d 4f 62 76 69 6f 75 73  6c 79 20 74 6f 20 75 73  |.Obviously to us|
00002ff0  65 20 74 68 65 73 65 20  70 73 65 75 64 6f 2d 6f  |e these pseudo-o|
00003000  70 65 72 61 74 69 76 65  73 20 79 6f 75 20 6e 65  |peratives you ne|
00003010  65 64 20 74 6f 20 68 61  76 65 0d 74 68 65 20 72  |ed to have.the r|
00003020  65 6c 65 76 61 6e 74 20  66 75 6e 63 74 69 6f 6e  |elevant function|
00003030  73 20 61 74 20 74 68 65  20 65 6e 64 20 6f 66 20  |s at the end of |
00003040  79 6f 75 72 20 70 72 6f  67 72 61 6d 2e 0d 0d 46  |your program...F|
00003050  4e 45 51 55 4d 28 58 25  2c 59 25 29 20 74 61 6b  |NEQUM(X%,Y%) tak|
00003060  65 73 20 74 68 65 20 62  79 74 65 20 59 25 20 61  |es the byte Y% a|
00003070  6e 64 20 70 75 74 73 20  58 25 20 6f 66 20 69 74  |nd puts X% of it|
00003080  20 69 6e 20 74 68 65 0d  6c 6f 63 61 74 69 6f 6e  | in the.location|
00003090  73 20 61 66 74 65 72 2c  20 61 6e 64 20 69 6e 63  |s after, and inc|
000030a0  6c 75 64 69 6e 67 2c 20  74 68 65 20 6c 61 62 65  |luding, the labe|
000030b0  6c 6c 65 64 20 6c 6f 63  61 74 69 6f 6e 2e 20 20  |lled location.  |
000030c0  54 68 69 73 0d 69 73 20  75 73 65 66 75 6c 20 66  |This.is useful f|
000030d0  6f 72 20 72 65 73 65 72  76 69 6e 67 20 62 6c 6f  |or reserving blo|
000030e0  63 6b 73 20 6f 66 20 6d  65 6d 6f 72 79 20 66 6f  |cks of memory fo|
000030f0  72 20 74 61 62 6c 65 73  2c 20 6f 72 20 66 6f 72  |r tables, or for|
00003100  0d 70 61 72 61 6d 65 74  65 72 73 20 77 68 65 6e  |.parameters when|
00003110  20 75 73 69 6e 67 20 4f  53 57 4f 52 44 20 63 61  | using OSWORD ca|
00003120  6c 6c 73 2e 0d 0d 46 4e  45 51 55 46 28 4e 29 20  |lls...FNEQUF(N) |
00003130  63 6f 6e 76 65 72 74 73  20 4e 20 69 6e 74 6f 20  |converts N into |
00003140  74 68 65 20 42 42 43 20  4d 69 63 72 6f 20 66 6f  |the BBC Micro fo|
00003150  72 6d 61 74 20 66 6f 72  20 66 6c 6f 61 74 69 6e  |rmat for floatin|
00003160  67 0d 70 6f 69 6e 74 20  6e 75 6d 62 65 72 73 20  |g.point numbers |
00003170  61 6e 64 20 73 74 6f 72  65 73 20 69 74 20 61 74  |and stores it at|
00003180  20 74 68 65 20 6c 61 62  65 6c 6c 65 64 20 6c 6f  | the labelled lo|
00003190  63 61 74 69 6f 6e 2e 20  20 49 74 0d 64 6f 65 73  |cation.  It.does|
000031a0  20 74 68 69 73 20 62 79  20 72 65 6c 79 69 6e 67  | this by relying|
000031b0  20 6f 6e 20 74 68 65 20  77 61 79 20 42 41 53 49  | on the way BASI|
000031c0  43 20 73 74 6f 72 65 73  20 69 74 73 20 76 61 72  |C stores its var|
000031d0  69 61 62 6c 65 73 2e 0d  57 65 20 6b 6e 6f 77 20  |iables..We know |
000031e0  74 68 61 74 20 74 68 65  20 76 61 72 69 61 62 6c  |that the variabl|
000031f0  65 20 60 20 28 70 6f 75  6e 64 20 73 69 67 6e 29  |e ` (pound sign)|
00003200  20 69 73 20 73 74 6f 72  65 64 20 61 74 20 74 68  | is stored at th|
00003210  65 0d 6c 6f 63 61 74 69  6f 6e 20 68 65 6c 64 20  |e.location held |
00003220  69 6e 20 6c 6f 63 61 74  69 6f 6e 73 20 26 34 43  |in locations &4C|
00003230  30 20 61 6e 64 20 26 34  43 31 2e 20 20 54 68 69  |0 and &4C1.  Thi|
00003240  73 20 69 73 20 6f 6e 6c  79 20 74 72 75 65 0d 69  |s is only true.i|
00003250  66 20 6e 6f 20 6f 74 68  65 72 20 76 61 72 69 61  |f no other varia|
00003260  62 6c 65 73 20 73 74 61  72 74 69 6e 67 20 77 69  |bles starting wi|
00003270  74 68 20 60 20 61 72 65  20 64 65 66 69 6e 65 64  |th ` are defined|
00003280  2c 20 62 75 74 20 74 68  69 73 0d 69 73 20 75 6e  |, but this.is un|
00003290  6c 69 6b 65 6c 79 2e 20  20 4d 61 6e 79 20 75 73  |likely.  Many us|
000032a0  65 72 73 20 64 6f 20 6e  6f 74 20 72 65 61 6c 69  |ers do not reali|
000032b0  73 65 20 79 6f 75 20 63  61 6e 20 73 74 61 72 74  |se you can start|
000032c0  20 61 0d 76 61 72 69 61  62 6c 65 20 77 69 74 68  | a.variable with|
000032d0  20 60 20 61 6e 79 77 61  79 2e 20 20 49 6e 20 6f  | ` anyway.  In o|
000032e0  72 64 65 72 20 74 6f 20  76 65 72 69 66 79 20 74  |rder to verify t|
000032f0  68 65 20 66 75 6e 63 74  69 6f 6e 20 74 68 65 0d  |he function the.|
00003300  73 68 65 6c 6c 20 70 72  6f 67 72 61 6d 20 70 72  |shell program pr|
00003310  69 6e 74 73 20 6f 75 74  20 74 68 65 20 76 61 6c  |ints out the val|
00003320  75 65 20 6f 66 20 60 20  75 73 69 6e 67 20 50 52  |ue of ` using PR|
00003330  4f 43 66 70 2e 0d 0d 49  20 70 6c 61 6e 20 74 6f  |OCfp...I plan to|
00003340  20 69 6e 76 65 73 74 69  67 61 74 65 20 66 6c 6f  | investigate flo|
00003350  61 74 69 6e 67 20 70 6f  69 6e 74 20 6e 75 6d 62  |ating point numb|
00003360  65 72 73 20 6c 61 74 65  72 20 69 6e 20 74 68 69  |ers later in thi|
00003370  73 0d 73 65 72 69 65 73  2e 20 20 4e 65 78 74 20  |s.series.  Next |
00003380  77 65 65 6b 20 49 20 73  68 61 6c 6c 20 73 74 61  |week I shall sta|
00003390  72 74 20 74 6f 20 64 69  73 63 75 73 73 20 74 68  |rt to discuss th|
000033a0  65 20 42 42 43 20 4d 69  63 72 6f 27 73 0d 6f 70  |e BBC Micro's.op|
000033b0  65 72 61 74 69 6e 67 20  73 79 73 74 65 6d 20 63  |erating system c|
000033c0  61 6c 6c 73 2e 20 20 4f  6e 63 65 20 77 65 27 76  |alls.  Once we'v|
000033d0  65 20 67 61 69 6e 65 64  20 61 63 63 65 73 73 20  |e gained access |
000033e0  74 6f 20 74 68 65 6d 0d  74 68 65 79 20 77 69 6c  |to them.they wil|
000033f0  6c 20 70 72 6f 76 69 64  65 20 75 73 20 77 69 74  |l provide us wit|
00003400  68 20 65 61 73 79 20 61  63 63 65 73 73 20 74 6f  |h easy access to|
00003410  20 73 6f 6d 65 20 76 65  72 79 20 70 6f 77 65 72  | some very power|
00003420  66 75 6c 0d 61 6e 64 20  68 65 6c 70 66 75 6c 20  |ful.and helpful |
00003430  74 68 69 6e 67 73 2e 0d                           |things..|
00003438
13_11_87/T\OSB04.m0
13_11_87/T\OSB04.m1
13_11_87/T\OSB04.m2
13_11_87/T\OSB04.m4
13_11_87/T\OSB04.m5