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

!BBCTape/BBCLoad

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/BBCLoad
Read OK:
File size: 205A bytes
Load address: 0000
Exec address: 0000
File contents
MODE 7
*TAPE
PAGE = &E00
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
:
name       = &0B00
name_high  = &0B
name_low   = &00
block      = &0B10
block_high = &0B
block_low  = &10
code_start = &0B30
load_page  = &0E
:
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_bget
          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
          JMP read_name     \ get load/exec address and name
.load_bget
          LDA #0
          STA &71:STA &72   \ file length in &71, &72
          STA &73
          LDA #load_page
          STA &74           \ load address in &73, &74
:
          LDX #name_low
          LDY #name_high
          LDA #&40
          JSR osfind        \ open file
          CMP #0
          BEQ end           \ open failed?
          STA &70           \ file handle
          LDY #0
.loop
          JSR escape        \ check for escape
          TYA:TAX           \ no TYX instruction!
          LDY &70
          JSR osbget        \ get byte
          PHA:TXA:TAY:PLA   \ just TXY!
          BCS eof           \ end of file?
          STA (&73),Y       \ can't use X register
          INY
          BNE loop          \ done 256 bytes?
          INC &72:INC &74   \ increment high bytes of counters
          BPL loop          \ should always be taken
.eof
          STY &71:STY &73   \ set low bytes of counters
          JSR read_load_exec
          JSR read_name     \ get load/exec address and name
          LDY &70
          LDA #0
          JMP osfind        \ close file
.read_name
          LDX #&FF
.nameloop
          INX
          CPX #&C
          BEQ too_far
          LDA &3B2,X        \ pull filename out of cassette workspace
          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
          LDA #&0F
          JSR osbyte        \ flush buffers (just in case)
          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 2a  54 41 50 45 0a 50 41 47  |MODE 7.*TAPE.PAG|
