Home » Archimedes archive » Zipped Apps » BBC Tape » !BBCTape/BBCLDisc

!BBCTape/BBCLDisc

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 » Archimedes archive » Zipped Apps » BBC Tape
Filename: !BBCTape/BBCLDisc
Read OK:
File size: 1C52 bytes
Load address: 0000
Exec address: 0000
File contents
MODE 7
REM
REM BBC end of !BBCTape application
REM
REM (C) S. Burke, 26/2/91
REM
REM The next few lines define where the buffers are, where the
REM code goes and where the file loads to.
REM
REM This version might work with discs, but I can't test it!
REM It fits in pages B and C with 0 bytes spare!
REM
:
name       = &0B00
name_high  = &0B
name_low   = &00
block      = &0B10
block_high = &0B
block_low  = &10
code_start = &0B30
load_page  = PAGE DIV &100
:
osfind = &FFCE
osbget = &FFD7
osfile = &FFDD  :REM Page 335 of the Advanced User Guide is wrong!
osbyte = &FFF4
:
FOR opt%=0 TO 3 STEP 3
P% = code_start
[OPT opt%
.go
          LDX #0
          LDA #2
          JSR osbyte        \ disable RS423
          LDX #0
          LDA #15
          JSR osbyte        \ flush all buffers
          LDX #2
          TXA
          JSR osbyte        \ enable RS423 receive
.mainloop
          LDA #&0D
          STA name          \ null name
          JSR handshake
:
          JSR get           \ get command
          CPY #&C0
          BEQ end           \ quit
:
          CPY #&30
          BNE load
          JSR put_ok        \ confirm command
          JSR get_name      \ get filename
          JSR handshake
          JSR get
.load
          CPY #&0C
          BNE load_byte
          JSR put_ok        \ confirm command
          JSR load_file
          JSR send_file
          JMP mainloop
.load_byte
          CPY #&03
          BNE command_error
          JSR put_ok        \ confirm command
          JSR load_file
          JSR send_file
          JMP mainloop
.command_error
          LDA #0
          JSR put           \ command error
          JMP mainloop
.end
          RTS
.load_file
          LDA #name_low     \ set up parameter block
          STA block
          LDA #name_high
          STA block+1
          LDA #0
          STA block+2
          STA block+6
          LDA #load_page
          STA block+3
          LDA #&FF
          STA block+4
          STA block+5
          LDX #block_low
          LDY #block_high
          JSR osfile        \ load file
          LDA block+10
          STA &71
          LDA block+11
          STA &72           \ put file length in &71, &72
          JSR read_load_exec\ get load/exec address and name
.read_name
          LDX #&FF
.nameloop
          INX
          CPX #&C
          BEQ too_far
\         LDA &3B2,X        ! pull filename out of cassette workspace
          LDA #0            \ don't know where to get it for a disc system
          STA name,X        \ see AUG p. 279
          BNE nameloop
.too_far
          LDA #&0D
          STA name,X
          RTS
.get_name
          LDX #&FF
          STX &81           \ "get" corrupts registers
.get_char
          CPX #&B
          BEQ too_far
          JSR get           \ get filename from Arc
          TYA
          INC &81   
          LDX &81
          STA name,X
          CMP #&0D
          BNE get_char
          RTS
.read_load_exec
          LDX #8
.load_exec_loop
          LDA &3BD,X        \ load/exec address from cassette workspace
          STA &81,X
          DEX
          BNE load_exec_loop
          RTS
.handshake
          LDA #ASC("S")
          JSR put
          LDA #ASC("B")
          JSR put           \ send "SB" ...
          JSR get
          CPY #ASC("s")
          BNE handshake
          JSR get
          CPY #ASC("b")
          BNE handshake     \ ... and receive "sb" to handshake
          RTS
.send_file
          LDA &71
          JSR put
          LDA &72
          JSR put           \ send file length
:
          LDA #load_page
          STA &74
          LDA #0 
          STA &73           \ reset load address
          DEC &72           \ need this for test below
          BMI last_block    \ file length < 256 bytes?
          STA &80           \ block length = 0 ( = 256)
.send_block
          JSR put_ok        \ not eof
          LDA #3            \ send length 3 times
          STA &76           \ use CRC low byte as counter
.lenout
          LDA &80
          JSR put           \ output block length
          DEC &76
          BNE lenout        \ CRC low byte zero at exit
          LDY #0
          STY &75           \ initialise CRC high byte
.send_byte
          STY &70           \ save offset
          LDA (&73),Y       \ load next byte ...
          PHA
          JSR put
          PLA               \ get character back
          JSR crc           \ update crc
          LDY &70
          INY               \ increment offset
          CPY &80
          BNE send_byte     \ end of block?
:
          LDA &75
          JSR put           \ output CRC high byte
          LDA &76
          JSR put           \ output CRC low byte
:
          JSR get           \ look for confirmation
          TYA
          BEQ send_block    \ zero means error, so do again
:
          INC &74           \ increment address high byte
          DEC &72           \ decrement length high byte
          BPL send_block    \ are we finished?
.last_block
          LDY #0
          LDA &71           \ length of last block
          STY &71           \ set length to zero
          STA &80
          BNE send_block    \ output if non-zero
          LDA #0
          JSR put           \ zero marks eof
          JSR put_load_exec \ send the load/exec adress
.put_name                   \ fall through to put_name ...
          LDX #&FF
          STX &81           \ "put" corrupts registers
.put_char                   \ output file name
          INC &81
          LDX &81
          LDA name,X
          PHA
          JSR put
          PLA
          CMP #&0D
          BNE put_char
          RTS
.put_load_exec              \ put out load/exec address
          LDX #0
          STX &81           \ "put" corrupts registers
.put_load_exec_loop
          LDA &82,X
          JSR put
          INC &81
          LDX &81
          CPX #8
          BNE put_load_exec_loop
          RTS
.put_ok
          LDA #&FF
.put
          PHA               \ save value to output
          JSR escape
          LDX #&FD
          LDA #&80
          JSR osbyte        \ get # empty bytes in RS423 output buffer
          CPX #9
          PLA
          BCC put           \ if < 9 bytes remain, wait ...
:
          LDX #2
          TAY
          LDA #&8A
          JMP osbyte        \ ... and send it
.get
          JSR escape
          LDX #1
          LDA #&91
          JSR osbyte        \ read a byte
          BCS get
          RTS
.crc
          EOR &75           \ calculate CRC in &75, &76
          STA &75           \ algorithm from Advanced User Guide
          LDX #8            \ I hope it's right!
.crc_loop
          LDA &75
          ROL A
          BCC b7z
          LDA &75
          EOR #8
          STA &75
          LDA &76
          EOR #&10
          STA &76
.b7z
          ROL &76
          ROL &75
          DEX
          BNE crc_loop
          RTS
.escape
          LDA &FF
          BMI error
          RTS
.error
          LDA #&7E
          JSR osbyte        \ acknowledge escape
          LDX #0
          LDY #0
          LDA #0
          JSR &FFCE         \ close all files
          BRK
]
?P% = &11
P%  = P% + 1
$P% = "Escape" + CHR$0
NEXT opt%
*OPT 1,2
RUN
CALL go
00000000  4d 4f 44 45 20 37 0a 52  45 4d 0a 52 45 4d 20 42  |MODE 7.REM.REM B|
00000010  42 43 20 65 6e 64 20 6f  66 20 21 42 42 43 54 61  |BC end of !BBCTa|
00000020  70 65 20 61 70 70 6c 69  63 61 74 69 6f 6e 0a 52  |pe application.R|
00000030  45 4d 0a 52 45 4d 20 28  43 29 20 53 2e 20 42 75  |EM.REM (C) S. Bu|
00000040  72 6b 65 2c 20 32 36 2f  32 2f 39 31 0a 52 45 4d  |rke, 26/2/91.REM|
00000050  0a 52 45 4d 20 54 68 65  20 6e 65 78 74 20 66 65  |.REM The next fe|
00000060  77 20 6c 69 6e 65 73 20  64 65 66 69 6e 65 20 77  |w lines define w|
00000070  68 65 72 65 20 74 68 65  20 62 75 66 66 65 72 73  |here the buffers|
00000080  20 61 72 65 2c 20 77 68  65 72 65 20 74 68 65 0a  | are, where the.|
00000090  52 45 4d 20 63 6f 64 65  20 67 6f 65 73 20 61 6e  |REM code goes an|
000000a0  64 20 77 68 65 72 65 20  74 68 65 20 66 69 6c 65  |d where the file|
000000b0  20 6c 6f 61 64 73 20 74  6f 2e 0a 52 45 4d 0a 52  | loads to..REM.R|
000000c0  45 4d 20 54 68 69 73 20  76 65 72 73 69 6f 6e 20  |EM This version |
000000d0  6d 69 67 68 74 20 77 6f  72 6b 20 77 69 74 68 20  |might work with |
000000e0  64 69 73 63 73 2c 20 62  75 74 20 49 20 63 61 6e  |discs, but I can|
000000f0  27 74 20 74 65 73 74 20  69 74 21 0a 52 45 4d 20  |'t test it!.REM |
00000100  49 74 20 66 69 74 73 20  69 6e 20 70 61 67 65 73  |It fits in pages|
00000110  20 42 20 61 6e 64 20 43  20 77 69 74 68 20 30 20  | B and C with 0 |
00000120  62 79 74 65 73 20 73 70  61 72 65 21 0a 52 45 4d  |bytes spare!.REM|
00000130  0a 3a 0a 6e 61 6d 65 20  20 20 20 20 20 20 3d 20  |.:.name       = |
00000140  26 30 42 30 30 0a 6e 61  6d 65 5f 68 69 67 68 20  |&0B00.name_high |
00000150  20 3d 20 26 30 42 0a 6e  61 6d 65 5f 6c 6f 77 20  | = &0B.name_low |
00000160  20 20 3d 20 26 30 30 0a  62 6c 6f 63 6b 20 20 20  |  = &00.block   |
00000170  20 20 20 3d 20 26 30 42  31 30 0a 62 6c 6f 63 6b  |   = &0B10.block|
00000180  5f 68 69 67 68 20 3d 20  26 30 42 0a 62 6c 6f 63  |_high = &0B.bloc|
00000190  6b 5f 6c 6f 77 20 20 3d  20 26 31 30 0a 63 6f 64  |k_low  = &10.cod|
000001a0  65 5f 73 74 61 72 74 20  3d 20 26 30 42 33 30 0a  |e_start = &0B30.|
000001b0  6c 6f 61 64 5f 70 61 67  65 20 20 3d 20 50 41 47  |load_page  = PAG|
000001c0  45 20 44 49 56 20 26 31  30 30 0a 3a 0a 6f 73 66  |E DIV &100.:.osf|
000001d0  69 6e 64 20 3d 20 26 46  46 43 45 0a 6f 73 62 67  |ind = &FFCE.osbg|
000001e0  65 74 20 3d 20 26 46 46  44 37 0a 6f 73 66 69 6c  |et = &FFD7.osfil|
000001f0  65 20 3d 20 26 46 46 44  44 20 20 3a 52 45 4d 20  |e = &FFDD  :REM |
00000200  50 61 67 65 20 33 33 35  20 6f 66 20 74 68 65 20  |Page 335 of the |
00000210  41 64 76 61 6e 63 65 64  20 55 73 65 72 20 47 75  |Advanced User Gu|
00000220  69 64 65 20 69 73 20 77  72 6f 6e 67 21 0a 6f 73  |ide is wrong!.os|
00000230  62 79 74 65 20 3d 20 26  46 46 46 34 0a 3a 0a 46  |byte = &FFF4.:.F|
00000240  4f 52 20 6f 70 74 25 3d  30 20 54 4f 20 33 20 53  |OR opt%=0 TO 3 S|
00000250  54 45 50 20 33 0a 50 25  20 3d 20 63 6f 64 65 5f  |TEP 3.P% = code_|
00000260  73 74 61 72 74 0a 5b 4f  50 54 20 6f 70 74 25 0a  |start.[OPT opt%.|
00000270  2e 67 6f 0a 20 20 20 20  20 20 20 20 20 20 4c 44  |.go.          LD|
00000280  58 20 23 30 0a 20 20 20  20 20 20 20 20 20 20 4c  |X #0.          L|
00000290  44 41 20 23 32 0a 20 20  20 20 20 20 20 20 20 20  |DA #2.          |
000002a0  4a 53 52 20 6f 73 62 79  74 65 20 20 20 20 20 20  |JSR osbyte      |
000002b0  20 20 5c 20 64 69 73 61  62 6c 65 20 52 53 34 32  |  \ disable RS42|
000002c0  33 0a 20 20 20 20 20 20  20 20 20 20 4c 44 58 20  |3.          LDX |
000002d0  23 30 0a 20 20 20 20 20  20 20 20 20 20 4c 44 41  |#0.          LDA|
000002e0  20 23 31 35 0a 20 20 20  20 20 20 20 20 20 20 4a  | #15.          J|
000002f0  53 52 20 6f 73 62 79 74  65 20 20 20 20 20 20 20  |SR osbyte       |
00000300  20 5c 20 66 6c 75 73 68  20 61 6c 6c 20 62 75 66  | \ flush all buf|
00000310  66 65 72 73 0a 20 20 20  20 20 20 20 20 20 20 4c  |fers.          L|
00000320  44 58 20 23 32 0a 20 20  20 20 20 20 20 20 20 20  |DX #2.          |
00000330  54 58 41 0a 20 20 20 20  20 20 20 20 20 20 4a 53  |TXA.          JS|
00000340  52 20 6f 73 62 79 74 65  20 20 20 20 20 20 20 20  |R osbyte        |
00000350  5c 20 65 6e 61 62 6c 65  20 52 53 34 32 33 20 72  |\ enable RS423 r|
00000360  65 63 65 69 76 65 0a 2e  6d 61 69 6e 6c 6f 6f 70  |eceive..mainloop|
00000370  0a 20 20 20 20 20 20 20  20 20 20 4c 44 41 20 23  |.          LDA #|
00000380  26 30 44 0a 20 20 20 20  20 20 20 20 20 20 53 54  |&0D.          ST|
00000390  41 20 6e 61 6d 65 20 20  20 20 20 20 20 20 20 20  |A name          |
000003a0  5c 20 6e 75 6c 6c 20 6e  61 6d 65 0a 20 20 20 20  |\ null name.    |
000003b0  20 20 20 20 20 20 4a 53  52 20 68 61 6e 64 73 68  |      JSR handsh|
000003c0  61 6b 65 0a 3a 0a 20 20  20 20 20 20 20 20 20 20  |ake.:.          |
000003d0  4a 53 52 20 67 65 74 20  20 20 20 20 20 20 20 20  |JSR get         |
000003e0  20 20 5c 20 67 65 74 20  63 6f 6d 6d 61 6e 64 0a  |  \ get command.|
000003f0  20 20 20 20 20 20 20 20  20 20 43 50 59 20 23 26  |          CPY #&|
00000400  43 30 0a 20 20 20 20 20  20 20 20 20 20 42 45 51  |C0.          BEQ|
00000410  20 65 6e 64 20 20 20 20  20 20 20 20 20 20 20 5c  | end           \|
00000420  20 71 75 69 74 0a 3a 0a  20 20 20 20 20 20 20 20  | quit.:.        |
00000430  20 20 43 50 59 20 23 26  33 30 0a 20 20 20 20 20  |  CPY #&30.     |
00000440  20 20 20 20 20 42 4e 45  20 6c 6f 61 64 0a 20 20  |     BNE load.  |
00000450  20 20 20 20 20 20 20 20  4a 53 52 20 70 75 74 5f  |        JSR put_|
00000460  6f 6b 20 20 20 20 20 20  20 20 5c 20 63 6f 6e 66  |ok        \ conf|
00000470  69 72 6d 20 63 6f 6d 6d  61 6e 64 0a 20 20 20 20  |irm command.    |
00000480  20 20 20 20 20 20 4a 53  52 20 67 65 74 5f 6e 61  |      JSR get_na|
00000490  6d 65 20 20 20 20 20 20  5c 20 67 65 74 20 66 69  |me      \ get fi|
000004a0  6c 65 6e 61 6d 65 0a 20  20 20 20 20 20 20 20 20  |lename.         |
000004b0  20 4a 53 52 20 68 61 6e  64 73 68 61 6b 65 0a 20  | JSR handshake. |
000004c0  20 20 20 20 20 20 20 20  20 4a 53 52 20 67 65 74  |         JSR get|
000004d0  0a 2e 6c 6f 61 64 0a 20  20 20 20 20 20 20 20 20  |..load.         |
000004e0  20 43 50 59 20 23 26 30  43 0a 20 20 20 20 20 20  | CPY #&0C.      |
000004f0  20 20 20 20 42 4e 45 20  6c 6f 61 64 5f 62 79 74  |    BNE load_byt|
00000500  65 0a 20 20 20 20 20 20  20 20 20 20 4a 53 52 20  |e.          JSR |
00000510  70 75 74 5f 6f 6b 20 20  20 20 20 20 20 20 5c 20  |put_ok        \ |
00000520  63 6f 6e 66 69 72 6d 20  63 6f 6d 6d 61 6e 64 0a  |confirm command.|
00000530  20 20 20 20 20 20 20 20  20 20 4a 53 52 20 6c 6f  |          JSR lo|
00000540  61 64 5f 66 69 6c 65 0a  20 20 20 20 20 20 20 20  |ad_file.        |
00000550  20 20 4a 53 52 20 73 65  6e 64 5f 66 69 6c 65 0a  |  JSR send_file.|
00000560  20 20 20 20 20 20 20 20  20 20 4a 4d 50 20 6d 61  |          JMP ma|
00000570  69 6e 6c 6f 6f 70 0a 2e  6c 6f 61 64 5f 62 79 74  |inloop..load_byt|
00000580  65 0a 20 20 20 20 20 20  20 20 20 20 43 50 59 20  |e.          CPY |
00000590  23 26 30 33 0a 20 20 20  20 20 20 20 20 20 20 42  |#&03.          B|
000005a0  4e 45 20 63 6f 6d 6d 61  6e 64 5f 65 72 72 6f 72  |NE command_error|
000005b0  0a 20 20 20 20 20 20 20  20 20 20 4a 53 52 20 70  |.          JSR p|
000005c0  75 74 5f 6f 6b 20 20 20  20 20 20 20 20 5c 20 63  |ut_ok        \ c|
000005d0  6f 6e 66 69 72 6d 20 63  6f 6d 6d 61 6e 64 0a 20  |onfirm command. |
000005e0  20 20 20 20 20 20 20 20  20 4a 53 52 20 6c 6f 61  |         JSR loa|
000005f0  64 5f 66 69 6c 65 0a 20  20 20 20 20 20 20 20 20  |d_file.         |
00000600  20 4a 53 52 20 73 65 6e  64 5f 66 69 6c 65 0a 20  | JSR send_file. |
00000610  20 20 20 20 20 20 20 20  20 4a 4d 50 20 6d 61 69  |         JMP mai|
00000620  6e 6c 6f 6f 70 0a 2e 63  6f 6d 6d 61 6e 64 5f 65  |nloop..command_e|
00000630  72 72 6f 72 0a 20 20 20  20 20 20 20 20 20 20 4c  |rror.          L|
00000640  44 41 20 23 30 0a 20 20  20 20 20 20 20 20 20 20  |DA #0.          |
00000650  4a 53 52 20 70 75 74 20  20 20 20 20 20 20 20 20  |JSR put         |
00000660  20 20 5c 20 63 6f 6d 6d  61 6e 64 20 65 72 72 6f  |  \ command erro|
00000670  72 0a 20 20 20 20 20 20  20 20 20 20 4a 4d 50 20  |r.          JMP |
00000680  6d 61 69 6e 6c 6f 6f 70  0a 2e 65 6e 64 0a 20 20  |mainloop..end.  |
00000690  20 20 20 20 20 20 20 20  52 54 53 0a 2e 6c 6f 61  |        RTS..loa|
000006a0  64 5f 66 69 6c 65 0a 20  20 20 20 20 20 20 20 20  |d_file.         |
000006b0  20 4c 44 41 20 23 6e 61  6d 65 5f 6c 6f 77 20 20  | LDA #name_low  |
000006c0  20 20 20 5c 20 73 65 74  20 75 70 20 70 61 72 61  |   \ set up para|
000006d0  6d 65 74 65 72 20 62 6c  6f 63 6b 0a 20 20 20 20  |meter block.    |
000006e0  20 20 20 20 20 20 53 54  41 20 62 6c 6f 63 6b 0a  |      STA block.|
000006f0  20 20 20 20 20 20 20 20  20 20 4c 44 41 20 23 6e  |          LDA #n|
00000700  61 6d 65 5f 68 69 67 68  0a 20 20 20 20 20 20 20  |ame_high.       |
00000710  20 20 20 53 54 41 20 62  6c 6f 63 6b 2b 31 0a 20  |   STA block+1. |
00000720  20 20 20 20 20 20 20 20  20 4c 44 41 20 23 30 0a  |         LDA #0.|
00000730  20 20 20 20 20 20 20 20  20 20 53 54 41 20 62 6c  |          STA bl|
00000740  6f 63 6b 2b 32 0a 20 20  20 20 20 20 20 20 20 20  |ock+2.          |
00000750  53 54 41 20 62 6c 6f 63  6b 2b 36 0a 20 20 20 20  |STA block+6.    |
00000760  20 20 20 20 20 20 4c 44  41 20 23 6c 6f 61 64 5f  |      LDA #load_|
00000770  70 61 67 65 0a 20 20 20  20 20 20 20 20 20 20 53  |page.          S|
00000780  54 41 20 62 6c 6f 63 6b  2b 33 0a 20 20 20 20 20  |TA block+3.     |
00000790  20 20 20 20 20 4c 44 41  20 23 26 46 46 0a 20 20  |     LDA #&FF.  |
000007a0  20 20 20 20 20 20 20 20  53 54 41 20 62 6c 6f 63  |        STA bloc|
000007b0  6b 2b 34 0a 20 20 20 20  20 20 20 20 20 20 53 54  |k+4.          ST|
000007c0  41 20 62 6c 6f 63 6b 2b  35 0a 20 20 20 20 20 20  |A block+5.      |
000007d0  20 20 20 20 4c 44 58 20  23 62 6c 6f 63 6b 5f 6c  |    LDX #block_l|
000007e0  6f 77 0a 20 20 20 20 20  20 20 20 20 20 4c 44 59  |ow.          LDY|
000007f0  20 23 62 6c 6f 63 6b 5f  68 69 67 68 0a 20 20 20  | #block_high.   |
00000800  20 20 20 20 20 20 20 4a  53 52 20 6f 73 66 69 6c  |       JSR osfil|
00000810  65 20 20 20 20 20 20 20  20 5c 20 6c 6f 61 64 20  |e        \ load |
00000820  66 69 6c 65 0a 20 20 20  20 20 20 20 20 20 20 4c  |file.          L|
00000830  44 41 20 62 6c 6f 63 6b  2b 31 30 0a 20 20 20 20  |DA block+10.    |
00000840  20 20 20 20 20 20 53 54  41 20 26 37 31 0a 20 20  |      STA &71.  |
00000850  20 20 20 20 20 20 20 20  4c 44 41 20 62 6c 6f 63  |        LDA bloc|
00000860  6b 2b 31 31 0a 20 20 20  20 20 20 20 20 20 20 53  |k+11.          S|
00000870  54 41 20 26 37 32 20 20  20 20 20 20 20 20 20 20  |TA &72          |
00000880  20 5c 20 70 75 74 20 66  69 6c 65 20 6c 65 6e 67  | \ put file leng|
00000890  74 68 20 69 6e 20 26 37  31 2c 20 26 37 32 0a 20  |th in &71, &72. |
000008a0  20 20 20 20 20 20 20 20  20 4a 53 52 20 72 65 61  |         JSR rea|
000008b0  64 5f 6c 6f 61 64 5f 65  78 65 63 5c 20 67 65 74  |d_load_exec\ get|
000008c0  20 6c 6f 61 64 2f 65 78  65 63 20 61 64 64 72 65  | load/exec addre|
000008d0  73 73 20 61 6e 64 20 6e  61 6d 65 0a 2e 72 65 61  |ss and name..rea|
000008e0  64 5f 6e 61 6d 65 0a 20  20 20 20 20 20 20 20 20  |d_name.         |
000008f0  20 4c 44 58 20 23 26 46  46 0a 2e 6e 61 6d 65 6c  | LDX #&FF..namel|
00000900  6f 6f 70 0a 20 20 20 20  20 20 20 20 20 20 49 4e  |oop.          IN|
00000910  58 0a 20 20 20 20 20 20  20 20 20 20 43 50 58 20  |X.          CPX |
00000920  23 26 43 0a 20 20 20 20  20 20 20 20 20 20 42 45  |#&C.          BE|
00000930  51 20 74 6f 6f 5f 66 61  72 0a 5c 20 20 20 20 20  |Q too_far.\     |
00000940  20 20 20 20 4c 44 41 20  26 33 42 32 2c 58 20 20  |    LDA &3B2,X  |
00000950  20 20 20 20 20 20 21 20  70 75 6c 6c 20 66 69 6c  |      ! pull fil|
00000960  65 6e 61 6d 65 20 6f 75  74 20 6f 66 20 63 61 73  |ename out of cas|
00000970  73 65 74 74 65 20 77 6f  72 6b 73 70 61 63 65 0a  |sette workspace.|
00000980  20 20 20 20 20 20 20 20  20 20 4c 44 41 20 23 30  |          LDA #0|
00000990  20 20 20 20 20 20 20 20  20 20 20 20 5c 20 64 6f  |            \ do|
000009a0  6e 27 74 20 6b 6e 6f 77  20 77 68 65 72 65 20 74  |n't know where t|
000009b0  6f 20 67 65 74 20 69 74  20 66 6f 72 20 61 20 64  |o get it for a d|
000009c0  69 73 63 20 73 79 73 74  65 6d 0a 20 20 20 20 20  |isc system.     |
000009d0  20 20 20 20 20 53 54 41  20 6e 61 6d 65 2c 58 20  |     STA name,X |
000009e0  20 20 20 20 20 20 20 5c  20 73 65 65 20 41 55 47  |       \ see AUG|
000009f0  20 70 2e 20 32 37 39 0a  20 20 20 20 20 20 20 20  | p. 279.        |
00000a00  20 20 42 4e 45 20 6e 61  6d 65 6c 6f 6f 70 0a 2e  |  BNE nameloop..|
00000a10  74 6f 6f 5f 66 61 72 0a  20 20 20 20 20 20 20 20  |too_far.        |
00000a20  20 20 4c 44 41 20 23 26  30 44 0a 20 20 20 20 20  |  LDA #&0D.     |
00000a30  20 20 20 20 20 53 54 41  20 6e 61 6d 65 2c 58 0a  |     STA name,X.|
00000a40  20 20 20 20 20 20 20 20  20 20 52 54 53 0a 2e 67  |          RTS..g|
00000a50  65 74 5f 6e 61 6d 65 0a  20 20 20 20 20 20 20 20  |et_name.        |
00000a60  20 20 4c 44 58 20 23 26  46 46 0a 20 20 20 20 20  |  LDX #&FF.     |
00000a70  20 20 20 20 20 53 54 58  20 26 38 31 20 20 20 20  |     STX &81    |
00000a80  20 20 20 20 20 20 20 5c  20 22 67 65 74 22 20 63  |       \ "get" c|
00000a90  6f 72 72 75 70 74 73 20  72 65 67 69 73 74 65 72  |orrupts register|
00000aa0  73 0a 2e 67 65 74 5f 63  68 61 72 0a 20 20 20 20  |s..get_char.    |
00000ab0  20 20 20 20 20 20 43 50  58 20 23 26 42 0a 20 20  |      CPX #&B.  |
00000ac0  20 20 20 20 20 20 20 20  42 45 51 20 74 6f 6f 5f  |        BEQ too_|
00000ad0  66 61 72 0a 20 20 20 20  20 20 20 20 20 20 4a 53  |far.          JS|
00000ae0  52 20 67 65 74 20 20 20  20 20 20 20 20 20 20 20  |R get           |
00000af0  5c 20 67 65 74 20 66 69  6c 65 6e 61 6d 65 20 66  |\ get filename f|
00000b00  72 6f 6d 20 41 72 63 0a  20 20 20 20 20 20 20 20  |rom Arc.        |
00000b10  20 20 54 59 41 0a 20 20  20 20 20 20 20 20 20 20  |  TYA.          |
00000b20  49 4e 43 20 26 38 31 20  20 20 0a 20 20 20 20 20  |INC &81   .     |
00000b30  20 20 20 20 20 4c 44 58  20 26 38 31 0a 20 20 20  |     LDX &81.   |
00000b40  20 20 20 20 20 20 20 53  54 41 20 6e 61 6d 65 2c  |       STA name,|
00000b50  58 0a 20 20 20 20 20 20  20 20 20 20 43 4d 50 20  |X.          CMP |
00000b60  23 26 30 44 0a 20 20 20  20 20 20 20 20 20 20 42  |#&0D.          B|
00000b70  4e 45 20 67 65 74 5f 63  68 61 72 0a 20 20 20 20  |NE get_char.    |
00000b80  20 20 20 20 20 20 52 54  53 0a 2e 72 65 61 64 5f  |      RTS..read_|
00000b90  6c 6f 61 64 5f 65 78 65  63 0a 20 20 20 20 20 20  |load_exec.      |
00000ba0  20 20 20 20 4c 44 58 20  23 38 0a 2e 6c 6f 61 64  |    LDX #8..load|
00000bb0  5f 65 78 65 63 5f 6c 6f  6f 70 0a 20 20 20 20 20  |_exec_loop.     |
00000bc0  20 20 20 20 20 4c 44 41  20 26 33 42 44 2c 58 20  |     LDA &3BD,X |
00000bd0  20 20 20 20 20 20 20 5c  20 6c 6f 61 64 2f 65 78  |       \ load/ex|
00000be0  65 63 20 61 64 64 72 65  73 73 20 66 72 6f 6d 20  |ec address from |
00000bf0  63 61 73 73 65 74 74 65  20 77 6f 72 6b 73 70 61  |cassette workspa|
00000c00  63 65 0a 20 20 20 20 20  20 20 20 20 20 53 54 41  |ce.          STA|
00000c10  20 26 38 31 2c 58 0a 20  20 20 20 20 20 20 20 20  | &81,X.         |
00000c20  20 44 45 58 0a 20 20 20  20 20 20 20 20 20 20 42  | DEX.          B|
00000c30  4e 45 20 6c 6f 61 64 5f  65 78 65 63 5f 6c 6f 6f  |NE load_exec_loo|
00000c40  70 0a 20 20 20 20 20 20  20 20 20 20 52 54 53 0a  |p.          RTS.|
00000c50  2e 68 61 6e 64 73 68 61  6b 65 0a 20 20 20 20 20  |.handshake.     |
00000c60  20 20 20 20 20 4c 44 41  20 23 41 53 43 28 22 53  |     LDA #ASC("S|
00000c70  22 29 0a 20 20 20 20 20  20 20 20 20 20 4a 53 52  |").          JSR|
00000c80  20 70 75 74 0a 20 20 20  20 20 20 20 20 20 20 4c  | put.          L|
00000c90  44 41 20 23 41 53 43 28  22 42 22 29 0a 20 20 20  |DA #ASC("B").   |
00000ca0  20 20 20 20 20 20 20 4a  53 52 20 70 75 74 20 20  |       JSR put  |
00000cb0  20 20 20 20 20 20 20 20  20 5c 20 73 65 6e 64 20  |         \ send |
00000cc0  22 53 42 22 20 2e 2e 2e  0a 20 20 20 20 20 20 20  |"SB" ....       |
00000cd0  20 20 20 4a 53 52 20 67  65 74 0a 20 20 20 20 20  |   JSR get.     |
00000ce0  20 20 20 20 20 43 50 59  20 23 41 53 43 28 22 73  |     CPY #ASC("s|
00000cf0  22 29 0a 20 20 20 20 20  20 20 20 20 20 42 4e 45  |").          BNE|
00000d00  20 68 61 6e 64 73 68 61  6b 65 0a 20 20 20 20 20  | handshake.     |
00000d10  20 20 20 20 20 4a 53 52  20 67 65 74 0a 20 20 20  |     JSR get.   |
00000d20  20 20 20 20 20 20 20 43  50 59 20 23 41 53 43 28  |       CPY #ASC(|
00000d30  22 62 22 29 0a 20 20 20  20 20 20 20 20 20 20 42  |"b").          B|
00000d40  4e 45 20 68 61 6e 64 73  68 61 6b 65 20 20 20 20  |NE handshake    |
00000d50  20 5c 20 2e 2e 2e 20 61  6e 64 20 72 65 63 65 69  | \ ... and recei|
00000d60  76 65 20 22 73 62 22 20  74 6f 20 68 61 6e 64 73  |ve "sb" to hands|
00000d70  68 61 6b 65 0a 20 20 20  20 20 20 20 20 20 20 52  |hake.          R|
00000d80  54 53 0a 2e 73 65 6e 64  5f 66 69 6c 65 0a 20 20  |TS..send_file.  |
00000d90  20 20 20 20 20 20 20 20  4c 44 41 20 26 37 31 0a  |        LDA &71.|
00000da0  20 20 20 20 20 20 20 20  20 20 4a 53 52 20 70 75  |          JSR pu|
00000db0  74 0a 20 20 20 20 20 20  20 20 20 20 4c 44 41 20  |t.          LDA |
00000dc0  26 37 32 0a 20 20 20 20  20 20 20 20 20 20 4a 53  |&72.          JS|
00000dd0  52 20 70 75 74 20 20 20  20 20 20 20 20 20 20 20  |R put           |
00000de0  5c 20 73 65 6e 64 20 66  69 6c 65 20 6c 65 6e 67  |\ send file leng|
00000df0  74 68 0a 3a 0a 20 20 20  20 20 20 20 20 20 20 4c  |th.:.          L|
00000e00  44 41 20 23 6c 6f 61 64  5f 70 61 67 65 0a 20 20  |DA #load_page.  |
00000e10  20 20 20 20 20 20 20 20  53 54 41 20 26 37 34 0a  |        STA &74.|
00000e20  20 20 20 20 20 20 20 20  20 20 4c 44 41 20 23 30  |          LDA #0|
00000e30  20 0a 20 20 20 20 20 20  20 20 20 20 53 54 41 20  | .          STA |
00000e40  26 37 33 20 20 20 20 20  20 20 20 20 20 20 5c 20  |&73           \ |
00000e50  72 65 73 65 74 20 6c 6f  61 64 20 61 64 64 72 65  |reset load addre|
00000e60  73 73 0a 20 20 20 20 20  20 20 20 20 20 44 45 43  |ss.          DEC|
00000e70  20 26 37 32 20 20 20 20  20 20 20 20 20 20 20 5c  | &72           \|
00000e80  20 6e 65 65 64 20 74 68  69 73 20 66 6f 72 20 74  | need this for t|
00000e90  65 73 74 20 62 65 6c 6f  77 0a 20 20 20 20 20 20  |est below.      |
00000ea0  20 20 20 20 42 4d 49 20  6c 61 73 74 5f 62 6c 6f  |    BMI last_blo|
00000eb0  63 6b 20 20 20 20 5c 20  66 69 6c 65 20 6c 65 6e  |ck    \ file len|
00000ec0  67 74 68 20 3c 20 32 35  36 20 62 79 74 65 73 3f  |gth < 256 bytes?|
00000ed0  0a 20 20 20 20 20 20 20  20 20 20 53 54 41 20 26  |.          STA &|
00000ee0  38 30 20 20 20 20 20 20  20 20 20 20 20 5c 20 62  |80           \ b|
00000ef0  6c 6f 63 6b 20 6c 65 6e  67 74 68 20 3d 20 30 20  |lock length = 0 |
00000f00  28 20 3d 20 32 35 36 29  0a 2e 73 65 6e 64 5f 62  |( = 256)..send_b|
00000f10  6c 6f 63 6b 0a 20 20 20  20 20 20 20 20 20 20 4a  |lock.          J|
00000f20  53 52 20 70 75 74 5f 6f  6b 20 20 20 20 20 20 20  |SR put_ok       |
00000f30  20 5c 20 6e 6f 74 20 65  6f 66 0a 20 20 20 20 20  | \ not eof.     |
00000f40  20 20 20 20 20 4c 44 41  20 23 33 20 20 20 20 20  |     LDA #3     |
00000f50  20 20 20 20 20 20 20 5c  20 73 65 6e 64 20 6c 65  |       \ send le|
00000f60  6e 67 74 68 20 33 20 74  69 6d 65 73 0a 20 20 20  |ngth 3 times.   |
00000f70  20 20 20 20 20 20 20 53  54 41 20 26 37 36 20 20  |       STA &76  |
00000f80  20 20 20 20 20 20 20 20  20 5c 20 75 73 65 20 43  |         \ use C|
00000f90  52 43 20 6c 6f 77 20 62  79 74 65 20 61 73 20 63  |RC low byte as c|
00000fa0  6f 75 6e 74 65 72 0a 2e  6c 65 6e 6f 75 74 0a 20  |ounter..lenout. |
00000fb0  20 20 20 20 20 20 20 20  20 4c 44 41 20 26 38 30  |         LDA &80|
00000fc0  0a 20 20 20 20 20 20 20  20 20 20 4a 53 52 20 70  |.          JSR p|
00000fd0  75 74 20 20 20 20 20 20  20 20 20 20 20 5c 20 6f  |ut           \ o|
00000fe0  75 74 70 75 74 20 62 6c  6f 63 6b 20 6c 65 6e 67  |utput block leng|
00000ff0  74 68 0a 20 20 20 20 20  20 20 20 20 20 44 45 43  |th.          DEC|
00001000  20 26 37 36 0a 20 20 20  20 20 20 20 20 20 20 42  | &76.          B|
00001010  4e 45 20 6c 65 6e 6f 75  74 20 20 20 20 20 20 20  |NE lenout       |
00001020  20 5c 20 43 52 43 20 6c  6f 77 20 62 79 74 65 20  | \ CRC low byte |
00001030  7a 65 72 6f 20 61 74 20  65 78 69 74 0a 20 20 20  |zero at exit.   |
00001040  20 20 20 20 20 20 20 4c  44 59 20 23 30 0a 20 20  |       LDY #0.  |
00001050  20 20 20 20 20 20 20 20  53 54 59 20 26 37 35 20  |        STY &75 |
00001060  20 20 20 20 20 20 20 20  20 20 5c 20 69 6e 69 74  |          \ init|
00001070  69 61 6c 69 73 65 20 43  52 43 20 68 69 67 68 20  |ialise CRC high |
00001080  62 79 74 65 0a 2e 73 65  6e 64 5f 62 79 74 65 0a  |byte..send_byte.|
00001090  20 20 20 20 20 20 20 20  20 20 53 54 59 20 26 37  |          STY &7|
000010a0  30 20 20 20 20 20 20 20  20 20 20 20 5c 20 73 61  |0           \ sa|
000010b0  76 65 20 6f 66 66 73 65  74 0a 20 20 20 20 20 20  |ve offset.      |
000010c0  20 20 20 20 4c 44 41 20  28 26 37 33 29 2c 59 20  |    LDA (&73),Y |
000010d0  20 20 20 20 20 20 5c 20  6c 6f 61 64 20 6e 65 78  |      \ load nex|
000010e0  74 20 62 79 74 65 20 2e  2e 2e 0a 20 20 20 20 20  |t byte ....     |
000010f0  20 20 20 20 20 50 48 41  0a 20 20 20 20 20 20 20  |     PHA.       |
00001100  20 20 20 4a 53 52 20 70  75 74 0a 20 20 20 20 20  |   JSR put.     |
00001110  20 20 20 20 20 50 4c 41  20 20 20 20 20 20 20 20  |     PLA        |
00001120  20 20 20 20 20 20 20 5c  20 67 65 74 20 63 68 61  |       \ get cha|
00001130  72 61 63 74 65 72 20 62  61 63 6b 0a 20 20 20 20  |racter back.    |
00001140  20 20 20 20 20 20 4a 53  52 20 63 72 63 20 20 20  |      JSR crc   |
00001150  20 20 20 20 20 20 20 20  5c 20 75 70 64 61 74 65  |        \ update|
00001160  20 63 72 63 0a 20 20 20  20 20 20 20 20 20 20 4c  | crc.          L|
00001170  44 59 20 26 37 30 0a 20  20 20 20 20 20 20 20 20  |DY &70.         |
00001180  20 49 4e 59 20 20 20 20  20 20 20 20 20 20 20 20  | INY            |
00001190  20 20 20 5c 20 69 6e 63  72 65 6d 65 6e 74 20 6f  |   \ increment o|
000011a0  66 66 73 65 74 0a 20 20  20 20 20 20 20 20 20 20  |ffset.          |
000011b0  43 50 59 20 26 38 30 0a  20 20 20 20 20 20 20 20  |CPY &80.        |
000011c0  20 20 42 4e 45 20 73 65  6e 64 5f 62 79 74 65 20  |  BNE send_byte |
000011d0  20 20 20 20 5c 20 65 6e  64 20 6f 66 20 62 6c 6f  |    \ end of blo|
000011e0  63 6b 3f 0a 3a 0a 20 20  20 20 20 20 20 20 20 20  |ck?.:.          |
000011f0  4c 44 41 20 26 37 35 0a  20 20 20 20 20 20 20 20  |LDA &75.        |
00001200  20 20 4a 53 52 20 70 75  74 20 20 20 20 20 20 20  |  JSR put       |
00001210  20 20 20 20 5c 20 6f 75  74 70 75 74 20 43 52 43  |    \ output CRC|
00001220  20 68 69 67 68 20 62 79  74 65 0a 20 20 20 20 20  | high byte.     |
00001230  20 20 20 20 20 4c 44 41  20 26 37 36 0a 20 20 20  |     LDA &76.   |
00001240  20 20 20 20 20 20 20 4a  53 52 20 70 75 74 20 20  |       JSR put  |
00001250  20 20 20 20 20 20 20 20  20 5c 20 6f 75 74 70 75  |         \ outpu|
00001260  74 20 43 52 43 20 6c 6f  77 20 62 79 74 65 0a 3a  |t CRC low byte.:|
00001270  0a 20 20 20 20 20 20 20  20 20 20 4a 53 52 20 67  |.          JSR g|
00001280  65 74 20 20 20 20 20 20  20 20 20 20 20 5c 20 6c  |et           \ l|
00001290  6f 6f 6b 20 66 6f 72 20  63 6f 6e 66 69 72 6d 61  |ook for confirma|
000012a0  74 69 6f 6e 0a 20 20 20  20 20 20 20 20 20 20 54  |tion.          T|
000012b0  59 41 0a 20 20 20 20 20  20 20 20 20 20 42 45 51  |YA.          BEQ|
000012c0  20 73 65 6e 64 5f 62 6c  6f 63 6b 20 20 20 20 5c  | send_block    \|
000012d0  20 7a 65 72 6f 20 6d 65  61 6e 73 20 65 72 72 6f  | zero means erro|
000012e0  72 2c 20 73 6f 20 64 6f  20 61 67 61 69 6e 0a 3a  |r, so do again.:|
000012f0  0a 20 20 20 20 20 20 20  20 20 20 49 4e 43 20 26  |.          INC &|
00001300  37 34 20 20 20 20 20 20  20 20 20 20 20 5c 20 69  |74           \ i|
00001310  6e 63 72 65 6d 65 6e 74  20 61 64 64 72 65 73 73  |ncrement address|
00001320  20 68 69 67 68 20 62 79  74 65 0a 20 20 20 20 20  | high byte.     |
00001330  20 20 20 20 20 44 45 43  20 26 37 32 20 20 20 20  |     DEC &72    |
00001340  20 20 20 20 20 20 20 5c  20 64 65 63 72 65 6d 65  |       \ decreme|
00001350  6e 74 20 6c 65 6e 67 74  68 20 68 69 67 68 20 62  |nt length high b|
00001360  79 74 65 0a 20 20 20 20  20 20 20 20 20 20 42 50  |yte.          BP|
00001370  4c 20 73 65 6e 64 5f 62  6c 6f 63 6b 20 20 20 20  |L send_block    |
00001380  5c 20 61 72 65 20 77 65  20 66 69 6e 69 73 68 65  |\ are we finishe|
00001390  64 3f 0a 2e 6c 61 73 74  5f 62 6c 6f 63 6b 0a 20  |d?..last_block. |
000013a0  20 20 20 20 20 20 20 20  20 4c 44 59 20 23 30 0a  |         LDY #0.|
000013b0  20 20 20 20 20 20 20 20  20 20 4c 44 41 20 26 37  |          LDA &7|
000013c0  31 20 20 20 20 20 20 20  20 20 20 20 5c 20 6c 65  |1           \ le|
000013d0  6e 67 74 68 20 6f 66 20  6c 61 73 74 20 62 6c 6f  |ngth of last blo|
000013e0  63 6b 0a 20 20 20 20 20  20 20 20 20 20 53 54 59  |ck.          STY|
000013f0  20 26 37 31 20 20 20 20  20 20 20 20 20 20 20 5c  | &71           \|
00001400  20 73 65 74 20 6c 65 6e  67 74 68 20 74 6f 20 7a  | set length to z|
00001410  65 72 6f 0a 20 20 20 20  20 20 20 20 20 20 53 54  |ero.          ST|
00001420  41 20 26 38 30 0a 20 20  20 20 20 20 20 20 20 20  |A &80.          |
00001430  42 4e 45 20 73 65 6e 64  5f 62 6c 6f 63 6b 20 20  |BNE send_block  |
00001440  20 20 5c 20 6f 75 74 70  75 74 20 69 66 20 6e 6f  |  \ output if no|
00001450  6e 2d 7a 65 72 6f 0a 20  20 20 20 20 20 20 20 20  |n-zero.         |
00001460  20 4c 44 41 20 23 30 0a  20 20 20 20 20 20 20 20  | LDA #0.        |
00001470  20 20 4a 53 52 20 70 75  74 20 20 20 20 20 20 20  |  JSR put       |
00001480  20 20 20 20 5c 20 7a 65  72 6f 20 6d 61 72 6b 73  |    \ zero marks|
00001490  20 65 6f 66 0a 20 20 20  20 20 20 20 20 20 20 4a  | eof.          J|
000014a0  53 52 20 70 75 74 5f 6c  6f 61 64 5f 65 78 65 63  |SR put_load_exec|
000014b0  20 5c 20 73 65 6e 64 20  74 68 65 20 6c 6f 61 64  | \ send the load|
000014c0  2f 65 78 65 63 20 61 64  72 65 73 73 0a 2e 70 75  |/exec adress..pu|
000014d0  74 5f 6e 61 6d 65 20 20  20 20 20 20 20 20 20 20  |t_name          |
000014e0  20 20 20 20 20 20 20 20  20 5c 20 66 61 6c 6c 20  |         \ fall |
000014f0  74 68 72 6f 75 67 68 20  74 6f 20 70 75 74 5f 6e  |through to put_n|
00001500  61 6d 65 20 2e 2e 2e 0a  20 20 20 20 20 20 20 20  |ame ....        |
00001510  20 20 4c 44 58 20 23 26  46 46 0a 20 20 20 20 20  |  LDX #&FF.     |
00001520  20 20 20 20 20 53 54 58  20 26 38 31 20 20 20 20  |     STX &81    |
00001530  20 20 20 20 20 20 20 5c  20 22 70 75 74 22 20 63  |       \ "put" c|
00001540  6f 72 72 75 70 74 73 20  72 65 67 69 73 74 65 72  |orrupts register|
00001550  73 0a 2e 70 75 74 5f 63  68 61 72 20 20 20 20 20  |s..put_char     |
00001560  20 20 20 20 20 20 20 20  20 20 20 20 20 20 5c 20  |              \ |
00001570  6f 75 74 70 75 74 20 66  69 6c 65 20 6e 61 6d 65  |output file name|
00001580  0a 20 20 20 20 20 20 20  20 20 20 49 4e 43 20 26  |.          INC &|
00001590  38 31 0a 20 20 20 20 20  20 20 20 20 20 4c 44 58  |81.          LDX|
000015a0  20 26 38 31 0a 20 20 20  20 20 20 20 20 20 20 4c  | &81.          L|
000015b0  44 41 20 6e 61 6d 65 2c  58 0a 20 20 20 20 20 20  |DA name,X.      |
000015c0  20 20 20 20 50 48 41 0a  20 20 20 20 20 20 20 20  |    PHA.        |
000015d0  20 20 4a 53 52 20 70 75  74 0a 20 20 20 20 20 20  |  JSR put.      |
000015e0  20 20 20 20 50 4c 41 0a  20 20 20 20 20 20 20 20  |    PLA.        |
000015f0  20 20 43 4d 50 20 23 26  30 44 0a 20 20 20 20 20  |  CMP #&0D.     |
00001600  20 20 20 20 20 42 4e 45  20 70 75 74 5f 63 68 61  |     BNE put_cha|
00001610  72 0a 20 20 20 20 20 20  20 20 20 20 52 54 53 0a  |r.          RTS.|
00001620  2e 70 75 74 5f 6c 6f 61  64 5f 65 78 65 63 20 20  |.put_load_exec  |
00001630  20 20 20 20 20 20 20 20  20 20 20 20 5c 20 70 75  |            \ pu|
00001640  74 20 6f 75 74 20 6c 6f  61 64 2f 65 78 65 63 20  |t out load/exec |
00001650  61 64 64 72 65 73 73 0a  20 20 20 20 20 20 20 20  |address.        |
00001660  20 20 4c 44 58 20 23 30  0a 20 20 20 20 20 20 20  |  LDX #0.       |
00001670  20 20 20 53 54 58 20 26  38 31 20 20 20 20 20 20  |   STX &81      |
00001680  20 20 20 20 20 5c 20 22  70 75 74 22 20 63 6f 72  |     \ "put" cor|
00001690  72 75 70 74 73 20 72 65  67 69 73 74 65 72 73 0a  |rupts registers.|
000016a0  2e 70 75 74 5f 6c 6f 61  64 5f 65 78 65 63 5f 6c  |.put_load_exec_l|
000016b0  6f 6f 70 0a 20 20 20 20  20 20 20 20 20 20 4c 44  |oop.          LD|
000016c0  41 20 26 38 32 2c 58 0a  20 20 20 20 20 20 20 20  |A &82,X.        |
000016d0  20 20 4a 53 52 20 70 75  74 0a 20 20 20 20 20 20  |  JSR put.      |
000016e0  20 20 20 20 49 4e 43 20  26 38 31 0a 20 20 20 20  |    INC &81.    |
000016f0  20 20 20 20 20 20 4c 44  58 20 26 38 31 0a 20 20  |      LDX &81.  |
00001700  20 20 20 20 20 20 20 20  43 50 58 20 23 38 0a 20  |        CPX #8. |
00001710  20 20 20 20 20 20 20 20  20 42 4e 45 20 70 75 74  |         BNE put|
00001720  5f 6c 6f 61 64 5f 65 78  65 63 5f 6c 6f 6f 70 0a  |_load_exec_loop.|
00001730  20 20 20 20 20 20 20 20  20 20 52 54 53 0a 2e 70  |          RTS..p|
00001740  75 74 5f 6f 6b 0a 20 20  20 20 20 20 20 20 20 20  |ut_ok.          |
00001750  4c 44 41 20 23 26 46 46  0a 2e 70 75 74 0a 20 20  |LDA #&FF..put.  |
00001760  20 20 20 20 20 20 20 20  50 48 41 20 20 20 20 20  |        PHA     |
00001770  20 20 20 20 20 20 20 20  20 20 5c 20 73 61 76 65  |          \ save|
00001780  20 76 61 6c 75 65 20 74  6f 20 6f 75 74 70 75 74  | value to output|
00001790  0a 20 20 20 20 20 20 20  20 20 20 4a 53 52 20 65  |.          JSR e|
000017a0  73 63 61 70 65 0a 20 20  20 20 20 20 20 20 20 20  |scape.          |
000017b0  4c 44 58 20 23 26 46 44  0a 20 20 20 20 20 20 20  |LDX #&FD.       |
000017c0  20 20 20 4c 44 41 20 23  26 38 30 0a 20 20 20 20  |   LDA #&80.    |
000017d0  20 20 20 20 20 20 4a 53  52 20 6f 73 62 79 74 65  |      JSR osbyte|
000017e0  20 20 20 20 20 20 20 20  5c 20 67 65 74 20 23 20  |        \ get # |
000017f0  65 6d 70 74 79 20 62 79  74 65 73 20 69 6e 20 52  |empty bytes in R|
00001800  53 34 32 33 20 6f 75 74  70 75 74 20 62 75 66 66  |S423 output buff|
00001810  65 72 0a 20 20 20 20 20  20 20 20 20 20 43 50 58  |er.          CPX|
00001820  20 23 39 0a 20 20 20 20  20 20 20 20 20 20 50 4c  | #9.          PL|
00001830  41 0a 20 20 20 20 20 20  20 20 20 20 42 43 43 20  |A.          BCC |
00001840  70 75 74 20 20 20 20 20  20 20 20 20 20 20 5c 20  |put           \ |
00001850  69 66 20 3c 20 39 20 62  79 74 65 73 20 72 65 6d  |if < 9 bytes rem|
00001860  61 69 6e 2c 20 77 61 69  74 20 2e 2e 2e 0a 3a 0a  |ain, wait ....:.|
00001870  20 20 20 20 20 20 20 20  20 20 4c 44 58 20 23 32  |          LDX #2|
00001880  0a 20 20 20 20 20 20 20  20 20 20 54 41 59 0a 20  |.          TAY. |
00001890  20 20 20 20 20 20 20 20  20 4c 44 41 20 23 26 38  |         LDA #&8|
000018a0  41 0a 20 20 20 20 20 20  20 20 20 20 4a 4d 50 20  |A.          JMP |
000018b0  6f 73 62 79 74 65 20 20  20 20 20 20 20 20 5c 20  |osbyte        \ |
000018c0  2e 2e 2e 20 61 6e 64 20  73 65 6e 64 20 69 74 0a  |... and send it.|
000018d0  2e 67 65 74 0a 20 20 20  20 20 20 20 20 20 20 4a  |.get.          J|
000018e0  53 52 20 65 73 63 61 70  65 0a 20 20 20 20 20 20  |SR escape.      |
000018f0  20 20 20 20 4c 44 58 20  23 31 0a 20 20 20 20 20  |    LDX #1.     |
00001900  20 20 20 20 20 4c 44 41  20 23 26 39 31 0a 20 20  |     LDA #&91.  |
00001910  20 20 20 20 20 20 20 20  4a 53 52 20 6f 73 62 79  |        JSR osby|
00001920  74 65 20 20 20 20 20 20  20 20 5c 20 72 65 61 64  |te        \ read|
00001930  20 61 20 62 79 74 65 0a  20 20 20 20 20 20 20 20  | a byte.        |
00001940  20 20 42 43 53 20 67 65  74 0a 20 20 20 20 20 20  |  BCS get.      |
00001950  20 20 20 20 52 54 53 0a  2e 63 72 63 0a 20 20 20  |    RTS..crc.   |
00001960  20 20 20 20 20 20 20 45  4f 52 20 26 37 35 20 20  |       EOR &75  |
00001970  20 20 20 20 20 20 20 20  20 5c 20 63 61 6c 63 75  |         \ calcu|
00001980  6c 61 74 65 20 43 52 43  20 69 6e 20 26 37 35 2c  |late CRC in &75,|
00001990  20 26 37 36 0a 20 20 20  20 20 20 20 20 20 20 53  | &76.          S|
000019a0  54 41 20 26 37 35 20 20  20 20 20 20 20 20 20 20  |TA &75          |
000019b0  20 5c 20 61 6c 67 6f 72  69 74 68 6d 20 66 72 6f  | \ algorithm fro|
000019c0  6d 20 41 64 76 61 6e 63  65 64 20 55 73 65 72 20  |m Advanced User |
000019d0  47 75 69 64 65 0a 20 20  20 20 20 20 20 20 20 20  |Guide.          |
000019e0  4c 44 58 20 23 38 20 20  20 20 20 20 20 20 20 20  |LDX #8          |
000019f0  20 20 5c 20 49 20 68 6f  70 65 20 69 74 27 73 20  |  \ I hope it's |
00001a00  72 69 67 68 74 21 0a 2e  63 72 63 5f 6c 6f 6f 70  |right!..crc_loop|
00001a10  0a 20 20 20 20 20 20 20  20 20 20 4c 44 41 20 26  |.          LDA &|
00001a20  37 35 0a 20 20 20 20 20  20 20 20 20 20 52 4f 4c  |75.          ROL|
00001a30  20 41 0a 20 20 20 20 20  20 20 20 20 20 42 43 43  | A.          BCC|
00001a40  20 62 37 7a 0a 20 20 20  20 20 20 20 20 20 20 4c  | b7z.          L|
00001a50  44 41 20 26 37 35 0a 20  20 20 20 20 20 20 20 20  |DA &75.         |
00001a60  20 45 4f 52 20 23 38 0a  20 20 20 20 20 20 20 20  | EOR #8.        |
00001a70  20 20 53 54 41 20 26 37  35 0a 20 20 20 20 20 20  |  STA &75.      |
00001a80  20 20 20 20 4c 44 41 20  26 37 36 0a 20 20 20 20  |    LDA &76.    |
00001a90  20 20 20 20 20 20 45 4f  52 20 23 26 31 30 0a 20  |      EOR #&10. |
00001aa0  20 20 20 20 20 20 20 20  20 53 54 41 20 26 37 36  |         STA &76|
00001ab0  0a 2e 62 37 7a 0a 20 20  20 20 20 20 20 20 20 20  |..b7z.          |
00001ac0  52 4f 4c 20 26 37 36 0a  20 20 20 20 20 20 20 20  |ROL &76.        |
00001ad0  20 20 52 4f 4c 20 26 37  35 0a 20 20 20 20 20 20  |  ROL &75.      |
00001ae0  20 20 20 20 44 45 58 0a  20 20 20 20 20 20 20 20  |    DEX.        |
00001af0  20 20 42 4e 45 20 63 72  63 5f 6c 6f 6f 70 0a 20  |  BNE crc_loop. |
00001b00  20 20 20 20 20 20 20 20  20 52 54 53 0a 2e 65 73  |         RTS..es|
00001b10  63 61 70 65 0a 20 20 20  20 20 20 20 20 20 20 4c  |cape.          L|
00001b20  44 41 20 26 46 46 0a 20  20 20 20 20 20 20 20 20  |DA &FF.         |
00001b30  20 42 4d 49 20 65 72 72  6f 72 0a 20 20 20 20 20  | BMI error.     |
00001b40  20 20 20 20 20 52 54 53  0a 2e 65 72 72 6f 72 0a  |     RTS..error.|
00001b50  20 20 20 20 20 20 20 20  20 20 4c 44 41 20 23 26  |          LDA #&|
00001b60  37 45 0a 20 20 20 20 20  20 20 20 20 20 4a 53 52  |7E.          JSR|
00001b70  20 6f 73 62 79 74 65 20  20 20 20 20 20 20 20 5c  | osbyte        \|
00001b80  20 61 63 6b 6e 6f 77 6c  65 64 67 65 20 65 73 63  | acknowledge esc|
00001b90  61 70 65 0a 20 20 20 20  20 20 20 20 20 20 4c 44  |ape.          LD|
00001ba0  58 20 23 30 0a 20 20 20  20 20 20 20 20 20 20 4c  |X #0.          L|
00001bb0  44 59 20 23 30 0a 20 20  20 20 20 20 20 20 20 20  |DY #0.          |
00001bc0  4c 44 41 20 23 30 0a 20  20 20 20 20 20 20 20 20  |LDA #0.         |
00001bd0  20 4a 53 52 20 26 46 46  43 45 20 20 20 20 20 20  | JSR &FFCE      |
00001be0  20 20 20 5c 20 63 6c 6f  73 65 20 61 6c 6c 20 66  |   \ close all f|
00001bf0  69 6c 65 73 0a 20 20 20  20 20 20 20 20 20 20 42  |iles.          B|
00001c00  52 4b 0a 5d 0a 3f 50 25  20 3d 20 26 31 31 0a 50  |RK.].?P% = &11.P|
00001c10  25 20 20 3d 20 50 25 20  2b 20 31 0a 24 50 25 20  |%  = P% + 1.$P% |
00001c20  3d 20 22 45 73 63 61 70  65 22 20 2b 20 43 48 52  |= "Escape" + CHR|
00001c30  24 30 0a 4e 45 58 54 20  6f 70 74 25 0a 2a 4f 50  |$0.NEXT opt%.*OP|
00001c40  54 20 31 2c 32 0a 52 55  4e 0a 43 41 4c 4c 20 67  |T 1,2.RUN.CALL g|
00001c50  6f 0a                                             |o.|
00001c52