Home » CEEFAX disks » telesoftware9.adl » 18-09-88/T\SWR11

18-09-88/T\SWR11

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 » telesoftware9.adl
Filename: 18-09-88/T\SWR11
Read OK:
File size: 4E46 bytes
Load address: 0000
Exec address: FFFFFFFF
Duplicates

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

File contents
Mastering Sideways ROM & RAM - Module 11 - Private workspace
------------------------------------------------------------

  It is often necessary for SWR programs to use ram workspace to store
various values and addresses. The ram within the SWR bank can only be
used for this purpose if it is not write protected and if the values
stored do not need to be accessed by other paged roms. If you intend
to write software for roms rather than sideways ram you must use ram
outside the 16k allocated to the paged roms. If you intend to write a
program which, for example, uses an Osword in the DFS then the Osword
parameter block must be in an area of memory accessable to both your
rom image and the DFS.

  It is usually possible to find an area of memory which can be used
as workspace by your SWR programs. If you use a disc based BBC B you
might consider using pages &09 and &0A. These pages are usually
defined as cassette or RS423 output and input buffers but, when they
are not used for their designated purpose, they may be available to
your programs. The really big problem with using these two pages as
workspace is that you will not be the first person to have had the
idea. There are dozens of roms which use this area of memory as
workspace. If your SWR programs use it as well you have to be aware
that this area of ram will not necessarily be available for exclusive
use by your program and any data you store in it could become
corrupted by other roms or by the Acorn speech system.

  Whatever area of memory you choose to use as workspace could become
corrupted by other roms unless your program claims and uses private
workspace. Private workspace starts at &1700 in BBC B computers with
the Acorn DFS and at &E00 in the BBC B without a DFS. The Master
computer makes private workspace available in paged memory overlaid on
the MOS as well as from &E00 in main memory.

  In this module I will explain and demonstrate how to claim and use
private workspace in main memory. At the end of the module I will
explain how to modify these techniques to use the alternative paged
memory private workspace available in the Master computer.

  In order to claim private workspace your SWR interpreter has to
intercept the private workspace service call. To demonstrate the
private workspace service call load the object code generated by the
program TRACE into SWR and press the Break key (Ctrl+Break on the
Master). A list of service calls similar to the one in figure 11.1
will be printed on the screen. Unless you use a BBC B with an Acorn
6502 Second Processor, Acorn DNFS and sideways ram in socket &0F your
trace will be different from the one in figure 11.1, but in all BBC
computers you will find service call 2, the private workspace claim,
somewhere in the list.




 A=19 X=0F Y=FF SPOOL/EXEC file closure
 A=0F X=0F Y=FF Vectors claimed
 A=FF X=0F Y=FF Tube system main init.
 A=01 X=0F Y=0E Abs. workspace claim
 A=02 X=0F Y=17 Private workspace claim
 A=FE X=0F Y=FF Tube system post init.
 A=11 X=0F Y=1F Font implode/explode

Acorn TUBE 6502 64K

 A=03 X=0F Y=08 Auto-boot
Acorn DFS

 A=10 X=0F Y=EE SPOOL/EXEC file closure
 A=0F X=0F Y=30 Vectors claimed
 A=0A X=0F Y=D4 Claim static workspace
BASIC

>

Figure 11.1  Service call trace after Break
-------------------------------------------



  In figure 11.1 you can see that the private workspace claim, service
call 2, is made with Y=&17. Private workspace starts at page &17 in
the BBC B with the Acorn DFS. If the trace is run from a lower
priority rom than the DFS rom then service call 2 will be made with
Y=&19 indicating that the DFS has claimed pages &17 and &18 as private
workspace. If the trace is run on a BBC B without a DFS then service
call 2 is made with Y=&0E indicating that private workspace is
available from &E00. The Master also makes service call 2 with Y=&0E
indicating that, if private workspace is claimed in main memory rather
than in paged memory, it also starts at &E00.

  Service call 2 is issued to all the paged roms, starting with rom
&0F. It gives the roms the opportunity to claim their own private
workspace. Private workspace is allocated in pages of 256 bytes and is
exclusive to the rom claiming it. Service call 2 is made to each rom
with its rom number in the X register and the first page number of the
workspace available to it in the Y register. A rom can claim private
workspace by saving the contents of the Y register (ie. the most
significant byte of the address of the start of private workspace) in
the paged rom workspace table from &DF0 to &DFF (one byte per rom for
roms &00 to &0F respectively). It must then increment the Y register
once for each page of private workspace required. The Y register must
never be decremented when service call 2 has been intercepted.

  The example coding in figure 11.2 could be used to claim one page of
private workspace.



  .service
         PHA             \ push accumulator on stack
         CMP #2          \ is it service call 2?
         BNE nottwo      \ branch if not 2
         TYA             \ prepare to store start of workspace
         STA &DF0,X      \ store start address in workspace table
         INY             \ claim 1 page of workspace
         PLA             \ restore accumulator
         RTS             \ return to MOS
  .nottwo



Figure 11.2  Claiming private workspace
---------------------------------------




  For obvious reasons page &0D of the I/O processor memory should
never be corrupted by using it to run programs.

  Whenever a rom needs to use its private workspace it should look up
the most significant byte of the start address of the workspace in the
paged rom workspace table and access the workspace with indirect
addressing. The rom must not refer to the workspace directly because
its start address will depend on the amount of workspace claimed by
higher priority roms.

  If a rom claims private workspace in main memory the value of the
Oshwm and PAGE will be raised. If, for example, your program claims 2
pages of private workspace then Oshwm and PAGE will be raised, on a
BBC B with DFS, from &1900 to &1B00. In this example, the private
workspace could start at either &1700 or &1900 depending on the
priority of your rom with respect to the DFS rom.

  Your program will work properly from all rom sockets if it accesses
the private workspace indirectly after looking up the most significant
byte of the start address of private workspace in the paged rom
workspace table. This technique is illustrated in figure 11.3 which
shows how your SWR program can use post-indexed indirect addressing to
read the contents of the first byte of its private workspace.




         LDX &F4         \ load X with rom number
         LDA &DF0,X      \ find most sig. byte of workspace address
         STA &71         \ store it for indirect addressing
         LDA #0          \ workspace always starts at a page boundary
         STA &70         \ store least sig. byte of workspace address
         TAY             \ Y = 0
         LDA (&70),Y     \ Read first byte of private workspace


Figure 11.3  Reading private workspace
--------------------------------------



  The techniques illustrated in figures 11.2 and 11.3 have been used
in the program PRIVATE. This program claims one page of private
workspace to use for an Osword parameter block.

  Osword &7D, one of the DFS Oswords, is used to demonstrate how your
SWR programs can use Osword routines in other paged roms. In order to
use Osword calls in this way the parameter block must be accessed by
both roms, it cannot be within the paged ram bank used by the SWR
program. Private workspace in main memory is claimed by the program
PRIVATE but it is made available to the DFS by specifying its address
in the X and Y registers before calling Osword &7D. The private
workspace will not be available to the DFS, or any other rom, unless
the program which claimed the workspace makes it available in this
way.

  Osword &7D reads the catalogue for the current default disc drive.
From this it extracts the number of times that disc has been written.
This is known as the disc cycles. The number of cycles is available as
a binary coded decimal number in a one byte parameter block specified
by the X and Y registers on entry to Osword &7D.

  To use the program PRIVATE load the object code it generates into
SWR and press the Break key. Type PRINT ~ PAGE and press Return. You
will see that PAGE has been raised from &1900 to &1A00 (BBC B with
Acorn DFS). Type *CYCLES and press Return. The program will read the
current default disc drive and print the number of cycles.

  The program uses the unrecognised * command interpreter (lines
410-680) and error routine (lines 1080-1230) introduced in earlier
modules of the course.

  One page of private workspace is claimed in lines 330 to 400. The
start of the workspace is stored in the paged rom workspace table
(line 370) and the Y register is incremented once (line 380) to
indicate that the minimum one page of private workspace is required.
Only one byte of the one page is used by the program but workspace is
only available in units of 256 bytes.

  When the unrecognised * command interpreter recognises the command
*CYCLES control is passed to the label ".found" (line 690). The
program stores the contents of the two zero page bytes it uses by
pushing them on the stack (lines 700-730) and then uses Osargs to see
if the DFS is active (lines 740-790). If the DFS is not active control
is passed to the error routine (lines 1080-1230) which, after
restoring the zero page bytes, halts the program and prints an error
message.

  If the DFS is active the most significant byte of the address of the
start of private workspace is read from the paged rom workspace table
(lines 800-810) and stored in the most significant of the two zero
page bytes (line 820). These two zero page bytes are used later in the
program to read the contents of the parameter block.

  The accumulator is transfered to the Y register (line 830) to make
the most significant byte of the parameter block address available to
Osword. The X register is loaded with zero (line 840) to make the
least significant byte of the parameter block address available to
Osword and X is stored in the least significant byte of the two zero
page bytes (line 850).

  Osword &7D is called (lines 860-870) and the result is read from the
parameter block in the first byte of the private workspace (lines
880-890). The result is printed (line 900 and lines 1240-1390) with a
suitable message (lines 910-970). The zero page memory locations are
restored (lines 990-1020), the stack is balanced (lines 1030-1050) and
control is returned to the MOS after reseting the accumulator to zero
to indicate that the command has been recognised (lines 1060-1070).




   10 REM: PRIVATE
   20 MODE7
   30 HIMEM=&3C00
   40 DIM save 50
   50 diff=&8000-HIMEM
   60 address=&70
   70 comvec=&F2
   80 errstack=&100
   90 romnumber=&F4
  100 workspace=&DF0
  110 gsread=&FFC5
  120 osargs=&FFDA
  130 osasci=&FFE3
  140 osword=&FFF1
  150 oscli=&FFF7
  160 FOR pass = 0 TO 2 STEP 2
  170 P%=HIMEM
  180 [       OPT pass
  190         BRK
  200         BRK
  210         BRK
  220         JMP service+diff
  230         OPT FNequb(&82)
  240         OPT FNequb((copyright+diff) MOD 256)
  250         BRK
  260 .title
  270         OPT FNequs("CYCLES")
  280 .copyright
  290         BRK
  300         OPT FNequs("(C) Gordon Horsington 1987")
  310         BRK
  320 .service
  330         PHA
  340         CMP #2
  350         BNE tryfour
  360         TYA
  370         STA workspace,X
  380         INY
  390         PLA
  400         RTS
  410 .tryfour
  420         CMP #4
  430         BEQ unrecognised
  440         PLA
  450         RTS
  460 .unrecognised
  470         TXA
  480         PHA
  490         TYA
  500         PHA
  510         LDX #&FF
  520 .comloop
  530         INX
  540         LDA title+diff,X
  550         BEQ found
  560         LDA (comvec),Y
  570         INY
  580         CMP #ASC(".")
  590         BEQ found
  600         AND #&DF
  610         CMP title+diff,X
  620         BEQ comloop
  630         PLA
  640         TAY
  650         PLA
  660         TAX
  670         PLA
  680         RTS
  690 .found
  700         LDA address
  710         PHA
  720         LDA address+1
  730         PHA
  740         LDA #0
  750         TAX
  760         TAY
  770         JSR osargs
  780         CMP #4        \ Is DFS active?
  790         BNE error
  800         LDX romnumber
  810         LDA workspace,X \ MSB of workspace
  820         STA address+1
  830         TAY           \ MSB for Osword
  840         LDX #0        \ LSB of workspace
  850         STX address
  860         LDA #&7D
  870         JSR osword    \ Read disc cycles
  880         LDY #0
  890         LDA (address),Y \ Read result
  900         JSR hexbyte+diff
  910         LDX #&FF
  920 .printloop
  930         INX
  940         LDA message+diff,X
  950         BEQ quit
  960         JSR osasci
  970         JMP printloop+diff
  980 .quit
  990         PLA
 1000         STA address+1
 1010         PLA
 1020         STA address
 1030         PLA
 1040         PLA
 1050         PLA
 1060         LDA #0
 1070         RTS
 1080 .error
 1090         LDA #(wrong+diff) MOD 256
 1100         STA address
 1110         LDA #(wrong+diff) DIV 256
 1120         STA address+1
 1130         LDY #&FF
 1140 .errorloop
 1150         INY
 1160         LDA (address),Y
 1170         STA errstack,Y
 1180         BPL errorloop
 1190         PLA
 1200         STA address+1
 1210         PLA
 1220         STA address
 1230         JMP errstack
 1240 .hexbyte
 1250         PHA
 1260         LSR A
 1270         LSR A
 1280         LSR A
 1290         LSR A
 1300         JSR nybble+diff
 1310         PLA
 1320 .nybble
 1330         AND #&0F
 1340         SED
 1350         CLC
 1360         ADC #&90
 1370         ADC #&40
 1380         CLD
 1390         JMP osasci
 1400 .message
 1410         OPT FNequs(" Disc cycles")
 1420         OPT FNequb(&0D)
 1430         BRK
 1440 .wrong
 1450         BRK
 1460         BRK
 1470         OPT FNequs("DFS not active")
 1480         BRK
 1490         OPT FNequb(&FF)
 1500 .lastbyte
 1510 ]
 1520 NEXT
 1530 INPUT'"Save filename = "filename$
 1540 IF filename$="" END
 1550 $save="SAVE "+filename$+" "+STR$~(HIMEM)+" "+STR$~(las
      tbyte)+" FFFF8000 FFFF8000"
 1560 X%=save MOD 256
 1570 Y%=save DIV 256
 1580 *OPT1,2
 1590 CALL oscli
 1600 *OPT1,0
 1610 END
 1620 DEFFNequb(byte)
 1630 ?P%=byte
 1640 P%=P%+1
 1650 =pass
 1660 DEFFNequw(word)
 1670 ?P%=word MOD 256
 1680 P%?1=word DIV 256
 1690 P%=P%+2
 1700 =pass
 1710 DEFFNequd(double)
 1720 !P%=double
 1730 P%=P%+4
 1740 =pass
 1750 DEFFNequs(string$)
 1760 $P%=string$
 1770 P%=P%+LEN(string$)
 1780 =pass




  The techniques illustrated in figures 11.2 and 11.3 and demonstrated
in the program PRIVATE need to be modified to use the alternative
paged memory private workspace available in the Master series of
computers.

  In Module 1 of the course I explained how setting bit 3 of the paged
memory select register at &FE34 can be used to overlay the paged
memory from &C000 to &DFFF onto the MOS so that it appears above the
currently selected paged rom. The paged memory private workspace is
available in this area of paged memory.

  The Master uses service call &24 to give the roms the opportunity to
request paged private workspace followed by service call &22 to claim
the requested paged private workspace. The coding in figure 11.2 and
11.3 needs to be modified as shown in figures 11.4 and 11.5 if your
Master SWR program needs to use paged private workspace.




  .service
         CMP #&24        \ is it service call &24?
         BNE try22       \ branch if not &24
         INY             \ request 1 page of workspace
         RTS             \ and return
.try22
         CMP #&22        \ is it service call &22?
         BNE not22       \ branch if not &22
         PHA             \ push accumulator on stack
         TYA             \ prepare to store start of workspace
         STA &DF0,X      \ store start of workspace
         PLA             \ restore accumulator
         RTS             \ return to MOS
  .not22


Figure 11.4  Claiming paged private workspace on the Master.
------------------------------------------------------------



  Claiming paged memory private workspace is a bit more involved than
claiming private workspace in user memory. Your Master SWR program has
to intercept service calls &24 and &22 instead of service call 2.
Service calls &24 and &22 are not issued on the BBC B.

  Intercepting service calls &24 and &22 is illustrated in figure
11.4. If your SWR program uses paged private workspace it must use
service call &22 to claim only the number of pages requested with
service call &24. The amount of claimed paged private workspace must
agree with the amount of requested paged private workspace.

  A Master SWR program must not use both service call 2 and service
calls &24 and &22 to claim private workspace. You should also be aware
that, if you use service calls &24 and &22 to request and claim more
paged private workspace than is available in the paged memory, private
workspace will be claimed from user memory starting at &E00. This has
the effect of raising Oshwm and PAGE even when paged private workspace
is requested and claimed.

  Using paged memory private workspace in the Master is a bit more
complicated than claiming it. Before attempting to read or write the
contents of the paged private workspace, the SWR program must first
set bit 3 of the paged memory select register at &FE34 to switch the
paged memory into the main memory map. To set bit 3 of &FE34 load the
accumulator with &08 (0000 1000 binary), OR the accumulator with the
contents of &FE34 and store the accumulator in &FE34.

  To switch the paged private workspace out of the main memory map it
is necessary to clear bit 3 of the paged memory select register. To
clear bit 3 of &FE34 load the accumulator with &F7 (1111 0111 binary),
AND the accumulator with the contents of &FE34 and store the
accumulator in &FE34. If you use the subroutines illustrated in figure
11.5 the paged memory can be switched in and out of the main memory
map without altering any of the other bits in the paged memory select
register.




         LDX &F4         \ load X with rom number
         LDA &DF0,X      \ find most sig. byte of workspace address
         STA &71         \ store it for indirect addressing
         LDA #0          \ workspace always starts at a page boundary
         STA &70         \ store least sig. byte of workspace address
         JSR pagein      \ switch paged workspace in
         LDY #0
         LDA (address),Y \ Read first byte of private workspace
         JSR pageout     \ switch paged workspace out
          .
          .
          .
.pagein
         PHA
         LDA #8          \ 0000 1000 binary
         ORA &FE34
         STA &FE34       \ set bit 3 of &FE34
         PLA             \ restore accumulator
         RTS
.pageout
         PHA
         LDA #&F7        \ 1111 0111 binary
         AND &FE34
         STA &FE34       \ clear bit 3 of &FE34
         PLA             \ restore accumulator
         RTS


Figure 11.5  Reading paged private workspace on the Master.
-----------------------------------------------------------

  Figure 11.5 illustrates how the two subroutines, pagein and pageout,
should be used to switch the paged memory in and out of the main
memory map when reading the contents of the paged private workspace in
the Master series computers.

  After switching the paged memory into the main memory map you must