00000010  45 20 3d 20 26 45 30 30  0a 52 45 4d 0a 52 45 4d  |E = &E00.REM.REM|
00000020  20 42 42 43 20 65 6e 64  20 6f 66 20 21 42 42 43  | BBC end of !BBC|
00000030  54 61 70 65 20 61 70 70  6c 69 63 61 74 69 6f 6e  |Tape application|
00000040  0a 52 45 4d 0a 52 45 4d  20 28 43 29 20 53 2e 20  |.REM.REM (C) S. |
00000050  42 75 72 6b 65 2c 20 32  36 2f 32 2f 39 31 0a 52  |Burke, 26/2/91.R|
00000060  45 4d 0a 52 45 4d 20 54  68 65 20 6e 65 78 74 20  |EM.REM The next |
00000070  66 65 77 20 6c 69 6e 65  73 20 64 65 66 69 6e 65  |few lines define|
00000080  20 77 68 65 72 65 20 74  68 65 20 62 75 66 66 65  | where the buffe|
00000090  72 73 20 61 72 65 2c 20  77 68 65 72 65 20 74 68  |rs are, where th|
000000a0  65 0a 52 45 4d 20 63 6f  64 65 20 67 6f 65 73 20  |e.REM code goes |
000000b0  61 6e 64 20 77 68 65 72  65 20 74 68 65 20 66 69  |and where the fi|
000000c0  6c 65 20 6c 6f 61 64 73  20 74 6f 2e 0a 52 45 4d  |le loads to..REM|
000000d0  0a 3a 0a 6e 61 6d 65 20  20 20 20 20 20 20 3d 20  |.:.name       = |
000000e0  26 30 42 30 30 0a 6e 61  6d 65 5f 68 69 67 68 20  |&0B00.name_high |
000000f0  20 3d 20 26 30 42 0a 6e  61 6d 65 5f 6c 6f 77 20  | = &0B.name_low |
00000100  20 20 3d 20 26 30 30 0a  62 6c 6f 63 6b 20 20 20  |  = &00.block   |
00000110  20 20 20 3d 20 26 30 42  31 30 0a 62 6c 6f 63 6b  |   = &0B10.block|
00000120  5f 68 69 67 68 20 3d 20  26 30 42 0a 62 6c 6f 63  |_high = &0B.bloc|
00000130  6b 5f 6c 6f 77 20 20 3d  20 26 31 30 0a 63 6f 64  |k_low  = &10.cod|
00000140  65 5f 73 74 61 72 74 20  3d 20 26 30 42 33 30 0a  |e_start = &0B30.|
00000150  6c 6f 61 64 5f 70 61 67  65 20 20 3d 20 26 30 45  |load_page  = &0E|
00000160  0a 3a 0a 6f 73 66 69 6e  64 20 3d 20 26 46 46 43  |.:.osfind = &FFC|
00000170  45 0a 6f 73 62 67 65 74  20 3d 20 26 46 46 44 37  |E.osbget = &FFD7|
00000180  0a 6f 73 66 69 6c 65 20  3d 20 26 46 46 44 44 20  |.osfile = &FFDD |
00000190  20 3a 52 45 4d 20 50 61  67 65 20 33 33 35 20 6f  | :REM Page 335 o|
000001a0  66 20 74 68 65 20 41 64  76 61 6e 63 65 64 20 55  |f the Advanced U|
000001b0  73 65 72 20 47 75 69 64  65 20 69 73 20 77 72 6f  |ser Guide is wro|
000001c0  6e 67 21 0a 6f 73 62 79  74 65 20 3d 20 26 46 46  |ng!.osbyte = &FF|
000001d0  46 34 0a 3a 0a 46 4f 52  20 6f 70 74 25 3d 30 20  |F4.:.FOR opt%=0 |
000001e0  54 4f 20 33 20 53 54 45  50 20 33 0a 50 25 20 3d  |TO 3 STEP 3.P% =|
000001f0  20 63 6f 64 65 5f 73 74  61 72 74 0a 5b 4f 50 54  | code_start.[OPT|
00000200  20 6f 70 74 25 0a 2e 67  6f 0a 20 20 20 20 20 20  | opt%..go.      |
00000210  20 20 20 20 4c 44 58 20  23 30 0a 20 20 20 20 20  |    LDX #0.     |
00000220  20 20 20 20 20 4c 44 41  20 23 32 0a 20 20 20 20  |     LDA #2.    |
00000230  20 20 20 20 20 20 4a 53  52 20 6f 73 62 79 74 65  |      JSR osbyte|
00000240  20 20 20 20 20 20 20 20  5c 20 64 69 73 61 62 6c  |        \ disabl|
00000250  65 20 52 53 34 32 33 0a  20 20 20 20 20 20 20 20  |e RS423.        |
00000260  20 20 4c 44 58 20 23 30  0a 20 20 20 20 20 20 20  |  LDX #0.       |
00000270  20 20 20 4c 44 41 20 23  31 35 0a 20 20 20 20 20  |   LDA #15.     |
00000280  20 20 20 20 20 4a 53 52  20 6f 73 62 79 74 65 20  |     JSR osbyte |
00000290  20 20 20 20 20 20 20 5c  20 66 6c 75 73 68 20 61  |       \ flush a|
000002a0  6c 6c 20 62 75 66 66 65  72 73 0a 20 20 20 20 20  |ll buffers.     |
000002b0  20 20 20 20 20 4c 44 58  20 23 32 0a 20 20 20 20  |     LDX #2.    |
000002c0  20 20 20 20 20 20 54 58  41 0a 20 20 20 20 20 20  |      TXA.      |
000002d0  20 20 20 20 4a 53 52 20  6f 73 62 79 74 65 20 20  |    JSR osbyte  |
000002e0  20 20 20 20 20 20 5c 20  65 6e 61 62 6c 65 20 52  |      \ enable R|
000002f0  53 34 32 33 20 72 65 63  65 69 76 65 0a 2e 6d 61  |S423 receive..ma|
00000300  69 6e 6c 6f 6f 70 0a 20  20 20 20 20 20 20 20 20  |inloop.         |
00000310  20 4c 44 41 20 23 26 30  44 0a 20 20 20 20 20 20  | LDA #&0D.      |
00000320  20 20 20 20 53 54 41 20  6e 61 6d 65 20 20 20 20  |    STA name    |
00000330  20 20 20 20 20 20 5c 20  6e 75 6c 6c 20 6e 61 6d  |      \ null nam|
00000340  65 0a 20 20 20 20 20 20  20 20 20 20 4a 53 52 20  |e.          JSR |
00000350  68 61 6e 64 73 68 61 6b  65 0a 3a 0a 20 20 20 20  |handshake.:.    |
00000360  20 20 20 20 20 20 4a 53  52 20 67 65 74 20 20 20  |      JSR get   |
00000370  20 20 20 20 20 20 20 20  5c 20 67 65 74 20 63 6f  |        \ get co|
00000380  6d 6d 61 6e 64 0a 20 20  20 20 20 20 20 20 20 20  |mmand.          |
00000390  43 50 59 20 23 26 43 30  0a 20 20 20 20 20 20 20  |CPY #&C0.       |
000003a0  20 20 20 42 45 51 20 65  6e 64 20 20 20 20 20 20  |   BEQ end      |
000003b0  20 20 20 20 20 5c 20 71  75 69 74 0a 3a 0a 20 20  |     \ quit.:.  |
000003c0  20 20 20 20 20 20 20 20  43 50 59 20 23 26 33 30  |        CPY #&30|
000003d0  0a 20 20 20 20 20 20 20  20 20 20 42 4e 45 20 6c  |.          BNE l|
000003e0  6f 61 64 0a 20 20 20 20  20 20 20 20 20 20 4a 53  |oad.          JS|
000003f0  52 20 70 75 74 5f 6f 6b  20 20 20 20 20 20 20 20  |R put_ok        |
00000400  5c 20 63 6f 6e 66 69 72  6d 20 63 6f 6d 6d 61 6e  |\ confirm comman|
00000410  64 0a 20 20 20 20 20 20  20 20 20 20 4a 53 52 20  |d.          JSR |
00000420  67 65 74 5f 6e 61 6d 65  20 20 20 20 20 20 5c 20  |get_name      \ |
00000430  67 65 74 20 66 69 6c 65  6e 61 6d 65 0a 20 20 20  |get filename.   |
00000440  20 20 20 20 20 20 20 4a  53 52 20 68 61 6e 64 73  |       JSR hands|
00000450  68 61 6b 65 0a 20 20 20  20 20 20 20 20 20 20 4a  |hake.          J|
00000460  53 52 20 67 65 74 0a 2e  6c 6f 61 64 0a 20 20 20  |SR get..load.   |
00000470  20 20 20 20 20 20 20 43  50 59 20 23 26 30 43 0a  |       CPY #&0C.|
00000480  20 20 20 20 20 20 20 20  20 20 42 4e 45 20 6c 6f  |          BNE lo|
00000490  61 64 5f 62 79 74 65 0a  20 20 20 20 20 20 20 20  |ad_byte.        |
000004a0  20 20 4a 53 52 20 70 75  74 5f 6f 6b 20 20 20 20  |  JSR put_ok    |
000004b0  20 20 20 20 5c 20 63 6f  6e 66 69 72 6d 20 63 6f  |    \ confirm co|
000004c0  6d 6d 61 6e 64 0a 20 20  20 20 20 20 20 20 20 20  |mmand.          |
000004d0  4a 53 52 20 6c 6f 61 64  5f 66 69 6c 65 0a 20 20  |JSR load_file.  |
000004e0  20 20 20 20 20 20 20 20  4a 53 52 20 73 65 6e 64  |        JSR send|
000004f0  5f 66 69 6c 65 0a 20 20  20 20 20 20 20 20 20 20  |_file.          |
00000500  4a 4d 50 20 6d 61 69 6e  6c 6f 6f 70 0a 2e 6c 6f  |JMP mainloop..lo|
00000510  61 64 5f 62 79 74 65 0a  20 20 20 20 20 20 20 20  |ad_byte.        |
00000520  20 20 43 50 59 20 23 26  30 33 0a 20 20 20 20 20  |  CPY #&03.     |
00000530  20 20 20 20 20 42 4e 45  20 63 6f 6d 6d 61 6e 64  |     BNE command|
00000540  5f 65 72 72 6f 72 0a 20  20 20 20 20 20 20 20 20  |_error.         |
00000550  20 4a 53 52 20 70 75 74  5f 6f 6b 20 20 20 20 20  | JSR put_ok     |
00000560  20 20 20 5c 20 63 6f 6e  66 69 72 6d 20 63 6f 6d  |   \ confirm com|
00000570  6d 61 6e 64 0a 20 20 20  20 20 20 20 20 20 20 4a  |mand.          J|
00000580  53 52 20 6c 6f 61 64 5f  62 67 65 74 0a 20 20 20  |SR load_bget.   |
00000590  20 20 20 20 20 20 20 4a  53 52 20 73 65 6e 64 5f  |       JSR send_|
000005a0  66 69 6c 65 0a 20 20 20  20 20 20 20 20 20 20 4a  |file.          J|
000005b0  4d 50 20 6d 61 69 6e 6c  6f 6f 70 0a 2e 63 6f 6d  |MP mainloop..com|
000005c0  6d 61 6e 64 5f 65 72 72  6f 72 0a 20 20 20 20 20  |mand_error.     |
000005d0  20 20 20 20 20 4c 44 41  20 23 30 0a 20 20 20 20  |     LDA #0.    |
000005e0  20 20 20 20 20 20 4a 53  52 20 70 75 74 20 20 20  |      JSR put   |
000005f0  20 20 20 20 20 20 20 20  5c 20 63 6f 6d 6d 61 6e  |        \ comman|
00000600  64 20 65 72 72 6f 72 0a  20 20 20 20 20 20 20 20  |d error.        |
00000610  20 20 4a 4d 50 20 6d 61  69 6e 6c 6f 6f 70 0a 2e  |  JMP mainloop..|
00000620  65 6e 64 0a 20 20 20 20  20 20 20 20 20 20 52 54  |end.          RT|
00000630  53 0a 2e 6c 6f 61 64 5f  66 69 6c 65 0a 20 20 20  |S..load_file.   |
00000640  20 20 20 20 20 20 20 4c  44 41 20 23 6e 61 6d 65  |       LDA #name|
00000650  5f 6c 6f 77 20 20 20 20  20 5c 20 73 65 74 20 75  |_low     \ set u|
00000660  70 20 70 61 72 61 6d 65  74 65 72 20 62 6c 6f 63  |p parameter bloc|
00000670  6b 0a 20 20 20 20 20 20  20 20 20 20 53 54 41 20  |k.          STA |
00000680  62 6c 6f 63 6b 0a 20 20  20 20 20 20 20 20 20 20  |block.          |
00000690  4c 44 41 20 23 6e 61 6d  65 5f 68 69 67 68 0a 20  |LDA #name_high. |
000006a0  20 20 20 20 20 20 20 20  20 53 54 41 20 62 6c 6f  |         STA blo|
000006b0  63 6b 2b 31 0a 20 20 20  20 20 20 20 20 20 20 4c  |ck+1.          L|
000006c0  44 41 20 23 30 0a 20 20  20 20 20 20 20 20 20 20  |DA #0.          |
000006d0  53 54 41 20 62 6c 6f 63  6b 2b 32 0a 20 20 20 20  |STA block+2.    |
000006e0  20 20 20 20 20 20 53 54  41 20 62 6c 6f 63 6b 2b  |      STA block+|
000006f0  36 0a 20 20 20 20 20 20  20 20 20 20 4c 44 41 20  |6.          LDA |
00000700  23 6c 6f 61 64 5f 70 61  67 65 0a 20 20 20 20 20  |#load_page.     |
00000710  20 20 20 20 20 53 54 41  20 62 6c 6f 63 6b 2b 33  |     STA block+3|
00000720  0a 20 20 20 20 20 20 20  20 20 20 4c 44 41 20 23  |.          LDA #|
00000730  26 46 46 0a 20 20 20 20  20 20 20 20 20 20 53 54  |&FF.          ST|
00000740  41 20 62 6c 6f 63 6b 2b  34 0a 20 20 20 20 20 20  |A block+4.      |
00000750  20 20 20 20 53 54 41 20  62 6c 6f 63 6b 2b 35 0a  |    STA block+5.|
00000760  20 20 20 20 20 20 20 20  20 20 4c 44 58 20 23 62  |          LDX #b|
00000770  6c 6f 63 6b 5f 6c 6f 77  0a 20 20 20 20 20 20 20  |lock_low.       |
00000780  20 20 20 4c 44 59 20 23  62 6c 6f 63 6b 5f 68 69  |   LDY #block_hi|
00000790  67 68 0a 20 20 20 20 20  20 20 20 20 20 4a 53 52  |gh.          JSR|
000007a0  20 6f 73 66 69 6c 65 20  20 20 20 20 20 20 20 5c  | osfile        \|
000007b0  20 6c 6f 61 64 20 66 69  6c 65 0a 20 20 20 20 20  | load file.     |
000007c0  20 20 20 20 20 4c 44 41  20 62 6c 6f 63 6b 2b 31  |     LDA block+1|
000007d0  30 0a 20 20 20 20 20 20  20 20 20 20 53 54 41 20  |0.          STA |
000007e0  26 37 31 0a 20 20 20 20  20 20 20 20 20 20 4c 44  |&71.          LD|
000007f0  41 20 62 6c 6f 63 6b 2b  31 31 0a 20 20 20 20 20  |A block+11.     |
00000800  20 20 20 20 20 53 54 41  20 26 37 32 20 20 20 20  |     STA &72    |
00000810  20 20 20 20 20 20 20 5c  20 70 75 74 20 66 69 6c  |       \ put fil|
00000820  65 20 6c 65 6e 67 74 68  20 69 6e 20 26 37 31 2c  |e length in &71,|
00000830  20 26 37 32 0a 20 20 20  20 20 20 20 20 20 20 4a  | &72.          J|
00000840  53 52 20 72 65 61 64 5f  6c 6f 61 64 5f 65 78 65  |SR read_load_exe|
00000850  63 0a 20 20 20 20 20 20  20 20 20 20 4a 4d 50 20  |c.          JMP |
00000860  72 65 61 64 5f 6e 61 6d  65 20 20 20 20 20 5c 20  |read_name     \ |
00000870  67 65 74 20 6c 6f 61 64  2f 65 78 65 63 20 61 64  |get load/exec ad|
00000880  64 72 65 73 73 20 61 6e  64 20 6e 61 6d 65 0a 2e  |dress and name..|
00000890  6c 6f 61 64 5f 62 67 65  74 0a 20 20 20 20 20 20  |load_bget.      |
000008a0  20 20 20 20 4c 44 41 20  23 30 0a 20 20 20 20 20  |    LDA #0.     |
000008b0  20 20 20 20 20 53 54 41  20 26 37 31 3a 53 54 41  |     STA &71:STA|
000008c0  20 26 37 32 20 20 20 5c  20 66 69 6c 65 20 6c 65  | &72   \ file le|
000008d0  6e 67 74 68 20 69 6e 20  26 37 31 2c 20 26 37 32  |ngth in &71, &72|
000008e0  0a 20 20 20 20 20 20 20  20 20 20 53 54 41 20 26  |.          STA &|
000008f0  37 33 0a 20 20 20 20 20  20 20 20 20 20 4c 44 41  |73.          LDA|
00000900  20 23 6c 6f 61 64 5f 70  61 67 65 0a 20 20 20 20  | #load_page.    |
00000910  20 20 20 20 20 20 53 54  41 20 26 37 34 20 20 20  |      STA &74   |
00000920  20 20 20 20 20 20 20 20  5c 20 6c 6f 61 64 20 61  |        \ load a|
00000930  64 64 72 65 73 73 20 69  6e 20 26 37 33 2c 20 26  |ddress in &73, &|
00000940  37 34 0a 3a 0a 20 20 20  20 20 20 20 20 20 20 4c  |74.:.          L|
00000950  44 58 20 23 6e 61 6d 65  5f 6c 6f 77 0a 20 20 20  |DX #name_low.   |
00000960  20 20 20 20 20 20 20 4c  44 59 20 23 6e 61 6d 65  |       LDY #name|
00000970  5f 68 69 67 68 0a 20 20  20 20 20 20 20 20 20 20  |_high.          |
00000980  4c 44 41 20 23 26 34 30  0a 20 20 20 20 20 20 20  |LDA #&40.       |
00000990  20 20 20 4a 53 52 20 6f  73 66 69 6e 64 20 20 20  |   JSR osfind   |
000009a0  20 20 20 20 20 5c 20 6f  70 65 6e 20 66 69 6c 65  |     \ open file|
000009b0  0a 20 20 20 20 20 20 20  20 20 20 43 4d 50 20 23  |.          CMP #|
000009c0  30 0a 20 20 20 20 20 20  20 20 20 20 42 45 51 20  |0.          BEQ |
000009d0  65 6e 64 20 20 20 20 20  20 20 20 20 20 20 5c 20  |end           \ |
000009e0  6f 70 65 6e 20 66 61 69  6c 65 64 3f 0a 20 20 20  |open failed?.   |
000009f0  20 20 20 20 20 20 20 53  54 41 20 26 37 30 20 20  |       STA &70  |
00000a00  20 20 20 20 20 20 20 20  20 5c 20 66 69 6c 65 20  |         \ file |
00000a10  68 61 6e 64 6c 65 0a 20  20 20 20 20 20 20 20 20  |handle.         |
00000a20  20 4c 44 59 20 23 30 0a  2e 6c 6f 6f 70 0a 20 20  | LDY #0..loop.  |
00000a30  20 20 20 20 20 20 20 20  4a 53 52 20 65 73 63 61  |        JSR esca|
00000a40  70 65 20 20 20 20 20 20  20 20 5c 20 63 68 65 63  |pe        \ chec|
00000a50  6b 20 66 6f 72 20 65 73  63 61 70 65 0a 20 20 20  |k for escape.   |
00000a60  20 20 20 20 20 20 20 54  59 41 3a 54 41 58 20 20  |       TYA:TAX  |
00000a70  20 20 20 20 20 20 20 20  20 5c 20 6e 6f 20 54 59  |         \ no TY|
00000a80  58 20 69 6e 73 74 72 75  63 74 69 6f 6e 21 0a 20  |X instruction!. |
00000a90  20 20 20 20 20 20 20 20  20 4c 44 59 20 26 37 30  |         LDY &70|
00000aa0  0a 20 20 20 20 20 20 20  20 20 20 4a 53 52 20 6f  |.          JSR o|
00000ab0  73 62 67 65 74 20 20 20  20 20 20 20 20 5c 20 67  |sbget        \ g|
00000ac0  65 74 20 62 79 74 65 0a  20 20 20 20 20 20 20 20  |et byte.        |
00000ad0  20 20 50 48 41 3a 54 58  41 3a 54 41 59 3a 50 4c  |  PHA:TXA:TAY:PL|
00000ae0  41 20 20 20 5c 20 6a 75  73 74 20 54 58 59 21 0a  |A   \ just TXY!.|
00000af0  20 20 20 20 20 20 20 20  20 20 42 43 53 20 65 6f  |          BCS eo|
00000b00  66 20 20 20 20 20 20 20  20 20 20 20 5c 20 65 6e  |f           \ en|
00000b10  64 20 6f 66 20 66 69 6c  65 3f 0a 20 20 20 20 20  |d of file?.     |
00000b20  20 20 20 20 20 53 54 41  20 28 26 37 33 29 2c 59  |     STA (&73),Y|
00000b30  20 20 20 20 20 20 20 5c  20 63 61 6e 27 74 20 75  |       \ can't u|
00000b40  73 65 20 58 20 72 65 67  69 73 74 65 72 0a 20 20  |se X register.  |
00000b50  20 20 20 20 20 20 20 20  49 4e 59 0a 20 20 20 20  |        INY.    |
00000b60  20 20 20 20 20 20 42 4e  45 20 6c 6f 6f 70 20 20  |      BNE loop  |
00000b70  20 20 20 20 20 20 20 20  5c 20 64 6f 6e 65 20 32  |        \ done 2|
00000b80  35 36 20 62 79 74 65 73  3f 0a 20 20 20 20 20 20  |56 bytes?.      |
00000b90  20 20 20 20 49 4e 43 20  26 37 32 3a 49 4e 43 20  |    INC &72:INC |
00000ba0  26 37 34 20 20 20 5c 20  69 6e 63 72 65 6d 65 6e  |&74   \ incremen|
00000bb0  74 20 68 69 67 68 20 62  79 74 65 73 20 6f 66 20  |t high bytes of |
00000bc0  63 6f 75 6e 74 65 72 73  0a 20 20 20 20 20 20 20  |counters.       |
00000bd0  20 20 20 42 50 4c 20 6c  6f 6f 70 20 20 20 20 20  |   BPL loop     |
00000be0  20 20 20 20 20 5c 20 73  68 6f 75 6c 64 20 61 6c  |     \ should al|
00000bf0  77 61 79 73 20 62 65 20  74 61 6b 65 6e 0a 2e 65  |ways be taken..e|
00000c00  6f 66 0a 20 20 20 20 20  20 20 20 20 20 53 54 59  |of.          STY|
00000c10  20 26 37 31 3a 53 54 59  20 26 37 33 20 20 20 5c  | &71:STY &73   \|
00000c20  20 73 65 74 20 6c 6f 77  20 62 79 74 65 73 20 6f  | set low bytes o|
00000c30  66 20 63 6f 75 6e 74 65  72 73 0a 20 20 20 20 20  |f counters.     |
00000c40  20 20 20 20 20 4a 53 52  20 72 65 61 64 5f 6c 6f  |     JSR read_lo|
00000c50  61 64 5f 65 78 65 63 0a  20 20 20 20 20 20 20 20  |ad_exec.        |
00000c60  20 20 4a 53 52 20 72 65  61 64 5f 6e 61 6d 65 20  |  JSR read_name |
00000c70  20 20 20 20 5c 20 67 65  74 20 6c 6f 61 64 2f 65  |    \ get load/e|
00000c80  78 65 63 20 61 64 64 72  65 73 73 20 61 6e 64 20  |xec address and |
00000c90  6e 61 6d 65 0a 20 20 20  20 20 20 20 20 20 20 4c  |name.          L|
00000ca0  44 59 20 26 37 30 0a 20  20 20 20 20 20 20 20 20  |DY &70.         |
00000cb0  20 4c 44 41 20 23 30 0a  20 20 20 20 20 20 20 20  | LDA #0.        |
00000cc0  20 20 4a 4d 50 20 6f 73  66 69 6e 64 20 20 20 20  |  JMP osfind    |
00000cd0  20 20 20 20 5c 20 63 6c  6f 73 65 20 66 69 6c 65  |    \ close file|
00000ce0  0a 2e 72 65 61 64 5f 6e  61 6d 65 0a 20 20 20 20  |..read_name.    |
00000cf0  20 20 20 20 20 20 4c 44  58 20 23 26 46 46 0a 2e  |      LDX #&FF..|
00000d00  6e 61 6d 65 6c 6f 6f 70  0a 20 20 20 20 20 20 20  |nameloop.       |
00000d10  20 20 20 49 4e 58 0a 20  20 20 20 20 20 20 20 20  |   INX.         |
00000d20  20 43 50 58 20 23 26 43  0a 20 20 20 20 20 20 20  | CPX #&C.       |
00000d30  20 20 20 42 45 51 20 74  6f 6f 5f 66 61 72 0a 20  |   BEQ too_far. |
00000d40  20 20 20 20 20 20 20 20  20 4c 44 41 20 26 33 42  |         LDA &3B|
00000d50  32 2c 58 20 20 20 20 20  20 20 20 5c 20 70 75 6c  |2,X        \ pul|
00000d60  6c 20 66 69 6c 65 6e 61  6d 65 20 6f 75 74 20 6f  |l filename out o|
00000d70  66 20 63 61 73 73 65 74  74 65 20 77 6f 72 6b 73  |f cassette works|
00000d80  70 61 63 65 0a 20 20 20  20 20 20 20 20 20 20 53  |pace.          S|
00000d90  54 41 20 6e 61 6d 65 2c  58 20 20 20 20 20 20 20  |TA name,X       |
00000da0  20 5c 20 73 65 65 20 41  55 47 20 70 2e 20 32 37  | \ see AUG p. 27|
00000db0  39 0a 20 20 20 20 20 20  20 20 20 20 42 4e 45 20  |9.          BNE |
00000dc0  6e 61 6d 65 6c 6f 6f 70  0a 2e 74 6f 6f 5f 66 61  |nameloop..too_fa|
00000dd0  72 0a 20 20 20 20 20 20  20 20 20 20 4c 44 41 20  |r.          LDA |
00000de0  23 26 30 44 0a 20 20 20  20 20 20 20 20 20 20 53  |#&0D.          S|
00000df0  54 41 20 6e 61 6d 65 2c  58 0a 20 20 20 20 20 20  |TA name,X.      |
00000e00  20 20 20 20 52 54 53 0a  2e 67 65 74 5f 6e 61 6d  |    RTS..get_nam|
00000e10  65 0a 20 20 20 20 20 20  20 20 20 20 4c 44 58 20  |e.          LDX |
00000e20  23 26 46 46 0a 20 20 20  20 20 20 20 20 20 20 53  |#&FF.          S|
00000e30  54 58 20 26 38 31 20 20  20 20 20 20 20 20 20 20  |TX &81          |
00000e40  20 5c 20 22 67 65 74 22  20 63 6f 72 72 75 70 74  | \ "get" corrupt|
00000e50  73 20 72 65 67 69 73 74  65 72 73 0a 2e 67 65 74  |s registers..get|
00000e60  5f 63 68 61 72 0a 20 20  20 20 20 20 20 20 20 20  |_char.          |
00000e70  43 50 58 20 23 26 42 0a  20 20 20 20 20 20 20 20  |CPX #&B.        |
00000e80  20 20 42 45 51 20 74 6f  6f 5f 66 61 72 0a 20 20  |  BEQ too_far.  |
00000e90  20 20 20 20 20 20 20 20  4a 53 52 20 67 65 74 20  |        JSR get |
00000ea0  20 20 20 20 20 20 20 20  20 20 5c 20 67 65 74 20  |          \ get |
00000eb0  66 69 6c 65 6e 61 6d 65  20 66 72 6f 6d 20 41 72  |filename from Ar|
00000ec0  63 0a 20 20 20 20 20 20  20 20 20 20 54 59 41 0a  |c.          TYA.|
00000ed0  20 20 20 20 20 20 20 20  20 20 49 4e 43 20 26 38  |          INC &8|
00000ee0  31 20 20 20 0a 20 20 20  20 20 20 20 20 20 20 4c  |1   .          L|
00000ef0  44 58 20 26 38 31 0a 20  20 20 20 20 20 20 20 20  |DX &81.         |
00000f00  20 53 54 41 20 6e 61 6d  65 2c 58 0a 20 20 20 20  | STA name,X.    |
00000f10  20 20 20 20 20 20 43 4d  50 20 23 26 30 44 0a 20  |      CMP #&0D. |
00000f20  20 20 20 20 20 20 20 20  20 42 4e 45 20 67 65 74  |         BNE get|
00000f30  5f 63 68 61 72 0a 20 20  20 20 20 20 20 20 20 20  |_char.          |
00000f40  52 54 53 0a 2e 72 65 61  64 5f 6c 6f 61 64 5f 65  |RTS..read_load_e|
00000f50  78 65 63 0a 20 20 20 20  20 20 20 20 20 20 4c 44  |xec.          LD|
00000f60  58 20 23 38 0a 2e 6c 6f  61 64 5f 65 78 65 63 5f  |X #8..load_exec_|
00000f70  6c 6f 6f 70 0a 20 20 20  20 20 20 20 20 20 20 4c  |loop.          L|
00000f80  44 41 20 26 33 42 44 2c  58 20 20 20 20 20 20 20  |DA &3BD,X       |
00000f90  20 5c 20 6c 6f 61 64 2f  65 78 65 63 20 61 64 64  | \ load/exec add|
00000fa0  72 65 73 73 20 66 72 6f  6d 20 63 61 73 73 65 74  |ress from casset|
00000fb0  74 65 20 77 6f 72 6b 73  70 61 63 65 0a 20 20 20  |te workspace.   |
00000fc0  20 20 20 20 20 20 20 53  54 41 20 26 38 31 2c 58  |       STA &81,X|
00000fd0  0a 20 20 20 20 20 20 20  20 20 20 44 45 58 0a 20  |.          DEX. |
00000fe0  20 20 20 20 20 20 20 20  20 42 4e 45 20 6c 6f 61  |         BNE loa|
00000ff0  64 5f 65 78 65 63 5f 6c  6f 6f 70 0a 20 20 20 20  |d_exec_loop.    |
00001000  20 20 20 20 20 20 52 54  53 0a 2e 68 61 6e 64 73  |      RTS..hands|
00001010  68 61 6b 65 0a 20 20 20  20 20 20 20 20 20 20 4c  |hake.          L|
00001020  44 41 20 23 41 53 43 28  22 53 22 29 0a 20 20 20  |DA #ASC("S").   |
00001030  20 20 20 20 20 20 20 4a  53 52 20 70 75 74 0a 20  |       JSR put. |
00001040  20 20 20 20 20 20 20 20  20 4c 44 41 20 23 41 53  |         LDA #AS|
00001050  43 28 22 42 22 29 0a 20  20 20 20 20 20 20 20 20  |C("B").         |
00001060  20 4a 53 52 20 70 75 74  20 20 20 20 20 20 20 20  | JSR put        |
00001070  20 20 20 5c 20 73 65 6e  64 20 22 53 42 22 20 2e  |   \ send "SB" .|
00001080  2e 2e 0a 20 20 20 20 20  20 20 20 20 20 4a 53 52  |...          JSR|
00001090  20 67 65 74 0a 20 20 20  20 20 20 20 20 20 20 43  | get.          C|
000010a0  50 59 20 23 41 53 43 28  22 73 22 29 0a 20 20 20  |PY #ASC("s").   |
000010b0  20 20 20 20 20 20 20 42  4e 45 20 68 61 6e 64 73  |       BNE hands|
000010c0  68 61 6b 65 0a 20 20 20  20 20 20 20 20 20 20 4a  |hake.          J|
000010d0  53 52 20 67 65 74 0a 20  20 20 20 20 20 20 20 20  |SR get.         |
000010e0  20 43 50 59 20 23 41 53  43 28 22 62 22 29 0a 20  | CPY #ASC("b"). |
000010f0  20 20 20 20 20 20 20 20  20 42 4e 45 20 68 61 6e  |         BNE han|
00001100  64 73 68 61 6b 65 20 20  20 20 20 5c 20 2e 2e 2e  |dshake     \ ...|
00001110  20 61 6e 64 20 72 65 63  65 69 76 65 20 22 73 62  | and receive "sb|
00001120  22 20 74 6f 20 68 61 6e  64 73 68 61 6b 65 0a 20  |" to handshake. |
00001130  20 20 20 20 20 20 20 20  20 52 54 53 0a 2e 73 65  |         RTS..se|
00001140  6e 64 5f 66 69 6c 65 0a  20 20 20 20 20 20 20 20  |nd_file.        |
00001150  20 20 4c 44 41 20 26 37  31 0a 20 20 20 20 20 20  |  LDA &71.      |
00001160  20 20 20 20 4a 53 52 20  70 75 74 0a 20 20 20 20  |    JSR put.    |
00001170  20 20 20 20 20 20 4c 44  41 20 26 37 32 0a 20 20  |      LDA &72.  |
00001180  20 20 20 20 20 20 20 20  4a 53 52 20 70 75 74 20  |        JSR put |
00001190  20 20 20 20 20 20 20 20  20 20 5c 20 73 65 6e 64  |          \ send|
000011a0  20 66 69 6c 65 20 6c 65  6e 67 74 68 0a 3a 0a 20  | file length.:. |
000011b0  20 20 20 20 20 20 20 20  20 4c 44 41 20 23 6c 6f  |         LDA #lo|
000011c0  61 64 5f 70 61 67 65 0a  20 20 20 20 20 20 20 20  |ad_page.        |
000011d0  20 20 53 54 41 20 26 37  34 0a 20 20 20 20 20 20  |  STA &74.      |
000011e0  20 20 20 20 4c 44 41 20  23 30 20 0a 20 20 20 20  |    LDA #0 .    |
000011f0  20 20 20 20 20 20 53 54  41 20 26 37 33 20 20 20  |      STA &73   |
00001200  20 20 20 20 20 20 20 20  5c 20 72 65 73 65 74 20  |        \ reset |
00001210  6c 6f 61 64 20 61 64 64  72 65 73 73 0a 20 20 20  |load address.   |
00001220  20 20 20 20 20 20 20 44  45 43 20 26 37 32 20 20  |       DEC &72  |
00001230  20 20 20 20 20 20 20 20  20 5c 20 6e 65 65 64 20  |         \ need |
00001240  74 68 69 73 20 66 6f 72  20 74 65 73 74 20 62 65  |this for test be|
00001250  6c 6f 77 0a 20 20 20 20  20 20 20 20 20 20 42 4d  |low.          BM|
00001260  49 20 6c 61 73 74 5f 62  6c 6f 63 6b 20 20 20 20  |I last_block    |
00001270  5c 20 66 69 6c 65 20 6c  65 6e 67 74 68 20 3c 20  |\ file length < |
00001280  32 35 36 20 62 79 74 65  73 3f 0a 20 20 20 20 20  |256 bytes?.     |
00001290  20 20 20 20 20 53 54 41  20 26 38 30 20 20 20 20  |     STA &80    |
000012a0  20 20 20 20 20 20 20 5c  20 62 6c 6f 63 6b 20 6c  |       \ block l|
000012b0  65 6e 67 74 68 20 3d 20  30 20 28 20 3d 20 32 35  |ength = 0 ( = 25|
000012c0  36 29 0a 2e 73 65 6e 64  5f 62 6c 6f 63 6b 0a 20  |6)..send_block. |
000012d0  20 20 20 20 20 20 20 20  20 4a 53 52 20 70 75 74  |         JSR put|
000012e0  5f 6f 6b 20 20 20 20 20  20 20 20 5c 20 6e 6f 74  |_ok        \ not|
000012f0  20 65 6f 66 0a 20 20 20  20 20 20 20 20 20 20 4c  | eof.          L|
00001300  44 41 20 23 33 20 20 20  20 20 20 20 20 20 20 20  |DA #3           |
00001310  20 5c 20 73 65 6e 64 20  6c 65 6e 67 74 68 20 33  | \ send length 3|
00001320  20 74 69 6d 65 73 0a 20  20 20 20 20 20 20 20 20  | times.         |
00001330  20 53 54 41 20 26 37 36  20 20 20 20 20 20 20 20  | STA &76        |
00001340  20 20 20 5c 20 75 73 65  20 43 52 43 20 6c 6f 77  |   \ use CRC low|
00001350  20 62 79 74 65 20 61 73  20 63 6f 75 6e 74 65 72  | byte as counter|
00001360  0a 2e 6c 65 6e 6f 75 74  0a 20 20 20 20 20 20 20  |..lenout.       |
00001370  20 20 20 4c 44 41 20 26  38 30 0a 20 20 20 20 20  |   LDA &80.     |
00001380  20 20 20 20 20 4a 53 52  20 70 75 74 20 20 20 20  |     JSR put    |
00001390  20 20 20 20 20 20 20 5c  20 6f 75 74 70 75 74 20  |       \ output |
000013a0  62 6c 6f 63 6b 20 6c 65  6e 67 74 68 0a 20 20 20  |block length.   |
000013b0  20 20 20 20 20 20 20 44  45 43 20 26 37 36 0a 20  |       DEC &76. |
000013c0  20 20 20 20 20 20 20 20  20 42 4e 45 20 6c 65 6e  |         BNE len|
000013d0  6f 75 74 20 20 20 20 20  20 20 20 5c 20 43 52 43  |out        \ CRC|
000013e0  20 6c 6f 77 20 62 79 74  65 20 7a 65 72 6f 20 61  | low byte zero a|
000013f0  74 20 65 78 69 74 0a 20  20 20 20 20 20 20 20 20  |t exit.         |
00001400  20 4c 44 59 20 23 30 0a  20 20 20 20 20 20 20 20  | LDY #0.        |
00001410  20 20 53 54 59 20 26 37  35 20 20 20 20 20 20 20  |  STY &75       |
00001420  20 20 20 20 5c 20 69 6e  69 74 69 61 6c 69 73 65  |    \ initialise|
00001430  20 43 52 43 20 68 69 67  68 20 62 79 74 65 0a 2e  | CRC high byte..|
00001440  73 65 6e 64 5f 62 79 74  65 0a 20 20 20 20 20 20  |send_byte.      |
00001450  20 20 20 20 53 54 59 20  26 37 30 20 20 20 20 20  |    STY &70     |
00001460  20 20 20 20 20 20 5c 20  73 61 76 65 20 6f 66 66  |      \ save off|
00001470  73 65 74 0a 20 20 20 20  20 20 20 20 20 20 4c 44  |set.          LD|
00001480  41 20 28 26 37 33 29 2c  59 20 20 20 20 20 20 20  |A (&73),Y       |
00001490  5c 20 6c 6f 61 64 20 6e  65 78 74 20 62 79 74 65  |\ load next byte|
000014a0  20 2e 2e 2e 0a 20 20 20  20 20 20 20 20 20 20 50  | ....          P|
000014b0  48 41 0a 20 20 20 20 20  20 20 20 20 20 4a 53 52  |HA.          JSR|
000014c0  20 70 75 74 0a 20 20 20  20 20 20 20 20 20 20 50  | put.          P|
000014d0  4c 41 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |LA              |
000014e0  20 5c 20 67 65 74 20 63  68 61 72 61 63 74 65 72  | \ get character|
000014f0  20 62 61 63 6b 0a 20 20  20 20 20 20 20 20 20 20  | back.          |
00001500  4a 53 52 20 63 72 63 20  20 20 20 20 20 20 20 20  |JSR crc         |
00001510  20 20 5c 20 75 70 64 61  74 65 20 63 72 63 0a 20  |  \ update crc. |
00001520  20 20 20 20 20 20 20 20  20 4c 44 59 20 26 37 30  |         LDY &70|
00001530  0a 20 20 20 20 20 20 20  20 20 20 49 4e 59 20 20  |.          INY  |
00001540  20 20 20 20 20 20 20 20  20 20 20 20 20 5c 20 69  |             \ i|
00001550  6e 63 72 65 6d 65 6e 74  20 6f 66 66 73 65 74 0a  |ncrement offset.|
00001560  20 20 20 20 20 20 20 20  20 20 43 50 59 20 26 38  |          CPY &8|
00001570  30 0a 20 20 20 20 20 20  20 20 20 20 42 4e 45 20  |0.          BNE |
00001580  73 65 6e 64 5f 62 79 74  65 20 20 20 20 20 5c 20  |send_byte     \ |
00001590  65 6e 64 20 6f 66 20 62  6c 6f 63 6b 3f 0a 3a 0a  |end of block?.:.|
000015a0  20 20 20 20 20 20 20 20  20 20 4c 44 41 20 26 37  |          LDA &7|
000015b0  35 0a 20 20 20 20 20 20  20 20 20 20 4a 53 52 20  |5.          JSR |
000015c0  70 75 74 20 20 20 20 20  20 20 20 20 20 20 5c 20  |put           \ |
000015d0  6f 75 74 70 75 74 20 43  52 43 20 68 69 67 68 20  |output CRC high |
000015e0  62 79 74 65 0a 20 20 20  20 20 20 20 20 20 20 4c  |byte.          L|
000015f0  44 41 20 26 37 36 0a 20  20 20 20 20 20 20 20 20  |DA &76.         |
00001600  20 4a 53 52 20 70 75 74  20 20 20 20 20 20 20 20  | JSR put        |
00001610  20 20 20 5c 20 6f 75 74  70 75 74 20 43 52 43 20  |   \ output CRC |
00001620  6c 6f 77 20 62 79 74 65  0a 3a 0a 20 20 20 20 20  |low byte.:.     |
00001630  20 20 20 20 20 4a 53 52  20 67 65 74 20 20 20 20  |     JSR get    |
00001640  20 20 20 20 20 20 20 5c  20 6c 6f 6f 6b 20 66 6f  |       \ look fo|
00001650  72 20 63 6f 6e 66 69 72  6d 61 74 69 6f 6e 0a 20  |r confirmation. |
00001660  20 20 20 20 20 20 20 20  20 54 59 41 0a 20 20 20  |         TYA.   |
00001670  20 20 20 20 20 20 20 42  45 51 20 73 65 6e 64 5f  |       BEQ send_|
00001680  62 6c 6f 63 6b 20 20 20  20 5c 20 7a 65 72 6f 20  |block    \ zero |
00001690  6d 65 61 6e 73 20 65 72  72 6f 72 2c 20 73 6f 20  |means error, so |
000016a0  64 6f 20 61 67 61 69 6e  0a 3a 0a 20 20 20 20 20  |do again.:.     |
000016b0  20 20 20 20 20 49 4e 43  20 26 37 34 20 20 20 20  |     INC &74    |
000016c0  20 20 20 20 20 20 20 5c  20 69 6e 63 72 65 6d 65  |       \ increme|
000016d0  6e 74 20 61 64 64 72 65  73 73 20 68 69 67 68 20  |nt address high |
000016e0  62 79 74 65 0a 20 20 20  20 20 20 20 20 20 20 44  |byte.          D|
000016f0  45 43 20 26 37 32 20 20  20 20 20 20 20 20 20 20  |EC &72          |
00001700  20 5c 20 64 65 63 72 65  6d 65 6e 74 20 6c 65 6e  | \ decrement len|
00001710  67 74 68 20 68 69 67 68  20 62 79 74 65 0a 20 20  |gth high byte.  |
00001720  20 20 20 20 20 20 20 20  42 50 4c 20 73 65 6e 64  |        BPL send|
00001730  5f 62 6c 6f 63 6b 20 20  20 20 5c 20 61 72 65 20  |_block    \ are |
00001740  77 65 20 66 69 6e 69 73  68 65 64 3f 0a 2e 6c 61  |we finished?..la|
00001750  73 74 5f 62 6c 6f 63 6b  0a 20 20 20 20 20 20 20  |st_block.       |
00001760  20 20 20 4c 44 59 20 23  30 0a 20 20 20 20 20 20  |   LDY #0.      |
00001770  20 20 20 20 4c 44 41 20  26 37 31 20 20 20 20 20  |    LDA &71     |
00001780  20 20 20 20 20 20 5c 20  6c 65 6e 67 74 68 20 6f  |      \ length o|
00001790  66 20 6c 61 73 74 20 62  6c 6f 63 6b 0a 20 20 20  |f last block.   |
000017a0  20 20 20 20 20 20 20 53  54 59 20 26 37 31 20 20  |       STY &71  |
000017b0  20 20 20 20 20 20 20 20  20 5c 20 73 65 74 20 6c  |         \ set l|
000017c0  65 6e 67 74 68 20 74 6f  20 7a 65 72 6f 0a 20 20  |ength to zero.  |
000017d0  20 20 20 20 20 20 20 20  53 54 41 20 26 38 30 0a  |        STA &80.|
000017e0  20 20 20 20 20 20 20 20  20 20 42 4e 45 20 73 65  |          BNE se|
000017f0  6e 64 5f 62 6c 6f 63 6b  20 20 20 20 5c 20 6f 75  |nd_block    \ ou|
00001800  74 70 75 74 20 69 66 20  6e 6f 6e 2d 7a 65 72 6f  |tput if non-zero|
00001810  0a 20 20 20 20 20 20 20  20 20 20 4c 44 41 20 23  |.          LDA #|
00001820  30 0a 20 20 20 20 20 20  20 20 20 20 4a 53 52 20  |0.          JSR |
00001830  70 75 74 20 20 20 20 20  20 20 20 20 20 20 5c 20  |put           \ |
00001840  7a 65 72 6f 20 6d 61 72  6b 73 20 65 6f 66 0a 20  |zero marks eof. |
00001850  20 20 20 20 20 20 20 20  20 4a 53 52 20 70 75 74  |         JSR put|
00001860  5f 6c 6f 61 64 5f 65 78  65 63 20 5c 20 73 65 6e  |_load_exec \ sen|
00001870  64 20 74 68 65 20 6c 6f  61 64 2f 65 78 65 63 20  |d the load/exec |
00001880  61 64 72 65 73 73 0a 2e  70 75 74 5f 6e 61 6d 65  |adress..put_name|
00001890  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000018a0  20 20 20 5c 20 66 61 6c  6c 20 74 68 72 6f 75 67  |   \ fall throug|
000018b0  68 20 74 6f 20 70 75 74  5f 6e 61 6d 65 20 2e 2e  |h to put_name ..|
000018c0  2e 0a 20 20 20 20 20 20  20 20 20 20 4c 44 58 20  |..          LDX |
000018d0  23 26 46 46 0a 20 20 20  20 20 20 20 20 20 20 53  |#&FF.          S|
000018e0  54 58 20 26 38 31 20 20  20 20 20 20 20 20 20 20  |TX &81          |
000018f0  20 5c 20 22 70 75 74 22  20 63 6f 72 72 75 70 74  | \ "put" corrupt|
00001900  73 20 72 65 67 69 73 74  65 72 73 0a 2e 70 75 74  |s registers..put|
00001910  5f 63 68 61 72 20 20 20  20 20 20 20 20 20 20 20  |_char           |
00001920  20 20 20 20 20 20 20 20  5c 20 6f 75 74 70 75 74  |        \ output|
00001930  20 66 69 6c 65 20 6e 61  6d 65 0a 20 20 20 20 20  | file name.     |
00001940  20 20 20 20 20 49 4e 43  20 26 38 31 0a 20 20 20  |     INC &81.   |
00001950  20 20 20 20 20 20 20 4c  44 58 20 26 38 31 0a 20  |       LDX &81. |
00001960  20 20 20 20 20 20 20 20  20 4c 44 41 20 6e 61 6d  |         LDA nam|
00001970  65 2c 58 0a 20 20 20 20  20 20 20 20 20 20 50 48  |e,X.          PH|
00001980  41 0a 20 20 20 20 20 20  20 20 20 20 4a 53 52 20  |A.          JSR |
00001990  70 75 74 0a 20 20 20 20  20 20 20 20 20 20 50 4c  |put.          PL|
000019a0  41 0a 20 20 20 20 20 20  20 20 20 20 43 4d 50 20  |A.          CMP |
000019b0  23 26 30 44 0a 20 20 20  20 20 20 20 20 20 20 42  |#&0D.          B|
000019c0  4e 45 20 70 75 74 5f 63  68 61 72 0a 20 20 20 20  |NE put_char.    |
000019d0  20 20 20 20 20 20 52 54  53 0a 2e 70 75 74 5f 6c  |      RTS..put_l|
000019e0  6f 61 64 5f 65 78 65 63  20 20 20 20 20 20 20 20  |oad_exec        |
000019f0  20 20 20 20 20 20 5c 20  70 75 74 20 6f 75 74 20  |      \ put out |
00001a00  6c 6f 61 64 2f 65 78 65  63 20 61 64 64 72 65 73  |load/exec addres|
00001a10  73 0a 20 20 20 20 20 20  20 20 20 20 4c 44 58 20  |s.          LDX |
00001a20  23 30 0a 20 20 20 20 20  20 20 20 20 20 53 54 58  |#0.          STX|
00001a30  20 26 38 31 20 20 20 20  20 20 20 20 20 20 20 5c  | &81           \|
00001a40  20 22 70 75 74 22 20 63  6f 72 72 75 70 74 73 20  | "put" corrupts |
00001a50  72 65 67 69 73 74 65 72  73 0a 2e 70 75 74 5f 6c  |registers..put_l|
00001a60  6f 61 64 5f 65 78 65 63  5f 6c 6f 6f 70 0a 20 20  |oad_exec_loop.  |
00001a70  20 20 20 20 20 20 20 20  4c 44 41 20 26 38 32 2c  |        LDA &82,|
00001a80  58 0a 20 20 20 20 20 20  20 20 20 20 4a 53 52 20  |X.          JSR |
00001a90  70 75 74 0a 20 20 20 20  20 20 20 20 20 20 49 4e  |put.          IN|
00001aa0  43 20 26 38 31 0a 20 20  20 20 20 20 20 20 20 20  |C &81.          |
00001ab0  4c 44 58 20 26 38 31 0a  20 20 20 20 20 20 20 20  |LDX &81.        |
00001ac0  20 20 43 50 58 20 23 38  0a 20 20 20 20 20 20 20  |  CPX #8.       |
00001ad0  20 20 20 42 4e 45 20 70  75 74 5f 6c 6f 61 64 5f  |   BNE put_load_|
00001ae0  65 78 65 63 5f 6c 6f 6f  70 0a 20 20 20 20 20 20  |exec_loop.      |
00001af0  20 20 20 20 52 54 53 0a  2e 70 75 74 5f 6f 6b 0a  |    RTS..put_ok.|
00001b00  20 20 20 20 20 20 20 20  20 20 4c 44 41 20 23 26  |          LDA #&|
00001b10  46 46 0a 2e 70 75 74 0a  20 20 20 20 20 20 20 20  |FF..put.        |
00001b20  20 20 50 48 41 20 20 20  20 20 20 20 20 20 20 20  |  PHA           |
00001b30  20 20 20 20 5c 20 73 61  76 65 20 76 61 6c 75 65  |    \ save value|
00001b40  20 74 6f 20 6f 75 74 70  75 74 0a 20 20 20 20 20  | to output.     |
00001b50  20 20 20 20 20 4a 53 52  20 65 73 63 61 70 65 0a  |     JSR escape.|
00001b60  20 20 20 20 20 20 20 20  20 20 4c 44 58 20 23 26  |          LDX #&|
00001b70  46 44 0a 20 20 20 20 20  20 20 20 20 20 4c 44 41  |FD.          LDA|
00001b80  20 23 26 38 30 0a 20 20  20 20 20 20 20 20 20 20  | #&80.          |
00001b90  4a 53 52 20 6f 73 62 79  74 65 20 20 20 20 20 20  |JSR osbyte      |
00001ba0  20 20 5c 20 67 65 74 20  23 20 65 6d 70 74 79 20  |  \ get # empty |
00001bb0  62 79 74 65 73 20 69 6e  20 52 53 34 32 33 20 6f  |bytes in RS423 o|
00001bc0  75 74 70 75 74 20 62 75  66 66 65 72 0a 20 20 20  |utput buffer.   |
00001bd0  20 20 20 20 20 20 20 43  50 58 20 23 39 0a 20 20  |       CPX #9.  |
00001be0  20 20 20 20 20 20 20 20  50 4c 41 0a 20 20 20 20  |        PLA.    |
00001bf0  20 20 20 20 20 20 42 43  43 20 70 75 74 20 20 20  |      BCC put   |
00001c00  20 20 20 20 20 20 20 20  5c 20 69 66 20 3c 20 39  |        \ if < 9|
00001c10  20 62 79 74 65 73 20 72  65 6d 61 69 6e 2c 20 77  | bytes remain, w|
00001c20  61 69 74 20 2e 2e 2e 0a  3a 0a 20 20 20 20 20 20  |ait ....:.      |
00001c30  20 20 20 20 4c 44 58 20  23 32 0a 20 20 20 20 20  |    LDX #2.     |
00001c40  20 20 20 20 20 54 41 59  0a 20 20 20 20 20 20 20  |     TAY.       |
00001c50  20 20 20 4c 44 41 20 23  26 38 41 0a 20 20 20 20  |   LDA #&8A.    |
00001c60  20 20 20 20 20 20 4a 4d  50 20 6f 73 62 79 74 65  |      JMP osbyte|
00001c70  20 20 20 20 20 20 20 20  5c 20 2e 2e 2e 20 61 6e  |        \ ... an|
00001c80  64 20 73 65 6e 64 20 69  74 0a 2e 67 65 74 0a 20  |d send it..get. |
00001c90  20 20 20 20 20 20 20 20  20 4a 53 52 20 65 73 63  |         JSR esc|
00001ca0  61 70 65 0a 20 20 20 20  20 20 20 20 20 20 4c 44  |ape.          LD|
00001cb0  58 20 23 31 0a 20 20 20  20 20 20 20 20 20 20 4c  |X #1.          L|
00001cc0  44 41 20 23 26 39 31 0a  20 20 20 20 20 20 20 20  |DA #&91.        |
00001cd0  20 20 4a 53 52 20 6f 73  62 79 74 65 20 20 20 20  |  JSR osbyte    |
00001ce0  20 20 20 20 5c 20 72 65  61 64 20 61 20 62 79 74  |    \ read a byt|
00001cf0  65 0a 20 20 20 20 20 20  20 20 20 20 42 43 53 20  |e.          BCS |
00001d00  67 65 74 0a 20 20 20 20  20 20 20 20 20 20 52 54  |get.          RT|
00001d10  53 0a 2e 63 72 63 0a 20  20 20 20 20 20 20 20 20  |S..crc.         |
00001d20  20 45 4f 52 20 26 37 35  20 20 20 20 20 20 20 20  | EOR &75        |
00001d30  20 20 20 5c 20 63 61 6c  63 75 6c 61 74 65 20 43  |   \ calculate C|
00001d40  52 43 20 69 6e 20 26 37  35 2c 20 26 37 36 0a 20  |RC in &75, &76. |
00001d50  20 20 20 20 20 20 20 20  20 53 54 41 20 26 37 35  |         STA &75|
00001d60  20 20 20 20 20 20 20 20  20 20 20 5c 20 61 6c 67  |           \ alg|
00001d70  6f 72 69 74 68 6d 20 66  72 6f 6d 20 41 64 76 61  |orithm from Adva|
00001d80  6e 63 65 64 20 55 73 65  72 20 47 75 69 64 65 0a  |nced User Guide.|
00001d90  20 20 20 20 20 20 20 20  20 20 4c 44 58 20 23 38  |          LDX #8|
00001da0  20 20 20 20 20 20 20 20  20 20 20 20 5c 20 49 20  |            \ I |
00001db0  68 6f 70 65 20 69 74 27  73 20 72 69 67 68 74 21  |hope it's right!|
00001dc0  0a 2e 63 72 63 5f 6c 6f  6f 70 0a 20 20 20 20 20  |..crc_loop.     |
00001dd0  20 20 20 20 20 4c 44 41  20 26 37 35 0a 20 20 20  |     LDA &75.   |
00001de0  20 20 20 20 20 20 20 52  4f 4c 20 41 0a 20 20 20  |       ROL A.   |
00001df0  20 20 20 20 20 20 20 42  43 43 20 62 37 7a 0a 20  |       BCC b7z. |
00001e00  20 20 20 20 20 20 20 20  20 4c 44 41 20 26 37 35  |         LDA &75|
00001e10  0a 20 20 20 20 20 20 20  20 20 20 45 4f 52 20 23  |.          EOR #|
00001e20  38 0a 20 20 20 20 20 20  20 20 20 20 53 54 41 20  |8.          STA |
00001e30  26 37 35 0a 20 20 20 20  20 20 20 20 20 20 4c 44  |&75.          LD|
00001e40  41 20 26 37 36 0a 20 20  20 20 20 20 20 20 20 20  |A &76.          |
00001e50  45 4f 52 20 23 26 31 30  0a 20 20 20 20 20 20 20  |EOR #&10.       |
00001e60  20 20 20 53 54 41 20 26  37 36 0a 2e 62 37 7a 0a  |   STA &76..b7z.|
00001e70  20 20 20 20 20 20 20 20  20 20 52 4f 4c 20 26 37  |          ROL &7|
00001e80  36 0a 20 20 20 20 20 20  20 20 20 20 52 4f 4c 20  |6.          ROL |
00001e90  26 37 35 0a 20 20 20 20  20 20 20 20 20 20 44 45  |&75.          DE|
00001ea0  58 0a 20 20 20 20 20 20  20 20 20 20 42 4e 45 20  |X.          BNE |
00001eb0  63 72 63 5f 6c 6f 6f 70  0a 20 20 20 20 20 20 20  |crc_loop.       |
00001ec0  20 20 20 52 54 53 0a 2e  65 73 63 61 70 65 0a 20  |   RTS..escape. |
00001ed0  20 20 20 20 20 20 20 20  20 4c 44 41 20 26 46 46  |         LDA &FF|
00001ee0  0a 20 20 20 20 20 20 20  20 20 20 42 4d 49 20 65  |.          BMI e|
00001ef0  72 72 6f 72 0a 20 20 20  20 20 20 20 20 20 20 52  |rror.          R|
00001f00  54 53 0a 2e 65 72 72 6f  72 0a 20 20 20 20 20 20  |TS..error.      |
00001f10  20 20 20 20 4c 44 41 20  23 26 37 45 0a 20 20 20  |    LDA #&7E.   |
00001f20  20 20 20 20 20 20 20 4a  53 52 20 6f 73 62 79 74  |       JSR osbyt|
00001f30  65 20 20 20 20 20 20 20  20 5c 20 61 63 6b 6e 6f  |e        \ ackno|
00001f40  77 6c 65 64 67 65 20 65  73 63 61 70 65 0a 20 20  |wledge escape.  |
00001f50  20 20 20 20 20 20 20 20  4c 44 58 20 23 30 0a 20  |        LDX #0. |
00001f60  20 20 20 20 20 20 20 20  20 4c 44 41 20 23 26 30  |         LDA #&0|
00001f70  46 0a 20 20 20 20 20 20  20 20 20 20 4a 53 52 20  |F.          JSR |
00001f80  6f 73 62 79 74 65 20 20  20 20 20 20 20 20 5c 20  |osbyte        \ |
00001f90  66 6c 75 73 68 20 62 75  66 66 65 72 73 20 28 6a  |flush buffers (j|
00001fa0  75 73 74 20 69 6e 20 63  61 73 65 29 0a 20 20 20  |ust in case).   |
00001fb0  20 20 20 20 20 20 20 4c  44 59 20 23 30 0a 20 20  |       LDY #0.  |
00001fc0  20 20 20 20 20 20 20 20  4c 44 41 20 23 30 0a 20  |        LDA #0. |
00001fd0  20 20 20 20 20 20 20 20  20 4a 53 52 20 26 46 46  |         JSR &FF|
00001fe0  43 45 20 20 20 20 20 20  20 20 20 5c 20 63 6c 6f  |CE         \ clo|
00001ff0  73 65 20 61 6c 6c 20 66  69 6c 65 73 0a 20 20 20  |se all files.   |
00002000  20 20 20 20 20 20 20 42  52 4b 0a 5d 0a 3f 50 25  |       BRK.].?P%|
00002010  20 3d 20 26 31 31 0a 50  25 20 20 3d 20 50 25 20  | = &11.P%  = P% |
00002020  2b 20 31 0a 24 50 25 20  3d 20 22 45 73 63 61 70  |+ 1.$P% = "Escap|
00002030  65 22 20 2b 20 43 48 52  24 30 0a 4e 45 58 54 20  |e" + CHR$0.NEXT |
00002040  6f 70 74 25 0a 2a 4f 50  54 20 31 2c 32 0a 52 55  |opt%.*OPT 1,2.RU|
00002050  4e 0a 43 41 4c 4c 20 67  6f 0a                    |N.CALL go.|
0000205a