be very careful about using MOS subroutines because the bottom 7.25k
of the MOS has been replaced with the paged memory. You would be wise
not to use the MOS at all until it has been restored by calling
pageout.
00000000  4d 61 73 74 65 72 69 6e  67 20 53 69 64 65 77 61  |Mastering Sidewa|
00000010  79 73 20 52 4f 4d 20 26  20 52 41 4d 20 2d 20 4d  |ys ROM & RAM - M|
00000020  6f 64 75 6c 65 20 31 31  20 2d 20 50 72 69 76 61  |odule 11 - Priva|
00000030  74 65 20 77 6f 72 6b 73  70 61 63 65 0d 2d 2d 2d  |te workspace.---|
00000040  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000070  2d 2d 2d 2d 2d 2d 2d 2d  2d 0d 0d 20 20 49 74 20  |---------..  It |
00000080  69 73 20 6f 66 74 65 6e  20 6e 65 63 65 73 73 61  |is often necessa|
00000090  72 79 20 66 6f 72 20 53  57 52 20 70 72 6f 67 72  |ry for SWR progr|
000000a0  61 6d 73 20 74 6f 20 75  73 65 20 72 61 6d 20 77  |ams to use ram w|
000000b0  6f 72 6b 73 70 61 63 65  20 74 6f 20 73 74 6f 72  |orkspace to stor|
000000c0  65 0d 76 61 72 69 6f 75  73 20 76 61 6c 75 65 73  |e.various values|
000000d0  20 61 6e 64 20 61 64 64  72 65 73 73 65 73 2e 20  | and addresses. |
000000e0  54 68 65 20 72 61 6d 20  77 69 74 68 69 6e 20 74  |The ram within t|
000000f0  68 65 20 53 57 52 20 62  61 6e 6b 20 63 61 6e 20  |he SWR bank can |
00000100  6f 6e 6c 79 20 62 65 0d  75 73 65 64 20 66 6f 72  |only be.used for|
00000110  20 74 68 69 73 20 70 75  72 70 6f 73 65 20 69 66  | this purpose if|
00000120  20 69 74 20 69 73 20 6e  6f 74 20 77 72 69 74 65  | it is not write|
00000130  20 70 72 6f 74 65 63 74  65 64 20 61 6e 64 20 69  | protected and i|
00000140  66 20 74 68 65 20 76 61  6c 75 65 73 0d 73 74 6f  |f the values.sto|
00000150  72 65 64 20 64 6f 20 6e  6f 74 20 6e 65 65 64 20  |red do not need |
00000160  74 6f 20 62 65 20 61 63  63 65 73 73 65 64 20 62  |to be accessed b|
00000170  79 20 6f 74 68 65 72 20  70 61 67 65 64 20 72 6f  |y other paged ro|
00000180  6d 73 2e 20 49 66 20 79  6f 75 20 69 6e 74 65 6e  |ms. If you inten|
00000190  64 0d 74 6f 20 77 72 69  74 65 20 73 6f 66 74 77  |d.to write softw|
000001a0  61 72 65 20 66 6f 72 20  72 6f 6d 73 20 72 61 74  |are for roms rat|
000001b0  68 65 72 20 74 68 61 6e  20 73 69 64 65 77 61 79  |her than sideway|
000001c0  73 20 72 61 6d 20 79 6f  75 20 6d 75 73 74 20 75  |s ram you must u|
000001d0  73 65 20 72 61 6d 0d 6f  75 74 73 69 64 65 20 74  |se ram.outside t|
000001e0  68 65 20 31 36 6b 20 61  6c 6c 6f 63 61 74 65 64  |he 16k allocated|
000001f0  20 74 6f 20 74 68 65 20  70 61 67 65 64 20 72 6f  | to the paged ro|
00000200  6d 73 2e 20 49 66 20 79  6f 75 20 69 6e 74 65 6e  |ms. If you inten|
00000210  64 20 74 6f 20 77 72 69  74 65 20 61 0d 70 72 6f  |d to write a.pro|
00000220  67 72 61 6d 20 77 68 69  63 68 2c 20 66 6f 72 20  |gram which, for |
00000230  65 78 61 6d 70 6c 65 2c  20 75 73 65 73 20 61 6e  |example, uses an|
00000240  20 4f 73 77 6f 72 64 20  69 6e 20 74 68 65 20 44  | Osword in the D|
00000250  46 53 20 74 68 65 6e 20  74 68 65 20 4f 73 77 6f  |FS then the Oswo|
00000260  72 64 0d 70 61 72 61 6d  65 74 65 72 20 62 6c 6f  |rd.parameter blo|
00000270  63 6b 20 6d 75 73 74 20  62 65 20 69 6e 20 61 6e  |ck must be in an|
00000280  20 61 72 65 61 20 6f 66  20 6d 65 6d 6f 72 79 20  | area of memory |
00000290  61 63 63 65 73 73 61 62  6c 65 20 74 6f 20 62 6f  |accessable to bo|
000002a0  74 68 20 79 6f 75 72 0d  72 6f 6d 20 69 6d 61 67  |th your.rom imag|
000002b0  65 20 61 6e 64 20 74 68  65 20 44 46 53 2e 0d 0d  |e and the DFS...|
000002c0  20 20 49 74 20 69 73 20  75 73 75 61 6c 6c 79 20  |  It is usually |
000002d0  70 6f 73 73 69 62 6c 65  20 74 6f 20 66 69 6e 64  |possible to find|
000002e0  20 61 6e 20 61 72 65 61  20 6f 66 20 6d 65 6d 6f  | an area of memo|
000002f0  72 79 20 77 68 69 63 68  20 63 61 6e 20 62 65 20  |ry which can be |
00000300  75 73 65 64 0d 61 73 20  77 6f 72 6b 73 70 61 63  |used.as workspac|
00000310  65 20 62 79 20 79 6f 75  72 20 53 57 52 20 70 72  |e by your SWR pr|
00000320  6f 67 72 61 6d 73 2e 20  49 66 20 79 6f 75 20 75  |ograms. If you u|
00000330  73 65 20 61 20 64 69 73  63 20 62 61 73 65 64 20  |se a disc based |
00000340  42 42 43 20 42 20 79 6f  75 0d 6d 69 67 68 74 20  |BBC B you.might |
00000350  63 6f 6e 73 69 64 65 72  20 75 73 69 6e 67 20 70  |consider using p|
00000360  61 67 65 73 20 26 30 39  20 61 6e 64 20 26 30 41  |ages &09 and &0A|
00000370  2e 20 54 68 65 73 65 20  70 61 67 65 73 20 61 72  |. These pages ar|
00000380  65 20 75 73 75 61 6c 6c  79 0d 64 65 66 69 6e 65  |e usually.define|
00000390  64 20 61 73 20 63 61 73  73 65 74 74 65 20 6f 72  |d as cassette or|
000003a0  20 52 53 34 32 33 20 6f  75 74 70 75 74 20 61 6e  | RS423 output an|
000003b0  64 20 69 6e 70 75 74 20  62 75 66 66 65 72 73 20  |d input buffers |
000003c0  62 75 74 2c 20 77 68 65  6e 20 74 68 65 79 0d 61  |but, when they.a|
000003d0  72 65 20 6e 6f 74 20 75  73 65 64 20 66 6f 72 20  |re not used for |
000003e0  74 68 65 69 72 20 64 65  73 69 67 6e 61 74 65 64  |their designated|
000003f0  20 70 75 72 70 6f 73 65  2c 20 74 68 65 79 20 6d  | purpose, they m|
00000400  61 79 20 62 65 20 61 76  61 69 6c 61 62 6c 65 20  |ay be available |
00000410  74 6f 0d 79 6f 75 72 20  70 72 6f 67 72 61 6d 73  |to.your programs|
00000420  2e 20 54 68 65 20 72 65  61 6c 6c 79 20 62 69 67  |. The really big|
00000430  20 70 72 6f 62 6c 65 6d  20 77 69 74 68 20 75 73  | problem with us|
00000440  69 6e 67 20 74 68 65 73  65 20 74 77 6f 20 70 61  |ing these two pa|
00000450  67 65 73 20 61 73 0d 77  6f 72 6b 73 70 61 63 65  |ges as.workspace|
00000460  20 69 73 20 74 68 61 74  20 79 6f 75 20 77 69 6c  | is that you wil|
00000470  6c 20 6e 6f 74 20 62 65  20 74 68 65 20 66 69 72  |l not be the fir|
00000480  73 74 20 70 65 72 73 6f  6e 20 74 6f 20 68 61 76  |st person to hav|
00000490  65 20 68 61 64 20 74 68  65 0d 69 64 65 61 2e 20  |e had the.idea. |
000004a0  54 68 65 72 65 20 61 72  65 20 64 6f 7a 65 6e 73  |There are dozens|
000004b0  20 6f 66 20 72 6f 6d 73  20 77 68 69 63 68 20 75  | of roms which u|
000004c0  73 65 20 74 68 69 73 20  61 72 65 61 20 6f 66 20  |se this area of |
000004d0  6d 65 6d 6f 72 79 20 61  73 0d 77 6f 72 6b 73 70  |memory as.worksp|
000004e0  61 63 65 2e 20 49 66 20  79 6f 75 72 20 53 57 52  |ace. If your SWR|
000004f0  20 70 72 6f 67 72 61 6d  73 20 75 73 65 20 69 74  | programs use it|
00000500  20 61 73 20 77 65 6c 6c  20 79 6f 75 20 68 61 76  | as well you hav|
00000510  65 20 74 6f 20 62 65 20  61 77 61 72 65 0d 74 68  |e to be aware.th|
00000520  61 74 20 74 68 69 73 20  61 72 65 61 20 6f 66 20  |at this area of |
00000530  72 61 6d 20 77 69 6c 6c  20 6e 6f 74 20 6e 65 63  |ram will not nec|
00000540  65 73 73 61 72 69 6c 79  20 62 65 20 61 76 61 69  |essarily be avai|
00000550  6c 61 62 6c 65 20 66 6f  72 20 65 78 63 6c 75 73  |lable for exclus|
00000560  69 76 65 0d 75 73 65 20  62 79 20 79 6f 75 72 20  |ive.use by your |
00000570  70 72 6f 67 72 61 6d 20  61 6e 64 20 61 6e 79 20  |program and any |
00000580  64 61 74 61 20 79 6f 75  20 73 74 6f 72 65 20 69  |data you store i|
00000590  6e 20 69 74 20 63 6f 75  6c 64 20 62 65 63 6f 6d  |n it could becom|
000005a0  65 0d 63 6f 72 72 75 70  74 65 64 20 62 79 20 6f  |e.corrupted by o|
000005b0  74 68 65 72 20 72 6f 6d  73 20 6f 72 20 62 79 20  |ther roms or by |
000005c0  74 68 65 20 41 63 6f 72  6e 20 73 70 65 65 63 68  |the Acorn speech|
000005d0  20 73 79 73 74 65 6d 2e  0d 0d 20 20 57 68 61 74  | system...  What|
000005e0  65 76 65 72 20 61 72 65  61 20 6f 66 20 6d 65 6d  |ever area of mem|
000005f0  6f 72 79 20 79 6f 75 20  63 68 6f 6f 73 65 20 74  |ory you choose t|
00000600  6f 20 75 73 65 20 61 73  20 77 6f 72 6b 73 70 61  |o use as workspa|
00000610  63 65 20 63 6f 75 6c 64  20 62 65 63 6f 6d 65 0d  |ce could become.|
00000620  63 6f 72 72 75 70 74 65  64 20 62 79 20 6f 74 68  |corrupted by oth|
00000630  65 72 20 72 6f 6d 73 20  75 6e 6c 65 73 73 20 79  |er roms unless y|
00000640  6f 75 72 20 70 72 6f 67  72 61 6d 20 63 6c 61 69  |our program clai|
00000650  6d 73 20 61 6e 64 20 75  73 65 73 20 70 72 69 76  |ms and uses priv|
00000660  61 74 65 0d 77 6f 72 6b  73 70 61 63 65 2e 20 50  |ate.workspace. P|
00000670  72 69 76 61 74 65 20 77  6f 72 6b 73 70 61 63 65  |rivate workspace|
00000680  20 73 74 61 72 74 73 20  61 74 20 26 31 37 30 30  | starts at &1700|
00000690  20 69 6e 20 42 42 43 20  42 20 63 6f 6d 70 75 74  | in BBC B comput|
000006a0  65 72 73 20 77 69 74 68  0d 74 68 65 20 41 63 6f  |ers with.the Aco|
000006b0  72 6e 20 44 46 53 20 61  6e 64 20 61 74 20 26 45  |rn DFS and at &E|
000006c0  30 30 20 69 6e 20 74 68  65 20 42 42 43 20 42 20  |00 in the BBC B |
000006d0  77 69 74 68 6f 75 74 20  61 20 44 46 53 2e 20 54  |without a DFS. T|
000006e0  68 65 20 4d 61 73 74 65  72 0d 63 6f 6d 70 75 74  |he Master.comput|
000006f0  65 72 20 6d 61 6b 65 73  20 70 72 69 76 61 74 65  |er makes private|
00000700  20 77 6f 72 6b 73 70 61  63 65 20 61 76 61 69 6c  | workspace avail|
00000710  61 62 6c 65 20 69 6e 20  70 61 67 65 64 20 6d 65  |able in paged me|
00000720  6d 6f 72 79 20 6f 76 65  72 6c 61 69 64 20 6f 6e  |mory overlaid on|
00000730  0d 74 68 65 20 4d 4f 53  20 61 73 20 77 65 6c 6c  |.the MOS as well|
00000740  20 61 73 20 66 72 6f 6d  20 26 45 30 30 20 69 6e  | as from &E00 in|
00000750  20 6d 61 69 6e 20 6d 65  6d 6f 72 79 2e 0d 0d 20  | main memory... |
00000760  20 49 6e 20 74 68 69 73  20 6d 6f 64 75 6c 65 20  | In this module |
00000770  49 20 77 69 6c 6c 20 65  78 70 6c 61 69 6e 20 61  |I will explain a|
00000780  6e 64 20 64 65 6d 6f 6e  73 74 72 61 74 65 20 68  |nd demonstrate h|
00000790  6f 77 20 74 6f 20 63 6c  61 69 6d 20 61 6e 64 20  |ow to claim and |
000007a0  75 73 65 0d 70 72 69 76  61 74 65 20 77 6f 72 6b  |use.private work|
000007b0  73 70 61 63 65 20 69 6e  20 6d 61 69 6e 20 6d 65  |space in main me|
000007c0  6d 6f 72 79 2e 20 41 74  20 74 68 65 20 65 6e 64  |mory. At the end|
000007d0  20 6f 66 20 74 68 65 20  6d 6f 64 75 6c 65 20 49  | of the module I|
000007e0  20 77 69 6c 6c 0d 65 78  70 6c 61 69 6e 20 68 6f  | will.explain ho|
000007f0  77 20 74 6f 20 6d 6f 64  69 66 79 20 74 68 65 73  |w to modify thes|
00000800  65 20 74 65 63 68 6e 69  71 75 65 73 20 74 6f 20  |e techniques to |
00000810  75 73 65 20 74 68 65 20  61 6c 74 65 72 6e 61 74  |use the alternat|
00000820  69 76 65 20 70 61 67 65  64 0d 6d 65 6d 6f 72 79  |ive paged.memory|
00000830  20 70 72 69 76 61 74 65  20 77 6f 72 6b 73 70 61  | private workspa|
00000840  63 65 20 61 76 61 69 6c  61 62 6c 65 20 69 6e 20  |ce available in |
00000850  74 68 65 20 4d 61 73 74  65 72 20 63 6f 6d 70 75  |the Master compu|
00000860  74 65 72 2e 0d 0d 20 20  49 6e 20 6f 72 64 65 72  |ter...  In order|
00000870  20 74 6f 20 63 6c 61 69  6d 20 70 72 69 76 61 74  | to claim privat|
00000880  65 20 77 6f 72 6b 73 70  61 63 65 20 79 6f 75 72  |e workspace your|
00000890  20 53 57 52 20 69 6e 74  65 72 70 72 65 74 65 72  | SWR interpreter|
000008a0  20 68 61 73 20 74 6f 0d  69 6e 74 65 72 63 65 70  | has to.intercep|
000008b0  74 20 74 68 65 20 70 72  69 76 61 74 65 20 77 6f  |t the private wo|
000008c0  72 6b 73 70 61 63 65 20  73 65 72 76 69 63 65 20  |rkspace service |
000008d0  63 61 6c 6c 2e 20 54 6f  20 64 65 6d 6f 6e 73 74  |call. To demonst|
000008e0  72 61 74 65 20 74 68 65  0d 70 72 69 76 61 74 65  |rate the.private|
000008f0  20 77 6f 72 6b 73 70 61  63 65 20 73 65 72 76 69  | workspace servi|
00000900  63 65 20 63 61 6c 6c 20  6c 6f 61 64 20 74 68 65  |ce call load the|
00000910  20 6f 62 6a 65 63 74 20  63 6f 64 65 20 67 65 6e  | object code gen|
00000920  65 72 61 74 65 64 20 62  79 20 74 68 65 0d 70 72  |erated by the.pr|
00000930  6f 67 72 61 6d 20 54 52  41 43 45 20 69 6e 74 6f  |ogram TRACE into|
00000940  20 53 57 52 20 61 6e 64  20 70 72 65 73 73 20 74  | SWR and press t|
00000950  68 65 20 42 72 65 61 6b  20 6b 65 79 20 28 43 74  |he Break key (Ct|
00000960  72 6c 2b 42 72 65 61 6b  20 6f 6e 20 74 68 65 0d  |rl+Break on the.|
00000970  4d 61 73 74 65 72 29 2e  20 41 20 6c 69 73 74 20  |Master). A list |
00000980  6f 66 20 73 65 72 76 69  63 65 20 63 61 6c 6c 73  |of service calls|
00000990  20 73 69 6d 69 6c 61 72  20 74 6f 20 74 68 65 20  | similar to the |
000009a0  6f 6e 65 20 69 6e 20 66  69 67 75 72 65 20 31 31  |one in figure 11|
000009b0  2e 31 0d 77 69 6c 6c 20  62 65 20 70 72 69 6e 74  |.1.will be print|
000009c0  65 64 20 6f 6e 20 74 68  65 20 73 63 72 65 65 6e  |ed on the screen|
000009d0  2e 20 55 6e 6c 65 73 73  20 79 6f 75 20 75 73 65  |. Unless you use|
000009e0  20 61 20 42 42 43 20 42  20 77 69 74 68 20 61 6e  | a BBC B with an|
000009f0  20 41 63 6f 72 6e 0d 36  35 30 32 20 53 65 63 6f  | Acorn.6502 Seco|
00000a00  6e 64 20 50 72 6f 63 65  73 73 6f 72 2c 20 41 63  |nd Processor, Ac|
00000a10  6f 72 6e 20 44 4e 46 53  20 61 6e 64 20 73 69 64  |orn DNFS and sid|
00000a20  65 77 61 79 73 20 72 61  6d 20 69 6e 20 73 6f 63  |eways ram in soc|
00000a30  6b 65 74 20 26 30 46 20  79 6f 75 72 0d 74 72 61  |ket &0F your.tra|
00000a40  63 65 20 77 69 6c 6c 20  62 65 20 64 69 66 66 65  |ce will be diffe|
00000a50  72 65 6e 74 20 66 72 6f  6d 20 74 68 65 20 6f 6e  |rent from the on|
00000a60  65 20 69 6e 20 66 69 67  75 72 65 20 31 31 2e 31  |e in figure 11.1|
00000a70  2c 20 62 75 74 20 69 6e  20 61 6c 6c 20 42 42 43  |, but in all BBC|
00000a80  0d 63 6f 6d 70 75 74 65  72 73 20 79 6f 75 20 77  |.computers you w|
00000a90  69 6c 6c 20 66 69 6e 64  20 73 65 72 76 69 63 65  |ill find service|
00000aa0  20 63 61 6c 6c 20 32 2c  20 74 68 65 20 70 72 69  | call 2, the pri|
00000ab0  76 61 74 65 20 77 6f 72  6b 73 70 61 63 65 20 63  |vate workspace c|
00000ac0  6c 61 69 6d 2c 0d 73 6f  6d 65 77 68 65 72 65 20  |laim,.somewhere |
00000ad0  69 6e 20 74 68 65 20 6c  69 73 74 2e 0d 0d 0d 0d  |in the list.....|
00000ae0  0d 20 41 3d 31 39 20 58  3d 30 46 20 59 3d 46 46  |. A=19 X=0F Y=FF|
00000af0  20 53 50 4f 4f 4c 2f 45  58 45 43 20 66 69 6c 65  | SPOOL/EXEC file|
00000b00  20 63 6c 6f 73 75 72 65  0d 20 41 3d 30 46 20 58  | closure. A=0F X|
00000b10  3d 30 46 20 59 3d 46 46  20 56 65 63 74 6f 72 73  |=0F Y=FF Vectors|
00000b20  20 63 6c 61 69 6d 65 64  0d 20 41 3d 46 46 20 58  | claimed. A=FF X|
00000b30  3d 30 46 20 59 3d 46 46  20 54 75 62 65 20 73 79  |=0F Y=FF Tube sy|
00000b40  73 74 65 6d 20 6d 61 69  6e 20 69 6e 69 74 2e 0d  |stem main init..|
00000b50  20 41 3d 30 31 20 58 3d  30 46 20 59 3d 30 45 20  | A=01 X=0F Y=0E |
00000b60  41 62 73 2e 20 77 6f 72  6b 73 70 61 63 65 20 63  |Abs. workspace c|
00000b70  6c 61 69 6d 0d 20 41 3d  30 32 20 58 3d 30 46 20  |laim. A=02 X=0F |
00000b80  59 3d 31 37 20 50 72 69  76 61 74 65 20 77 6f 72  |Y=17 Private wor|
00000b90  6b 73 70 61 63 65 20 63  6c 61 69 6d 0d 20 41 3d  |kspace claim. A=|
00000ba0  46 45 20 58 3d 30 46 20  59 3d 46 46 20 54 75 62  |FE X=0F Y=FF Tub|
00000bb0  65 20 73 79 73 74 65 6d  20 70 6f 73 74 20 69 6e  |e system post in|
00000bc0  69 74 2e 0d 20 41 3d 31  31 20 58 3d 30 46 20 59  |it.. A=11 X=0F Y|
00000bd0  3d 31 46 20 46 6f 6e 74  20 69 6d 70 6c 6f 64 65  |=1F Font implode|
00000be0  2f 65 78 70 6c 6f 64 65  0d 0d 41 63 6f 72 6e 20  |/explode..Acorn |
00000bf0  54 55 42 45 20 36 35 30  32 20 36 34 4b 0d 0d 20  |TUBE 6502 64K.. |
00000c00  41 3d 30 33 20 58 3d 30  46 20 59 3d 30 38 20 41  |A=03 X=0F Y=08 A|
00000c10  75 74 6f 2d 62 6f 6f 74  0d 41 63 6f 72 6e 20 44  |uto-boot.Acorn D|
00000c20  46 53 0d 0d 20 41 3d 31  30 20 58 3d 30 46 20 59  |FS.. A=10 X=0F Y|
00000c30  3d 45 45 20 53 50 4f 4f  4c 2f 45 58 45 43 20 66  |=EE SPOOL/EXEC f|
00000c40  69 6c 65 20 63 6c 6f 73  75 72 65 0d 20 41 3d 30  |ile closure. A=0|
00000c50  46 20 58 3d 30 46 20 59  3d 33 30 20 56 65 63 74  |F X=0F Y=30 Vect|
00000c60  6f 72 73 20 63 6c 61 69  6d 65 64 0d 20 41 3d 30  |ors claimed. A=0|
00000c70  41 20 58 3d 30 46 20 59  3d 44 34 20 43 6c 61 69  |A X=0F Y=D4 Clai|
00000c80  6d 20 73 74 61 74 69 63  20 77 6f 72 6b 73 70 61  |m static workspa|
00000c90  63 65 0d 42 41 53 49 43  0d 0d 3e 0d 0d 46 69 67  |ce.BASIC..>..Fig|
00000ca0  75 72 65 20 31 31 2e 31  20 20 53 65 72 76 69 63  |ure 11.1  Servic|
00000cb0  65 20 63 61 6c 6c 20 74  72 61 63 65 20 61 66 74  |e call trace aft|
00000cc0  65 72 20 42 72 65 61 6b  0d 2d 2d 2d 2d 2d 2d 2d  |er Break.-------|
00000cd0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000cf0  2d 2d 2d 2d 0d 0d 0d 0d  20 20 49 6e 20 66 69 67  |----....  In fig|
00000d00  75 72 65 20 31 31 2e 31  20 79 6f 75 20 63 61 6e  |ure 11.1 you can|
00000d10  20 73 65 65 20 74 68 61  74 20 74 68 65 20 70 72  | see that the pr|
00000d20  69 76 61 74 65 20 77 6f  72 6b 73 70 61 63 65 20  |ivate workspace |
00000d30  63 6c 61 69 6d 2c 20 73  65 72 76 69 63 65 0d 63  |claim, service.c|
00000d40  61 6c 6c 20 32 2c 20 69  73 20 6d 61 64 65 20 77  |all 2, is made w|
00000d50  69 74 68 20 59 3d 26 31  37 2e 20 50 72 69 76 61  |ith Y=&17. Priva|
00000d60  74 65 20 77 6f 72 6b 73  70 61 63 65 20 73 74 61  |te workspace sta|
00000d70  72 74 73 20 61 74 20 70  61 67 65 20 26 31 37 20  |rts at page &17 |
00000d80  69 6e 0d 74 68 65 20 42  42 43 20 42 20 77 69 74  |in.the BBC B wit|
00000d90  68 20 74 68 65 20 41 63  6f 72 6e 20 44 46 53 2e  |h the Acorn DFS.|
00000da0  20 49 66 20 74 68 65 20  74 72 61 63 65 20 69 73  | If the trace is|
00000db0  20 72 75 6e 20 66 72 6f  6d 20 61 20 6c 6f 77 65  | run from a lowe|
00000dc0  72 0d 70 72 69 6f 72 69  74 79 20 72 6f 6d 20 74  |r.priority rom t|
00000dd0  68 61 6e 20 74 68 65 20  44 46 53 20 72 6f 6d 20  |han the DFS rom |
00000de0  74 68 65 6e 20 73 65 72  76 69 63 65 20 63 61 6c  |then service cal|
00000df0  6c 20 32 20 77 69 6c 6c  20 62 65 20 6d 61 64 65  |l 2 will be made|
00000e00  20 77 69 74 68 0d 59 3d  26 31 39 20 69 6e 64 69  | with.Y=&19 indi|
00000e10  63 61 74 69 6e 67 20 74  68 61 74 20 74 68 65 20  |cating that the |
00000e20  44 46 53 20 68 61 73 20  63 6c 61 69 6d 65 64 20  |DFS has claimed |
00000e30  70 61 67 65 73 20 26 31  37 20 61 6e 64 20 26 31  |pages &17 and &1|
00000e40  38 20 61 73 20 70 72 69  76 61 74 65 0d 77 6f 72  |8 as private.wor|
00000e50  6b 73 70 61 63 65 2e 20  49 66 20 74 68 65 20 74  |kspace. If the t|
00000e60  72 61 63 65 20 69 73 20  72 75 6e 20 6f 6e 20 61  |race is run on a|
00000e70  20 42 42 43 20 42 20 77  69 74 68 6f 75 74 20 61  | BBC B without a|
00000e80  20 44 46 53 20 74 68 65  6e 20 73 65 72 76 69 63  | DFS then servic|
00000e90  65 0d 63 61 6c 6c 20 32  20 69 73 20 6d 61 64 65  |e.call 2 is made|
00000ea0  20 77 69 74 68 20 59 3d  26 30 45 20 69 6e 64 69  | with Y=&0E indi|
00000eb0  63 61 74 69 6e 67 20 74  68 61 74 20 70 72 69 76  |cating that priv|
00000ec0  61 74 65 20 77 6f 72 6b  73 70 61 63 65 20 69 73  |ate workspace is|
00000ed0  0d 61 76 61 69 6c 61 62  6c 65 20 66 72 6f 6d 20  |.available from |
00000ee0  26 45 30 30 2e 20 54 68  65 20 4d 61 73 74 65 72  |&E00. The Master|
00000ef0  20 61 6c 73 6f 20 6d 61  6b 65 73 20 73 65 72 76  | also makes serv|
00000f00  69 63 65 20 63 61 6c 6c  20 32 20 77 69 74 68 20  |ice call 2 with |
00000f10  59 3d 26 30 45 0d 69 6e  64 69 63 61 74 69 6e 67  |Y=&0E.indicating|
00000f20  20 74 68 61 74 2c 20 69  66 20 70 72 69 76 61 74  | that, if privat|
00000f30  65 20 77 6f 72 6b 73 70  61 63 65 20 69 73 20 63  |e workspace is c|
00000f40  6c 61 69 6d 65 64 20 69  6e 20 6d 61 69 6e 20 6d  |laimed in main m|
00000f50  65 6d 6f 72 79 20 72 61  74 68 65 72 0d 74 68 61  |emory rather.tha|
00000f60  6e 20 69 6e 20 70 61 67  65 64 20 6d 65 6d 6f 72  |n in paged memor|
00000f70  79 2c 20 69 74 20 61 6c  73 6f 20 73 74 61 72 74  |y, it also start|
00000f80  73 20 61 74 20 26 45 30  30 2e 0d 0d 20 20 53 65  |s at &E00...  Se|
00000f90  72 76 69 63 65 20 63 61  6c 6c 20 32 20 69 73 20  |rvice call 2 is |
00000fa0  69 73 73 75 65 64 20 74  6f 20 61 6c 6c 20 74 68  |issued to all th|
00000fb0  65 20 70 61 67 65 64 20  72 6f 6d 73 2c 20 73 74  |e paged roms, st|
00000fc0  61 72 74 69 6e 67 20 77  69 74 68 20 72 6f 6d 0d  |arting with rom.|
00000fd0  26 30 46 2e 20 49 74 20  67 69 76 65 73 20 74 68  |&0F. It gives th|
00000fe0  65 20 72 6f 6d 73 20 74  68 65 20 6f 70 70 6f 72  |e roms the oppor|
00000ff0  74 75 6e 69 74 79 20 74  6f 20 63 6c 61 69 6d 20  |tunity to claim |
00001000  74 68 65 69 72 20 6f 77  6e 20 70 72 69 76 61 74  |their own privat|
00001010  65 0d 77 6f 72 6b 73 70  61 63 65 2e 20 50 72 69  |e.workspace. Pri|
00001020  76 61 74 65 20 77 6f 72  6b 73 70 61 63 65 20 69  |vate workspace i|
00001030  73 20 61 6c 6c 6f 63 61  74 65 64 20 69 6e 20 70  |s allocated in p|
00001040  61 67 65 73 20 6f 66 20  32 35 36 20 62 79 74 65  |ages of 256 byte|
00001050  73 20 61 6e 64 20 69 73  0d 65 78 63 6c 75 73 69  |s and is.exclusi|
00001060  76 65 20 74 6f 20 74 68  65 20 72 6f 6d 20 63 6c  |ve to the rom cl|
00001070  61 69 6d 69 6e 67 20 69  74 2e 20 53 65 72 76 69  |aiming it. Servi|
00001080  63 65 20 63 61 6c 6c 20  32 20 69 73 20 6d 61 64  |ce call 2 is mad|
00001090  65 20 74 6f 20 65 61 63  68 20 72 6f 6d 0d 77 69  |e to each rom.wi|
000010a0  74 68 20 69 74 73 20 72  6f 6d 20 6e 75 6d 62 65  |th its rom numbe|
000010b0  72 20 69 6e 20 74 68 65  20 58 20 72 65 67 69 73  |r in the X regis|
000010c0  74 65 72 20 61 6e 64 20  74 68 65 20 66 69 72 73  |ter and the firs|
000010d0  74 20 70 61 67 65 20 6e  75 6d 62 65 72 20 6f 66  |t page number of|
000010e0  20 74 68 65 0d 77 6f 72  6b 73 70 61 63 65 20 61  | the.workspace a|
000010f0  76 61 69 6c 61 62 6c 65  20 74 6f 20 69 74 20 69  |vailable to it i|
00001100  6e 20 74 68 65 20 59 20  72 65 67 69 73 74 65 72  |n the Y register|
00001110  2e 20 41 20 72 6f 6d 20  63 61 6e 20 63 6c 61 69  |. A rom can clai|
00001120  6d 20 70 72 69 76 61 74  65 0d 77 6f 72 6b 73 70  |m private.worksp|
00001130  61 63 65 20 62 79 20 73  61 76 69 6e 67 20 74 68  |ace by saving th|
00001140  65 20 63 6f 6e 74 65 6e  74 73 20 6f 66 20 74 68  |e contents of th|
00001150  65 20 59 20 72 65 67 69  73 74 65 72 20 28 69 65  |e Y register (ie|
00001160  2e 20 74 68 65 20 6d 6f  73 74 0d 73 69 67 6e 69  |. the most.signi|
00001170  66 69 63 61 6e 74 20 62  79 74 65 20 6f 66 20 74  |ficant byte of t|
00001180  68 65 20 61 64 64 72 65  73 73 20 6f 66 20 74 68  |he address of th|
00001190  65 20 73 74 61 72 74 20  6f 66 20 70 72 69 76 61  |e start of priva|
000011a0  74 65 20 77 6f 72 6b 73  70 61 63 65 29 20 69 6e  |te workspace) in|
000011b0  0d 74 68 65 20 70 61 67  65 64 20 72 6f 6d 20 77  |.the paged rom w|
000011c0  6f 72 6b 73 70 61 63 65  20 74 61 62 6c 65 20 66  |orkspace table f|
000011d0  72 6f 6d 20 26 44 46 30  20 74 6f 20 26 44 46 46  |rom &DF0 to &DFF|
000011e0  20 28 6f 6e 65 20 62 79  74 65 20 70 65 72 20 72  | (one byte per r|
000011f0  6f 6d 20 66 6f 72 0d 72  6f 6d 73 20 26 30 30 20  |om for.roms &00 |
00001200  74 6f 20 26 30 46 20 72  65 73 70 65 63 74 69 76  |to &0F respectiv|
00001210  65 6c 79 29 2e 20 49 74  20 6d 75 73 74 20 74 68  |ely). It must th|
00001220  65 6e 20 69 6e 63 72 65  6d 65 6e 74 20 74 68 65  |en increment the|
00001230  20 59 20 72 65 67 69 73  74 65 72 0d 6f 6e 63 65  | Y register.once|
00001240  20 66 6f 72 20 65 61 63  68 20 70 61 67 65 20 6f  | for each page o|
00001250  66 20 70 72 69 76 61 74  65 20 77 6f 72 6b 73 70  |f private worksp|
00001260  61 63 65 20 72 65 71 75  69 72 65 64 2e 20 54 68  |ace required. Th|
00001270  65 20 59 20 72 65 67 69  73 74 65 72 20 6d 75 73  |e Y register mus|
00001280  74 0d 6e 65 76 65 72 20  62 65 20 64 65 63 72 65  |t.never be decre|
00001290  6d 65 6e 74 65 64 20 77  68 65 6e 20 73 65 72 76  |mented when serv|
000012a0  69 63 65 20 63 61 6c 6c  20 32 20 68 61 73 20 62  |ice call 2 has b|
000012b0  65 65 6e 20 69 6e 74 65  72 63 65 70 74 65 64 2e  |een intercepted.|
000012c0  0d 0d 20 20 54 68 65 20  65 78 61 6d 70 6c 65 20  |..  The example |
000012d0  63 6f 64 69 6e 67 20 69  6e 20 66 69 67 75 72 65  |coding in figure|
000012e0  20 31 31 2e 32 20 63 6f  75 6c 64 20 62 65 20 75  | 11.2 could be u|
000012f0  73 65 64 20 74 6f 20 63  6c 61 69 6d 20 6f 6e 65  |sed to claim one|
00001300  20 70 61 67 65 20 6f 66  0d 70 72 69 76 61 74 65  | page of.private|
00001310  20 77 6f 72 6b 73 70 61  63 65 2e 0d 0d 0d 0d 20  | workspace..... |
00001320  20 2e 73 65 72 76 69 63  65 0d 20 20 20 20 20 20  | .service.      |
00001330  20 20 20 50 48 41 20 20  20 20 20 20 20 20 20 20  |   PHA          |
00001340  20 20 20 5c 20 70 75 73  68 20 61 63 63 75 6d 75  |   \ push accumu|
00001350  6c 61 74 6f 72 20 6f 6e  20 73 74 61 63 6b 0d 20  |lator on stack. |
00001360  20 20 20 20 20 20 20 20  43 4d 50 20 23 32 20 20  |        CMP #2  |
00001370  20 20 20 20 20 20 20 20  5c 20 69 73 20 69 74 20  |        \ is it |
00001380  73 65 72 76 69 63 65 20  63 61 6c 6c 20 32 3f 0d  |service call 2?.|
00001390  20 20 20 20 20 20 20 20  20 42 4e 45 20 6e 6f 74  |         BNE not|
000013a0  74 77 6f 20 20 20 20 20  20 5c 20 62 72 61 6e 63  |two      \ branc|
000013b0  68 20 69 66 20 6e 6f 74  20 32 0d 20 20 20 20 20  |h if not 2.     |
000013c0  20 20 20 20 54 59 41 20  20 20 20 20 20 20 20 20  |    TYA         |
000013d0  20 20 20 20 5c 20 70 72  65 70 61 72 65 20 74 6f  |    \ prepare to|
000013e0  20 73 74 6f 72 65 20 73  74 61 72 74 20 6f 66 20  | store start of |
000013f0  77 6f 72 6b 73 70 61 63  65 0d 20 20 20 20 20 20  |workspace.      |
00001400  20 20 20 53 54 41 20 26  44 46 30 2c 58 20 20 20  |   STA &DF0,X   |
00001410  20 20 20 5c 20 73 74 6f  72 65 20 73 74 61 72 74  |   \ store start|
00001420  20 61 64 64 72 65 73 73  20 69 6e 20 77 6f 72 6b  | address in work|
00001430  73 70 61 63 65 20 74 61  62 6c 65 0d 20 20 20 20  |space table.    |
00001440  20 20 20 20 20 49 4e 59  20 20 20 20 20 20 20 20  |     INY        |
00001450  20 20 20 20 20 5c 20 63  6c 61 69 6d 20 31 20 70  |     \ claim 1 p|
00001460  61 67 65 20 6f 66 20 77  6f 72 6b 73 70 61 63 65  |age of workspace|
00001470  0d 20 20 20 20 20 20 20  20 20 50 4c 41 20 20 20  |.         PLA   |
00001480  20 20 20 20 20 20 20 20  20 20 5c 20 72 65 73 74  |          \ rest|
00001490  6f 72 65 20 61 63 63 75  6d 75 6c 61 74 6f 72 0d  |ore accumulator.|
000014a0  20 20 20 20 20 20 20 20  20 52 54 53 20 20 20 20  |         RTS    |
000014b0  20 20 20 20 20 20 20 20  20 5c 20 72 65 74 75 72  |         \ retur|
000014c0  6e 20 74 6f 20 4d 4f 53  0d 20 20 2e 6e 6f 74 74  |n to MOS.  .nott|
000014d0  77 6f 0d 0d 0d 0d 46 69  67 75 72 65 20 31 31 2e  |wo....Figure 11.|
000014e0  32 20 20 43 6c 61 69 6d  69 6e 67 20 70 72 69 76  |2  Claiming priv|
000014f0  61 74 65 20 77 6f 72 6b  73 70 61 63 65 0d 2d 2d  |ate workspace.--|
00001500  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00001520  2d 2d 2d 2d 2d 0d 0d 0d  0d 0d 20 20 46 6f 72 20  |-----.....  For |
00001530  6f 62 76 69 6f 75 73 20  72 65 61 73 6f 6e 73 20  |obvious reasons |
00001540  70 61 67 65 20 26 30 44  20 6f 66 20 74 68 65 20  |page &0D of the |
00001550  49 2f 4f 20 70 72 6f 63  65 73 73 6f 72 20 6d 65  |I/O processor me|
00001560  6d 6f 72 79 20 73 68 6f  75 6c 64 0d 6e 65 76 65  |mory should.neve|
00001570  72 20 62 65 20 63 6f 72  72 75 70 74 65 64 20 62  |r be corrupted b|
00001580  79 20 75 73 69 6e 67 20  69 74 20 74 6f 20 72 75  |y using it to ru|
00001590  6e 20 70 72 6f 67 72 61  6d 73 2e 0d 0d 20 20 57  |n programs...  W|
000015a0  68 65 6e 65 76 65 72 20  61 20 72 6f 6d 20 6e 65  |henever a rom ne|
000015b0  65 64 73 20 74 6f 20 75  73 65 20 69 74 73 20 70  |eds to use its p|
000015c0  72 69 76 61 74 65 20 77  6f 72 6b 73 70 61 63 65  |rivate workspace|
000015d0  20 69 74 20 73 68 6f 75  6c 64 20 6c 6f 6f 6b 20  | it should look |
000015e0  75 70 0d 74 68 65 20 6d  6f 73 74 20 73 69 67 6e  |up.the most sign|
000015f0  69 66 69 63 61 6e 74 20  62 79 74 65 20 6f 66 20  |ificant byte of |
00001600  74 68 65 20 73 74 61 72  74 20 61 64 64 72 65 73  |the start addres|
00001610  73 20 6f 66 20 74 68 65  20 77 6f 72 6b 73 70 61  |s of the workspa|
00001620  63 65 20 69 6e 20 74 68  65 0d 70 61 67 65 64 20  |ce in the.paged |
00001630  72 6f 6d 20 77 6f 72 6b  73 70 61 63 65 20 74 61  |rom workspace ta|
00001640  62 6c 65 20 61 6e 64 20  61 63 63 65 73 73 20 74  |ble and access t|
00001650  68 65 20 77 6f 72 6b 73  70 61 63 65 20 77 69 74  |he workspace wit|
00001660  68 20 69 6e 64 69 72 65  63 74 0d 61 64 64 72 65  |h indirect.addre|
00001670  73 73 69 6e 67 2e 20 54  68 65 20 72 6f 6d 20 6d  |ssing. The rom m|
00001680  75 73 74 20 6e 6f 74 20  72 65 66 65 72 20 74 6f  |ust not refer to|
00001690  20 74 68 65 20 77 6f 72  6b 73 70 61 63 65 20 64  | the workspace d|
000016a0  69 72 65 63 74 6c 79 20  62 65 63 61 75 73 65 0d  |irectly because.|
000016b0  69 74 73 20 73 74 61 72  74 20 61 64 64 72 65 73  |its start addres|
000016c0  73 20 77 69 6c 6c 20 64  65 70 65 6e 64 20 6f 6e  |s will depend on|
000016d0  20 74 68 65 20 61 6d 6f  75 6e 74 20 6f 66 20 77  | the amount of w|
000016e0  6f 72 6b 73 70 61 63 65  20 63 6c 61 69 6d 65 64  |orkspace claimed|
000016f0  20 62 79 0d 68 69 67 68  65 72 20 70 72 69 6f 72  | by.higher prior|
00001700  69 74 79 20 72 6f 6d 73  2e 0d 0d 20 20 49 66 20  |ity roms...  If |
00001710  61 20 72 6f 6d 20 63 6c  61 69 6d 73 20 70 72 69  |a rom claims pri|
00001720  76 61 74 65 20 77 6f 72  6b 73 70 61 63 65 20 69  |vate workspace i|
00001730  6e 20 6d 61 69 6e 20 6d  65 6d 6f 72 79 20 74 68  |n main memory th|
00001740  65 20 76 61 6c 75 65 20  6f 66 20 74 68 65 0d 4f  |e value of the.O|
00001750  73 68 77 6d 20 61 6e 64  20 50 41 47 45 20 77 69  |shwm and PAGE wi|
00001760  6c 6c 20 62 65 20 72 61  69 73 65 64 2e 20 49 66  |ll be raised. If|
00001770  2c 20 66 6f 72 20 65 78  61 6d 70 6c 65 2c 20 79  |, for example, y|
00001780  6f 75 72 20 70 72 6f 67  72 61 6d 20 63 6c 61 69  |our program clai|
00001790  6d 73 20 32 0d 70 61 67  65 73 20 6f 66 20 70 72  |ms 2.pages of pr|
000017a0  69 76 61 74 65 20 77 6f  72 6b 73 70 61 63 65 20  |ivate workspace |
000017b0  74 68 65 6e 20 4f 73 68  77 6d 20 61 6e 64 20 50  |then Oshwm and P|
000017c0  41 47 45 20 77 69 6c 6c  20 62 65 20 72 61 69 73  |AGE will be rais|
000017d0  65 64 2c 20 6f 6e 20 61  0d 42 42 43 20 42 20 77  |ed, on a.BBC B w|
000017e0  69 74 68 20 44 46 53 2c  20 66 72 6f 6d 20 26 31  |ith DFS, from &1|
000017f0  39 30 30 20 74 6f 20 26  31 42 30 30 2e 20 49 6e  |900 to &1B00. In|
00001800  20 74 68 69 73 20 65 78  61 6d 70 6c 65 2c 20 74  | this example, t|
00001810  68 65 20 70 72 69 76 61  74 65 0d 77 6f 72 6b 73  |he private.works|
00001820  70 61 63 65 20 63 6f 75  6c 64 20 73 74 61 72 74  |pace could start|
00001830  20 61 74 20 65 69 74 68  65 72 20 26 31 37 30 30  | at either &1700|
00001840  20 6f 72 20 26 31 39 30  30 20 64 65 70 65 6e 64  | or &1900 depend|
00001850  69 6e 67 20 6f 6e 20 74  68 65 0d 70 72 69 6f 72  |ing on the.prior|
00001860  69 74 79 20 6f 66 20 79  6f 75 72 20 72 6f 6d 20  |ity of your rom |
00001870  77 69 74 68 20 72 65 73  70 65 63 74 20 74 6f 20  |with respect to |
00001880  74 68 65 20 44 46 53 20  72 6f 6d 2e 0d 0d 20 20  |the DFS rom...  |
00001890  59 6f 75 72 20 70 72 6f  67 72 61 6d 20 77 69 6c  |Your program wil|
000018a0  6c 20 77 6f 72 6b 20 70  72 6f 70 65 72 6c 79 20  |l work properly |
000018b0  66 72 6f 6d 20 61 6c 6c  20 72 6f 6d 20 73 6f 63  |from all rom soc|
000018c0  6b 65 74 73 20 69 66 20  69 74 20 61 63 63 65 73  |kets if it acces|
000018d0  73 65 73 0d 74 68 65 20  70 72 69 76 61 74 65 20  |ses.the private |
000018e0  77 6f 72 6b 73 70 61 63  65 20 69 6e 64 69 72 65  |workspace indire|
000018f0  63 74 6c 79 20 61 66 74  65 72 20 6c 6f 6f 6b 69  |ctly after looki|
00001900  6e 67 20 75 70 20 74 68  65 20 6d 6f 73 74 20 73  |ng up the most s|
00001910  69 67 6e 69 66 69 63 61  6e 74 0d 62 79 74 65 20  |ignificant.byte |
00001920  6f 66 20 74 68 65 20 73  74 61 72 74 20 61 64 64  |of the start add|
00001930  72 65 73 73 20 6f 66 20  70 72 69 76 61 74 65 20  |ress of private |
00001940  77 6f 72 6b 73 70 61 63  65 20 69 6e 20 74 68 65  |workspace in the|
00001950  20 70 61 67 65 64 20 72  6f 6d 0d 77 6f 72 6b 73  | paged rom.works|
00001960  70 61 63 65 20 74 61 62  6c 65 2e 20 54 68 69 73  |pace table. This|
00001970  20 74 65 63 68 6e 69 71  75 65 20 69 73 20 69 6c  | technique is il|
00001980  6c 75 73 74 72 61 74 65  64 20 69 6e 20 66 69 67  |lustrated in fig|
00001990  75 72 65 20 31 31 2e 33  20 77 68 69 63 68 0d 73  |ure 11.3 which.s|
000019a0  68 6f 77 73 20 68 6f 77  20 79 6f 75 72 20 53 57  |hows how your SW|
000019b0  52 20 70 72 6f 67 72 61  6d 20 63 61 6e 20 75 73  |R program can us|
000019c0  65 20 70 6f 73 74 2d 69  6e 64 65 78 65 64 20 69  |e post-indexed i|
000019d0  6e 64 69 72 65 63 74 20  61 64 64 72 65 73 73 69  |ndirect addressi|
000019e0  6e 67 20 74 6f 0d 72 65  61 64 20 74 68 65 20 63  |ng to.read the c|
000019f0  6f 6e 74 65 6e 74 73 20  6f 66 20 74 68 65 20 66  |ontents of the f|
00001a00  69 72 73 74 20 62 79 74  65 20 6f 66 20 69 74 73  |irst byte of its|
00001a10  20 70 72 69 76 61 74 65  20 77 6f 72 6b 73 70 61  | private workspa|
00001a20  63 65 2e 0d 0d 0d 0d 0d  20 20 20 20 20 20 20 20  |ce......        |
00001a30  20 4c 44 58 20 26 46 34  20 20 20 20 20 20 20 20  | LDX &F4        |
00001a40  20 5c 20 6c 6f 61 64 20  58 20 77 69 74 68 20 72  | \ load X with r|
00001a50  6f 6d 20 6e 75 6d 62 65  72 0d 20 20 20 20 20 20  |om number.      |
00001a60  20 20 20 4c 44 41 20 26  44 46 30 2c 58 20 20 20  |   LDA &DF0,X   |
00001a70  20 20 20 5c 20 66 69 6e  64 20 6d 6f 73 74 20 73  |   \ find most s|
00001a80  69 67 2e 20 62 79 74 65  20 6f 66 20 77 6f 72 6b  |ig. byte of work|
00001a90  73 70 61 63 65 20 61 64  64 72 65 73 73 0d 20 20  |space address.  |
00001aa0  20 20 20 20 20 20 20 53  54 41 20 26 37 31 20 20  |       STA &71  |
00001ab0  20 20 20 20 20 20 20 5c  20 73 74 6f 72 65 20 69  |       \ store i|
00001ac0  74 20 66 6f 72 20 69 6e  64 69 72 65 63 74 20 61  |t for indirect a|
00001ad0  64 64 72 65 73 73 69 6e  67 0d 20 20 20 20 20 20  |ddressing.      |
00001ae0  20 20 20 4c 44 41 20 23  30 20 20 20 20 20 20 20  |   LDA #0       |
00001af0  20 20 20 5c 20 77 6f 72  6b 73 70 61 63 65 20 61  |   \ workspace a|
00001b00  6c 77 61 79 73 20 73 74  61 72 74 73 20 61 74 20  |lways starts at |
00001b10  61 20 70 61 67 65 20 62  6f 75 6e 64 61 72 79 0d  |a page boundary.|
00001b20  20 20 20 20 20 20 20 20  20 53 54 41 20 26 37 30  |         STA &70|
00001b30  20 20 20 20 20 20 20 20  20 5c 20 73 74 6f 72 65  |         \ store|
00001b40  20 6c 65 61 73 74 20 73  69 67 2e 20 62 79 74 65  | least sig. byte|
00001b50  20 6f 66 20 77 6f 72 6b  73 70 61 63 65 20 61 64  | of workspace ad|
00001b60  64 72 65 73 73 0d 20 20  20 20 20 20 20 20 20 54  |dress.         T|
00001b70  41 59 20 20 20 20 20 20  20 20 20 20 20 20 20 5c  |AY             \|
00001b80  20 59 20 3d 20 30 0d 20  20 20 20 20 20 20 20 20  | Y = 0.         |
00001b90  4c 44 41 20 28 26 37 30  29 2c 59 20 20 20 20 20  |LDA (&70),Y     |
00001ba0  5c 20 52 65 61 64 20 66  69 72 73 74 20 62 79 74  |\ Read first byt|
00001bb0  65 20 6f 66 20 70 72 69  76 61 74 65 20 77 6f 72  |e of private wor|
00001bc0  6b 73 70 61 63 65 0d 0d  0d 46 69 67 75 72 65 20  |kspace...Figure |
00001bd0  31 31 2e 33 20 20 52 65  61 64 69 6e 67 20 70 72  |11.3  Reading pr|
00001be0  69 76 61 74 65 20 77 6f  72 6b 73 70 61 63 65 0d  |ivate workspace.|
00001bf0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00001c10  2d 2d 2d 2d 2d 2d 0d 0d  0d 0d 20 20 54 68 65 20  |------....  The |
00001c20  74 65 63 68 6e 69 71 75  65 73 20 69 6c 6c 75 73  |techniques illus|
00001c30  74 72 61 74 65 64 20 69  6e 20 66 69 67 75 72 65  |trated in figure|
00001c40  73 20 31 31 2e 32 20 61  6e 64 20 31 31 2e 33 20  |s 11.2 and 11.3 |
00001c50  68 61 76 65 20 62 65 65  6e 20 75 73 65 64 0d 69  |have been used.i|
00001c60  6e 20 74 68 65 20 70 72  6f 67 72 61 6d 20 50 52  |n the program PR|
00001c70  49 56 41 54 45 2e 20 54  68 69 73 20 70 72 6f 67  |IVATE. This prog|
00001c80  72 61 6d 20 63 6c 61 69  6d 73 20 6f 6e 65 20 70  |ram claims one p|
00001c90  61 67 65 20 6f 66 20 70  72 69 76 61 74 65 0d 77  |age of private.w|
00001ca0  6f 72 6b 73 70 61 63 65  20 74 6f 20 75 73 65 20  |orkspace to use |
00001cb0  66 6f 72 20 61 6e 20 4f  73 77 6f 72 64 20 70 61  |for an Osword pa|
00001cc0  72 61 6d 65 74 65 72 20  62 6c 6f 63 6b 2e 0d 0d  |rameter block...|
00001cd0  20 20 4f 73 77 6f 72 64  20 26 37 44 2c 20 6f 6e  |  Osword &7D, on|
00001ce0  65 20 6f 66 20 74 68 65  20 44 46 53 20 4f 73 77  |e of the DFS Osw|
00001cf0  6f 72 64 73 2c 20 69 73  20 75 73 65 64 20 74 6f  |ords, is used to|
00001d00  20 64 65 6d 6f 6e 73 74  72 61 74 65 20 68 6f 77  | demonstrate how|
00001d10  20 79 6f 75 72 0d 53 57  52 20 70 72 6f 67 72 61  | your.SWR progra|
00001d20  6d 73 20 63 61 6e 20 75  73 65 20 4f 73 77 6f 72  |ms can use Oswor|
00001d30  64 20 72 6f 75 74 69 6e  65 73 20 69 6e 20 6f 74  |d routines in ot|
00001d40  68 65 72 20 70 61 67 65  64 20 72 6f 6d 73 2e 20  |her paged roms. |
00001d50  49 6e 20 6f 72 64 65 72  20 74 6f 0d 75 73 65 20  |In order to.use |
00001d60  4f 73 77 6f 72 64 20 63  61 6c 6c 73 20 69 6e 20  |Osword calls in |
00001d70  74 68 69 73 20 77 61 79  20 74 68 65 20 70 61 72  |this way the par|
00001d80  61 6d 65 74 65 72 20 62  6c 6f 63 6b 20 6d 75 73  |ameter block mus|
00001d90  74 20 62 65 20 61 63 63  65 73 73 65 64 20 62 79  |t be accessed by|
00001da0  0d 62 6f 74 68 20 72 6f  6d 73 2c 20 69 74 20 63  |.both roms, it c|
00001db0  61 6e 6e 6f 74 20 62 65  20 77 69 74 68 69 6e 20  |annot be within |
00001dc0  74 68 65 20 70 61 67 65  64 20 72 61 6d 20 62 61  |the paged ram ba|
00001dd0  6e 6b 20 75 73 65 64 20  62 79 20 74 68 65 20 53  |nk used by the S|
00001de0  57 52 0d 70 72 6f 67 72  61 6d 2e 20 50 72 69 76  |WR.program. Priv|
00001df0  61 74 65 20 77 6f 72 6b  73 70 61 63 65 20 69 6e  |ate workspace in|
00001e00  20 6d 61 69 6e 20 6d 65  6d 6f 72 79 20 69 73 20  | main memory is |
00001e10  63 6c 61 69 6d 65 64 20  62 79 20 74 68 65 20 70  |claimed by the p|
00001e20  72 6f 67 72 61 6d 0d 50  52 49 56 41 54 45 20 62  |rogram.PRIVATE b|
00001e30  75 74 20 69 74 20 69 73  20 6d 61 64 65 20 61 76  |ut it is made av|
00001e40  61 69 6c 61 62 6c 65 20  74 6f 20 74 68 65 20 44  |ailable to the D|
00001e50  46 53 20 62 79 20 73 70  65 63 69 66 79 69 6e 67  |FS by specifying|
00001e60  20 69 74 73 20 61 64 64  72 65 73 73 0d 69 6e 20  | its address.in |
00001e70  74 68 65 20 58 20 61 6e  64 20 59 20 72 65 67 69  |the X and Y regi|
00001e80  73 74 65 72 73 20 62 65  66 6f 72 65 20 63 61 6c  |sters before cal|
00001e90  6c 69 6e 67 20 4f 73 77  6f 72 64 20 26 37 44 2e  |ling Osword &7D.|
00001ea0  20 54 68 65 20 70 72 69  76 61 74 65 0d 77 6f 72  | The private.wor|
00001eb0  6b 73 70 61 63 65 20 77  69 6c 6c 20 6e 6f 74 20  |kspace will not |
00001ec0  62 65 20 61 76 61 69 6c  61 62 6c 65 20 74 6f 20  |be available to |
00001ed0  74 68 65 20 44 46 53 2c  20 6f 72 20 61 6e 79 20  |the DFS, or any |
00001ee0  6f 74 68 65 72 20 72 6f  6d 2c 20 75 6e 6c 65 73  |other rom, unles|
00001ef0  73 0d 74 68 65 20 70 72  6f 67 72 61 6d 20 77 68  |s.the program wh|
00001f00  69 63 68 20 63 6c 61 69  6d 65 64 20 74 68 65 20  |ich claimed the |
00001f10  77 6f 72 6b 73 70 61 63  65 20 6d 61 6b 65 73 20  |workspace makes |
00001f20  69 74 20 61 76 61 69 6c  61 62 6c 65 20 69 6e 20  |it available in |
00001f30  74 68 69 73 0d 77 61 79  2e 0d 0d 20 20 4f 73 77  |this.way...  Osw|
00001f40  6f 72 64 20 26 37 44 20  72 65 61 64 73 20 74 68  |ord &7D reads th|
00001f50  65 20 63 61 74 61 6c 6f  67 75 65 20 66 6f 72 20  |e catalogue for |
00001f60  74 68 65 20 63 75 72 72  65 6e 74 20 64 65 66 61  |the current defa|
00001f70  75 6c 74 20 64 69 73 63  20 64 72 69 76 65 2e 0d  |ult disc drive..|
00001f80  46 72 6f 6d 20 74 68 69  73 20 69 74 20 65 78 74  |From this it ext|
00001f90  72 61 63 74 73 20 74 68  65 20 6e 75 6d 62 65 72  |racts the number|
00001fa0  20 6f 66 20 74 69 6d 65  73 20 74 68 61 74 20 64  | of times that d|
00001fb0  69 73 63 20 68 61 73 20  62 65 65 6e 20 77 72 69  |isc has been wri|
00001fc0  74 74 65 6e 2e 0d 54 68  69 73 20 69 73 20 6b 6e  |tten..This is kn|
00001fd0  6f 77 6e 20 61 73 20 74  68 65 20 64 69 73 63 20  |own as the disc |
00001fe0  63 79 63 6c 65 73 2e 20  54 68 65 20 6e 75 6d 62  |cycles. The numb|
00001ff0  65 72 20 6f 66 20 63 79  63 6c 65 73 20 69 73 20  |er of cycles is |
00002000  61 76 61 69 6c 61 62 6c  65 20 61 73 0d 61 20 62  |available as.a b|
00002010  69 6e 61 72 79 20 63 6f  64 65 64 20 64 65 63 69  |inary coded deci|
00002020  6d 61 6c 20 6e 75 6d 62  65 72 20 69 6e 20 61 20  |mal number in a |
00002030  6f 6e 65 20 62 79 74 65  20 70 61 72 61 6d 65 74  |one byte paramet|
00002040  65 72 20 62 6c 6f 63 6b  20 73 70 65 63 69 66 69  |er block specifi|
00002050  65 64 0d 62 79 20 74 68  65 20 58 20 61 6e 64 20  |ed.by the X and |
00002060  59 20 72 65 67 69 73 74  65 72 73 20 6f 6e 20 65  |Y registers on e|
00002070  6e 74 72 79 20 74 6f 20  4f 73 77 6f 72 64 20 26  |ntry to Osword &|
00002080  37 44 2e 0d 0d 20 20 54  6f 20 75 73 65 20 74 68  |7D...  To use th|
00002090  65 20 70 72 6f 67 72 61  6d 20 50 52 49 56 41 54  |e program PRIVAT|
000020a0  45 20 6c 6f 61 64 20 74  68 65 20 6f 62 6a 65 63  |E load the objec|
000020b0  74 20 63 6f 64 65 20 69  74 20 67 65 6e 65 72 61  |t code it genera|
000020c0  74 65 73 20 69 6e 74 6f  0d 53 57 52 20 61 6e 64  |tes into.SWR and|
000020d0  20 70 72 65 73 73 20 74  68 65 20 42 72 65 61 6b  | press the Break|
000020e0  20 6b 65 79 2e 20 54 79  70 65 20 50 52 49 4e 54  | key. Type PRINT|
000020f0  20 7e 20 50 41 47 45 20  61 6e 64 20 70 72 65 73  | ~ PAGE and pres|
00002100  73 20 52 65 74 75 72 6e  2e 20 59 6f 75 0d 77 69  |s Return. You.wi|
00002110  6c 6c 20 73 65 65 20 74  68 61 74 20 50 41 47 45  |ll see that PAGE|
00002120  20 68 61 73 20 62 65 65  6e 20 72 61 69 73 65 64  | has been raised|
00002130  20 66 72 6f 6d 20 26 31  39 30 30 20 74 6f 20 26  | from &1900 to &|
00002140  31 41 30 30 20 28 42 42  43 20 42 20 77 69 74 68  |1A00 (BBC B with|
00002150  0d 41 63 6f 72 6e 20 44  46 53 29 2e 20 54 79 70  |.Acorn DFS). Typ|
00002160  65 20 2a 43 59 43 4c 45  53 20 61 6e 64 20 70 72  |e *CYCLES and pr|
00002170  65 73 73 20 52 65 74 75  72 6e 2e 20 54 68 65 20  |ess Return. The |
00002180  70 72 6f 67 72 61 6d 20  77 69 6c 6c 20 72 65 61  |program will rea|
00002190  64 20 74 68 65 0d 63 75  72 72 65 6e 74 20 64 65  |d the.current de|
000021a0  66 61 75 6c 74 20 64 69  73 63 20 64 72 69 76 65  |fault disc drive|
000021b0  20 61 6e 64 20 70 72 69  6e 74 20 74 68 65 20 6e  | and print the n|
000021c0  75 6d 62 65 72 20 6f 66  20 63 79 63 6c 65 73 2e  |umber of cycles.|
000021d0  0d 0d 20 20 54 68 65 20  70 72 6f 67 72 61 6d 20  |..  The program |
000021e0  75 73 65 73 20 74 68 65  20 75 6e 72 65 63 6f 67  |uses the unrecog|
000021f0  6e 69 73 65 64 20 2a 20  63 6f 6d 6d 61 6e 64 20  |nised * command |
00002200  69 6e 74 65 72 70 72 65  74 65 72 20 28 6c 69 6e  |interpreter (lin|
00002210  65 73 0d 34 31 30 2d 36  38 30 29 20 61 6e 64 20  |es.410-680) and |
00002220  65 72 72 6f 72 20 72 6f  75 74 69 6e 65 20 28 6c  |error routine (l|
00002230  69 6e 65 73 20 31 30 38  30 2d 31 32 33 30 29 20  |ines 1080-1230) |
00002240  69 6e 74 72 6f 64 75 63  65 64 20 69 6e 20 65 61  |introduced in ea|
00002250  72 6c 69 65 72 0d 6d 6f  64 75 6c 65 73 20 6f 66  |rlier.modules of|
00002260  20 74 68 65 20 63 6f 75  72 73 65 2e 0d 0d 20 20  | the course...  |
00002270  4f 6e 65 20 70 61 67 65  20 6f 66 20 70 72 69 76  |One page of priv|
00002280  61 74 65 20 77 6f 72 6b  73 70 61 63 65 20 69 73  |ate workspace is|
00002290  20 63 6c 61 69 6d 65 64  20 69 6e 20 6c 69 6e 65  | claimed in line|
000022a0  73 20 33 33 30 20 74 6f  20 34 30 30 2e 20 54 68  |s 330 to 400. Th|
000022b0  65 0d 73 74 61 72 74 20  6f 66 20 74 68 65 20 77  |e.start of the w|
000022c0  6f 72 6b 73 70 61 63 65  20 69 73 20 73 74 6f 72  |orkspace is stor|
000022d0  65 64 20 69 6e 20 74 68  65 20 70 61 67 65 64 20  |ed in the paged |
000022e0  72 6f 6d 20 77 6f 72 6b  73 70 61 63 65 20 74 61  |rom workspace ta|
000022f0  62 6c 65 0d 28 6c 69 6e  65 20 33 37 30 29 20 61  |ble.(line 370) a|
00002300  6e 64 20 74 68 65 20 59  20 72 65 67 69 73 74 65  |nd the Y registe|
00002310  72 20 69 73 20 69 6e 63  72 65 6d 65 6e 74 65 64  |r is incremented|
00002320  20 6f 6e 63 65 20 28 6c  69 6e 65 20 33 38 30 29  | once (line 380)|
00002330  20 74 6f 0d 69 6e 64 69  63 61 74 65 20 74 68 61  | to.indicate tha|
00002340  74 20 74 68 65 20 6d 69  6e 69 6d 75 6d 20 6f 6e  |t the minimum on|
00002350  65 20 70 61 67 65 20 6f  66 20 70 72 69 76 61 74  |e page of privat|
00002360  65 20 77 6f 72 6b 73 70  61 63 65 20 69 73 20 72  |e workspace is r|
00002370  65 71 75 69 72 65 64 2e  0d 4f 6e 6c 79 20 6f 6e  |equired..Only on|
00002380  65 20 62 79 74 65 20 6f  66 20 74 68 65 20 6f 6e  |e byte of the on|
00002390  65 20 70 61 67 65 20 69  73 20 75 73 65 64 20 62  |e page is used b|
000023a0  79 20 74 68 65 20 70 72  6f 67 72 61 6d 20 62 75  |y the program bu|
000023b0  74 20 77 6f 72 6b 73 70  61 63 65 20 69 73 0d 6f  |t workspace is.o|
000023c0  6e 6c 79 20 61 76 61 69  6c 61 62 6c 65 20 69 6e  |nly available in|
000023d0  20 75 6e 69 74 73 20 6f  66 20 32 35 36 20 62 79  | units of 256 by|
000023e0  74 65 73 2e 0d 0d 20 20  57 68 65 6e 20 74 68 65  |tes...  When the|
000023f0  20 75 6e 72 65 63 6f 67  6e 69 73 65 64 20 2a 20  | unrecognised * |
00002400  63 6f 6d 6d 61 6e 64 20  69 6e 74 65 72 70 72 65  |command interpre|
00002410  74 65 72 20 72 65 63 6f  67 6e 69 73 65 73 20 74  |ter recognises t|
00002420  68 65 20 63 6f 6d 6d 61  6e 64 0d 2a 43 59 43 4c  |he command.*CYCL|
00002430  45 53 20 63 6f 6e 74 72  6f 6c 20 69 73 20 70 61  |ES control is pa|
00002440  73 73 65 64 20 74 6f 20  74 68 65 20 6c 61 62 65  |ssed to the labe|
00002450  6c 20 22 2e 66 6f 75 6e  64 22 20 28 6c 69 6e 65  |l ".found" (line|
00002460  20 36 39 30 29 2e 20 54  68 65 0d 70 72 6f 67 72  | 690). The.progr|
00002470  61 6d 20 73 74 6f 72 65  73 20 74 68 65 20 63 6f  |am stores the co|
00002480  6e 74 65 6e 74 73 20 6f  66 20 74 68 65 20 74 77  |ntents of the tw|
00002490  6f 20 7a 65 72 6f 20 70  61 67 65 20 62 79 74 65  |o zero page byte|
000024a0  73 20 69 74 20 75 73 65  73 20 62 79 0d 70 75 73  |s it uses by.pus|
000024b0  68 69 6e 67 20 74 68 65  6d 20 6f 6e 20 74 68 65  |hing them on the|
000024c0  20 73 74 61 63 6b 20 28  6c 69 6e 65 73 20 37 30  | stack (lines 70|
000024d0  30 2d 37 33 30 29 20 61  6e 64 20 74 68 65 6e 20  |0-730) and then |
000024e0  75 73 65 73 20 4f 73 61  72 67 73 20 74 6f 20 73  |uses Osargs to s|
000024f0  65 65 0d 69 66 20 74 68  65 20 44 46 53 20 69 73  |ee.if the DFS is|
00002500  20 61 63 74 69 76 65 20  28 6c 69 6e 65 73 20 37  | active (lines 7|
00002510  34 30 2d 37 39 30 29 2e  20 49 66 20 74 68 65 20  |40-790). If the |
00002520  44 46 53 20 69 73 20 6e  6f 74 20 61 63 74 69 76  |DFS is not activ|
00002530  65 20 63 6f 6e 74 72 6f  6c 0d 69 73 20 70 61 73  |e control.is pas|
00002540  73 65 64 20 74 6f 20 74  68 65 20 65 72 72 6f 72  |sed to the error|
00002550  20 72 6f 75 74 69 6e 65  20 28 6c 69 6e 65 73 20  | routine (lines |
00002560  31 30 38 30 2d 31 32 33  30 29 20 77 68 69 63 68  |1080-1230) which|
00002570  2c 20 61 66 74 65 72 0d  72 65 73 74 6f 72 69 6e  |, after.restorin|
00002580  67 20 74 68 65 20 7a 65  72 6f 20 70 61 67 65 20  |g the zero page |
00002590  62 79 74 65 73 2c 20 68  61 6c 74 73 20 74 68 65  |bytes, halts the|
000025a0  20 70 72 6f 67 72 61 6d  20 61 6e 64 20 70 72 69  | program and pri|
000025b0  6e 74 73 20 61 6e 20 65  72 72 6f 72 0d 6d 65 73  |nts an error.mes|
000025c0  73 61 67 65 2e 0d 0d 20  20 49 66 20 74 68 65 20  |sage...  If the |
000025d0  44 46 53 20 69 73 20 61  63 74 69 76 65 20 74 68  |DFS is active th|
000025e0  65 20 6d 6f 73 74 20 73  69 67 6e 69 66 69 63 61  |e most significa|
000025f0  6e 74 20 62 79 74 65 20  6f 66 20 74 68 65 20 61  |nt byte of the a|
00002600  64 64 72 65 73 73 20 6f  66 20 74 68 65 0d 73 74  |ddress of the.st|
00002610  61 72 74 20 6f 66 20 70  72 69 76 61 74 65 20 77  |art of private w|
00002620  6f 72 6b 73 70 61 63 65  20 69 73 20 72 65 61 64  |orkspace is read|
00002630  20 66 72 6f 6d 20 74 68  65 20 70 61 67 65 64 20  | from the paged |
00002640  72 6f 6d 20 77 6f 72 6b  73 70 61 63 65 20 74 61  |rom workspace ta|
00002650  62 6c 65 0d 28 6c 69 6e  65 73 20 38 30 30 2d 38  |ble.(lines 800-8|
00002660  31 30 29 20 61 6e 64 20  73 74 6f 72 65 64 20 69  |10) and stored i|
00002670  6e 20 74 68 65 20 6d 6f  73 74 20 73 69 67 6e 69  |n the most signi|
00002680  66 69 63 61 6e 74 20 6f  66 20 74 68 65 20 74 77  |ficant of the tw|
00002690  6f 20 7a 65 72 6f 0d 70  61 67 65 20 62 79 74 65  |o zero.page byte|
000026a0  73 20 28 6c 69 6e 65 20  38 32 30 29 2e 20 54 68  |s (line 820). Th|
000026b0  65 73 65 20 74 77 6f 20  7a 65 72 6f 20 70 61 67  |ese two zero pag|
000026c0  65 20 62 79 74 65 73 20  61 72 65 20 75 73 65 64  |e bytes are used|
000026d0  20 6c 61 74 65 72 20 69  6e 20 74 68 65 0d 70 72  | later in the.pr|
000026e0  6f 67 72 61 6d 20 74 6f  20 72 65 61 64 20 74 68  |ogram to read th|
000026f0  65 20 63 6f 6e 74 65 6e  74 73 20 6f 66 20 74 68  |e contents of th|
00002700  65 20 70 61 72 61 6d 65  74 65 72 20 62 6c 6f 63  |e parameter bloc|
00002710  6b 2e 0d 0d 20 20 54 68  65 20 61 63 63 75 6d 75  |k...  The accumu|
00002720  6c 61 74 6f 72 20 69 73  20 74 72 61 6e 73 66 65  |lator is transfe|
00002730  72 65 64 20 74 6f 20 74  68 65 20 59 20 72 65 67  |red to the Y reg|
00002740  69 73 74 65 72 20 28 6c  69 6e 65 20 38 33 30 29  |ister (line 830)|
00002750  20 74 6f 20 6d 61 6b 65  0d 74 68 65 20 6d 6f 73  | to make.the mos|
00002760  74 20 73 69 67 6e 69 66  69 63 61 6e 74 20 62 79  |t significant by|
00002770  74 65 20 6f 66 20 74 68  65 20 70 61 72 61 6d 65  |te of the parame|
00002780  74 65 72 20 62 6c 6f 63  6b 20 61 64 64 72 65 73  |ter block addres|
00002790  73 20 61 76 61 69 6c 61  62 6c 65 20 74 6f 0d 4f  |s available to.O|
000027a0  73 77 6f 72 64 2e 20 54  68 65 20 58 20 72 65 67  |sword. The X reg|
000027b0  69 73 74 65 72 20 69 73  20 6c 6f 61 64 65 64 20  |ister is loaded |
000027c0  77 69 74 68 20 7a 65 72  6f 20 28 6c 69 6e 65 20  |with zero (line |
000027d0  38 34 30 29 20 74 6f 20  6d 61 6b 65 20 74 68 65  |840) to make the|
000027e0  0d 6c 65 61 73 74 20 73  69 67 6e 69 66 69 63 61  |.least significa|
000027f0  6e 74 20 62 79 74 65 20  6f 66 20 74 68 65 20 70  |nt byte of the p|
00002800  61 72 61 6d 65 74 65 72  20 62 6c 6f 63 6b 20 61  |arameter block a|
00002810  64 64 72 65 73 73 20 61  76 61 69 6c 61 62 6c 65  |ddress available|
00002820  20 74 6f 0d 4f 73 77 6f  72 64 20 61 6e 64 20 58  | to.Osword and X|
00002830  20 69 73 20 73 74 6f 72  65 64 20 69 6e 20 74 68  | is stored in th|
00002840  65 20 6c 65 61 73 74 20  73 69 67 6e 69 66 69 63  |e least signific|
00002850  61 6e 74 20 62 79 74 65  20 6f 66 20 74 68 65 20  |ant byte of the |
00002860  74 77 6f 20 7a 65 72 6f  0d 70 61 67 65 20 62 79  |two zero.page by|
00002870  74 65 73 20 28 6c 69 6e  65 20 38 35 30 29 2e 0d  |tes (line 850)..|
00002880  0d 20 20 4f 73 77 6f 72  64 20 26 37 44 20 69 73  |.  Osword &7D is|
00002890  20 63 61 6c 6c 65 64 20  28 6c 69 6e 65 73 20 38  | called (lines 8|
000028a0  36 30 2d 38 37 30 29 20  61 6e 64 20 74 68 65 20  |60-870) and the |
000028b0  72 65 73 75 6c 74 20 69  73 20 72 65 61 64 20 66  |result is read f|
000028c0  72 6f 6d 20 74 68 65 0d  70 61 72 61 6d 65 74 65  |rom the.paramete|
000028d0  72 20 62 6c 6f 63 6b 20  69 6e 20 74 68 65 20 66  |r block in the f|
000028e0  69 72 73 74 20 62 79 74  65 20 6f 66 20 74 68 65  |irst byte of the|
000028f0  20 70 72 69 76 61 74 65  20 77 6f 72 6b 73 70 61  | private workspa|
00002900  63 65 20 28 6c 69 6e 65  73 0d 38 38 30 2d 38 39  |ce (lines.880-89|
00002910  30 29 2e 20 54 68 65 20  72 65 73 75 6c 74 20 69  |0). The result i|
00002920  73 20 70 72 69 6e 74 65  64 20 28 6c 69 6e 65 20  |s printed (line |
00002930  39 30 30 20 61 6e 64 20  6c 69 6e 65 73 20 31 32  |900 and lines 12|
00002940  34 30 2d 31 33 39 30 29  20 77 69 74 68 20 61 0d  |40-1390) with a.|
00002950  73 75 69 74 61 62 6c 65  20 6d 65 73 73 61 67 65  |suitable message|
00002960  20 28 6c 69 6e 65 73 20  39 31 30 2d 39 37 30 29  | (lines 910-970)|
00002970  2e 20 54 68 65 20 7a 65  72 6f 20 70 61 67 65 20  |. The zero page |
00002980  6d 65 6d 6f 72 79 20 6c  6f 63 61 74 69 6f 6e 73  |memory locations|
00002990  20 61 72 65 0d 72 65 73  74 6f 72 65 64 20 28 6c  | are.restored (l|
000029a0  69 6e 65 73 20 39 39 30  2d 31 30 32 30 29 2c 20  |ines 990-1020), |
000029b0  74 68 65 20 73 74 61 63  6b 20 69 73 20 62 61 6c  |the stack is bal|
000029c0  61 6e 63 65 64 20 28 6c  69 6e 65 73 20 31 30 33  |anced (lines 103|
000029d0  30 2d 31 30 35 30 29 20  61 6e 64 0d 63 6f 6e 74  |0-1050) and.cont|
000029e0  72 6f 6c 20 69 73 20 72  65 74 75 72 6e 65 64 20  |rol is returned |
000029f0  74 6f 20 74 68 65 20 4d  4f 53 20 61 66 74 65 72  |to the MOS after|
00002a00  20 72 65 73 65 74 69 6e  67 20 74 68 65 20 61 63  | reseting the ac|
00002a10  63 75 6d 75 6c 61 74 6f  72 20 74 6f 20 7a 65 72  |cumulator to zer|
00002a20  6f 0d 74 6f 20 69 6e 64  69 63 61 74 65 20 74 68  |o.to indicate th|
00002a30  61 74 20 74 68 65 20 63  6f 6d 6d 61 6e 64 20 68  |at the command h|
00002a40  61 73 20 62 65 65 6e 20  72 65 63 6f 67 6e 69 73  |as been recognis|
00002a50  65 64 20 28 6c 69 6e 65  73 20 31 30 36 30 2d 31  |ed (lines 1060-1|
00002a60  30 37 30 29 2e 0d 0d 0d  0d 0d 20 20 20 31 30 20  |070)......   10 |
00002a70  52 45 4d 3a 20 50 52 49  56 41 54 45 0d 20 20 20  |REM: PRIVATE.   |
00002a80  32 30 20 4d 4f 44 45 37  0d 20 20 20 33 30 20 48  |20 MODE7.   30 H|
00002a90  49 4d 45 4d 3d 26 33 43  30 30 0d 20 20 20 34 30  |IMEM=&3C00.   40|
00002aa0  20 44 49 4d 20 73 61 76  65 20 35 30 0d 20 20 20  | DIM save 50.   |
00002ab0  35 30 20 64 69 66 66 3d  26 38 30 30 30 2d 48 49  |50 diff=&8000-HI|
00002ac0  4d 45 4d 0d 20 20 20 36  30 20 61 64 64 72 65 73  |MEM.   60 addres|
00002ad0  73 3d 26 37 30 0d 20 20  20 37 30 20 63 6f 6d 76  |s=&70.   70 comv|
00002ae0  65 63 3d 26 46 32 0d 20  20 20 38 30 20 65 72 72  |ec=&F2.   80 err|
00002af0  73 74 61 63 6b 3d 26 31  30 30 0d 20 20 20 39 30  |stack=&100.   90|
00002b00  20 72 6f 6d 6e 75 6d 62  65 72 3d 26 46 34 0d 20  | romnumber=&F4. |
00002b10  20 31 30 30 20 77 6f 72  6b 73 70 61 63 65 3d 26  | 100 workspace=&|
00002b20  44 46 30 0d 20 20 31 31  30 20 67 73 72 65 61 64  |DF0.  110 gsread|
00002b30  3d 26 46 46 43 35 0d 20  20 31 32 30 20 6f 73 61  |=&FFC5.  120 osa|
00002b40  72 67 73 3d 26 46 46 44  41 0d 20 20 31 33 30 20  |rgs=&FFDA.  130 |
00002b50  6f 73 61 73 63 69 3d 26  46 46 45 33 0d 20 20 31  |osasci=&FFE3.  1|
00002b60  34 30 20 6f 73 77 6f 72  64 3d 26 46 46 46 31 0d  |40 osword=&FFF1.|
00002b70  20 20 31 35 30 20 6f 73  63 6c 69 3d 26 46 46 46  |  150 oscli=&FFF|
00002b80  37 0d 20 20 31 36 30 20  46 4f 52 20 70 61 73 73  |7.  160 FOR pass|
00002b90  20 3d 20 30 20 54 4f 20  32 20 53 54 45 50 20 32  | = 0 TO 2 STEP 2|
00002ba0  0d 20 20 31 37 30 20 50  25 3d 48 49 4d 45 4d 0d  |.  170 P%=HIMEM.|
00002bb0  20 20 31 38 30 20 5b 20  20 20 20 20 20 20 4f 50  |  180 [       OP|
00002bc0  54 20 70 61 73 73 0d 20  20 31 39 30 20 20 20 20  |T pass.  190    |
00002bd0  20 20 20 20 20 42 52 4b  0d 20 20 32 30 30 20 20  |     BRK.  200  |
00002be0  20 20 20 20 20 20 20 42  52 4b 0d 20 20 32 31 30  |       BRK.  210|
00002bf0  20 20 20 20 20 20 20 20  20 42 52 4b 0d 20 20 32  |         BRK.  2|
00002c00  32 30 20 20 20 20 20 20  20 20 20 4a 4d 50 20 73  |20         JMP s|
00002c10  65 72 76 69 63 65 2b 64  69 66 66 0d 20 20 32 33  |ervice+diff.  23|
00002c20  30 20 20 20 20 20 20 20  20 20 4f 50 54 20 46 4e  |0         OPT FN|
00002c30  65 71 75 62 28 26 38 32  29 0d 20 20 32 34 30 20  |equb(&82).  240 |
00002c40  20 20 20 20 20 20 20 20  4f 50 54 20 46 4e 65 71  |        OPT FNeq|
00002c50  75 62 28 28 63 6f 70 79  72 69 67 68 74 2b 64 69  |ub((copyright+di|
00002c60  66 66 29 20 4d 4f 44 20  32 35 36 29 0d 20 20 32  |ff) MOD 256).  2|
00002c70  35 30 20 20 20 20 20 20  20 20 20 42 52 4b 0d 20  |50         BRK. |
00002c80  20 32 36 30 20 2e 74 69  74 6c 65 0d 20 20 32 37  | 260 .title.  27|
00002c90  30 20 20 20 20 20 20 20  20 20 4f 50 54 20 46 4e  |0         OPT FN|
00002ca0  65 71 75 73 28 22 43 59  43 4c 45 53 22 29 0d 20  |equs("CYCLES"). |
00002cb0  20 32 38 30 20 2e 63 6f  70 79 72 69 67 68 74 0d  | 280 .copyright.|
00002cc0  20 20 32 39 30 20 20 20  20 20 20 20 20 20 42 52  |  290         BR|
00002cd0  4b 0d 20 20 33 30 30 20  20 20 20 20 20 20 20 20  |K.  300         |
00002ce0  4f 50 54 20 46 4e 65 71  75 73 28 22 28 43 29 20  |OPT FNequs("(C) |
00002cf0  47 6f 72 64 6f 6e 20 48  6f 72 73 69 6e 67 74 6f  |Gordon Horsingto|
00002d00  6e 20 31 39 38 37 22 29  0d 20 20 33 31 30 20 20  |n 1987").  310  |
00002d10  20 20 20 20 20 20 20 42  52 4b 0d 20 20 33 32 30  |       BRK.  320|
00002d20  20 2e 73 65 72 76 69 63  65 0d 20 20 33 33 30 20  | .service.  330 |
00002d30  20 20 20 20 20 20 20 20  50 48 41 0d 20 20 33 34  |        PHA.  34|
00002d40  30 20 20 20 20 20 20 20  20 20 43 4d 50 20 23 32  |0         CMP #2|
00002d50  0d 20 20 33 35 30 20 20  20 20 20 20 20 20 20 42  |.  350         B|
00002d60  4e 45 20 74 72 79 66 6f  75 72 0d 20 20 33 36 30  |NE tryfour.  360|
00002d70  20 20 20 20 20 20 20 20  20 54 59 41 0d 20 20 33  |         TYA.  3|
00002d80  37 30 20 20 20 20 20 20  20 20 20 53 54 41 20 77  |70         STA w|
00002d90  6f 72 6b 73 70 61 63 65  2c 58 0d 20 20 33 38 30  |orkspace,X.  380|
00002da0  20 20 20 20 20 20 20 20  20 49 4e 59 0d 20 20 33  |         INY.  3|
00002db0  39 30 20 20 20 20 20 20  20 20 20 50 4c 41 0d 20  |90         PLA. |
00002dc0  20 34 30 30 20 20 20 20  20 20 20 20 20 52 54 53  | 400         RTS|
00002dd0  0d 20 20 34 31 30 20 2e  74 72 79 66 6f 75 72 0d  |.  410 .tryfour.|
00002de0  20 20 34 32 30 20 20 20  20 20 20 20 20 20 43 4d  |  420         CM|
00002df0  50 20 23 34 0d 20 20 34  33 30 20 20 20 20 20 20  |P #4.  430      |
00002e00  20 20 20 42 45 51 20 75  6e 72 65 63 6f 67 6e 69  |   BEQ unrecogni|
00002e10  73 65 64 0d 20 20 34 34  30 20 20 20 20 20 20 20  |sed.  440       |
00002e20  20 20 50 4c 41 0d 20 20  34 35 30 20 20 20 20 20  |  PLA.  450     |
00002e30  20 20 20 20 52 54 53 0d  20 20 34 36 30 20 2e 75  |    RTS.  460 .u|
00002e40  6e 72 65 63 6f 67 6e 69  73 65 64 0d 20 20 34 37  |nrecognised.  47|
00002e50  30 20 20 20 20 20 20 20  20 20 54 58 41 0d 20 20  |0         TXA.  |
00002e60  34 38 30 20 20 20 20 20  20 20 20 20 50 48 41 0d  |480         PHA.|
00002e70  20 20 34 39 30 20 20 20  20 20 20 20 20 20 54 59  |  490         TY|
00002e80  41 0d 20 20 35 30 30 20  20 20 20 20 20 20 20 20  |A.  500         |
00002e90  50 48 41 0d 20 20 35 31  30 20 20 20 20 20 20 20  |PHA.  510       |
00002ea0  20 20 4c 44 58 20 23 26  46 46 0d 20 20 35 32 30  |  LDX #&FF.  520|
00002eb0  20 2e 63 6f 6d 6c 6f 6f  70 0d 20 20 35 33 30 20  | .comloop.  530 |
00002ec0  20 20 20 20 20 20 20 20  49 4e 58 0d 20 20 35 34  |        INX.  54|
00002ed0  30 20 20 20 20 20 20 20  20 20 4c 44 41 20 74 69  |0         LDA ti|
00002ee0  74 6c 65 2b 64 69 66 66  2c 58 0d 20 20 35 35 30  |tle+diff,X.  550|
00002ef0  20 20 20 20 20 20 20 20  20 42 45 51 20 66 6f 75  |         BEQ fou|
00002f00  6e 64 0d 20 20 35 36 30  20 20 20 20 20 20 20 20  |nd.  560        |
00002f10  20 4c 44 41 20 28 63 6f  6d 76 65 63 29 2c 59 0d  | LDA (comvec),Y.|
00002f20  20 20 35 37 30 20 20 20  20 20 20 20 20 20 49 4e  |  570         IN|
00002f30  59 0d 20 20 35 38 30 20  20 20 20 20 20 20 20 20  |Y.  580         |
00002f40  43 4d 50 20 23 41 53 43  28 22 2e 22 29 0d 20 20  |CMP #ASC(".").  |
00002f50  35 39 30 20 20 20 20 20  20 20 20 20 42 45 51 20  |590         BEQ |
00002f60  66 6f 75 6e 64 0d 20 20  36 30 30 20 20 20 20 20  |found.  600     |
00002f70  20 20 20 20 41 4e 44 20  23 26 44 46 0d 20 20 36  |    AND #&DF.  6|
00002f80  31 30 20 20 20 20 20 20  20 20 20 43 4d 50 20 74  |10         CMP t|
00002f90  69 74 6c 65 2b 64 69 66  66 2c 58 0d 20 20 36 32  |itle+diff,X.  62|
00002fa0  30 20 20 20 20 20 20 20  20 20 42 45 51 20 63 6f  |0         BEQ co|
00002fb0  6d 6c 6f 6f 70 0d 20 20  36 33 30 20 20 20 20 20  |mloop.  630     |
00002fc0  20 20 20 20 50 4c 41 0d  20 20 36 34 30 20 20 20  |    PLA.  640   |
00002fd0  20 20 20 20 20 20 54 41  59 0d 20 20 36 35 30 20  |      TAY.  650 |
00002fe0  20 20 20 20 20 20 20 20  50 4c 41 0d 20 20 36 36  |        PLA.  66|
00002ff0  30 20 20 20 20 20 20 20  20 20 54 41 58 0d 20 20  |0         TAX.  |
00003000  36 37 30 20 20 20 20 20  20 20 20 20 50 4c 41 0d  |670         PLA.|
00003010  20 20 36 38 30 20 20 20  20 20 20 20 20 20 52 54  |  680         RT|
00003020  53 0d 20 20 36 39 30 20  2e 66 6f 75 6e 64 0d 20  |S.  690 .found. |
00003030  20 37 30 30 20 20 20 20  20 20 20 20 20 4c 44 41  | 700         LDA|
00003040  20 61 64 64 72 65 73 73  0d 20 20 37 31 30 20 20  | address.  710  |
00003050  20 20 20 20 20 20 20 50  48 41 0d 20 20 37 32 30  |       PHA.  720|
00003060  20 20 20 20 20 20 20 20  20 4c 44 41 20 61 64 64  |         LDA add|
00003070  72 65 73 73 2b 31 0d 20  20 37 33 30 20 20 20 20  |ress+1.  730    |
00003080  20 20 20 20 20 50 48 41  0d 20 20 37 34 30 20 20  |     PHA.  740  |
00003090  20 20 20 20 20 20 20 4c  44 41 20 23 30 0d 20 20  |       LDA #0.  |
000030a0  37 35 30 20 20 20 20 20  20 20 20 20 54 41 58 0d  |750         TAX.|
000030b0  20 20 37 36 30 20 20 20  20 20 20 20 20 20 54 41  |  760         TA|
000030c0  59 0d 20 20 37 37 30 20  20 20 20 20 20 20 20 20  |Y.  770         |
000030d0  4a 53 52 20 6f 73 61 72  67 73 0d 20 20 37 38 30  |JSR osargs.  780|
000030e0  20 20 20 20 20 20 20 20  20 43 4d 50 20 23 34 20  |         CMP #4 |
000030f0  20 20 20 20 20 20 20 5c  20 49 73 20 44 46 53 20  |       \ Is DFS |
00003100  61 63 74 69 76 65 3f 0d  20 20 37 39 30 20 20 20  |active?.  790   |
00003110  20 20 20 20 20 20 42 4e  45 20 65 72 72 6f 72 0d  |      BNE error.|
00003120  20 20 38 30 30 20 20 20  20 20 20 20 20 20 4c 44  |  800         LD|
00003130  58 20 72 6f 6d 6e 75 6d  62 65 72 0d 20 20 38 31  |X romnumber.  81|
00003140  30 20 20 20 20 20 20 20  20 20 4c 44 41 20 77 6f  |0         LDA wo|
00003150  72 6b 73 70 61 63 65 2c  58 20 5c 20 4d 53 42 20  |rkspace,X \ MSB |
00003160  6f 66 20 77 6f 72 6b 73  70 61 63 65 0d 20 20 38  |of workspace.  8|
00003170  32 30 20 20 20 20 20 20  20 20 20 53 54 41 20 61  |20         STA a|
00003180  64 64 72 65 73 73 2b 31  0d 20 20 38 33 30 20 20  |ddress+1.  830  |
00003190  20 20 20 20 20 20 20 54  41 59 20 20 20 20 20 20  |       TAY      |
000031a0  20 20 20 20 20 5c 20 4d  53 42 20 66 6f 72 20 4f  |     \ MSB for O|
000031b0  73 77 6f 72 64 0d 20 20  38 34 30 20 20 20 20 20  |sword.  840     |
000031c0  20 20 20 20 4c 44 58 20  23 30 20 20 20 20 20 20  |    LDX #0      |
000031d0  20 20 5c 20 4c 53 42 20  6f 66 20 77 6f 72 6b 73  |  \ LSB of works|
000031e0  70 61 63 65 0d 20 20 38  35 30 20 20 20 20 20 20  |pace.  850      |
000031f0  20 20 20 53 54 58 20 61  64 64 72 65 73 73 0d 20  |   STX address. |
00003200  20 38 36 30 20 20 20 20  20 20 20 20 20 4c 44 41  | 860         LDA|
00003210  20 23 26 37 44 0d 20 20  38 37 30 20 20 20 20 20  | #&7D.  870     |
00003220  20 20 20 20 4a 53 52 20  6f 73 77 6f 72 64 20 20  |    JSR osword  |
00003230  20 20 5c 20 52 65 61 64  20 64 69 73 63 20 63 79  |  \ Read disc cy|
00003240  63 6c 65 73 0d 20 20 38  38 30 20 20 20 20 20 20  |cles.  880      |
00003250  20 20 20 4c 44 59 20 23  30 0d 20 20 38 39 30 20  |   LDY #0.  890 |
00003260  20 20 20 20 20 20 20 20  4c 44 41 20 28 61 64 64  |        LDA (add|
00003270  72 65 73 73 29 2c 59 20  5c 20 52 65 61 64 20 72  |ress),Y \ Read r|
00003280  65 73 75 6c 74 0d 20 20  39 30 30 20 20 20 20 20  |esult.  900     |
00003290  20 20 20 20 4a 53 52 20  68 65 78 62 79 74 65 2b  |    JSR hexbyte+|
000032a0  64 69 66 66 0d 20 20 39  31 30 20 20 20 20 20 20  |diff.  910      |
000032b0  20 20 20 4c 44 58 20 23  26 46 46 0d 20 20 39 32  |   LDX #&FF.  92|
000032c0  30 20 2e 70 72 69 6e 74  6c 6f 6f 70 0d 20 20 39  |0 .printloop.  9|
000032d0  33 30 20 20 20 20 20 20  20 20 20 49 4e 58 0d 20  |30         INX. |
000032e0  20 39 34 30 20 20 20 20  20 20 20 20 20 4c 44 41  | 940         LDA|
000032f0  20 6d 65 73 73 61 67 65  2b 64 69 66 66 2c 58 0d  | message+diff,X.|
00003300  20 20 39 35 30 20 20 20  20 20 20 20 20 20 42 45  |  950         BE|
00003310  51 20 71 75 69 74 0d 20  20 39 36 30 20 20 20 20  |Q quit.  960    |
00003320  20 20 20 20 20 4a 53 52  20 6f 73 61 73 63 69 0d  |     JSR osasci.|
00003330  20 20 39 37 30 20 20 20  20 20 20 20 20 20 4a 4d  |  970         JM|
00003340  50 20 70 72 69 6e 74 6c  6f 6f 70 2b 64 69 66 66  |P printloop+diff|
00003350  0d 20 20 39 38 30 20 2e  71 75 69 74 0d 20 20 39  |.  980 .quit.  9|
00003360  39 30 20 20 20 20 20 20  20 20 20 50 4c 41 0d 20  |90         PLA. |
00003370  31 30 30 30 20 20 20 20  20 20 20 20 20 53 54 41  |1000         STA|
00003380  20 61 64 64 72 65 73 73  2b 31 0d 20 31 30 31 30  | address+1. 1010|
00003390  20 20 20 20 20 20 20 20  20 50 4c 41 0d 20 31 30  |         PLA. 10|
000033a0  32 30 20 20 20 20 20 20  20 20 20 53 54 41 20 61  |20         STA a|
000033b0  64 64 72 65 73 73 0d 20  31 30 33 30 20 20 20 20  |ddress. 1030    |
000033c0  20 20 20 20 20 50 4c 41  0d 20 31 30 34 30 20 20  |     PLA. 1040  |
000033d0  20 20 20 20 20 20 20 50  4c 41 0d 20 31 30 35 30  |       PLA. 1050|
000033e0  20 20 20 20 20 20 20 20  20 50 4c 41 0d 20 31 30  |         PLA. 10|
000033f0  36 30 20 20 20 20 20 20  20 20 20 4c 44 41 20 23  |60         LDA #|
00003400  30 0d 20 31 30 37 30 20  20 20 20 20 20 20 20 20  |0. 1070         |
00003410  52 54 53 0d 20 31 30 38  30 20 2e 65 72 72 6f 72  |RTS. 1080 .error|
00003420  0d 20 31 30 39 30 20 20  20 20 20 20 20 20 20 4c  |. 1090         L|
00003430  44 41 20 23 28 77 72 6f  6e 67 2b 64 69 66 66 29  |DA #(wrong+diff)|
00003440  20 4d 4f 44 20 32 35 36  0d 20 31 31 30 30 20 20  | MOD 256. 1100  |
00003450  20 20 20 20 20 20 20 53  54 41 20 61 64 64 72 65  |       STA addre|
00003460  73 73 0d 20 31 31 31 30  20 20 20 20 20 20 20 20  |ss. 1110        |
00003470  20 4c 44 41 20 23 28 77  72 6f 6e 67 2b 64 69 66  | LDA #(wrong+dif|
00003480  66 29 20 44 49 56 20 32  35 36 0d 20 31 31 32 30  |f) DIV 256. 1120|
00003490  20 20 20 20 20 20 20 20  20 53 54 41 20 61 64 64  |         STA add|
000034a0  72 65 73 73 2b 31 0d 20  31 31 33 30 20 20 20 20  |ress+1. 1130    |
000034b0  20 20 20 20 20 4c 44 59  20 23 26 46 46 0d 20 31  |     LDY #&FF. 1|
000034c0  31 34 30 20 2e 65 72 72  6f 72 6c 6f 6f 70 0d 20  |140 .errorloop. |
000034d0  31 31 35 30 20 20 20 20  20 20 20 20 20 49 4e 59  |1150         INY|
000034e0  0d 20 31 31 36 30 20 20  20 20 20 20 20 20 20 4c  |. 1160         L|
000034f0  44 41 20 28 61 64 64 72  65 73 73 29 2c 59 0d 20  |DA (address),Y. |
00003500  31 31 37 30 20 20 20 20  20 20 20 20 20 53 54 41  |1170         STA|
00003510  20 65 72 72 73 74 61 63  6b 2c 59 0d 20 31 31 38  | errstack,Y. 118|
00003520  30 20 20 20 20 20 20 20  20 20 42 50 4c 20 65 72  |0         BPL er|
00003530  72 6f 72 6c 6f 6f 70 0d  20 31 31 39 30 20 20 20  |rorloop. 1190   |
00003540  20 20 20 20 20 20 50 4c  41 0d 20 31 32 30 30 20  |      PLA. 1200 |
00003550  20 20 20 20 20 20 20 20  53 54 41 20 61 64 64 72  |        STA addr|
00003560  65 73 73 2b 31 0d 20 31  32 31 30 20 20 20 20 20  |ess+1. 1210     |
00003570  20 20 20 20 50 4c 41 0d  20 31 32 32 30 20 20 20  |    PLA. 1220   |
00003580  20 20 20 20 20 20 53 54  41 20 61 64 64 72 65 73  |      STA addres|
00003590  73 0d 20 31 32 33 30 20  20 20 20 20 20 20 20 20  |s. 1230         |
000035a0  4a 4d 50 20 65 72 72 73  74 61 63 6b 0d 20 31 32  |JMP errstack. 12|
000035b0  34 30 20 2e 68 65 78 62  79 74 65 0d 20 31 32 35  |40 .hexbyte. 125|
000035c0  30 20 20 20 20 20 20 20  20 20 50 48 41 0d 20 31  |0         PHA. 1|
000035d0  32 36 30 20 20 20 20 20  20 20 20 20 4c 53 52 20  |260         LSR |
000035e0  41 0d 20 31 32 37 30 20  20 20 20 20 20 20 20 20  |A. 1270         |
000035f0  4c 53 52 20 41 0d 20 31  32 38 30 20 20 20 20 20  |LSR A. 1280     |
00003600  20 20 20 20 4c 53 52 20  41 0d 20 31 32 39 30 20  |    LSR A. 1290 |
00003610  20 20 20 20 20 20 20 20  4c 53 52 20 41 0d 20 31  |        LSR A. 1|
00003620  33 30 30 20 20 20 20 20  20 20 20 20 4a 53 52 20  |300         JSR |
00003630  6e 79 62 62 6c 65 2b 64  69 66 66 0d 20 31 33 31  |nybble+diff. 131|
00003640  30 20 20 20 20 20 20 20  20 20 50 4c 41 0d 20 31  |0         PLA. 1|
00003650  33 32 30 20 2e 6e 79 62  62 6c 65 0d 20 31 33 33  |320 .nybble. 133|
00003660  30 20 20 20 20 20 20 20  20 20 41 4e 44 20 23 26  |0         AND #&|
00003670  30 46 0d 20 31 33 34 30  20 20 20 20 20 20 20 20  |0F. 1340        |
00003680  20 53 45 44 0d 20 31 33  35 30 20 20 20 20 20 20  | SED. 1350      |
00003690  20 20 20 43 4c 43 0d 20  31 33 36 30 20 20 20 20  |   CLC. 1360    |
000036a0  20 20 20 20 20 41 44 43  20 23 26 39 30 0d 20 31  |     ADC #&90. 1|
000036b0  33 37 30 20 20 20 20 20  20 20 20 20 41 44 43 20  |370         ADC |
000036c0  23 26 34 30 0d 20 31 33  38 30 20 20 20 20 20 20  |#&40. 1380      |
000036d0  20 20 20 43 4c 44 0d 20  31 33 39 30 20 20 20 20  |   CLD. 1390    |
000036e0  20 20 20 20 20 4a 4d 50  20 6f 73 61 73 63 69 0d  |     JMP osasci.|
000036f0  20 31 34 30 30 20 2e 6d  65 73 73 61 67 65 0d 20  | 1400 .message. |
00003700  31 34 31 30 20 20 20 20  20 20 20 20 20 4f 50 54  |1410         OPT|
00003710  20 46 4e 65 71 75 73 28  22 20 44 69 73 63 20 63  | FNequs(" Disc c|
00003720  79 63 6c 65 73 22 29 0d  20 31 34 32 30 20 20 20  |ycles"). 1420   |
00003730  20 20 20 20 20 20 4f 50  54 20 46 4e 65 71 75 62  |      OPT FNequb|
00003740  28 26 30 44 29 0d 20 31  34 33 30 20 20 20 20 20  |(&0D). 1430     |
00003750  20 20 20 20 42 52 4b 0d  20 31 34 34 30 20 2e 77  |    BRK. 1440 .w|
00003760  72 6f 6e 67 0d 20 31 34  35 30 20 20 20 20 20 20  |rong. 1450      |
00003770  20 20 20 42 52 4b 0d 20  31 34 36 30 20 20 20 20  |   BRK. 1460    |
00003780  20 20 20 20 20 42 52 4b  0d 20 31 34 37 30 20 20  |     BRK. 1470  |
00003790  20 20 20 20 20 20 20 4f  50 54 20 46 4e 65 71 75  |       OPT FNequ|
000037a0  73 28 22 44 46 53 20 6e  6f 74 20 61 63 74 69 76  |s("DFS not activ|
000037b0  65 22 29 0d 20 31 34 38  30 20 20 20 20 20 20 20  |e"). 1480       |
000037c0  20 20 42 52 4b 0d 20 31  34 39 30 20 20 20 20 20  |  BRK. 1490     |
000037d0  20 20 20 20 4f 50 54 20  46 4e 65 71 75 62 28 26  |    OPT FNequb(&|
000037e0  46 46 29 0d 20 31 35 30  30 20 2e 6c 61 73 74 62  |FF). 1500 .lastb|
000037f0  79 74 65 0d 20 31 35 31  30 20 5d 0d 20 31 35 32  |yte. 1510 ]. 152|
00003800  30 20 4e 45 58 54 0d 20  31 35 33 30 20 49 4e 50  |0 NEXT. 1530 INP|
00003810  55 54 27 22 53 61 76 65  20 66 69 6c 65 6e 61 6d  |UT'"Save filenam|
00003820  65 20 3d 20 22 66 69 6c  65 6e 61 6d 65 24 0d 20  |e = "filename$. |
00003830  31 35 34 30 20 49 46 20  66 69 6c 65 6e 61 6d 65  |1540 IF filename|
00003840  24 3d 22 22 20 45 4e 44  0d 20 31 35 35 30 20 24  |$="" END. 1550 $|
00003850  73 61 76 65 3d 22 53 41  56 45 20 22 2b 66 69 6c  |save="SAVE "+fil|
00003860  65 6e 61 6d 65 24 2b 22  20 22 2b 53 54 52 24 7e  |ename$+" "+STR$~|
00003870  28 48 49 4d 45 4d 29 2b  22 20 22 2b 53 54 52 24  |(HIMEM)+" "+STR$|
00003880  7e 28 6c 61 73 0d 20 20  20 20 20 20 74 62 79 74  |~(las.      tbyt|
00003890  65 29 2b 22 20 46 46 46  46 38 30 30 30 20 46 46  |e)+" FFFF8000 FF|
000038a0  46 46 38 30 30 30 22 0d  20 31 35 36 30 20 58 25  |FF8000". 1560 X%|
000038b0  3d 73 61 76 65 20 4d 4f  44 20 32 35 36 0d 20 31  |=save MOD 256. 1|
000038c0  35 37 30 20 59 25 3d 73  61 76 65 20 44 49 56 20  |570 Y%=save DIV |
000038d0  32 35 36 0d 20 31 35 38  30 20 2a 4f 50 54 31 2c  |256. 1580 *OPT1,|
000038e0  32 0d 20 31 35 39 30 20  43 41 4c 4c 20 6f 73 63  |2. 1590 CALL osc|
000038f0  6c 69 0d 20 31 36 30 30  20 2a 4f 50 54 31 2c 30  |li. 1600 *OPT1,0|
00003900  0d 20 31 36 31 30 20 45  4e 44 0d 20 31 36 32 30  |. 1610 END. 1620|
00003910  20 44 45 46 46 4e 65 71  75 62 28 62 79 74 65 29  | DEFFNequb(byte)|
00003920  0d 20 31 36 33 30 20 3f  50 25 3d 62 79 74 65 0d  |. 1630 ?P%=byte.|
00003930  20 31 36 34 30 20 50 25  3d 50 25 2b 31 0d 20 31  | 1640 P%=P%+1. 1|
00003940  36 35 30 20 3d 70 61 73  73 0d 20 31 36 36 30 20  |650 =pass. 1660 |
00003950  44 45 46 46 4e 65 71 75  77 28 77 6f 72 64 29 0d  |DEFFNequw(word).|
00003960  20 31 36 37 30 20 3f 50  25 3d 77 6f 72 64 20 4d  | 1670 ?P%=word M|
00003970  4f 44 20 32 35 36 0d 20  31 36 38 30 20 50 25 3f  |OD 256. 1680 P%?|
00003980  31 3d 77 6f 72 64 20 44  49 56 20 32 35 36 0d 20  |1=word DIV 256. |
00003990  31 36 39 30 20 50 25 3d  50 25 2b 32 0d 20 31 37  |1690 P%=P%+2. 17|
000039a0  30 30 20 3d 70 61 73 73  0d 20 31 37 31 30 20 44  |00 =pass. 1710 D|
000039b0  45 46 46 4e 65 71 75 64  28 64 6f 75 62 6c 65 29  |EFFNequd(double)|
000039c0  0d 20 31 37 32 30 20 21  50 25 3d 64 6f 75 62 6c  |. 1720 !P%=doubl|
000039d0  65 0d 20 31 37 33 30 20  50 25 3d 50 25 2b 34 0d  |e. 1730 P%=P%+4.|
000039e0  20 31 37 34 30 20 3d 70  61 73 73 0d 20 31 37 35  | 1740 =pass. 175|
000039f0  30 20 44 45 46 46 4e 65  71 75 73 28 73 74 72 69  |0 DEFFNequs(stri|
00003a00  6e 67 24 29 0d 20 31 37  36 30 20 24 50 25 3d 73  |ng$). 1760 $P%=s|
00003a10  74 72 69 6e 67 24 0d 20  31 37 37 30 20 50 25 3d  |tring$. 1770 P%=|
00003a20  50 25 2b 4c 45 4e 28 73  74 72 69 6e 67 24 29 0d  |P%+LEN(string$).|
00003a30  20 31 37 38 30 20 3d 70  61 73 73 0d 0d 0d 0d 0d  | 1780 =pass.....|
00003a40  20 20 54 68 65 20 74 65  63 68 6e 69 71 75 65 73  |  The techniques|
00003a50  20 69 6c 6c 75 73 74 72  61 74 65 64 20 69 6e 20  | illustrated in |
00003a60  66 69 67 75 72 65 73 20  31 31 2e 32 20 61 6e 64  |figures 11.2 and|
00003a70  20 31 31 2e 33 20 61 6e  64 20 64 65 6d 6f 6e 73  | 11.3 and demons|
00003a80  74 72 61 74 65 64 0d 69  6e 20 74 68 65 20 70 72  |trated.in the pr|
00003a90  6f 67 72 61 6d 20 50 52  49 56 41 54 45 20 6e 65  |ogram PRIVATE ne|
00003aa0  65 64 20 74 6f 20 62 65  20 6d 6f 64 69 66 69 65  |ed to be modifie|
00003ab0  64 20 74 6f 20 75 73 65  20 74 68 65 20 61 6c 74  |d to use the alt|
00003ac0  65 72 6e 61 74 69 76 65  0d 70 61 67 65 64 20 6d  |ernative.paged m|
00003ad0  65 6d 6f 72 79 20 70 72  69 76 61 74 65 20 77 6f  |emory private wo|
00003ae0  72 6b 73 70 61 63 65 20  61 76 61 69 6c 61 62 6c  |rkspace availabl|
00003af0  65 20 69 6e 20 74 68 65  20 4d 61 73 74 65 72 20  |e in the Master |
00003b00  73 65 72 69 65 73 20 6f  66 0d 63 6f 6d 70 75 74  |series of.comput|
00003b10  65 72 73 2e 0d 0d 20 20  49 6e 20 4d 6f 64 75 6c  |ers...  In Modul|
00003b20  65 20 31 20 6f 66 20 74  68 65 20 63 6f 75 72 73  |e 1 of the cours|
00003b30  65 20 49 20 65 78 70 6c  61 69 6e 65 64 20 68 6f  |e I explained ho|
00003b40  77 20 73 65 74 74 69 6e  67 20 62 69 74 20 33 20  |w setting bit 3 |
00003b50  6f 66 20 74 68 65 20 70  61 67 65 64 0d 6d 65 6d  |of the paged.mem|
00003b60  6f 72 79 20 73 65 6c 65  63 74 20 72 65 67 69 73  |ory select regis|
00003b70  74 65 72 20 61 74 20 26  46 45 33 34 20 63 61 6e  |ter at &FE34 can|
00003b80  20 62 65 20 75 73 65 64  20 74 6f 20 6f 76 65 72  | be used to over|
00003b90  6c 61 79 20 74 68 65 20  70 61 67 65 64 0d 6d 65  |lay the paged.me|
00003ba0  6d 6f 72 79 20 66 72 6f  6d 20 26 43 30 30 30 20  |mory from &C000 |
00003bb0  74 6f 20 26 44 46 46 46  20 6f 6e 74 6f 20 74 68  |to &DFFF onto th|
00003bc0  65 20 4d 4f 53 20 73 6f  20 74 68 61 74 20 69 74  |e MOS so that it|
00003bd0  20 61 70 70 65 61 72 73  20 61 62 6f 76 65 20 74  | appears above t|
00003be0  68 65 0d 63 75 72 72 65  6e 74 6c 79 20 73 65 6c  |he.currently sel|
00003bf0  65 63 74 65 64 20 70 61  67 65 64 20 72 6f 6d 2e  |ected paged rom.|
00003c00  20 54 68 65 20 70 61 67  65 64 20 6d 65 6d 6f 72  | The paged memor|
00003c10  79 20 70 72 69 76 61 74  65 20 77 6f 72 6b 73 70  |y private worksp|
00003c20  61 63 65 20 69 73 0d 61  76 61 69 6c 61 62 6c 65  |ace is.available|
00003c30  20 69 6e 20 74 68 69 73  20 61 72 65 61 20 6f 66  | in this area of|
00003c40  20 70 61 67 65 64 20 6d  65 6d 6f 72 79 2e 0d 0d  | paged memory...|
00003c50  20 20 54 68 65 20 4d 61  73 74 65 72 20 75 73 65  |  The Master use|
00003c60  73 20 73 65 72 76 69 63  65 20 63 61 6c 6c 20 26  |s service call &|
00003c70  32 34 20 74 6f 20 67 69  76 65 20 74 68 65 20 72  |24 to give the r|
00003c80  6f 6d 73 20 74 68 65 20  6f 70 70 6f 72 74 75 6e  |oms the opportun|
00003c90  69 74 79 20 74 6f 0d 72  65 71 75 65 73 74 20 70  |ity to.request p|
00003ca0  61 67 65 64 20 70 72 69  76 61 74 65 20 77 6f 72  |aged private wor|
00003cb0  6b 73 70 61 63 65 20 66  6f 6c 6c 6f 77 65 64 20  |kspace followed |
00003cc0  62 79 20 73 65 72 76 69  63 65 20 63 61 6c 6c 20  |by service call |
00003cd0  26 32 32 20 74 6f 20 63  6c 61 69 6d 0d 74 68 65  |&22 to claim.the|
00003ce0  20 72 65 71 75 65 73 74  65 64 20 70 61 67 65 64  | requested paged|
00003cf0  20 70 72 69 76 61 74 65  20 77 6f 72 6b 73 70 61  | private workspa|
00003d00  63 65 2e 20 54 68 65 20  63 6f 64 69 6e 67 20 69  |ce. The coding i|
00003d10  6e 20 66 69 67 75 72 65  20 31 31 2e 32 20 61 6e  |n figure 11.2 an|
00003d20  64 0d 31 31 2e 33 20 6e  65 65 64 73 20 74 6f 20  |d.11.3 needs to |
00003d30  62 65 20 6d 6f 64 69 66  69 65 64 20 61 73 20 73  |be modified as s|
00003d40  68 6f 77 6e 20 69 6e 20  66 69 67 75 72 65 73 20  |hown in figures |
00003d50  31 31 2e 34 20 61 6e 64  20 31 31 2e 35 20 69 66  |11.4 and 11.5 if|
00003d60  20 79 6f 75 72 0d 4d 61  73 74 65 72 20 53 57 52  | your.Master SWR|
00003d70  20 70 72 6f 67 72 61 6d  20 6e 65 65 64 73 20 74  | program needs t|
00003d80  6f 20 75 73 65 20 70 61  67 65 64 20 70 72 69 76  |o use paged priv|
00003d90  61 74 65 20 77 6f 72 6b  73 70 61 63 65 2e 0d 0d  |ate workspace...|
00003da0  0d 0d 0d 20 20 2e 73 65  72 76 69 63 65 0d 20 20  |...  .service.  |
00003db0  20 20 20 20 20 20 20 43  4d 50 20 23 26 32 34 20  |       CMP #&24 |
00003dc0  20 20 20 20 20 20 20 5c  20 69 73 20 69 74 20 73  |       \ is it s|
00003dd0  65 72 76 69 63 65 20 63  61 6c 6c 20 26 32 34 3f  |ervice call &24?|
00003de0  0d 20 20 20 20 20 20 20  20 20 42 4e 45 20 74 72  |.         BNE tr|
00003df0  79 32 32 20 20 20 20 20  20 20 5c 20 62 72 61 6e  |y22       \ bran|
00003e00  63 68 20 69 66 20 6e 6f  74 20 26 32 34 0d 20 20  |ch if not &24.  |
00003e10  20 20 20 20 20 20 20 49  4e 59 20 20 20 20 20 20  |       INY      |
00003e20  20 20 20 20 20 20 20 5c  20 72 65 71 75 65 73 74  |       \ request|
00003e30  20 31 20 70 61 67 65 20  6f 66 20 77 6f 72 6b 73  | 1 page of works|
00003e40  70 61 63 65 0d 20 20 20  20 20 20 20 20 20 52 54  |pace.         RT|
00003e50  53 20 20 20 20 20 20 20  20 20 20 20 20 20 5c 20  |S             \ |
00003e60  61 6e 64 20 72 65 74 75  72 6e 0d 2e 74 72 79 32  |and return..try2|
00003e70  32 0d 20 20 20 20 20 20  20 20 20 43 4d 50 20 23  |2.         CMP #|
00003e80  26 32 32 20 20 20 20 20  20 20 20 5c 20 69 73 20  |&22        \ is |
00003e90  69 74 20 73 65 72 76 69  63 65 20 63 61 6c 6c 20  |it service call |
00003ea0  26 32 32 3f 0d 20 20 20  20 20 20 20 20 20 42 4e  |&22?.         BN|
00003eb0  45 20 6e 6f 74 32 32 20  20 20 20 20 20 20 5c 20  |E not22       \ |
00003ec0  62 72 61 6e 63 68 20 69  66 20 6e 6f 74 20 26 32  |branch if not &2|
00003ed0  32 0d 20 20 20 20 20 20  20 20 20 50 48 41 20 20  |2.         PHA  |
00003ee0  20 20 20 20 20 20 20 20  20 20 20 5c 20 70 75 73  |           \ pus|
00003ef0  68 20 61 63 63 75 6d 75  6c 61 74 6f 72 20 6f 6e  |h accumulator on|
00003f00  20 73 74 61 63 6b 0d 20  20 20 20 20 20 20 20 20  | stack.         |
00003f10  54 59 41 20 20 20 20 20  20 20 20 20 20 20 20 20  |TYA             |
00003f20  5c 20 70 72 65 70 61 72  65 20 74 6f 20 73 74 6f  |\ prepare to sto|
00003f30  72 65 20 73 74 61 72 74  20 6f 66 20 77 6f 72 6b  |re start of work|
00003f40  73 70 61 63 65 0d 20 20  20 20 20 20 20 20 20 53  |space.         S|
00003f50  54 41 20 26 44 46 30 2c  58 20 20 20 20 20 20 5c  |TA &DF0,X      \|
00003f60  20 73 74 6f 72 65 20 73  74 61 72 74 20 6f 66 20  | store start of |
00003f70  77 6f 72 6b 73 70 61 63  65 0d 20 20 20 20 20 20  |workspace.      |
00003f80  20 20 20 50 4c 41 20 20  20 20 20 20 20 20 20 20  |   PLA          |
00003f90  20 20 20 5c 20 72 65 73  74 6f 72 65 20 61 63 63  |   \ restore acc|
00003fa0  75 6d 75 6c 61 74 6f 72  0d 20 20 20 20 20 20 20  |umulator.       |
00003fb0  20 20 52 54 53 20 20 20  20 20 20 20 20 20 20 20  |  RTS           |
00003fc0  20 20 5c 20 72 65 74 75  72 6e 20 74 6f 20 4d 4f  |  \ return to MO|
00003fd0  53 0d 20 20 2e 6e 6f 74  32 32 0d 0d 0d 46 69 67  |S.  .not22...Fig|
00003fe0  75 72 65 20 31 31 2e 34  20 20 43 6c 61 69 6d 69  |ure 11.4  Claimi|
00003ff0  6e 67 20 70 61 67 65 64  20 70 72 69 76 61 74 65  |ng paged private|
00004000  20 77 6f 72 6b 73 70 61  63 65 20 6f 6e 20 74 68  | workspace on th|
00004010  65 20 4d 61 73 74 65 72  2e 0d 2d 2d 2d 2d 2d 2d  |e Master..------|
00004020  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00004050  2d 2d 2d 2d 2d 2d 0d 0d  0d 0d 20 20 43 6c 61 69  |------....  Clai|
00004060  6d 69 6e 67 20 70 61 67  65 64 20 6d 65 6d 6f 72  |ming paged memor|
00004070  79 20 70 72 69 76 61 74  65 20 77 6f 72 6b 73 70  |y private worksp|
00004080  61 63 65 20 69 73 20 61  20 62 69 74 20 6d 6f 72  |ace is a bit mor|
00004090  65 20 69 6e 76 6f 6c 76  65 64 20 74 68 61 6e 0d  |e involved than.|
000040a0  63 6c 61 69 6d 69 6e 67  20 70 72 69 76 61 74 65  |claiming private|
000040b0  20 77 6f 72 6b 73 70 61  63 65 20 69 6e 20 75 73  | workspace in us|
000040c0  65 72 20 6d 65 6d 6f 72  79 2e 20 59 6f 75 72 20  |er memory. Your |
000040d0  4d 61 73 74 65 72 20 53  57 52 20 70 72 6f 67 72  |Master SWR progr|
000040e0  61 6d 20 68 61 73 0d 74  6f 20 69 6e 74 65 72 63  |am has.to interc|
000040f0  65 70 74 20 73 65 72 76  69 63 65 20 63 61 6c 6c  |ept service call|
00004100  73 20 26 32 34 20 61 6e  64 20 26 32 32 20 69 6e  |s &24 and &22 in|
00004110  73 74 65 61 64 20 6f 66  20 73 65 72 76 69 63 65  |stead of service|
00004120  20 63 61 6c 6c 20 32 2e  0d 53 65 72 76 69 63 65  | call 2..Service|
00004130  20 63 61 6c 6c 73 20 26  32 34 20 61 6e 64 20 26  | calls &24 and &|
00004140  32 32 20 61 72 65 20 6e  6f 74 20 69 73 73 75 65  |22 are not issue|
00004150  64 20 6f 6e 20 74 68 65  20 42 42 43 20 42 2e 0d  |d on the BBC B..|
00004160  0d 20 20 49 6e 74 65 72  63 65 70 74 69 6e 67 20  |.  Intercepting |
00004170  73 65 72 76 69 63 65 20  63 61 6c 6c 73 20 26 32  |service calls &2|
00004180  34 20 61 6e 64 20 26 32  32 20 69 73 20 69 6c 6c  |4 and &22 is ill|
00004190  75 73 74 72 61 74 65 64  20 69 6e 20 66 69 67 75  |ustrated in figu|
000041a0  72 65 0d 31 31 2e 34 2e  20 49 66 20 79 6f 75 72  |re.11.4. If your|
000041b0  20 53 57 52 20 70 72 6f  67 72 61 6d 20 75 73 65  | SWR program use|
000041c0  73 20 70 61 67 65 64 20  70 72 69 76 61 74 65 20  |s paged private |
000041d0  77 6f 72 6b 73 70 61 63  65 20 69 74 20 6d 75 73  |workspace it mus|
000041e0  74 20 75 73 65 0d 73 65  72 76 69 63 65 20 63 61  |t use.service ca|
000041f0  6c 6c 20 26 32 32 20 74  6f 20 63 6c 61 69 6d 20  |ll &22 to claim |
00004200  6f 6e 6c 79 20 74 68 65  20 6e 75 6d 62 65 72 20  |only the number |
00004210  6f 66 20 70 61 67 65 73  20 72 65 71 75 65 73 74  |of pages request|
00004220  65 64 20 77 69 74 68 0d  73 65 72 76 69 63 65 20  |ed with.service |
00004230  63 61 6c 6c 20 26 32 34  2e 20 54 68 65 20 61 6d  |call &24. The am|
00004240  6f 75 6e 74 20 6f 66 20  63 6c 61 69 6d 65 64 20  |ount of claimed |
00004250  70 61 67 65 64 20 70 72  69 76 61 74 65 20 77 6f  |paged private wo|
00004260  72 6b 73 70 61 63 65 20  6d 75 73 74 0d 61 67 72  |rkspace must.agr|
00004270  65 65 20 77 69 74 68 20  74 68 65 20 61 6d 6f 75  |ee with the amou|
00004280  6e 74 20 6f 66 20 72 65  71 75 65 73 74 65 64 20  |nt of requested |
00004290  70 61 67 65 64 20 70 72  69 76 61 74 65 20 77 6f  |paged private wo|
000042a0  72 6b 73 70 61 63 65 2e  0d 0d 20 20 41 20 4d 61  |rkspace...  A Ma|
000042b0  73 74 65 72 20 53 57 52  20 70 72 6f 67 72 61 6d  |ster SWR program|
000042c0  20 6d 75 73 74 20 6e 6f  74 20 75 73 65 20 62 6f  | must not use bo|
000042d0  74 68 20 73 65 72 76 69  63 65 20 63 61 6c 6c 20  |th service call |
000042e0  32 20 61 6e 64 20 73 65  72 76 69 63 65 0d 63 61  |2 and service.ca|
000042f0  6c 6c 73 20 26 32 34 20  61 6e 64 20 26 32 32 20  |lls &24 and &22 |
00004300  74 6f 20 63 6c 61 69 6d  20 70 72 69 76 61 74 65  |to claim private|
00004310  20 77 6f 72 6b 73 70 61  63 65 2e 20 59 6f 75 20  | workspace. You |
00004320  73 68 6f 75 6c 64 20 61  6c 73 6f 20 62 65 20 61  |should also be a|
00004330  77 61 72 65 0d 74 68 61  74 2c 20 69 66 20 79 6f  |ware.that, if yo|
00004340  75 20 75 73 65 20 73 65  72 76 69 63 65 20 63 61  |u use service ca|
00004350  6c 6c 73 20 26 32 34 20  61 6e 64 20 26 32 32 20  |lls &24 and &22 |
00004360  74 6f 20 72 65 71 75 65  73 74 20 61 6e 64 20 63  |to request and c|
00004370  6c 61 69 6d 20 6d 6f 72  65 0d 70 61 67 65 64 20  |laim more.paged |
00004380  70 72 69 76 61 74 65 20  77 6f 72 6b 73 70 61 63  |private workspac|
00004390  65 20 74 68 61 6e 20 69  73 20 61 76 61 69 6c 61  |e than is availa|
000043a0  62 6c 65 20 69 6e 20 74  68 65 20 70 61 67 65 64  |ble in the paged|
000043b0  20 6d 65 6d 6f 72 79 2c  20 70 72 69 76 61 74 65  | memory, private|
000043c0  0d 77 6f 72 6b 73 70 61  63 65 20 77 69 6c 6c 20  |.workspace will |
000043d0  62 65 20 63 6c 61 69 6d  65 64 20 66 72 6f 6d 20  |be claimed from |
000043e0  75 73 65 72 20 6d 65 6d  6f 72 79 20 73 74 61 72  |user memory star|
000043f0  74 69 6e 67 20 61 74 20  26 45 30 30 2e 20 54 68  |ting at &E00. Th|
00004400  69 73 20 68 61 73 0d 74  68 65 20 65 66 66 65 63  |is has.the effec|
00004410  74 20 6f 66 20 72 61 69  73 69 6e 67 20 4f 73 68  |t of raising Osh|
00004420  77 6d 20 61 6e 64 20 50  41 47 45 20 65 76 65 6e  |wm and PAGE even|
00004430  20 77 68 65 6e 20 70 61  67 65 64 20 70 72 69 76  | when paged priv|
00004440  61 74 65 20 77 6f 72 6b  73 70 61 63 65 0d 69 73  |ate workspace.is|
00004450  20 72 65 71 75 65 73 74  65 64 20 61 6e 64 20 63  | requested and c|
00004460  6c 61 69 6d 65 64 2e 0d  0d 20 20 55 73 69 6e 67  |laimed...  Using|
00004470  20 70 61 67 65 64 20 6d  65 6d 6f 72 79 20 70 72  | paged memory pr|
00004480  69 76 61 74 65 20 77 6f  72 6b 73 70 61 63 65 20  |ivate workspace |
00004490  69 6e 20 74 68 65 20 4d  61 73 74 65 72 20 69 73  |in the Master is|
000044a0  20 61 20 62 69 74 20 6d  6f 72 65 0d 63 6f 6d 70  | a bit more.comp|
000044b0  6c 69 63 61 74 65 64 20  74 68 61 6e 20 63 6c 61  |licated than cla|
000044c0  69 6d 69 6e 67 20 69 74  2e 20 42 65 66 6f 72 65  |iming it. Before|
000044d0  20 61 74 74 65 6d 70 74  69 6e 67 20 74 6f 20 72  | attempting to r|
000044e0  65 61 64 20 6f 72 20 77  72 69 74 65 20 74 68 65  |ead or write the|
000044f0  0d 63 6f 6e 74 65 6e 74  73 20 6f 66 20 74 68 65  |.contents of the|
00004500  20 70 61 67 65 64 20 70  72 69 76 61 74 65 20 77  | paged private w|
00004510  6f 72 6b 73 70 61 63 65  2c 20 74 68 65 20 53 57  |orkspace, the SW|
00004520  52 20 70 72 6f 67 72 61  6d 20 6d 75 73 74 20 66  |R program must f|
00004530  69 72 73 74 0d 73 65 74  20 62 69 74 20 33 20 6f  |irst.set bit 3 o|
00004540  66 20 74 68 65 20 70 61  67 65 64 20 6d 65 6d 6f  |f the paged memo|
00004550  72 79 20 73 65 6c 65 63  74 20 72 65 67 69 73 74  |ry select regist|
00004560  65 72 20 61 74 20 26 46  45 33 34 20 74 6f 20 73  |er at &FE34 to s|
00004570  77 69 74 63 68 20 74 68  65 0d 70 61 67 65 64 20  |witch the.paged |
00004580  6d 65 6d 6f 72 79 20 69  6e 74 6f 20 74 68 65 20  |memory into the |
00004590  6d 61 69 6e 20 6d 65 6d  6f 72 79 20 6d 61 70 2e  |main memory map.|
000045a0  20 54 6f 20 73 65 74 20  62 69 74 20 33 20 6f 66  | To set bit 3 of|
000045b0  20 26 46 45 33 34 20 6c  6f 61 64 20 74 68 65 0d  | &FE34 load the.|
000045c0  61 63 63 75 6d 75 6c 61  74 6f 72 20 77 69 74 68  |accumulator with|
000045d0  20 26 30 38 20 28 30 30  30 30 20 31 30 30 30 20  | &08 (0000 1000 |
000045e0  62 69 6e 61 72 79 29 2c  20 4f 52 20 74 68 65 20  |binary), OR the |
000045f0  61 63 63 75 6d 75 6c 61  74 6f 72 20 77 69 74 68  |accumulator with|
00004600  20 74 68 65 0d 63 6f 6e  74 65 6e 74 73 20 6f 66  | the.contents of|
00004610  20 26 46 45 33 34 20 61  6e 64 20 73 74 6f 72 65  | &FE34 and store|
00004620  20 74 68 65 20 61 63 63  75 6d 75 6c 61 74 6f 72  | the accumulator|
00004630  20 69 6e 20 26 46 45 33  34 2e 0d 0d 20 20 54 6f  | in &FE34...  To|
00004640  20 73 77 69 74 63 68 20  74 68 65 20 70 61 67 65  | switch the page|
00004650  64 20 70 72 69 76 61 74  65 20 77 6f 72 6b 73 70  |d private worksp|
00004660  61 63 65 20 6f 75 74 20  6f 66 20 74 68 65 20 6d  |ace out of the m|
00004670  61 69 6e 20 6d 65 6d 6f  72 79 20 6d 61 70 20 69  |ain memory map i|
00004680  74 0d 69 73 20 6e 65 63  65 73 73 61 72 79 20 74  |t.is necessary t|
00004690  6f 20 63 6c 65 61 72 20  62 69 74 20 33 20 6f 66  |o clear bit 3 of|
000046a0  20 74 68 65 20 70 61 67  65 64 20 6d 65 6d 6f 72  | the paged memor|
000046b0  79 20 73 65 6c 65 63 74  20 72 65 67 69 73 74 65  |y select registe|
000046c0  72 2e 20 54 6f 0d 63 6c  65 61 72 20 62 69 74 20  |r. To.clear bit |
000046d0  33 20 6f 66 20 26 46 45  33 34 20 6c 6f 61 64 20  |3 of &FE34 load |
000046e0  74 68 65 20 61 63 63 75  6d 75 6c 61 74 6f 72 20  |the accumulator |
000046f0  77 69 74 68 20 26 46 37  20 28 31 31 31 31 20 30  |with &F7 (1111 0|
00004700  31 31 31 20 62 69 6e 61  72 79 29 2c 0d 41 4e 44  |111 binary),.AND|
00004710  20 74 68 65 20 61 63 63  75 6d 75 6c 61 74 6f 72  | the accumulator|
00004720  20 77 69 74 68 20 74 68  65 20 63 6f 6e 74 65 6e  | with the conten|
00004730  74 73 20 6f 66 20 26 46  45 33 34 20 61 6e 64 20  |ts of &FE34 and |
00004740  73 74 6f 72 65 20 74 68  65 0d 61 63 63 75 6d 75  |store the.accumu|
00004750  6c 61 74 6f 72 20 69 6e  20 26 46 45 33 34 2e 20  |lator in &FE34. |
00004760  49 66 20 79 6f 75 20 75  73 65 20 74 68 65 20 73  |If you use the s|
00004770  75 62 72 6f 75 74 69 6e  65 73 20 69 6c 6c 75 73  |ubroutines illus|
00004780  74 72 61 74 65 64 20 69  6e 20 66 69 67 75 72 65  |trated in figure|
00004790  0d 31 31 2e 35 20 74 68  65 20 70 61 67 65 64 20  |.11.5 the paged |
000047a0  6d 65 6d 6f 72 79 20 63  61 6e 20 62 65 20 73 77  |memory can be sw|
000047b0  69 74 63 68 65 64 20 69  6e 20 61 6e 64 20 6f 75  |itched in and ou|
000047c0  74 20 6f 66 20 74 68 65  20 6d 61 69 6e 20 6d 65  |t of the main me|
000047d0  6d 6f 72 79 0d 6d 61 70  20 77 69 74 68 6f 75 74  |mory.map without|
000047e0  20 61 6c 74 65 72 69 6e  67 20 61 6e 79 20 6f 66  | altering any of|
000047f0  20 74 68 65 20 6f 74 68  65 72 20 62 69 74 73 20  | the other bits |
00004800  69 6e 20 74 68 65 20 70  61 67 65 64 20 6d 65 6d  |in the paged mem|
00004810  6f 72 79 20 73 65 6c 65  63 74 0d 72 65 67 69 73  |ory select.regis|
00004820  74 65 72 2e 0d 0d 0d 0d  0d 20 20 20 20 20 20 20  |ter......       |
00004830  20 20 4c 44 58 20 26 46  34 20 20 20 20 20 20 20  |  LDX &F4       |
00004840  20 20 5c 20 6c 6f 61 64  20 58 20 77 69 74 68 20  |  \ load X with |
00004850  72 6f 6d 20 6e 75 6d 62  65 72 0d 20 20 20 20 20  |rom number.     |
00004860  20 20 20 20 4c 44 41 20  26 44 46 30 2c 58 20 20  |    LDA &DF0,X  |
00004870  20 20 20 20 5c 20 66 69  6e 64 20 6d 6f 73 74 20  |    \ find most |
00004880  73 69 67 2e 20 62 79 74  65 20 6f 66 20 77 6f 72  |sig. byte of wor|
00004890  6b 73 70 61 63 65 20 61  64 64 72 65 73 73 0d 20  |kspace address. |
000048a0  20 20 20 20 20 20 20 20  53 54 41 20 26 37 31 20  |        STA &71 |
000048b0  20 20 20 20 20 20 20 20  5c 20 73 74 6f 72 65 20  |        \ store |
000048c0  69 74 20 66 6f 72 20 69  6e 64 69 72 65 63 74 20  |it for indirect |
000048d0  61 64 64 72 65 73 73 69  6e 67 0d 20 20 20 20 20  |addressing.     |
000048e0  20 20 20 20 4c 44 41 20  23 30 20 20 20 20 20 20  |    LDA #0      |
000048f0  20 20 20 20 5c 20 77 6f  72 6b 73 70 61 63 65 20  |    \ workspace |
00004900  61 6c 77 61 79 73 20 73  74 61 72 74 73 20 61 74  |always starts at|
00004910  20 61 20 70 61 67 65 20  62 6f 75 6e 64 61 72 79  | a page boundary|
00004920  0d 20 20 20 20 20 20 20  20 20 53 54 41 20 26 37  |.         STA &7|
00004930  30 20 20 20 20 20 20 20  20 20 5c 20 73 74 6f 72  |0         \ stor|
00004940  65 20 6c 65 61 73 74 20  73 69 67 2e 20 62 79 74  |e least sig. byt|
00004950  65 20 6f 66 20 77 6f 72  6b 73 70 61 63 65 20 61  |e of workspace a|
00004960  64 64 72 65 73 73 0d 20  20 20 20 20 20 20 20 20  |ddress.         |
00004970  4a 53 52 20 70 61 67 65  69 6e 20 20 20 20 20 20  |JSR pagein      |
00004980  5c 20 73 77 69 74 63 68  20 70 61 67 65 64 20 77  |\ switch paged w|
00004990  6f 72 6b 73 70 61 63 65  20 69 6e 0d 20 20 20 20  |orkspace in.    |
000049a0  20 20 20 20 20 4c 44 59  20 23 30 0d 20 20 20 20  |     LDY #0.    |
000049b0  20 20 20 20 20 4c 44 41  20 28 61 64 64 72 65 73  |     LDA (addres|
000049c0  73 29 2c 59 20 5c 20 52  65 61 64 20 66 69 72 73  |s),Y \ Read firs|
000049d0  74 20 62 79 74 65 20 6f  66 20 70 72 69 76 61 74  |t byte of privat|
000049e0  65 20 77 6f 72 6b 73 70  61 63 65 0d 20 20 20 20  |e workspace.    |
000049f0  20 20 20 20 20 4a 53 52  20 70 61 67 65 6f 75 74  |     JSR pageout|
00004a00  20 20 20 20 20 5c 20 73  77 69 74 63 68 20 70 61  |     \ switch pa|
00004a10  67 65 64 20 77 6f 72 6b  73 70 61 63 65 20 6f 75  |ged workspace ou|
00004a20  74 0d 20 20 20 20 20 20  20 20 20 20 2e 0d 20 20  |t.          ..  |
00004a30  20 20 20 20 20 20 20 20  2e 0d 20 20 20 20 20 20  |        ..      |
00004a40  20 20 20 20 2e 0d 2e 70  61 67 65 69 6e 0d 20 20  |    ...pagein.  |
00004a50  20 20 20 20 20 20 20 50  48 41 0d 20 20 20 20 20  |       PHA.     |
00004a60  20 20 20 20 4c 44 41 20  23 38 20 20 20 20 20 20  |    LDA #8      |
00004a70  20 20 20 20 5c 20 30 30  30 30 20 31 30 30 30 20  |    \ 0000 1000 |
00004a80  62 69 6e 61 72 79 0d 20  20 20 20 20 20 20 20 20  |binary.         |
00004a90  4f 52 41 20 26 46 45 33  34 0d 20 20 20 20 20 20  |ORA &FE34.      |
00004aa0  20 20 20 53 54 41 20 26  46 45 33 34 20 20 20 20  |   STA &FE34    |
00004ab0  20 20 20 5c 20 73 65 74  20 62 69 74 20 33 20 6f  |   \ set bit 3 o|
00004ac0  66 20 26 46 45 33 34 0d  20 20 20 20 20 20 20 20  |f &FE34.        |
00004ad0  20 50 4c 41 20 20 20 20  20 20 20 20 20 20 20 20  | PLA            |
00004ae0  20 5c 20 72 65 73 74 6f  72 65 20 61 63 63 75 6d  | \ restore accum|
00004af0  75 6c 61 74 6f 72 0d 20  20 20 20 20 20 20 20 20  |ulator.         |
00004b00  52 54 53 0d 2e 70 61 67  65 6f 75 74 0d 20 20 20  |RTS..pageout.   |
00004b10  20 20 20 20 20 20 50 48  41 0d 20 20 20 20 20 20  |      PHA.      |
00004b20  20 20 20 4c 44 41 20 23  26 46 37 20 20 20 20 20  |   LDA #&F7     |
00004b30  20 20 20 5c 20 31 31 31  31 20 30 31 31 31 20 62  |   \ 1111 0111 b|
00004b40  69 6e 61 72 79 0d 20 20  20 20 20 20 20 20 20 41  |inary.         A|
00004b50  4e 44 20 26 46 45 33 34  0d 20 20 20 20 20 20 20  |ND &FE34.       |
00004b60  20 20 53 54 41 20 26 46  45 33 34 20 20 20 20 20  |  STA &FE34     |
00004b70  20 20 5c 20 63 6c 65 61  72 20 62 69 74 20 33 20  |  \ clear bit 3 |
00004b80  6f 66 20 26 46 45 33 34  0d 20 20 20 20 20 20 20  |of &FE34.       |
00004b90  20 20 50 4c 41 20 20 20  20 20 20 20 20 20 20 20  |  PLA           |
00004ba0  20 20 5c 20 72 65 73 74  6f 72 65 20 61 63 63 75  |  \ restore accu|
00004bb0  6d 75 6c 61 74 6f 72 0d  20 20 20 20 20 20 20 20  |mulator.        |
00004bc0  20 52 54 53 0d 0d 0d 46  69 67 75 72 65 20 31 31  | RTS...Figure 11|
00004bd0  2e 35 20 20 52 65 61 64  69 6e 67 20 70 61 67 65  |.5  Reading page|
00004be0  64 20 70 72 69 76 61 74  65 20 77 6f 72 6b 73 70  |d private worksp|
00004bf0  61 63 65 20 6f 6e 20 74  68 65 20 4d 61 73 74 65  |ace on the Maste|
00004c00  72 2e 0d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |r..-------------|
00004c10  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00004c30  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 0d 0d  |--------------..|
00004c40  20 20 46 69 67 75 72 65  20 31 31 2e 35 20 69 6c  |  Figure 11.5 il|
00004c50  6c 75 73 74 72 61 74 65  73 20 68 6f 77 20 74 68  |lustrates how th|
00004c60  65 20 74 77 6f 20 73 75  62 72 6f 75 74 69 6e 65  |e two subroutine|
00004c70  73 2c 20 70 61 67 65 69  6e 20 61 6e 64 20 70 61  |s, pagein and pa|
00004c80  67 65 6f 75 74 2c 0d 73  68 6f 75 6c 64 20 62 65  |geout,.should be|
00004c90  20 75 73 65 64 20 74 6f  20 73 77 69 74 63 68 20  | used to switch |
00004ca0  74 68 65 20 70 61 67 65  64 20 6d 65 6d 6f 72 79  |the paged memory|
00004cb0  20 69 6e 20 61 6e 64 20  6f 75 74 20 6f 66 20 74  | in and out of t|
00004cc0  68 65 20 6d 61 69 6e 0d  6d 65 6d 6f 72 79 20 6d  |he main.memory m|
00004cd0  61 70 20 77 68 65 6e 20  72 65 61 64 69 6e 67 20  |ap when reading |
00004ce0  74 68 65 20 63 6f 6e 74  65 6e 74 73 20 6f 66 20  |the contents of |
00004cf0  74 68 65 20 70 61 67 65  64 20 70 72 69 76 61 74  |the paged privat|
00004d00  65 20 77 6f 72 6b 73 70  61 63 65 20 69 6e 0d 74  |e workspace in.t|
00004d10  68 65 20 4d 61 73 74 65  72 20 73 65 72 69 65 73  |he Master series|
00004d20  20 63 6f 6d 70 75 74 65  72 73 2e 0d 0d 20 20 41  | computers...  A|
00004d30  66 74 65 72 20 73 77 69  74 63 68 69 6e 67 20 74  |fter switching t|
00004d40  68 65 20 70 61 67 65 64  20 6d 65 6d 6f 72 79 20  |he paged memory |
00004d50  69 6e 74 6f 20 74 68 65  20 6d 61 69 6e 20 6d 65  |into the main me|
00004d60  6d 6f 72 79 20 6d 61 70  20 79 6f 75 20 6d 75 73  |mory map you mus|
00004d70  74 0d 62 65 20 76 65 72  79 20 63 61 72 65 66 75  |t.be very carefu|
00004d80  6c 20 61 62 6f 75 74 20  75 73 69 6e 67 20 4d 4f  |l about using MO|
00004d90  53 20 73 75 62 72 6f 75  74 69 6e 65 73 20 62 65  |S subroutines be|
00004da0  63 61 75 73 65 20 74 68  65 20 62 6f 74 74 6f 6d  |cause the bottom|
00004db0  20 37 2e 32 35 6b 0d 6f  66 20 74 68 65 20 4d 4f  | 7.25k.of the MO|
00004dc0  53 20 68 61 73 20 62 65  65 6e 20 72 65 70 6c 61  |S has been repla|
00004dd0  63 65 64 20 77 69 74 68  20 74 68 65 20 70 61 67  |ced with the pag|
00004de0  65 64 20 6d 65 6d 6f 72  79 2e 20 59 6f 75 20 77  |ed memory. You w|
00004df0  6f 75 6c 64 20 62 65 20  77 69 73 65 0d 6e 6f 74  |ould be wise.not|
00004e00  20 74 6f 20 75 73 65 20  74 68 65 20 4d 4f 53 20  | to use the MOS |
00004e10  61 74 20 61 6c 6c 20 75  6e 74 69 6c 20 69 74 20  |at all until it |
00004e20  68 61 73 20 62 65 65 6e  20 72 65 73 74 6f 72 65  |has been restore|
00004e30  64 20 62 79 20 63 61 6c  6c 69 6e 67 0d 70 61 67  |d by calling.pag|
00004e40  65 6f 75 74 2e 0d                                 |eout..|
00004e46
18-09-88/T\SWR11.m0
18-09-88/T\SWR11.m1
18-09-88/T\SWR11.m2
18-09-88/T\SWR11.m4
18-09-88/T\SWR11.m5