; -----------------------------------------------------------------------------
; Z80 Second Processor OS v1.20 (c) Acorn
; reverse engineered by Eelco Huininga
; Last update: March 6th, 2008
; DOS Filename   : Z80_120.rom
; Acorn filename : $.Z80-120
; Load address   : 00000000
; Exec address   : 00000000
; Length         : 00001000
; -----------------------------------------------------------------------------

; Memory usage
; $FF80 ESCAPE flag

; -----------------------------------------------------------------------------
; TUBE ULA registers
; -----------------------------------------------------------------------------
r1status		= $00
r1data			= $01
r2status		= $02
r2data			= $03
r3status		= $04
r3data			= $05
r4status		= $06
r4data			= $07


; -----------------------------------------------------------------------------
; Start of code
; -----------------------------------------------------------------------------
.reset
F000  F3           .     DI                       ; Disable Interrupts
F001  11 00 F0     ...   LD DE, $F000
F004  21 00 00     !..   LD HL, $0000
F007  01 00 10     ...   LD BC, $1000
F00A  ED B0        .     LDIR                     ; Move $1000 bytes from $0000 to $F000
F00C  C3 80 F2     ...   JP $F280

F00F  43 6F 70 79  Copy  DB "Copyright Acorn Computers Ltd. 1984"
      72 69 67 68  righ
      74 20 41 63  t Ac
      6F 72 6E 20  orn 
      43 6F 6D 70  Comp
      75 74 65 72  uter
      73 20 4C 74  s Lt
      64 2E 20 31  d. 1
      39 38 34     984
F032  0D           .     DB 13                    ; Carriage returm

F033  48           H     LD C, B                  ; Unused code
F034  3A 7D 3C     :}<   LD A, ($3C7D)
F037  B7           .     OR A
F038  C4 C0 2C     ..,   CALL NZ, $2CC0
F03B  3A 22 3A     :":   LD A, ($3A22)
F03E  B7           .     OR A
F03F  C4 F1 2C     ..,   CALL NZ, $2CF1
F042  F1           .     POP AF
F043  21 1B 3A     !.:   LD HL, $3A1B
F046  34           4     INC (HL)
F047  7E           ~     LD A, (HL)
F048  3D           =     DEC A
F049  C2 AB 2B     ..+   JP NZ $2BAB
F04C  21 EC 3B     !.;   LD HL, $3BEC
F04F  7E           ~     LD A, (HL)
F050  B7           .     OR A
F051  C2 34 2B     .4+   JP NZ $2B34
F054  21 4A 3B     !J;   LD HL, $3B4A
F057  7E           ~     LD A, (HL)
F058  B7           .     OR A
F059  C2 34 2B     .4+   JP NZ $2B34
F05C  21 58 3D     !X=   LD HL, $3D58
F05F  23           #     INC HL
F060  01 06 00     ...   LD BC, $0006
.
F063  11 EC 3B     ..;   LD DE, $3BEC
F066  C3 61 FC     .a.   JP $FC61                 ; Jump to NMI handler

F069  54 68 65 20  The   DB "The Business Systems Group would like to thank"
      42 75 73 69  Busi
      6E 65 73 73  ness
      20 53 79 73   Sys
      74 65 6D 73  tems
      20 47 72 6F   Gro
      75 70 20 77  up w
      6F 75 6C 64  ould
      20 6C 69 6B   lik
      65 20 74 6F  e to
      20 74 68 61   tha
      6E 6B        nk
F097  4D 69 6B 65  Mike  DB "Mike Bolley,Mike $ Allen Boothroyd,Richard Clayton,Andrew Gordon,Chris Hall,Kim Spence-Jones,Paul Overell,David Parkinson,John Tuten and Eric the half TUBE"
      20 42 6F 6C   Bol
      6C 65 79 2C  ley,
      4D 69 6B 65  Mike
      20 26 20 41   $ A
      6C 6C 65 6E  llen
      20 42 6F 6F   Boo
      74 68 72 6F  thro
      79 64 2C 52  yd,R
      69 63 68 61  icha
      72 64 20 43  rd C
      6C 61 79 74  layt
      6F 6E 2C 41  on,A
      6E 64 72 65  ndre
      77 20 47 6F  w Go
      72 64 6F 6E  rdon
      2C 43 68 72  ,Chr
      69 73 20 48  is H
      61 6C 6C 2C  all,
      4B 69 6D 20  Kim 
      53 70 65 6E  Spen
      63 65 2D 4A  ce-J
      6F 6E 65 73  ones
      2C 50 61 75  ,Pau
      6C 20 4F 76  l Ov
      65 72 65 6C  erel
      6C 2C 44 61  l,Da
      76 69 64 20  vid 
      50 61 72 6B  Park
      69 6E 73 6F  inso
      6E 2C 4A 6F  n,Jo
      68 6E 20 54  hn T
      75 74 65 6E  uten
      20 61 6E 64   and
      20 45 72 69   Eri
      63 20 74 68  c th
      65 20 68 61  e ha
      6C 66 20 54  lf T
      55 42 45     UBE 
F132  54 68 65 20  The   DB "The BSG is Big Arthur The Toucan,J Mark Carrington,Howard Fisher,Ian G Jack,Neil Robinson,Simon Woodward,John Corrall,Toby Cross,Ian Miller,Boris Southearsror(s)"
      42 53 47 20  BSG 
      69 73 20 42  is B
      69 67 20 41  ig A
      72 74 68 75  rthu
      72 20 54 68  r Th
      65 20 54 6F  e To
      75 63 61 6E  ucan
      2C 4A 20 4D  ,J M
      61 72 6B 20  ark 
      43 61 72 72  Carr
      69 6E 67 74  ingt
      6F 6E 2C 48  on,H
      6F 77 61 72  owar
      64 20 46 69  d Fi
      73 68 65 72  sher
      2C 49 61 6E  ,Ian
      20 47 20 4A   G J
      61 63 6B 2C  ack,
      4E 65 69 6C  Neil
      20 52 6F 62   Rob
      69 6E 73 6F  inso
      6E 2C 53 69  n,Si
      6D 6F 6E 20  mon 
      57 6F 6F 64  Wood
      77 61 72 64  ward
      2C 4A 6F 68  ,Joh
      6E 20 43 6F  n Co
      72 72 61 6C  rral
      6C 2C 54 6F  l,To
      62 79 20 43  by C
      72 6F 73 73  ross
      2C 49 61 6E  ,Ian
      20 4D 69 6C   Mil
      6C 65 72 2C  ler,
      42 6F 72 69  Bori
      73 20 53 6F  s So
      75 74 68 65  uthe
      61 72 73 72  arsr
      6F 72 28 73  or(s
      29           )
F1D3  00           .     DB 0                     ; String terminator
      
F1D4  20 57 61 72   War  DB " Warning(s)"
      6E 69 6E 67  ning
      28 73 29     (s)
F1DF  00           .     DB 0                     ; String terminator

F1E0  0E 00        ..    LD C, $00
F1E2  3A 00 3B     :.;   LD A, ($3B00)
F1E5  47           G     LD B, A
F1E6  CD 48 1A     .H.   CALL $1A48
F1E9  C3 6B 2B     .k+   JP $2B6B
F1EC  CD 16 2D     ..-   CALL $2D16
F1EF  21 CF 2C     !.,   LD HL, $2CCF
F1F2  CD 19 2D     ..-   CALL $2D19
F1F5  CD CA 19     ...   CALL $19CA
F1F8  C3 FD 2C     ..,   JP $2CFD
F1FB  52 45 50 54  REPT  DB "REPT/IRP/IRPC/MACRO"
      2F 49 52 50  /IRP
      2F 49 52 50  /IRP
      43 2F 4D 41  C/MA
      43 52 4F     CRO
F20E  00           .     DB $00                   ; String terminator

F20F  55 6E 74 65  Unte  DB "Unterminated "
      72 6D 69 6E  rmin
      61 74 65 64  ated
      20
F21C  00           .     DB $00                   ; String terminator
.
F21D  CD 16 2D     ..-   CALL $2D16
F220  21 26 2D     !&-   LD HL, $2D26
F223  CD 19 2D     ..-   CALL $2D19
F226  CD CA 19     ...   CALL $19CA
F229  3E 0D        >.    LD A, $0D
F22B  CD FC 18     ...   CALL $18FC
F22E  3E 0A        >.    LD A, $0A
F230  CD FC 18     ...   CALL $18FC
F233  3A 37 3D     :7=   LD A, ($3D37)
F236  3C           <     INC A
F237  C8           .     RET Z
F238  3E 0D        >.    LD A, $0D
F23A  CD 4E 47     .NG   CALL $474E
F23D  3E 0A        >.    LD A, $0A
F23F  C3 4E 47     .NG   JP $474E
F242  21 E3 2C     !.,   LD HL, $2CE3
.
F245  E5           .     PUSH HL
F246  CD 77 19     .w.   CALL $1977
F249  E1           .     POP HL
F24A  3A 37 3D     :7=   LD A, ($3D37)
F24D  3C           <     INC A
F24E  C8           .     RET Z
F24F  C3 4F 43     .OC   JP $434F

F252  43 6F 6E 64  Cond  DB "Contitional"
      69 74 69 6F  itio
      6E 61 6C     nal
F25D  00           .     DB $00                   ; String terminator

F25E  53 79 6D 62  Symb  DB "Symbols:"
      6F 6C 73 3A  ols:
F266  0D           .     DB $0D
F267  0A           .     DB $0A
F268  00           .     DB $00                   ; String terminator

F269  4D 61 63 72  Macr  DB "Macros:"
      6F 73 3A     os:
F270  0D           .     DB $0D
F271  0A           .     DB $0A
F272  00           .     DB $00                   ; String terminator

F273  21 E2 FF     !..   LD HL, $FFE2
F276  39           9     ADD HL, SP
F277  EB           .     EX DE, HL
F278  2A AC 3C     *.<   LD HL, ($3CAC)
F27B  CD 82 0D     ...   CALL $0D82
F27E  D2 5D        .]

; -----------------------------------------------------------------------------
; 
; -----------------------------------------------------------------------------
.
F280  31 80 FF     1..   LD SP, $FF80             ; Initialise stack pointer
F283  CD 5E F6     .^.   CALL $F65E               ; OSEVEN (Initialise RST $38 error call)
F286  3E FF        >.    LD A, $FF                ; Set interrupts to vector via $FFxx (MSB is supplied here, LSB is supplied by IC28)
F288  ED 47        .     LD I, A
F28A  ED 5E        .     IM 2                     ; Set maskable interrupt mode 2 (vectored interrupts)
F28C  FB           .     EI                       ; Enable interrupts
F28D  CD 0E F6     ...   CALL $F60E               ; Print message to output stream
F290  16           .     DB $16                   ; Set mode to 8
F291  08           .     DB $08
F292  0D           .     DB $0D
F293  41 63 6F 72  Acor  DB "Acorn TUBE Z80 64K 1.20"
      6E 20 54 55  n TU
      42 45 20 5A  BE Z
      38 30 20 36  80 6
      34 4B 20 31  4K 1
      2E 32 30     .20
F2AA  0D           .     DB $0D
F2AB  0D           .     DB $0D
F2AC  00           .     DB $00                   ; String terminator

F2AD  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A (byte is discarded)
F2B0  CD AE F5     ...   CALL $F5AE               ; Initialise OSWORD $FF code in the host processor
F2B3  3E FD        >.    LD A, $FD                ; OSBYTE $FD: Read hard/soft BREAK
F2B5  21 00 FF     !..   LD HL, $FF00             ; X = $00, Y = $FF
F2B8  CD 8E F8     ...   CALL $F88E               ; Call OSBYTE
F2BB  7D           }     LD A, L
F2BC  B7           .     OR A
F2BD  CA CE F2     ...   JP Z $F2CE               ; If it's a soft BREAK, enter CLI Prompt
F2C0  3E 0F        >.    LD A, $0F                ; OSBYTE $0F: Flush selected buffer class
F2C2  21 01 00     !..   LD HL, $0001             ; X = $01 (only flush input buffers), Y = $00
F2C5  CD 8E F8     ...   CALL $F88E               ; Call OSBYTE
F2C8  C3 EB F7     ...   JP $F7EB                 ; Try to enter current program or boot CP/M
.
F2CB  CD E7 FF     ...   CALL osnewl
.cliprompt                                        ; OSRDRM
F2CE  31 80 FF     1..   LD SP, $FF80             ; Initialise stack pointer
.
F2D1  3A 80 FF     :..   LD A, (escape_flag)      ; Get the ESCAPE flag
F2D4  CB 7F        .     BIT 7, A                 ; Check bit 7 (the ESCAPE flag)
F2D6  28 08        (.    JR Z, $F2E0
.                                                 ; ESCAPE flag has been set
F2D8  3E 7E        >~    LD A, $7E                ; OSBYTE $7E: Acknowledge detection of an ESCAPE condition
F2DA  21 00 00     !..   LD HL, $0000             ; X = $00 (ESCAPE condition not cleared), Y = $00
F2DD  CD 8E F8     ...   CALL $F88E               ; Call OSBYTE
.                                                 ; No ESCAPE flag has been set
F2E0  3E 2A        >*    LD A, ASC"*"             ; * Prompt
F2E2  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
F2E5  21 9D FC     !..   LD HL, $FC9D             ; X = $9D, Y = $FC (OSWORD $00 parameter block)
F2E8  AF           .     XOR A                    ; A = $00
F2E9  CD EF F8     ...   CALL $F8EF               ; Call OSWORD
F2EC  DA FA F2     ...   JP C $F2FA               ; Jump is ESCAPE has been pressed
F2EF  21 B0 FC     !..   LD HL, $FCB0             ; X = $B0, Y = $FC
F2F2  CD B7 F6     ...   CALL $F6B7               ; Call OSCLI
F2F5  18 D7        ..    JR $F2CE                 ; Loop forever

.                                                 ; ESCAPE has been pressed
F2F7  CD E7 FF     ...   CALL osnewl
.
F2FA  3E 7E        >~    LD A, $7E                ; OSBYTE $7E: Acknowledge detection of an ESCAPE condition
F2FC  CD 8E F8     ...   CALL $F88E               ; Call OSBYTE
F2FF  FF           .     RST 38H                  ; Generate error

F300  00           .     DB $00
F301  45 73 63 61  Esca  DB "Escape"
      70 65        pe
F307  00           .     DB $00                   ; String terminator

; -----------------------------------------------------------------------------
; *GO
; -----------------------------------------------------------------------------
.
F308  13           .     INC DE
F309  1A           .     LD A, (DE)
F30A  E6 DF        ..    AND %11011111            ; Make character upper-case
F30C  FE 4F        .O    CP ASC"O"                ; Was the command *GO ?
F30E  C2 CC F7     ...   JP NZ $F7CC
F311  CD 76 F8     .v.   CALL $F876               ; Loop until (DE) isn't ASCII value 32 (space)
F314  06 00        ..    LD B, $00
F316  CD 39 F4     .9.   CALL $F439               ; Return hex value of string at (DE) in ??
F319  CD 77 F8     .w.   CALL $F877               ; Loop until (DE) isn't ASCII value 32 (space)
F31C  FE 0D        ..    CP $0D
F31E  C2 CC F7     ...   JP NZ $F7CC              ; Jump if syntax error
F321  3A AA FC     :..   LD A, ($FCAA)
F324  32 A8 FC     2..   LD ($FCA8), A
F327  3A AB FC     :..   LD A, ($FCAB)
F32A  32 A9 FC     2..   LD ($FCA9), A
F32D  C3 DF F7     ...   JP $F7DF

; -----------------------------------------------------------------------------
; S <start address> (Set)
; -----------------------------------------------------------------------------
.
F330  CD 76 F8     .v.   CALL $F876               ; Loop until (DE) isn't ASCII value 32 (space)
F333  06 00        ..    LD B, $00
F335  CD 39 F4     .9.   CALL $F439               ; Return hex value of string at (DE) in ??
F338  CD 77 F8     .w.   CALL $F877               ; Loop until (DE) isn't ASCII value 32 (space)
F33B  FE 0D        ..    CP $0D
F33D  C2 CC F7     ...   JP NZ $F7CC
F340  3E 04        >.    LD A, $04                ; OSBYTE $04: Enable/disable cursor editing
F342  21 01 00     !..   LD HL, $0001             ; X = $01 (Disable cursor editing; return ASCII values 135-139), Y = $00
F345  CD F4 FF     ...   CALL osbyte              ; Call OSBYTE
F348  7D           }     LD A, L
F349  32 AE FC     2..   LD ($FCAE), A
F34C  2A AA FC     *..   LD HL, ($FCAA)
.
F34F  CD E7 FF     ...   CALL osnewl
F352  CD 71 F4     .q.   CALL $F471
F355  CD 1D F4     ...   CALL $F41D
.
F358  7E           ~     LD A, (HL)
F359  CD 0D F4     ...   CALL $F40D
F35C  CD 1D F4     ...   CALL $F41D
F35F  7E           ~     LD A, (HL)
F360  CD 76 F4     .v.   CALL $F476
F363  E5           .     PUSH HL
F364  06 01        ..    LD B, $01
F366  21 00 00     !..   LD HL, $0000
F369  CD E0 FF     ...   CALL osrdch
F36C  CD 40 F4     .@.   CALL $F440
F36F  06 00        ..    LD B, $00
F371  5D           ]     LD E, L
F372  E1           .     POP HL
F373  FE 8A        ..    CP $8A
F375  28 27        ('    JR Z, $F39E
F377  FE 8B        ..    CP $8B
F379  28 20        (     JR Z, $F39B
F37B  FE 01        ..    CP $01
F37D  C2 A1 F3     ...   JP NZ $F3A1
F380  7E           ~     LD A, (HL)
F381  CB 27        .     SLA A
F383  CB 27        .     SLA A
F385  CB 27        .     SLA A
F387  CB 27        .     SLA A
F389  83           .     ADD A, E
F38A  77           w     LD (HL), A
F38B  3E 08        >.    LD A, $08
F38D  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
F390  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
F393  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
F396  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
F399  18 BD        ..    JR $F358
.
F39B  23           #     INC HL
F39C  18 B1        ..    JR $F34F
.
F39E  2B           +     DEC HL
F39F  18 AE        ..    JR $F34F
.
F3A1  3A AE FC     :..   LD A, ($FCAE)
F3A4  6F           o     LD L, A
F3A5  26 00        $.    LD H, $00
F3A7  3E 04        >.    LD A, $04
F3A9  CD F4 FF     ...   CALL osbyte
F3AC  CD E7 FF     ...   CALL osnewl
F3AF  D1           .     POP DE
F3B0  C1           .     POP BC
F3B1  F1           .     POP AF
F3B2  C9           .     RET

; -----------------------------------------------------------------------------
; *D <start address> <end address> (Dump)
; -----------------------------------------------------------------------------
.
F3B3  CD 76 F8     .v.   CALL $F876               ; Loop until (DE) isn't ASCII value 32 (space)
F3B6  06 00        ..    LD B, $00
F3B8  CD 39 F4     .9.   CALL $F439               ; Return hex value of string at (DE) in ??
F3BB  FE 0D        ..    CP $0D
F3BD  28 10        (.    JR Z, $F3CF
F3BF  FE 20        .     CP $20
F3C1  C2 CC F7     ...   JP NZ $F7CC
F3C4  2A AA FC     *..   LD HL, ($FCAA)
F3C7  CD 77 F8     .w.   CALL $F877               ; Loop until (DE) isn't ASCII value 32 (space)
F3CA  CD 39 F4     .9.   CALL $F439               ; Return hex value of string at (DE) in ??
F3CD  18 03        ..    JR $F3D2
.
F3CF  2A AA FC     *..   LD HL, ($FCAA)
.
F3D2  ED 5B AA FC  ...   LD DE, ($FCAA)
.
F3D6  3A 80 FF     :..   LD A, (escape_flag)      ; Get the ESCAPE flag
F3D9  CB 7F        .     BIT 7, A                 ; Check bit 7 (the ESCAPE flag)
F3DB  C2 F7 F2     ...   JP NZ $F2F7
F3DE  CD E7 FF     ...   CALL osnewl
F3E1  CD 71 F4     .q.   CALL $F471
F3E4  06 08        ..    LD B, $08
F3E6  E5           .     PUSH HL
.
F3E7  CD 1D F4     ...   CALL $F41D
F3EA  7E           ~     LD A, (HL)
F3EB  CD 76 F4     .v.   CALL $F476
F3EE  23           #     INC HL
F3EF  10 F6        ..    DJNZ $F3E7
F3F1  06 08        ..    LD B, $08
F3F3  E1           .     POP HL
F3F4  CD 1D F4     ...   CALL $F41D
.
F3F7  7E           ~     LD A, (HL)
F3F8  CD 0D F4     ...   CALL $F40D
F3FB  23           #     INC HL
F3FC  10 F9        ..    DJNZ $F3F7
F3FE  CD 23 F4     .#.   CALL $F423
F401  D2 06 F4     ...   JP NC $F406
F404  18 D0        ..    JR $F3D6
.
F406  CD E7 FF     ...   CALL osnewl
F409  D1           .     POP DE
F40A  C1           .     POP BC
F40B  F1           .     POP AF
F40C  C9           .     RET
F40D  FE 20        .     CP $20
F40F  38 06        8.    JR C, $F417
F411  FE 7F        .    CP $7F
F413  30 02        0.    JR NC $F417
F415  18 02        ..    JR $F419
.
F417  3E 2E        >.    LD A, ASC "."
.
F419  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
F41C  C9           .     RET
F41D  3E 20        >     LD A, ASC " "
F41F  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
F422  C9           .     RET
F423  E5           .     PUSH HL
F424  01 08 00     ...   LD BC, $0008
F427  BF           .     CP A
F428  ED 42        .     SBC HL, BC
F42A  30 06        0.    JR NC $F432
F42C  21 00 00     !..   LD HL, $0000
F42F  BF           .     CP A
F430  18 02        ..    JR $F434
.
F432  E1           .     POP HL
F433  E5           .     PUSH HL
.
F434  2B           +     DEC HL
F435  ED 52        .     SBC HL, DE
F437  E1           .     POP HL
F438  C9           .     RET

; -----------------------------------------------------------------------------
; Return hex value of string at (DE) in ??
; -----------------------------------------------------------------------------
.
F439  22 AC FC     "..   LD ($FCAC), HL
F43C  21 00 00     !..   LD HL, $0000
.
F43F  1A           .     LD A, (DE)
F440  CB 77        .     BIT 6, A
F442  28 02        (.    JR Z, $F446
F444  E6 DF        ..    AND %11011111            ; Make character upper-case
.
F446  FE 30        .0    CP ASC "O"
F448  FA 6D F4     .m.   JP M $F46D
F44B  FE 47        .G    CP ASC "G"
F44D  F2 6D F4     .m.   JP P $F46D
F450  FE 3A        .:    CP ASC ":"
F452  38 07        8.    JR C, $F45B
F454  FE 41        .A    CP ASC "A"
F456  FA 6D F4     .m.   JP M $F46D
F459  C6 09        ..    ADD A, $09
.
F45B  E6 0F        ..    AND $0F
F45D  29           )     ADD HL, HL               ; HL = HL * 16
F45E  29           )     ADD HL, HL
F45F  29           )     ADD HL, HL
F460  29           )     ADD HL, HL
F461  B5           .     OR L
F462  6F           o     LD L, A
F463  3E 01        >.    LD A, $01
F465  B8           .     CP B
F466  C8           .     RET Z
F467  13           .     INC DE
F468  22 AA FC     "..   LD ($FCAA), HL
F46B  18 D2        ..    JR $F43F
.
F46D  2A AC FC     *..   LD HL, ($FCAC)
F470  C9           .     RET

; -----------------------------------------------------------------------------
; Print HL in hex
; -----------------------------------------------------------------------------
.
F471  7C           |     LD A, H
F472  CD 76 F4     .v.   CALL $F476
F475  7D           }     LD A, L
.                                                 ; Print A in hex
F476  F5           .     PUSH AF
F477  0F           .     RCCA
F478  0F           .     RCCA
F479  0F           .     RCCA
F47A  0F           .     RCCA
F47B  CD 7F F4     ..   CALL $F47F
F47E  F1           .     POP AF
F47F  E6 0F        ..    AND $0F
F481  C6 30        .0    ADD A, '0'
F483  FE 3A        .:    CP $3A
F485  FA 71 F6     .q.   JP M $F671               ; If A < $3A then jump to OSWRCH
F488  C6 07        ..    ADD A, $07
F48A  C3 71 F6     .q.   JP $F671                 ; Jump to OSWRCH

; -----------------------------------------------------------------------------
; *CPM
; -----------------------------------------------------------------------------
.
F48D  13           .     INC DE
F48E  1A           .     LD A, (DE)
F48F  E6 DF        ..    AND %11011111            ; Make character upper-case
F491  FE 50        .P    CP ASC"P"
F493  C2 CC F7     ...   JP NZ $F7CC
F496  13           .     INC DE
F497  1A           .     LD A, (DE)
F498  E6 DF        ..    AND %11011111            ; Make character upper-case
F49A  FE 4D        .M    CP ASC"M"
F49C  C2 CC F7     ...   JP NZ $F7CC
F49F  CD 76 F8     .v.   CALL $F876               ; Loop until (DE) isn't ASCII value 32 (space)
F4A2  FE 0D        ..    CP $0D
F4A4  C2 CC F7     ...   JP NZ $F7CC
F4A7  18 26        .&    JR $F4CF
.
F4A9  CD 0E F6     ...   CALL $F60E               ; Print message to output stream
F4AC  49 6E 73 65  Inse  DB "Insert CP/M System disc in drive A"
      72 74 20 43  rt C
      50 2F 4D 20  P/M 
      53 79 73 74  Syst
      65 6D 20 64  em d
      69 73 63 20  isc 
      69 6E 20 64  in d
      72 69 76 65  rive
      20 41         A
F4CE  00           .     DB $00                   ; String terminator

.
F4CF  3E E5        >.    LD A, $E5
F4D1  21 01 00     !..   LD HL, $0001
F4D4  CD 8E F8     ...   CALL $F88E               ; Call OSBYTE
F4D7  21 82 F5     !..   LD HL, $F582             ; OSWORD $7F parameter block
F4DA  CD 4A F5     .J.   CALL $F54A
F4DD  21 00 EB     !..   LD HL, $EB00
F4E0  11 F0 EA     ...   LD DE, $EAF0
F4E3  01 F0 00     ...   LD BC, $00F0
F4E6  ED B0        .     LDIR                     ; Move $00F0 bytes from $EB00 to $EAF0
F4E8  21 F0 EB     !..   LD HL, $EBF0
F4EB  11 E0 EB     ...   LD DE, $EBE0
F4EE  01 00 06     ...   LD BC, $0600
F4F1  ED B0        .     LDIR                     ; Move $0600 bytes from $EBF0 to $EBE0
F4F3  CD 3B F5     .;.   CALL $F53B
F4F6  3A 00 D4     :..   LD A, ($D400)
F4F9  FE C3        ..    CP $C3                   ; Check for CP/M identifier
F4FB  CA 22 F5     .".   JP Z $F522
F4FE  3E E5        >.    LD A, $E5
F500  21 00 00     !..   LD HL, $0000
F503  CD 8E F8     ...   CALL $F88E               ; Call OSBYTE
F506  CD E7 FF     ...   CALL osnewl
F509  FF           .     RST 38H

F50A  00           .     DB $00
F50B  4E 6F 74 20  Not   DB "Not a CP/M System disc"
      61 20 43 50  a CP
      2F 4D 20 53  /M S
      79 73 74 65  yste
      6D 20 64 69  m di
      73 63        sc
F521  00           .     DB $00                   ; String terminator

.
F522  21 B2 FA     !..   LD HL, $FAB2
F525  22 FA FF     "..   LD ($FFFA), HL
F528  3E 90        >.    LD A, $90
F52A  32 A3 FC     2..   LD ($FCA3), A
F52D  21 00 01     !..   LD HL, $0100
F530  CD 8E F8     ...   CALL $F88E               ; Call OSBYTE
F533  CD 0E F6     ...   CALL $F60E               ; Print message to output stream
F536  16 00        ..    LD D, $00
F538  C3 00 EA     ...   JP $EA00

; -----------------------------------------------------------------------------
; Load CCP and BDOS
; -----------------------------------------------------------------------------
.
F53B  21 8D F5     !..   LD HL, $F58D             ; OSWORD $7F parameter block for loading track 00 sectors 08-09 in $D400-$D5FF
F53E  CD 4A F5     .J.   CALL $F54A
F541  21 98 F5     !..   LD HL, $F598             ; OSWORD $7F parameter block for loading track 01 sectors 00-09 in $D600-$DFFF
F544  CD 4A F5     .J.   CALL $F54A
F547  21 A3 F5     !..   LD HL, $F5A3             ; OSWORD $7F parameter block for loading track 01 sectors 00-09 in $D600-$DFFF
.
F54A  CD 5C F5     .\.   CALL $F55C
F54D  B7           .     OR A
F54E  C8           .     RET Z
F54F  FF           .     RST 38H

F550  C7           .     RST 0

F551  44 69 73 63  Disc  DB "Disc fault"
      20 66 61 75   fau
      6C 74        lt
F55B  00           .     DB $00                   ; String terminator

; -----------------------------------------------------------------------------
; Repeated OSWORD $7F call
; -----------------------------------------------------------------------------
.
F55C  06 04        ..    LD B, $04
.
F55E  48           H     LD C, B
F55F  06 0A        ..    LD B, $0A
.
F561  3E 7F        >    LD A, $7F                ; OSWORD $7F
F563  CD EF F8     ...   CALL $F8EF               ; Call OSWORD
F566  11 0A 00     ...   LD DE, $000A
F569  EB           .     EX DE, HL
.
F56A  19           .     ADD HL, DE
F56B  7E           ~     LD A, (HL)
F56C  32 A7 FC     2..   LD ($FCA7), A
F56F  EB           .     EX DE, HL
F570  FE 12        ..    CP $12
F572  C8           .     RET Z
F573  B7           .     OR A
F574  C8           .     RET Z
F575  10 EA        ..    DJNZ $F561
F577  7E           ~     LD A, (HL)
F578  CD 1B F6     ...   CALL $F61B
F57B  41           A     LD B, C
F57C  10 E0        ..    DJNZ $F55E
F57E  3A A7 FC     :..   LD A, ($FCA7)
F581  C9           .     RET

; -----------------------------------------------------------------------------
; OSWORD $7F parameter block for loading track 00 sectors 00-07 in $E9F0-$F1EF
; -----------------------------------------------------------------------------
.
F582  00           .     NOP
F583  F0           .     RET P
F584  E9           .     JP (HL)
F585  00           .     NOP
F586  00           .     NOP
F587  03           .     INC BC
F588  53           S     LD D, E
F589  00           .     NOP
F58A  00           .     NOP
F58B  28 FF        (.    JR Z, $F58C

; -----------------------------------------------------------------------------
; OSWORD $7F parameter block for loading track 00 sectors 08-09 in $D400-$D5FF
; -----------------------------------------------------------------------------
.
F58D  00           .     NOP
F58E  00           .     NOP
F58F  D4 00 00     ...   CALL NC, $0000
F592  03           .     INC BC
F593  53           S     LD D, E
F594  00           .     NOP
F595  08           .     EX AF, AF'
F596  22 FF        ".    DB $22, $FF

; -----------------------------------------------------------------------------
; OSWORD $7F parameter block for loading track 01 sectors 00-09 in $D600-$DFFF
; -----------------------------------------------------------------------------
.
F598  00           .     DB $00
F599  00           .     NOP
F59A  D6 00        ..    SUB $00
F59C  00           .     NOP
F59D  03           .     INC BC
F59E  53           S     LD D, E
F59F  01 00 2A     ..*   LD BC, $2A00
F5A2  FF           .     RST 38H

; -----------------------------------------------------------------------------
; OSWORD $7F parameter block for loading track 01 sectors 00-09 in $D600-$DFFF
; -----------------------------------------------------------------------------
.
F5A3  00           .     DB $00
F5A4  00           .     NOP
F5A5  E0           .     RET PO
F5A6  00           .     NOP
F5A7  00           .     NOP
F5A8  03           .     INC BC
F5A9  53           S     LD D, E
F5AA  02           .     LD (BC), A
F5AB  00           .     NOP
F5AC  2A FF

; -----------------------------------------------------------------------------
; Initialise OSWORD $FF code in the host processor
; -----------------------------------------------------------------------------
.
F5AE  F3           .     DI                       ; Disable Interrupts
F5AF  21 00 25     !.%   LD HL, $2500
F5B2  11 30 FD     .0.   LD DE, $FD30
F5B5  06 AA        ..    LD B, $AA
F5B7  CD F3 F5     ...   CALL $F5F3
F5BA  21 00 02     !..   LD HL, $0200
.
F5BD  11 DC FD     ...   LD DE, $FDDC
F5C0  06 02        ..    LD B, $02
F5C2  CD DD F5     ...   CALL $F5DD
F5C5  21 03 25     !.%   LD HL, $2503
F5C8  11 DC FD     ...   LD DE, $FDDC
F5CB  06 02        ..    LD B, $02
F5CD  CD F3 F5     ...   CALL $F5F3
F5D0  21 00 02     !..   LD HL, $0200
F5D3  11 DA FD     ...   LD DE, $FDDA
F5D6  06 02        ..    LD B, $02
F5D8  CD F3 F5     ...   CALL $F5F3
F5DB  FB           .     EI                       ; Enable interrupts
F5DC  C9           .     RET
.
F5DD  22 09 F6     "..   LD ($F609), HL
F5E0  E5           .     PUSH HL
F5E1  21 09 F6     !..   LD HL, $F609
F5E4  3E 05        >.    LD A, $05                ; Read I/O processor memory
F5E6  CD F1 FF     ...   CALL osword
F5E9  3A 0D F6     :..   LD A, ($F60D)
F5EC  12           .     LD (DE), A
F5ED  13           .     INC DE
F5EE  E1           .     POP HL
F5EF  23           #     INC HL
F5F0  10 EB        ..    DJNZ $F5DD
F5F2  C9           .     RET
.
F5F3  22 09 F6     "..   LD ($F609), HL
F5F6  1A           .     LD A, (DE)
F5F7  32 0D F6     2..   LD ($F60D), A
F5FA  E5           .     PUSH HL
F5FB  21 09 F6     !..   LD HL, $F609
F5FE  3E 06        >.    LD A, $06                ; Write I/O processor memory
F600  CD F1 FF     ...   CALL osword
F603  13           .     INC DE
F604  E1           .     POP HL
F605  23           #     INC HL
F606  10 EB        ..    DJNZ $F5F3
F608  C9           .     RET

.                                                 ; OSWORD $05/$06 parameterblock
F609  00           .     NOP                      ; 32-bit address LSB
F60A  00           .     NOP
F60B  00           .     NOP
F60C  00           .     NOP                      ; 32-bit address MSB
F60D  00           .     NOP                      ; data

; -----------------------------------------------------------------------------
; Print message to output stream
; -----------------------------------------------------------------------------
.
F60E  E3           .     EX (SP), HL
F60F  F5           .     PUSH AF
.
F610  7E           ~     LD A, (HL)
F611  CD E3 FF     ...   CALL osasci
F614  23           #     INC HL
F615  B7           .     OR A
F616  20 F8         .    JR NZ $F610
F618  F1           .     POP AF
F619  E3           .     EX (SP), HL
F61A  C9           .     RET

; -----------------------------------------------------------------------------
; GSINIT
; -----------------------------------------------------------------------------
.
F61B  F5           .     PUSH AF
F61C  E5           .     PUSH HL
F61D  32 36 F6     26.   LD ($F636), A
F620  21 36 F6     !6.   LD HL, $F636
F623  3E 7F        >    LD A, $7F
F625  ED 73 A5 FC  ...   LD ($FCA5), SP
F629  31 80 FF     1..   LD SP, $FF80             ; Initialise stack pointer
F62C  CD EF F8     ...   CALL $F8EF               ; Call OSWORD
F62F  ED 7B A5 FC  ...   LD SP, ($FCA5)
F633  E1           .     POP HL
F634  F1           .     POP AF
F635  C9           .     RET
F636  00           .     NOP
F637  00           .     NOP
F638  00           .     NOP
F639  00           .     NOP
F63A  00           .     NOP
F63B  01 69 00     .i.   LD BC, $0069
F63E  00           .     NOP

; -----------------------------------------------------------------------------
; GSREAD
; -----------------------------------------------------------------------------
.
F63F  E5           .     PUSH HL
F640  21 FF FF     !..   LD HL, $FFFF
F643  3E 80        >.    LD A, $80
F645  CD 8E F8     ...   CALL $F88E               ; Call OSBYTE
F648  7D           }     LD A, L
F649  B7           .     OR A
F64A  28 02        (.    JR Z, $F64E
F64C  18 0C        ..    JR $F65A
.
F64E  3E D8        >.    LD A, $D8
F650  21 00 FF     !..   LD HL, $FF00
F653  CD 8E F8     ...   CALL $F88E               ; Call OSBYTE
F656  7D           }     LD A, L
F657  B7           .     OR A
F658  28 02        (.    JR Z, $F65C
.
F65A  3E FF        >.    LD A, $FF
.
F65C  E1           .     POP HL
F65D  C9           .     RET

; -----------------------------------------------------------------------------
; OSEVEN
; -----------------------------------------------------------------------------
.
F65E  C5           .     PUSH BC
F65F  D5           .     PUSH DE
F660  E5           .     PUSH HL
F661  21 BC FF     !..   LD HL, $FFBC
F664  11 38 00     .8.   LD DE, $0038
F667  01 03 00     ...   LD BC, $0003
F66A  ED B0        .     LDIR                     ; Move $0003 bytes from $FFBC to $0038
F66C  E1           .     POP HL
F66D  D1           .     POP DE
F66E  C1           .     POP BC
F66F  C9           .     RET
.
F670  C9           .     RET

; -----------------------------------------------------------------------------
; OSWRCH
; -----------------------------------------------------------------------------
.
F671  F5           .     PUSH AF
.
F672  DB 00        ..    IN A, (r1status)         ; Check TUBE ULA Status Register 1...
F674  CB 77        .     BIT 6, A                 ; ... for the NF1 flag
F676  28 FA        (.    JR Z, $F672              ; Loop until it's set
F678  F1           .     POP AF
F679  D3 01        ..    OUT ($01), A
F67B  C9           .     RET
.
F67C  DB 00        ..    IN A, (r1status)         ; Check TUBE ULA Status Register 1...
F67E  CB 7F        .     BIT 7, A                 ; ... for the DA1 flag
F680  20 0B         .    JR NZ $F68D              ; Exit if it's set
F682  DB 06        ..    IN A, (r4status)         ; Check TUBE ULA Status Register 4...
F684  CB 7F        .     BIT 7, A                 ; ... for the DA4 flag
F686  28 F4        (.    JR Z, $F67C              ; Loop until it's cleared
F688  CD 0B FB     ...   CALL $FB0B
F68B  18 EF        ..    JR $F67C
.
F68D  DB 01        ..    IN A, (r1data)
F68F  C9           .     RET

; -----------------------------------------------------------------------------
; OSRDCH
; -----------------------------------------------------------------------------
.
F690  3E 00        >.    LD A, $00
F692  CD A3 F6     ...   CALL $F6A3
.
F695  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
F698  CB 27        .     SLA A                    ; Move bit 7 to carry flag

; -----------------------------------------------------------------------------
; Wait for data in TUBE ULA Data register 2 and return it in A
; -----------------------------------------------------------------------------
.read_from_r2data
F69A  DB 02        ..    IN A, (r2status)         ; Check TUBE ULA Status Register 2...
F69C  CB 7F        .     BIT 7, A                 ; ... for the DA2 flag
F69E  28 FA        (.    JR Z, $F69A
F6A0  DB 03        ..    IN A, (r2data)
F6A2  C9           .     RET

; -----------------------------------------------------------------------------
; 
; -----------------------------------------------------------------------------
.write_to_r2data
F6A3  F5           .     PUSH AF
.
F6A4  DB 02        ..    IN A, (r2status)         ; Check TUBE ULA Status Register 2...
F6A6  CB 77        .     BIT 6, A                 ; ... for the NF2 flag
F6A8  28 FA        (.    JR Z, $F6A4
F6AA  F1           .     POP AF
F6AB  D3 03        ..    OUT (r2data), A
F6AD  C9           .     RET

; -----------------------------------------------------------------------------
; 
; -----------------------------------------------------------------------------
.
F6AE  DB 06        ..    IN A, (r4status)         ; Check TUBE ULA Status Register 4...
F6B0  CB 7F        .     BIT 7, A                 ; ... for the DA4 flag
F6B2  28 FA        (.    JR Z, $F6AE
F6B4  DB 07        ..    IN A, (r4data)
F6B6  C9           .     RET

; -----------------------------------------------------------------------------
; OSCLI
; -----------------------------------------------------------------------------
.
.
F6B7  F5           .     PUSH AF
F6B8  C5           .     PUSH BC
F6B9  D5           .     PUSH DE
F6BA  54           T     LD D, H
F6BB  5D           ]     LD E, L
.
F6BC  CD 7E F8     .~.   CALL $F87E               ; Loop until (DE) isn't ASCII value $2A (*)
F6BF  CD 77 F8     .w.   CALL $F877               ; Loop until (DE) isn't ASCII value 32 (space)
F6C2  FE 2A        .*    CP ASC "*"
F6C4  28 F6        (.    JR Z, $F6BC
F6C6  E6 DF        ..    AND %11011111            ; Make character upper-case
F6C8  FE 48        .H    CP ASC "H"
F6CA  28 20        (     JR Z, $F6EC
F6CC  4F           O     LD C, A
F6CD  3A A3 FC     :..   LD A, ($FCA3)
F6D0  B7           .     OR A
F6D1  79           y     LD A, C
F6D2  C2 CC F7     ...   JP NZ $F7CC
F6D5  FE 47        .G    CP ASC "G"
F6D7  CA 08 F3     ...   JP Z $F308
F6DA  FE 44        .D    CP ASC "D"
F6DC  CA B3 F3     ...   JP Z $F3B3
F6DF  FE 53        .S    CP ASC "S"
F6E1  CA 30 F3     .0.   JP Z $F330
F6E4  FE 43        .C    CP ASC "C"
F6E6  CA 8D F4     ...   JP Z $F48D
F6E9  C3 CC F7     ...   JP $F7CC
.                                                 ; Check for *HELP
F6EC  13           .     INC DE
F6ED  1A           .     LD A, (DE)
F6EE  FE 2E        ..    CP ASC "."
F6F0  28 2E        (.    JR Z, $F720
F6F2  E6 DF        ..    AND %11011111            ; Make character upper-case
F6F4  FE 45        .E    CP ASC "E"
F6F6  C2 CC F7     ...   JP NZ $F7CC
F6F9  13           .     INC DE
F6FA  1A           .     LD A, (DE)
F6FB  FE 2E        ..    CP ASC"."
F6FD  28 21        (!    JR Z, $F720
F6FF  E6 DF        ..    AND %11011111            ; Make character upper-case
F701  FE 4C        .L    CP ASC"L"
F703  C2 CC F7     ...   JP NZ $F7CC
F706  13           .     INC DE
F707  1A           .     LD A, (DE)
F708  FE 2E        ..    CP ASC "."
F70A  28 14        (.    JR Z, $F720
F70C  E6 DF        ..    AND %11011111            ; Make character upper-case
F70E  FE 50        .P    CP ASC "P"
F710  C2 CC F7     ...   JP NZ $F7CC
F713  13           .     INC DE
F714  1A           .     LD A, (DE)
F715  CD 6D F8     .m.   CALL $F86D
F718  D2 CC F7     ...   JP NC $F7CC
F71B  CD 77 F8     .w.   CALL $F877               ; Loop until (DE) isn't ASCII value 32 (space)
F71E  18 03        ..    JR $F723
.
F720  CD 76 F8     .v.   CALL $F876               ; Loop until (DE) isn't ASCII value 32 (space)
.
F723  CD B3 FF     ...   CALL $FFB3

F726  0D           .     DB $0D                   ; Carriage returm
F727  5A 38 30 20  Z80   DB "Z80 TUBE 1.20"
      54 55 42 45  TUBE
      20 31 2E 32  1.20
F734  0D           .     DB $0D                   ; Carriage returm
F735  00           .     DB $00                   ; String terminator

F736  4F           O     LD C, A
F737  3A A3 FC     :..   LD A, ($FCA3)
F73A  B7           .     OR A
F73B  79           y     LD A, C
F73C  C2 CC F7     ...   JP NZ $F7CC
F73F  FE 0D        ..    CP $0D
F741  28 29        ()    JR Z, $F76C
.
F743  E6 DF        ..    AND %11011111            ; Make character upper-case
F745  FE 4D        .M    CP ASC "M"
F747  28 09        (.    JR Z, $F752
F749  FE 0D        ..    CP $0D
F74B  CA CC F7     ...   JP Z $F7CC
.
F74E  13           .     INC DE
F74F  1A           .     LD A, (DE)
F750  18 F1        ..    JR $F743
.
F752  13           .     INC DE
F753  1A           .     LD A, (DE)
F754  E6 DF        ..    AND %11011111            ; Make character upper-case
F756  FE 4F        .O    CP ASC "O"
F758  20 F4         .    JR NZ $F74E
.
F75A  13           .     INC DE
F75B  1A           .     LD A, (DE)
F75C  E6 DF        ..    AND %11011111            ; Make character upper-case
F75E  FE 4E        .N    CP ASC "N"
F760  20 EC         .    JR NZ $F74E
.
F762  13           .     INC DE
F763  1A           .     LD A, (DE)
F764  CD 6D F8     .m.   CALL $F86D
F767  D2 4E F7     .N.   JP NC $F74E
F76A  18 0C        ..    JR $F778
.
F76C  CD 0E F6     ...   CALL $F60E               ; Print message to output stream

F76F  20 20 4D 4F    MO  DB "  MON"
      4E           N
F774  0D           .     DB $0D                   ; Carriage returm
F775  00           .     DB $00                   ; String terminator

F776  18 54        .T    JR $F7CC
.
F778  CD 0E F6     ...   CALL $F60E               ; Print message to output stream

F77B  20 20 43 50    CP  DB "  CPM"
      4D           M
F780  0D           .     DB $0D                   ; Carriage returm
F781  20 20 44 75    Du  DB "  Dump <start address> <end address>"
      6D 70 20 3C  mp <
      73 74 61 72  star
      74 20 61 64  t ad
      64 72 65 73  dres
      73 3E 20 3C  s> <
      65 6E 64 20  end 
      61 64 64 72  addr
      65 73 73 3E  ess>
F7A5  0D           .     DB $0D                   ; Carriage returm
F7A6  20 20 47 4F    GO  DB "  GO <address>"
      20 3C 61 64   <ad
      64 72 65 73  dres
      73 3E        s>
F7B4  0D           .     DB $0D                   ; Carriage return
F7B5  20 20 53 65    Se  DB "  Set <start address>"
      74 20 3C 73  t <s
      74 61 72 74  tart
      20 61 64 64   add
      72 65 73 73  ress
      3E           >
F7CA  0D           .     DB $0D                   ; Carriage return
F7CB  00           .     DB $00                   ; String terminator

.
F7CC  3E 02        >.    LD A, $02
F7CE  CD A3 F6     ...   CALL $F6A3
F7D1  CD 84 F8     ...   CALL $F884
F7D4  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
.
F7D7  FE 80        ..    CP $80
F7D9  28 04        (.    JR Z, $F7DF
F7DB  D1           .     POP DE
F7DC  C1           .     POP BC
F7DD  F1           .     POP AF
F7DE  C9           .     RET

; -----------------------------------------------------------------------------
; 
; -----------------------------------------------------------------------------
.
F7DF  3E 01        >.    LD A, $01
F7E1  32 AF FC     2..   LD ($FCAF), A
F7E4  CD EB F7     ...   CALL $F7EB
F7E7  D1           .     POP DE
.
F7E8  C1           .     POP BC
F7E9  F1           .     POP AF
F7EA  C9           .     RET

; -----------------------------------------------------------------------------
; Check copyright message and ROM type and enter language ROM
; -----------------------------------------------------------------------------
.
F7EB  2A A8 FC     *..   LD HL, ($FCA8)
F7EE  11 07 00     ...   LD DE, $0007             ; Copyright offset in paged ROM
.
F7F1  19           .     ADD HL, DE
F7F2  E5           .     PUSH HL
F7F3  7E           ~     LD A, (HL)
F7F4  2A A8 FC     *..   LD HL, ($FCA8)
F7F7  5F           _     LD E, A
.
F7F8  19           .     ADD HL, DE
F7F9  22 82 FF     "..   LD (faultptr), HL
F7FC  7E           ~     LD A, (HL)
F7FD  FE 00        ..    CP $00                   ; First byte of the copyright string must be zero
.
F7FF  20 25         %    JR NZ $F826
F801  23           #     INC HL
F802  7E           ~     LD A, (HL)
F803  FE 28        .(    CP ASC "("
F805  20 1F         .    JR NZ $F826              ; Next three bytes must be (C)
F807  23           #     INC HL
F808  7E           ~     LD A, (HL)
F809  FE 43        .C    CP ASC "C"
F80B  20 19         .    JR NZ $F826
F80D  23           #     INC HL
F80E  7E           ~     LD A, (HL)
F80F  FE 29        .)    CP ASC ")"
F811  20 13         .    JR NZ $F826
F813  E1           .     POP HL
F814  2B           +     DEC HL
F815  3A AF FC     :..   LD A, ($FCAF)
F818  B7           .     OR A
F819  20 0F         .    JR NZ $F82A
F81B  7E           ~     LD A, (HL)
F81C  CB 77        .     BIT 6, A
F81E  CA A9 F4     ...   JP Z $F4A9
F821  CB 5F        ._    BIT 3, A
F823  CA A9 F4     ...   JP Z $F4A9
.
F826  2A A8 FC     *..   LD HL, ($FCA8)
F829  E9           .     JP (HL)
.
F82A  AF           .     XOR A
F82B  32 AF FC     2..   LD ($FCAF), A                                ; Set flag to reboot to CPM
F82E  7E           ~     LD A, (HL)                                   ; Get ROM type
F82F  CB 77        .     BIT 6, A                                     ; Mask out language bit
F831  28 0A        (.    JR Z, $F83D                                  ; Jump if not a language
F833  CB 5F        ._    BIT 3, A
F835  28 1F        (.    JR Z, $F856                                  ; Jump if's not Z80 code
F837  3E 01        >.    LD A, $01
F839  2A A8 FC     *..   LD HL, ($FCA8)                               ; Set HL to program address
F83C  E9           .     JP (HL)                                      ; Enter language ROM
.
F83D  FF           .     RST 38H

F83E  00           .     DB $00
F83F  54 68 69 73  This  DB "This is not a language"
      20 69 73 20   is 
      6E 6F 74 20  not 
      61 20 6C 61  a la
      6E 67 75 61  ngua
      67 65        ge
F855  00           .     DB $00                   ; String terminator

.
F856  FF           .     RST 38H

F857  00           .     DB $00
F858  54 68 69 73  This  DB "This is not Z80 code"
      20 69 73 20   is 
      6E 6F 74 20  not 
      5A 38 30 20  Z80 
      63 6F 64 65  code
F86C  00           .     DB $00                   ; String terminator

; -----------------------------------------------------------------------------
; 
; -----------------------------------------------------------------------------
.
F86D  E6 DF        ..    AND %11011111            ; Make character upper-case
F86F  FE 41        .A    CP ASC "A"
F871  D8           .     RET C
F872  FE 5B        .[    CP ASC "Z"+1
F874  3F           ?     CCF
F875  C9           .     RET

; -----------------------------------------------------------------------------
; Loop until (DE) isn't ASCII value 32 (space)
; -----------------------------------------------------------------------------
.
F876  13           .     INC DE
.
F877  1A           .     LD A, (DE)
F878  FE 20        .     CP ASC" "
F87A  28 FA        (.    JR Z, $F876
F87C  C9           .     RET

; -----------------------------------------------------------------------------
; Loop until (DE) isn't ASCII value $2A (*)
; -----------------------------------------------------------------------------
.
F87D  13           .     INC DE
.
F87E  1A           .     LD A, (DE)
F87F  FE 2A        .*    CP $2A
F881  28 FA        (.    JR Z, $F87D
F883  C9           .     RET

; -----------------------------------------------------------------------------
; Get string termiated by $0D from r2data
; -----------------------------------------------------------------------------
.
F884  7E           ~     LD A, (HL)
F885  CD A3 F6     ...   CALL $F6A3
F888  23           #     INC HL
F889  FE 0D        ..    CP $0D
F88B  20 F7         .    JR NZ $F884
F88D  C9           .     RET

; -----------------------------------------------------------------------------
; OSBYTE
; -----------------------------------------------------------------------------
.
F88E  FE 80        ..    CP $80
F890  30 15        0.    JR NC $F8A7
F892  F5           .     PUSH AF
F893  3E 04        >.    LD A, $04
F895  CD A3 F6     ...   CALL $F6A3
F898  7D           }     LD A, L
F899  CD A3 F6     ...   CALL $F6A3
F89C  F1           .     POP AF
F89D  F5           .     PUSH AF
F89E  CD A3 F6     ...   CALL $F6A3
F8A1  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
F8A4  6F           o     LD L, A
F8A5  F1           .     POP AF
F8A6  C9           .     RET
.
F8A7  FE 82        ..    CP $82
F8A9  28 31        (1    JR Z, $F8DC
F8AB  FE 83        ..    CP $83
.
F8AD  28 31        (1    JR Z, $F8E0
F8AF  FE 84        ..    CP $84
F8B1  28 31        (1    JR Z, $F8E4
F8B3  F5           .     PUSH AF
F8B4  3E 06        >.    LD A, $06
.
F8B6  CD A3 F6     ...   CALL $F6A3
F8B9  7D           }     LD A, L
.
F8BA  CD A3 F6     ...   CALL $F6A3
F8BD  7C           |     LD A, H
F8BE  CD A3 F6     ...   CALL $F6A3
F8C1  F1           .     POP AF
F8C2  F5           .     PUSH AF
F8C3  CD A3 F6     ...   CALL $F6A3
F8C6  FE 9D        ..    CP $9D
F8C8  28 10        (.    JR Z, $F8DA
F8CA  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
F8CD  6F           o     LD L, A
F8CE  F1           .     POP AF
.
F8CF  CB 25        .     SLA L
F8D1  F5           .     PUSH AF
F8D2  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
F8D5  67           g     LD H, A
F8D6  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
F8D9  6F           o     LD L, A
.
F8DA  F1           .     POP AF
F8DB  C9           .     RET
.
F8DC  21 00 00     !..   LD HL, $0000
F8DF  C9           .     RET
.
F8E0  21 03 3B     !.;   LD HL, $3B03
F8E3  C9           .     RET
.
F8E4  21 00 DC     !..   LD HL, $DC00
F8E7  C9           .     RET

; -----------------------------------------------------------------------------
; NVWRCH
; -----------------------------------------------------------------------------
.
F8E8  F5           .     PUSH AF
F8E9  3E 01        >.    LD A, $01
F8EB  32 A4 FC     2..   LD ($FCA4), A
F8EE  F1           .     POP AF

; -----------------------------------------------------------------------------
; OSWORD
; -----------------------------------------------------------------------------
.
F8EF  B7           .     OR A
F8F0  28 6B        (k    JR Z, $F95D
F8F2  C5           .     PUSH BC
F8F3  E5           .     PUSH HL
F8F4  DD E5        .     PUSH IX
F8F6  F5           .     PUSH AF
F8F7  3E 08        >.    LD A, $08
F8F9  CD A3 F6     ...   CALL $F6A3
F8FC  F1           .     POP AF
F8FD  F5           .     PUSH AF
F8FE  CD A3 F6     ...   CALL $F6A3
F901  06 00        ..    LD B, $00
F903  4F           O     LD C, A
F904  FE 80        ..    CP $80
F906  38 06        8.    JR C, $F90E
F908  46           F     LD B, (HL)
F909  23           #     INC HL
F90A  4E           N     LD C, (HL)
F90B  2B           +     DEC HL
F90C  18 15        ..    JR $F923
.
F90E  FE 15        ..    CP $15
F910  38 05        8.    JR C, $F917
F912  01 10 10     ...   LD BC, $1010
F915  18 0C        ..    JR $F923
.
F917  DD 21 75 FC  .!u.  LD IX, $FC75
F91B  DD 09        .     ADD IX, BC
F91D  DD 46 FF     .F.   LD B, (IX+$FF)
F920  DD 4E 13     .N.   LD C, (IX+$13)
.
F923  E5           .     PUSH HL
F924  C5           .     PUSH BC
F925  48           H     LD C, B
F926  06 00        ..    LD B, $00
F928  09           .     ADD HL, BC
F929  C1           .     POP BC
F92A  78           x     LD A, B
F92B  CD A3 F6     ...   CALL $F6A3
F92E  B7           .     OR A
F92F  28 07        (.    JR Z, $F938
.
F931  2B           +     DEC HL
F932  7E           ~     LD A, (HL)
F933  CD A3 F6     ...   CALL $F6A3
F936  10 F9        ..    DJNZ $F931
.
F938  79           y     LD A, C
F939  CD A3 F6     ...   CALL $F6A3
F93C  E1           .     POP HL
F93D  F5           .     PUSH AF
F93E  3A A4 FC     :..   LD A, ($FCA4)
F941  B7           .     OR A
F942  28 06        (.    JR Z, $F94A
F944  62           b     LD H, D
F945  6B           k     LD L, E
F946  AF           .     XOR A
F947  32 A4 FC     2..   LD ($FCA4), A
.
F94A  F1           .     POP AF
F94B  B7           .     OR A
F94C  28 09        (.    JR Z, $F957
F94E  09           .     ADD HL, BC
F94F  41           A     LD B, C
.
F950  2B           +     DEC HL
F951  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
F954  77           w     LD (HL), A
F955  10 F9        ..    DJNZ $F950
.
F957  F1           .     POP AF
F958  DD E1        .     POP IX
F95A  E1           .     POP HL
F95B  C1           .     POP BC
F95C  C9           .     RET
.
F95D  C5           .     PUSH BC
F95E  F5           .     PUSH AF
F95F  3E 0A        >.    LD A, $0A
F961  CD A3 F6     ...   CALL $F6A3
F964  23           #     INC HL
F965  23           #     INC HL
F966  23           #     INC HL
F967  23           #     INC HL
F968  06 03        ..    LD B, $03
.
F96A  7E           ~     LD A, (HL)
F96B  CD A3 F6     ...   CALL $F6A3
F96E  2B           +     DEC HL
F96F  10 F9        ..    DJNZ $F96A
F971  3E 07        >.    LD A, $07
F973  CD A3 F6     ...   CALL $F6A3
F976  97           .     SUB A
F977  CD A3 F6     ...   CALL $F6A3
F97A  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
F97D  07           .     RCLA
F97E  38 18        8.    JR C, $F998
F980  7E           ~     LD A, (HL)
F981  2B           +     DEC HL
F982  6E           n     LD L, (HL)
F983  67           g     LD H, A
F984  06 FF        ..    LD B, $FF
.
F986  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
F989  77           w     LD (HL), A
F98A  23           #     INC HL
F98B  04           .     INC B
F98C  FE 0D        ..    CP $0D
F98E  20 F6         .    JR NZ $F986
F990  2E 00        ..    LD L, $00
F992  60           `     LD H, B
F993  F1           .     POP AF
F994  C1           .     POP BC
F995  37           7     SCF
F996  3F           ?     CCF
F997  C9           .     RET
.
F998  21 FF 00     !..   LD HL, $00FF
F99B  F1           .     POP AF
F99C  C1           .     POP BC
F99D  37           7     SCF
F99E  C9           .     RET

; -----------------------------------------------------------------------------
; OSARGS
; -----------------------------------------------------------------------------
.
F99F  E5           .     PUSH HL
F9A0  D5           .     PUSH DE
F9A1  C5           .     PUSH BC
F9A2  F5           .     PUSH AF
F9A3  3E 0C        >.    LD A, $0C
F9A5  CD A3 F6     ...   CALL $F6A3
F9A8  7B           {     LD A, E
F9A9  CD A3 F6     ...   CALL $F6A3
F9AC  23           #     INC HL
F9AD  23           #     INC HL
F9AE  23           #     INC HL
F9AF  06 04        ..    LD B, $04
.
F9B1  7E           ~     LD A, (HL)
F9B2  CD A3 F6     ...   CALL $F6A3
F9B5  2B           +     DEC HL
F9B6  10 F9        ..    DJNZ $F9B1
F9B8  23           #     INC HL
F9B9  F1           .     POP AF
F9BA  CD A3 F6     ...   CALL $F6A3
F9BD  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
F9C0  F5           .     PUSH AF
F9C1  23           #     INC HL
F9C2  23           #     INC HL
F9C3  23           #     INC HL
F9C4  06 04        ..    LD B, $04
.
F9C6  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
F9C9  77           w     LD (HL), A
F9CA  2B           +     DEC HL
F9CB  10 F9        ..    DJNZ $F9C6
F9CD  F1           .     POP AF
F9CE  C1           .     POP BC
F9CF  D1           .     POP DE
F9D0  E1           .     POP HL
F9D1  C9           .     RET

; -----------------------------------------------------------------------------
; OSFIND
; -----------------------------------------------------------------------------
.
F9D2  F5           .     PUSH AF
F9D3  3E 12        >.    LD A, $12
F9D5  CD A3 F6     ...   CALL $F6A3
F9D8  F1           .     POP AF
F9D9  CD A3 F6     ...   CALL $F6A3
F9DC  FE 00        ..    CP $00
F9DE  20 0A         .    JR NZ $F9EA
F9E0  F5           .     PUSH AF
F9E1  7C           |     LD A, H
F9E2  CD A3 F6     ...   CALL $F6A3
F9E5  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
F9E8  F1           .     POP AF
F9E9  C9           .     RET
.
F9EA  CD 84 F8     ...   CALL $F884
F9ED  C3 9A F6     ...   JP $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A

; -----------------------------------------------------------------------------
; OSBGET
; -----------------------------------------------------------------------------
.
F9F0  3E 0E        >.    LD A, $0E
F9F2  CD A3 F6     ...   CALL $F6A3
F9F5  7C           |     LD A, H
F9F6  CD A3 F6     ...   CALL $F6A3
F9F9  C3 95 F6     ...   JP $F695

; -----------------------------------------------------------------------------
; OSBPUT
; -----------------------------------------------------------------------------
.
F9FC  F5           .     PUSH AF
F9FD  3E 10        >.    LD A, $10
F9FF  CD A3 F6     ...   CALL $F6A3
FA02  7C           |     LD A, H
FA03  CD A3 F6     ...   CALL $F6A3
FA06  F1           .     POP AF
FA07  CD A3 F6     ...   CALL $F6A3
FA0A  F5           .     PUSH AF
FA0B  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
FA0E  F1           .     POP AF
FA0F  C9           .     RET

; -----------------------------------------------------------------------------
; OSFILE
; -----------------------------------------------------------------------------
.
FA10  C5           .     PUSH BC
FA11  F5           .     PUSH AF
FA12  22 AC FC     "..   LD ($FCAC), HL
FA15  3E 14        >.    LD A, $14
FA17  CD A3 F6     ...   CALL $F6A3
FA1A  01 11 00     ...   LD BC, $0011
FA1D  09           .     ADD HL, BC
FA1E  06 10        ..    LD B, $10
.
FA20  7E           ~     LD A, (HL)
FA21  CD A3 F6     ...   CALL $F6A3
FA24  2B           +     DEC HL
FA25  10 F9        ..    DJNZ $FA20
FA27  7E           ~     LD A, (HL)
FA28  2B           +     DEC HL
FA29  6E           n     LD L, (HL)
FA2A  67           g     LD H, A
FA2B  CD 84 F8     ...   CALL $F884
FA2E  F1           .     POP AF
FA2F  CD A3 F6     ...   CALL $F6A3
FA32  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
FA35  E6 7F        .    AND $7F
FA37  F5           .     PUSH AF
FA38  2A AC FC     *..   LD HL, ($FCAC)
FA3B  01 11 00     ...   LD BC, $0011
FA3E  09           .     ADD HL, BC
FA3F  06 10        ..    LD B, $10
.
FA41  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
FA44  77           w     LD (HL), A
FA45  2B           +     DEC HL
FA46  10 F9        ..    DJNZ $FA41
FA48  2A AC FC     *..   LD HL, ($FCAC)
FA4B  F1           .     POP AF
FA4C  C1           .     POP BC
FA4D  C9           .     RET

; -----------------------------------------------------------------------------
; OSGBPB
; -----------------------------------------------------------------------------
.
FA4E  C5           .     PUSH BC
FA4F  F5           .     PUSH AF
FA50  22 AC FC     "..   LD ($FCAC), HL
FA53  3E 16        >.    LD A, $16
FA55  CD A3 F6     ...   CALL $F6A3
FA58  01 0C 00     ...   LD BC, $000C
FA5B  09           .     ADD HL, BC
FA5C  06 0D        ..    LD B, $0D
.
FA5E  7E           ~     LD A, (HL)
FA5F  CD A3 F6     ...   CALL $F6A3
FA62  2B           +     DEC HL
FA63  10 F9        ..    DJNZ $FA5E
FA65  F1           .     POP AF
FA66  CD A3 F6     ...   CALL $F6A3
FA69  2A AC FC     *..   LD HL, ($FCAC)
FA6C  01 0C 00     ...   LD BC, $000C
FA6F  09           .     ADD HL, BC
FA70  06 0D        ..    LD B, $0D
.
FA72  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
FA75  77           w     LD (HL), A
FA76  2B           +     DEC HL
FA77  10 F9        ..    DJNZ $FA72
FA79  2A AC FC     *..   LD HL, ($FCAC)
FA7C  C1           .     POP BC
FA7D  C3 95 F6     ...   JP $F695

; -----------------------------------------------------------------------------
; Interrupt SP (stack pointer) save register
; -----------------------------------------------------------------------------
.
FA80  00           .     NOP
FA81  00           .     NOP

; -----------------------------------------------------------------------------
; Interrupt handler
; -----------------------------------------------------------------------------
.
FA82  ED 73 80 FA  .s..  LD ($FA80), SP           ; Save SP (stack pointer)
FA86  31 60 FF     1`.   LD SP, $FF60             ; Set SP to temporary stack
FA89  CD 93 FA     ...   CALL $FA93               ; 
FA8C  ED 7B 80 FA  .{..  LD SP, ($FA80)           ; Restore SP (stack pointer)
FA90  FB           .     EI                       ; Enable interrupts
FA91  ED 4D        .     RETI                     ; Return to main code

.
FA93  F5           .     PUSH AF
FA94  DB 06        ..    IN A, (r4status)         ; Check TUBE ULA Status Register 4...
FA96  CB 7F        .     BIT 7, A                 ; ... for the DA4 flag
FA98  20 71         q    JR NZ $FB0B
FA9A  DB 00        ..    IN A, (r1status)         ; Check TUBE ULA Status Register 1...
FA9C  CB 7F        .     BIT 7, A                 ; ... for the DA1 flag
FA9E  20 39         9    JR NZ $FAD9
FAA0  F1           .     POP AF
FAA1  C3 B0 FF     ...   JP $FFB0

.
FAA4  E1           .     POP HL
FAA5  22 82 FF     "..   LD (faultptr), HL
FAA8  2A FA FF     *..   LD HL, ($FFFA)
FAAB  E9           .     JP (HL)

; -----------------------------------------------------------------------------
; IRQ/BRK handler
; -----------------------------------------------------------------------------
.
FAAC  CD C6 FA     ...   CALL $FAC6
FAAF  C3 CB F2     ...   JP $F2CB

; -----------------------------------------------------------------------------
; Default error handler
; -----------------------------------------------------------------------------
.
FAB2  3E 03        >.    LD A, $03
FAB4  2E 00        ..    LD L, $00
FAB6  CD 8E F8     ...   CALL $F88E               ; Call OSBYTE
FAB9  3E 02        >.    LD A, $02
FABB  2E 02        ..    LD L, $02
FABD  CD 8E F8     ...   CALL $F88E               ; Call OSBYTE
FAC0  CD C6 FA     ...   CALL $FAC6
FAC3  C3 00 00     ...   JP $0000
FAC6  2A 82 FF     *..   LD HL, (faultptr)
FAC9  3E 0D        >.    LD A, $0D
FACB  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
FACE  3E 0A        >.    LD A, $0A
.
FAD0  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
FAD3  23           #     INC HL
FAD4  7E           ~     LD A, (HL)
FAD5  B7           .     OR A
FAD6  20 F8         .    JR NZ $FAD0
FAD8  C9           .     RET
; -----------------------------------------------------------------------------
; IRQEvent handler
; -----------------------------------------------------------------------------
.irq_event
FAD9  DB 01        ..    IN A, (r1data)
FADB  CB 7F        .     BIT 7, A
FADD  20 25         %    JR NZ $FB04
FADF  3E 01        >.    LD A, $01
FAE1  32 A2 FC     2..   LD ($FCA2), A
FAE4  E5           .     PUSH HL
FAE5  DD E5        .     PUSH IX
FAE7  CD 7C F6     .|.   CALL $F67C
FAEA  67           g     LD H, A
FAEB  CD 7C F6     .|.   CALL $F67C
FAEE  6F           o     LD L, A
FAEF  CD 7C F6     .|.   CALL $F67C
FAF2  CD FE FA     ...   CALL $FAFE
FAF5  AF           .     XOR A
FAF6  32 A2 FC     2..   LD ($FCA2), A
FAF9  DD E1        .     POP IX
FAFB  E1           .     POP HL
FAFC  F1           .     POP AF
.                                                 ; User interrupt routine
FAFD  C9           .     RET
.
FAFE  DD 2A FC FF  ....  LD IX, ($FFFC)
FB02  DD E9        .     JP (IX)
.
FB04  CB 27        .     SLA A
FB06  32 80 FF     2..   LD (escape_flag), A
FB09  F1           .     POP AF
FB0A  C9           .     RET
; -----------------------------------------------------------------------------
; IRQ transfer
; -----------------------------------------------------------------------------
.irq_transfer
FB0B  DB 07        ..    IN A, (r4data)
FB0D  CB 7F        .     BIT 7, A
FB0F  28 45        (E    JR Z, $FB56
.                                                 ; BRK occurred
FB11  DB 02        ..    IN A, (r2status)         ; Check TUBE ULA Status Register 2...
FB13  CB 7F        .     BIT 7, A                 ; ... for the DA2 flag
FB15  28 FA        (.    JR Z, $FB11
FB17  DB 03        ..    IN A, (r2data)
FB19  FB           .     EI                       ; Enable interrupts
FB1A  21 B0 FC     !..   LD HL, $FCB0
FB1D  36 CD        6.    LD (HL), $CD
FB1F  23           #     INC HL
FB20  3A BD FF     :..   LD A, ($FFBD)
FB23  77           w     LD (HL), A
FB24  23           #     INC HL
FB25  3A BE FF     :..   LD A, ($FFBE)
FB28  77           w     LD (HL), A
FB29  23           #     INC HL
FB2A  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
FB2D  77           w     LD (HL), A
FB2E  B7           .     OR A
FB2F  20 1A         .    JR NZ $FB4B
FB31  CD 0E F6     ...   CALL $F60E               ; Print message to output stream

FB34  0D           .     DEC C
FB35  46           F     LD B, (HL)
FB36  61           a     LD H, C
FB37  74           t     LD (HL), H
FB38  61           a     LD H, C
FB39  6C           l     LD L, H
FB3A  20 65         e    JR NZ $FBA1
FB3C  72           r     LD (HL), D
FB3D  72           r     LD (HL), D
FB3E  6F           o     LD L, A
FB3F  72           r     LD (HL), D
FB40  00           .     DB $00                   ; String terminator

FB41  3A A3 FC     :..   LD A, ($FCA3)
FB44  B7           .     OR A
FB45  C2 00 00     ...   JP NZ $0000
FB48  C3 CB F2     ...   JP $F2CB
.
FB4B  23           #     INC HL
FB4C  CD 9A F6     ...   CALL $F69A               ; Wait for data in TUBE ULA Data register 2 and return it in A
FB4F  77           w     LD (HL), A
FB50  B7           .     OR A
FB51  20 F8         .    JR NZ $FB4B
FB53  C3 B0 FC     ...   JP $FCB0

.irq_data_transfer
FB56  C5           .     PUSH BC
FB57  D5           .     PUSH DE
FB58  E5           .     PUSH HL
FB59  F5           .     PUSH AF
FB5A  07           .     RCLA
FB5B  5F           _     LD E, A
FB5C  07           .     RCLA
FB5D  07           .     RCLA
FB5E  83           .     ADD A, E
FB5F  07           .     RCLA
FB60  5F           _     LD E, A
FB61  16 00        ..    LD D, $00
FB63  21 C1 FB     !..   LD HL, $FBC1
FB66  19           .     ADD HL, DE
FB67  11 61 FC     .a.   LD DE, $FC61
FB6A  01 14 00     ...   LD BC, $0014
FB6D  ED B0        .     LDIR                     ; Move $0014 bytes from $FBC1+DE to $FC61
FB6F  CD AE F6     ...   CALL $F6AE
FB72  F1           .     POP AF
FB73  FE 05        ..    CP $05
FB75  28 33        (3    JR Z, $FBAA
FB77  F5           .     PUSH AF
FB78  CD AE F6     ...   CALL $F6AE
FB7B  CD AE F6     ...   CALL $F6AE
FB7E  CD AE F6     ...   CALL $F6AE
FB81  67           g     LD H, A
FB82  CD AE F6     ...   CALL $F6AE
FB85  6F           o     LD L, A
FB86  22 A8 FC     "..   LD ($FCA8), HL
FB89  0E 05        ..    LD C, $05
FB8B  06 00        ..    LD B, $00
FB8D  CD AE F6     ...   CALL $F6AE
FB90  F1           .     POP AF
FB91  FE 06        ..    CP $06
FB93  38 15        8.    JR C, $FBAA
FB95  20 1D         .    JR NZ $FBB4
.
FB97  DB 04        ..    IN A, (r3status)         ; Check TUBE ULA Status Register 3...
FB99  B7           .     OR A
FB9A  F2 97 FB     ...   JP P $FB97
FB9D  ED A3        .     OUTI
FB9F  C2 97 FB     ...   JP NZ $FB97
.
FBA2  DB 04        ..    IN A, (r3status)         ; Check TUBE ULA Status Register 3...
FBA4  B7           .     OR A
FBA5  F2 A2 FB     ...   JP P $FBA2
FBA8  D3 05        ..    OUT ($05), A
.
FBAA  E1           .     POP HL
FBAB  D1           .     POP DE
FBAC  C1           .     POP BC
FBAD  3A A2 FC     :..   LD A, ($FCA2)
FBB0  B7           .     OR A
FBB1  C0           .     RET NZ
FBB2  F1           .     POP AF
FBB3  C9           .     RET
.
FBB4  DB 04        ..    IN A, (r3status)         ; Check TUBE ULA Status Register 3...
FBB6  B7           .     OR A
FBB7  F2 B4 FB     ...   JP P $FBB4
FBBA  ED A2        .     INI
FBBC  C2 B4 FB     ...   JP NZ $FBB4
FBBF  18 E9        ..    JR $FBAA
FBC1  E5           .     PUSH HL
FBC2  F5           .     PUSH AF
FBC3  2A A8 FC     *..   LD HL, ($FCA8)
FBC6  7E           ~     LD A, (HL)
FBC7  D3 05        ..    OUT (r3data), A
FBC9  23           #     INC HL
FBCA  22 A8 FC     "..   LD ($FCA8), HL
FBCD  F1           .     POP AF
FBCE  E1           .     POP HL
FBCF  ED 45        .     RETN

FBD1  3A 12 3B     :.;   LD A, ($3B12)
FBD4  B7           .     OR A
FBD5  E5           .     PUSH HL
FBD6  F5           .     PUSH AF
FBD7  DB 05        ..    IN A, (r3data)
FBD9  2A A8 FC     *..   LD HL, ($FCA8)
FBDC  77           w     LD (HL), A
FBDD  23           #     INC HL
FBDE  22 A8 FC     "..   LD ($FCA8), HL
FBE1  F1           .     POP AF
FBE2  E1           .     POP HL
FBE3  ED 45        .     RETN

FBE5  01 3B EB     .;.   LD BC, $EB3B
FBE8  CD E5 F5     ...   CALL $F5E5
FBEB  2A A8 FC     *..   LD HL, ($FCA8)
FBEE  7E           ~     LD A, (HL)
FBEF  D3 05        ..    OUT ($05), A
FBF1  23           #     INC HL
FBF2  7E           ~     LD A, (HL)
FBF3  D3 05        ..    OUT ($05), A
FBF5  23           #     INC HL
FBF6  22 A8 FC     "..   LD ($FCA8), HL
FBF9  F1           .     POP AF
FBFA  E1           .     POP HL
FBFB  ED 45        .     RETN

FBFD  E5           .     PUSH HL
FBFE  F5           .     PUSH AF
FBFF  DB 05        ..    IN A, (r3data)
FC01  2A A8 FC     *..   LD HL, ($FCA8)
FC04  77           w     LD (HL), A
FC05  23           #     INC HL
FC06  DB 05        ..    IN A, (r3data)
FC08  77           w     LD (HL), A
FC09  23           #     INC HL
FC0A  22 A8 FC     "..   LD ($FCA8), HL
FC0D  F1           .     POP AF
FC0E  E1           .     POP HL
FC0F  ED 45        .     RETN

FC11  D3 05        ..    OUT ($05), A
FC13  ED 45        .     RETN

FC15  23           #     INC HL
FC16  56           V     LD D, (HL)
FC17  2B           +     DEC HL
FC18  C9           .     RET

FC19  2A A0 3C     *.<   LD HL, ($3CA0)
FC1C  19           .     ADD HL, DE
FC1D  23           #     INC HL
FC1E  23           #     INC HL
FC1F  5E           ^     LD E, (HL)
FC20  23           #     INC HL
FC21  56           V     LD D, (HL)
FC22  2B           +     DEC HL
FC23  C9           .     RET

FC24  2A D3 05     *..   LD HL, ($05D3)
FC27  ED 45        .     RETN

FC29  CA 0D 37     ..7   JP Z $370D
FC2C  EB           .     EX DE, HL
FC2D  D5           .     PUSH DE
FC2E  CD ED 36     ..6   CALL $36ED
FC31  EB           .     EX DE, HL
FC32  22 A4 3C     ".<   LD ($3CA4), HL
FC35  D1           .     POP DE
FC36  C3 39 37     .97   JP $3739
FC39  D3 05        ..    OUT ($05), A
FC3B  ED 45        .     RETN

FC3D  20 00         .    JR NZ $FC3F
.
FC3F  EB           .     EX DE, HL
FC40  19           .     ADD HL, DE
FC41  22 A2 3C     ".<   LD ($3CA2), HL
FC44  D5           .     PUSH DE
FC45  EB           .     EX DE, HL
FC46  2A AC 3C     *.<   LD HL, ($3CAC)
FC49  CD 82 0D     ...   CALL $0D82
FC4C  D1           .     POP DE
FC4D  D3 05        ..    OUT ($05), A
FC4F  ED 45        .     RETN
FC51  7B           {     LD A, E
FC52  3C           <     INC A
FC53  25           %     DEC H
FC54  3A 7D 3C     :}<   LD A, ($3C7D)
FC57  B7           .     OR A
FC58  CD 82 0D     ...   CALL $0D82
FC5B  DA 87 38     ..8   JP C $3887
FC5E  2A A0 3C     *.<   LD HL, ($3CA0)
.
FC61  D3 05        ..    OUT ($05), A
FC63  ED 45        .     RETN

FC65  D5           .     PUSH DE
FC66  CD E4 36     ..6   CALL $36E4
FC69  EB           .     EX DE, HL
FC6A  2A A8 3C     *.<   LD HL, ($3CA8)
FC6D  EB           .     EX DE, HL
FC6E  7B           {     LD A, E
FC6F  E6 E0        ..    AND $E0
FC71  5F           _     LD E, A
FC72  7B           {     LD A, E
FC73  B2           .     OR D
FC74  C2 00 05     ...   JP NZ $0500
FC77  00           .     NOP
FC78  05           .     DEC B
FC79  02           .     LD (BC), A
FC7A  05           .     DEC B
FC7B  08           .     EX AF, AF'
FC7C  0E 04        ..    LD C, $04
FC7E  01 01 05     ...   LD BC, $0501
FC81  00           .     NOP
FC82  10 10        ..    DJNZ $FC94
FC84  10 0D        ..    DJNZ $FC93
FC86  00           .     NOP
FC87  08           .     EX AF, AF'
FC88  80           .     ADD A, B
FC89  05           .     DEC B
FC8A  00           .     NOP
FC8B  05           .     DEC B
FC8C  00           .     NOP
FC8D  05           .     DEC B
FC8E  00           .     NOP
FC8F  00           .     NOP
FC90  00           .     NOP
FC91  05           .     DEC B
FC92  09           .     ADD HL, BC
.
FC93  05           .     DEC B
.
FC94  00           .     NOP
FC95  08           .     EX AF, AF'
FC96  10 10        ..    DJNZ $FCA8
FC98  01 0D 80     ...   LD BC, $800D
FC9B  08           .     EX AF, AF'
FC9C  80           .     ADD A, B

; -----------------------------------------------------------------------------
; OSWORD $00 parameter block
; -----------------------------------------------------------------------------
.
FC9D  B0 FC        ..    DW $FCB0                 ; Buffer address at $FCB0
FC9F  80           .     DB $80                   ; Maximum line length is 128 bytes
FCA0  20                 DB $20                   ; Minimum acceptable ASCII value
FCA1  FF           .     DB $FF                   ; Maximum acceptable ASCII value

FCA2  00           .     NOP
FCA3  00           .     NOP

.
FCA4  00           .     NOP
FCA5  D5           .     PUSH DE
FCA6  F5           .     PUSH AF
FCA7  2A A8 3C     *.<   LD HL, ($3CA8)
FCAA  00           .     NOP
FCAB  00           .     NOP
FCAC  E6 1F        ..    AND $1F
FCAE  00           .     NOP
FCAF  00           .     NOP
.
FCB0  36 2A        6*    LD (HL), $2A
FCB2  A0           .     AND B
FCB3  3C           <     INC A
FCB4  19           .     ADD HL, DE
FCB5  F1           .     POP AF
FCB6  F5           .     PUSH AF
FCB7  77           w     LD (HL), A
FCB8  7B           {     LD A, E
FCB9  E6 1F        ..    AND $1F
FCBB  FE 1F        ..    CP $1F
FCBD  CA 95 37     ..7   JP Z $3795
FCC0  13           .     INC DE
FCC1  CC 9F 37     ..7   CALL Z, $379F
FCC4  EB           .     EX DE, HL
FCC5  22 A8 3C     ".<   LD ($3CA8), HL
FCC8  F1           .     POP AF
FCC9  D1           .     POP DE
FCCA  C9           .     RET
FCCB  7B           {     LD A, E
FCCC  E6 E0        ..    AND $E0
FCCE  5F           _     LD E, A
FCCF  CD ED 36     ..6   CALL $36ED
FCD2  7A           z     LD A, D
FCD3  B3           .     OR E
FCD4  CA F8 36     ..6   JP Z $36F8
FCD7  13           .     INC DE
FCD8  13           .     INC DE
FCD9  13           .     INC DE
FCDA  13           .     INC DE
FCDB  C9           .     RET
FCDC  D5           .     PUSH DE
FCDD  EB           .     EX DE, HL
FCDE  2A A0 3C     *.<   LD HL, ($3CA0)
FCE1  EB           .     EX DE, HL
FCE2  7D           }     LD A, L
FCE3  E6 1F        ..    AND $1F
FCE5  C2 C0 37     ..7   JP NZ $37C0
FCE8  7D           }     LD A, L
FCE9  F6 04        ..    OR $04
.
FCEB  6F           o     LD L, A
FCEC  EB           .     EX DE, HL
FCED  19           .     ADD HL, DE
FCEE  7E           ~     LD A, (HL)
FCEF  EB           .     EX DE, HL
FCF0  D1           .     POP DE
FCF1  C9           .     RET
FCF2  CD B0 37     ..7   CALL $37B0
FCF5  F5           .     PUSH AF
FCF6  D5           .     PUSH DE
FCF7  EB           .     EX DE, HL
FCF8  7B           {     LD A, E
FCF9  E6 1F        ..    AND $1F
FCFB  FE 1F        ..    CP $1F
FCFD  CA D5 37     ..7   JP Z $37D5
FD00  13           .     INC DE
FD01  CC 9F 37     ..7   CALL Z, $379F
FD04  EB           .     EX DE, HL
FD05  D1           .     POP DE
FD06  F1           .     POP AF
FD07  C9           .     RET
FD08  EB           .     EX DE, HL
FD09  7B           {     LD A, E
FD0A  E6 E0        ..    AND $E0
FD0C  5F           _     LD E, A
FD0D  D5           .     PUSH DE
FD0E  CD ED 36     ..6   CALL $36ED
FD11  7B           {     LD A, E
FD12  B2           .     OR D
FD13  C1           .     POP BC
FD14  C8           .     RET Z
FD15  AF           .     XOR A
FD16  77           w     LD (HL), A
FD17  23           #     INC HL
.
FD18  77           w     LD (HL), A
FD19  2A A0 3C     *.<   LD HL, ($3CA0)
FD1C  19           .     ADD HL, DE
.
FD1D  73           s     LD (HL), E
FD1E  23           #     INC HL
FD1F  72           r     LD (HL), D
.
FD20  C5           .     PUSH BC
FD21  CD D2 36     ..6   CALL $36D2
FD24  C1           .     POP BC
FD25  2A A6 3C     *.<   LD HL, ($3CA6)
FD28  EB           .     EX DE, HL
FD29  CD E4 36     ..6   CALL $36E4
FD2C  71           q     LD (HL), C
.
FD2D  23           #     INC HL
FD2E  70           p     LD (HL), B
FD2F  C9           .     RET
.

; -----------------------------------------------------------------------------
; 
; -----------------------------------------------------------------------------
.
FD30  4C 05 25     L.%   DB $4C, $05, $25                   ; 2500  4C 05 25           L.%     JMP &2505
FD33  10 E3        ..    DB $10, $E3                        ; 2503  10 E3              ..      BPL &24E8
                                                            ; .
FD35  C9 FF        ..    DB $C9, $FF                        ; 2505  C9 FF              ..      CMP #&FF
FD37  F0 03        ..    DB $F0, $03                        ; 2507  F0 03              ..      BEQ &250C
FD39  6C 03 25     l.%   DB $6C, $03, $25                   ; 2509  6C 03 25           l.%     JMP (&2503)
                                                            ; .
FD3C  86 70        .p    DB $86, $70                        ; 250C  86 70              .p      STX &70
FD3E  84 71        .q    DB $84, $71                        ; 250E  84 71              .q      STY &71
FD40  85 72        .r    DB $85, $72                        ; 2510  85 72              .r      STA &72
FD42  A0 02        ..    DB $A0, $02                        ; 2512  A0 02              ..      LDY #&02
FD44  B1 70        .p    DB $B1, $70                        ; 2514  B1 70              .p      LDA (&70),Y
FD46  85 74        .t    DB $85, $74                        ; 2516  85 74              .t      STA &74
FD48  C8           .     DB $C8                             ; 2518  C8                 .       INY
FD49  B1 70        .p    DB $B1, $70                        ; 2519  B1 70              .p      LDA (&70),Y
FD4B  85 75        .u    DB $85, $75                        ; 251B  85 75              .u      STA &75
FD4D  20 9C 25      .%   DB $20, $9C, $25                   ; 251D  20 9C 25            .%     JSR &259C
FD50  A0 0C        ..    DB $A0, $0C                        ; 2520  A0 0C              ..      LDY #&0C
FD52  B1 70        .p    DB $B1, $70                        ; 2522  B1 70              .p      LDA (&70),Y
FD54  48           H     DB $48                             ; 2524  48                 H       PHA
FD55  A5 70        .p    DB $A5, $70                        ; 2525  A5 70              .p      LDA &70
FD57  18           .     DB $18                             ; 2527  18                 .       CLC
FD58  69 06        i.    DB $69, $06                        ; 2528  69 06              i.      ADC #&06
FD5A  AA           .     DB $AA                             ; 252A  AA                 .       TAX
FD5B  A9 00        ..    DB $A9, $00                        ; 252B  A9 00              ..      LDA #&00
FD5D  65 71        eq    DB $65, $71                        ; 252D  65 71              eq      ADC &71
FD5F  A8           .     DB $A8                             ; 252F  A8                 .       TAY
FD60  68           h     DB $68                             ; 2530  68                 h       PLA
FD61  48           H     DB $48                             ; 2531  48                 H       PHA
FD62  20 06 04      ..   DB $20, $06, $04                   ; 2532  20 06 04            ..     JSR &0406
FD65  A0 0A        ..    DB $A0, $0A                        ; 2535  A0 0A              ..      LDY #&0A
FD67  B1 70        .p    DB $B1, $70                        ; 2537  B1 70              .p      LDA (&70),Y
FD69  AA           .     DB $AA                             ; 2539  AA                 .       TAX
FD6A  C8           .     DB $C8                             ; 253A  C8                 .       INY
FD6B  B1 70        .p    DB $B1, $70                        ; 253B  B1 70              .p      LDA (&70),Y  
FD6D  85 76        .v    DB $85, $76                        ; 253D  85 76              .v      STA &76
FD6F  D0 03        ..    DB $D0, $03                        ; 253F  D0 03              ..      BNE &2544
FD71  8A           .     DB $8A                             ; 2541  8A                 .       TXA
FD72  F0 4E        .N    DB $F0, $4E                        ; 2542  F0 4E              .N      BEQ &2592
                                                            ; .
FD74  8A           .     DB $8A                             ; 2544  8A                 .       TXA
FD75  F0 02        ..    DB $F0, $02                        ; 2545  F0 02              ..      BEQ &2549
FD77  E6 76        .v    DB $E6, $76                        ; 2547  E6 76              .v      INC &76
                                                            ; .
FD79  68           h     DB $68                             ; 2549  68                 h       PLA
FD7A  6A           j     DB $6A                             ; 254A  6A                 j       ROR A
FD7B  B0 28        .(    DB $B0, $28                        ; 254B  B0 28              .(      BCS &2575
FD7D  20 9B 25      .%   DB $20, $9B, $25                   ; 254D  20 9B 25            .%     JSR &259B
FD80  20 9B 25      .%   DB $20, $9B, $25                   ; 2550  20 9B 25            .%     JSR &259B
FD83  20 9B 25      .%   DB $20, $9B, $25                   ; 2553  20 9B 25            .%     JSR &259B
FD86  A0 00        ..    DB $A0, $00                        ; 2556  A0 00              ..      LDY #&00
                                                            ; .
FD88  AD E5 FE     ...   DB $AD, $E5, $FE                   ; 2558  AD E5 FE           ...     LDA &FEE5
FD8B  91 74        .t    DB $91, $&74                       ; 255B  91 74              .t      STA (&74),Y
FD8D  20 9B 25      .%   DB $20, $9B, $25                   ; 255D  20 9B 25            .%     JSR &259B
FD90  20 9B 25      .%   DB $20, $9B, $25                   ; 2560  20 9B 25            .%     JSR &259B
FD93  20 9B 25      .%   DB $20, $9B, $25                   ; 2563  20 9B 25            .%     JSR &259B
FD96  E6 74        .t    DB $E6, $74                        ; 2566  E6 74              .t      INC &74
FD98  D0 02        ..    DB $D0, $02                        ; 2568  D0 02              ..      BNE &256C
FD9A  E6 75        .u    DB $E6, $75                        ; 256A  E6 75              .u      INC &75
                                                            ; .
FD9C  CA           .     DB $CA                             ; 256C  CA                 .       DEX
FD9D  D0 E9        ..    DB $D0, $E9                        ; 256D  D0 E9              ..      BNE &2558
FD9F  C6 76        .v    DB $C6, $76                        ; 256F  C6 76              .v      DEC &76    
FDA1  D0 E5        ..    DB $D0, $E5                        ; 2571  D0 E5              ..      BNE &2558
FDA3  F0 1D        ..    DB $F0, $1D                        ; 2573  F0 1D              ..      BEQ &2592
                                                            ; .
FDA5  A0 00        ..    DB $A0, $00                        ; 2575  A0 00              ..      LDY #&00
                                                            ; .
FDA7  B1 74        .t    DB $B1, $74                        ; 2577  B1 74              .t      LDA (&74),Y
FDA9  8D E5 FE     ...   DB $8D, $E5, $FE                   ; 2579  8D E5 FE           ...     STA &FEE5
FDAC  20 9B 25      .%   DB $20, $9B, $25                   ; 257C  20 9B 25            .%     JSR &259B
FDAF  20 9B 25      .%   DB $20, $9B, $25                   ; 257F  20 9B 25            .%     JSR &259B
FDB2  20 9B 25      .%   DB $20, $9B, $25                   ; 2582  20 9B 25            .%     JSR &259B
FDB5  E6 74        .t    DB $E6, $74                        ; 2585  E6 74              .t      INC &74
FDB7  D0 02        ..    DB $D0, $02                        ; 2587  D0 02              ..      BNE &258B
FDB9  E6 75        .u    DB $E6, $75                        ; 2589  E6 75              .u      INC &75
                                                            ; .
FDBB  CA           .     DB $CA                             ; 258B  CA                 .       DEX
FDBC  D0 E9        ..    DB $D0, $E9                        ; 258C  D0 E9              ..      BNE &2577
FDBE  C6 76        .v    DB $C6, $76                        ; 258E  C6 76              .v      DEC &76
FDC0  D0 E5        ..    DB $D0, $E5                        ; 2590  D0 E5              ..      BNE &2577
                                                            ; .
FDC2  20 A4 25      .%   DB $20, $A4, $25                   ; 2592  20 A4 25            .%     JSR &25A4
FDC5  A6 70        .p    DB $A6, $70                        ; 2595  A6 70              .p      LDX &70
FDC7  A4 71        .q    DB $A4, $71                        ; 2597  A4 71              .q      LDY &71
FDC9  A5 72        .r    DB $A5, $72                        ; 2599  A5 72              .r      LDA &72
                                                            ; .
FDCB  60           `     DB $60                             ; 259B  60                 `       RTS
                                                            ; .
FDCC  A9 C7        ..    DB $A9, $C7                        ; 259C  A9 C7              ..      LDA #&C7
FDCE  20 06 04      ..   DB $20, $06, $04                   ; 259E  20 06 04            ..     JSR &0406
FDD1  90 F9        ..    DB $90, $F9                        ; 25A1  90 F9              ..      BCC &259C
FDD3  60           `     DB $60                             ; 25A3  60                 `       RTS
                                                            ; .
FDD4  A9 87        ..    DB $A9, $87                        ; 25A4  A9 87              ..      LDA #&87
FDD6  20 06 04      ..   DB $20, $06, $04                   ; 25A6  20 06 04            ..     JSR &0406
FDD9  60           `     DB $60                             ; 25A9  60                 `       RTS

FDDA  00           .     DB $00                             ; 25AA  00                 .       EQUB &00
FDDB  25           %     DB $25                             ; 25AB  25                 %       EQUB &25
FDDC  36           6     DB $36                             ; 25AC  36                 6       EQUB &36
FDDD  42           B     DB $42                             ; 25AD  42                 B       EQUB &42

; -----------------------------------------------------------------------------
; NVRDCH
; -----------------------------------------------------------------------------
.
FDDE  FE 02        ..    CP $02
FDE0  30 22        0"    JR NC $FE04
FDE2  F5           .     PUSH AF
FDE3  3A 81 FF     :..   LD A, (term_flag)
FDE6  E6 01        ..    AND $01
FDE8  32 AA FC     2..   LD ($FCAA), A
FDEB  F1           .     POP AF
FDEC  32 81 FF     2..   LD (term_flag), A
FDEF  B7           .     OR A
FDF0  20 08         .    JR NZ $FDFA
FDF2  21 71 F6     !q.   LD HL, $F671             ; Pointer to OSWRCH routine
FDF5  22 9F FF     "..   LD ($FF9F), HL
FDF8  18 06        ..    JR $FE00
.
FDFA  21 0D FE     !..   LD HL, $FE0D
FDFD  22 9F FF     "..   LD ($FF9F), HL
.
FE00  3A AA FC     :..   LD A, ($FCAA)
FE03  C9           .     RET
.
FE04  FE FF        ..    CP $FF
FE06  C0           .     RET NZ
FE07  3A 81 FF     :..   LD A, (term_flag)
FE0A  E6 01        ..    AND $01
FE0C  C9           .     RET
FE0D  4F           O     LD C, A
.
FE0E  3A 81 FF     :..   LD A, (term_flag)
FE11  CB 7F        .     BIT 7, A
FE13  20 12         .    JR NZ $FE27
FE15  79           y     LD A, C
FE16  FE 1B        ..    CP $1B
FE18  28 04        (.    JR Z, $FE1E
FE1A  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
FE1D  C9           .     RET
.
FE1E  3A 81 FF     :..   LD A, (term_flag)
FE21  CB FF        .     SET 7, A
FE23  32 81 FF     2..   LD (term_flag), A
FE26  C9           .     RET
.
FE27  CB 77        .     BIT 6, A
FE29  C2 A6 FE     ...   JP NZ $FEA6
FE2C  CB 6F        .     BIT 5, A
FE2E  C2 D9 FE     ...   JP NZ $FED9
FE31  79           y     LD A, C
FE32  FE 3D        .=    CP $3D
FE34  28 15        (.    JR Z, $FE4B
FE36  FE 3E        .>    CP $3E
FE38  28 1A        (.    JR Z, $FE54
FE3A  FE 3F        .?    CP $3F
FE3C  28 1F        (.    JR Z, $FE5D
FE3E  FE 40        .@    CP $40
FE40  28 3E        (>    JR Z, $FE80
.
FE42  3A 81 FF     :..   LD A, (term_flag)
FE45  CB BF        .     RES 7, A
FE47  32 81 FF     2..   LD (term_flag), A
FE4A  C9           .     RET
.
FE4B  3A 81 FF     :..   LD A, (term_flag)
FE4E  CB F7        .     SET 6, A
FE50  32 81 FF     2..   LD (term_flag), A
FE53  C9           .     RET
.
FE54  3A 81 FF     :..   LD A, (term_flag)
FE57  CB EF        .     SET 5, A
FE59  32 81 FF     2..   LD (term_flag), A
FE5C  C9           .     RET
.
FE5D  CD EC FE     ...   CALL $FEEC
FE60  28 08        (.    JR Z, $FE6A
FE62  FE 00        ..    CP $00
FE64  20 DC         .    JR NZ $FE42
FE66  3E 1F        >.    LD A, $1F
FE68  18 02        ..    JR $FE6C
.
FE6A  3E 18        >.    LD A, $18
.
FE6C  32 18 FF     2..   LD ($FF18), A
FE6F  CD F5 FE     ...   CALL $FEF5
FE72  06 10        ..    LD B, $10
FE74  21 10 FF     !..   LD HL, $FF10
.
FE77  7E           ~     LD A, (HL)
FE78  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
FE7B  23           #     INC HL
FE7C  10 F9        ..    DJNZ $FE77
FE7E  18 C2        ..    JR $FE42
.
FE80  CD EC FE     ...   CALL $FEEC
FE83  28 04        (.    JR Z, $FE89
FE85  FE 00        ..    CP $00
FE87  20 B9         .    JR NZ $FE42
.
FE89  CD F5 FE     ...   CALL $FEF5
FE8C  06 06        ..    LD B, $06
FE8E  21 10 FF     !..   LD HL, $FF10
.
FE91  7E           ~     LD A, (HL)
FE92  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
FE95  23           #     INC HL
FE96  10 F9        ..    DJNZ $FE91
FE98  06 05        ..    LD B, $05
FE9A  21 1B FF     !..   LD HL, $FF1B
.
FE9D  7E           ~     LD A, (HL)
FE9E  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
FEA1  23           #     INC HL
FEA2  10 F9        ..    DJNZ $FE9D
FEA4  18 9C        ..    JR $FE42
.
FEA6  CB 67        .     BIT 4, A
FEA8  20 0F         .    JR NZ $FEB9
FEAA  79           y     LD A, C
FEAB  D6 20        .     SUB $20
FEAD  32 21 FF     2!.   LD ($FF21), A
FEB0  3A 81 FF     :..   LD A, (term_flag)
FEB3  CB E7        .     SET 4, A
FEB5  32 81 FF     2..   LD (term_flag), A
FEB8  C9           .     RET
.
FEB9  79           y     LD A, C
FEBA  D6 20        .     SUB $20
FEBC  32 20 FF     2 .   LD ($FF20), A
FEBF  3E 1F        >.    LD A, $1F
FEC1  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
FEC4  3A 20 FF     : .   LD A, ($FF20)
FEC7  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
FECA  3A 21 FF     :!.   LD A, ($FF21)
FECD  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
FED0  3A 81 FF     :..   LD A, (term_flag)
FED3  E6 01        ..    AND $01
FED5  32 81 FF     2..   LD (term_flag), A
FED8  C9           .     RET
.
FED9  79           y     LD A, C
FEDA  B7           .     OR A
FEDB  28 06        (.    JR Z, $FEE3
FEDD  D6 20        .     SUB $20
FEDF  CD 71 F6     .q.   CALL $F671               ; Call OSWRCH
FEE2  C9           .     RET
.
FEE3  3A 81 FF     :..   LD A, (term_flag)
FEE6  E6 01        ..    AND $01
FEE8  32 81 FF     2..   LD (term_flag), A
FEEB  C9           .     RET
FEEC  3E 87        >.    LD A, $87
FEEE  CD 8E F8     ...   CALL $F88E               ; Call OSBYTE
FEF1  7C           |     LD A, H
FEF2  FE 03        ..    CP $03
FEF4  C9           .     RET
FEF5  3E 86        >.    LD A, $86
FEF7  CD 8E F8     ...   CALL $F88E               ; Call OSBYTE
FEFA  7D           }     LD A, L
FEFB  32 11 FF     2..   LD ($FF11), A
FEFE  32 1E FF     2..   LD ($FF1E), A
FF01  7C           |     LD A, H
FF02  32 12 FF     2..   LD ($FF12), A
FF05  32 14 FF     2..   LD ($FF14), A
FF08  32 1F FF     2..   LD ($FF1F), A
FF0B  3C           <     INC A
FF0C  32 1A FF     2..   LD ($FF1A), A
FF0F  C9           .     RET
FF10  1C           .     INC E
FF11  C4 48 4F     .HO   CALL NZ, $4F48
FF14  C1           .     POP BC
FF15  0C           .     INC C
FF16  1C           .     INC E
FF17  00           .     NOP
FF18  1F           .     RRA
FF19  4F           O     LD C, A
FF1A  48           H     LD C, B
FF1B  0C           .     INC C
FF1C  1A           .     LD A, (DE)
FF1D  1F           .     RRA
FF1E  22 28 00     "(.   LD ($0028), HL
FF21  00           .     NOP
FF22  6B           k     LD L, E
FF23  17           .     RLA
FF24  2A 28 3B     *(;   LD HL, ($3B28)
FF27  36 00        6.    LD (HL), $00
FF29  21 2A 3B     !*;   LD HL, $3B2A
FF2C  C3 77 19     .w.   JP $1977
FF2F  C5           .     PUSH BC
FF30  E5           .     PUSH HL
FF31  7E           ~     LD A, (HL)
FF32  E6 03        ..    AND $03
FF34  47           G     LD B, A
FF35  0E 06        ..    LD C, $06
FF37  23           #     INC HL
FF38  5E           ^     LD E, (HL)
FF39  23           #     INC HL
FF3A  56           V     LD D, (HL)
FF3B  CD 48 1A     .H.   CALL $1A48
FF3E  E1           .     POP HL
FF3F  C1           .     POP BC
FF40  C9           .     RET
FF41  53           S     LD D, E
FF42  00           .     NOP
FF43  00           .     NOP
FF44  00           .     NOP
FF45  00           .     NOP
FF46  00           .     NOP
FF47  02           .     LD (BC), A
FF48  00           .     NOP
FF49  00           .     NOP
FF4A  00           .     NOP
FF4B  00           .     NOP
FF4C  0A           .     LD A, (BC)
FF4D  00           .     NOP
FF4E  00           .     NOP
FF4F  00           .     NOP
FF50  00           .     NOP
FF51  00           .     NOP
FF52  00           .     NOP
FF53  00           .     NOP
FF54  00           .     NOP
FF55  00           .     NOP
FF56  00           .     NOP
FF57  00           .     NOP
FF58  00           .     NOP
FF59  00           .     NOP
FF5A  00           .     NOP
FF5B  00           .     NOP
FF5C  00           .     NOP
FF5D  00           .     NOP
FF5E  00           .     NOP
FF5F  00           .     NOP
FF60  00           .     NOP
FF61  00           .     NOP
FF62  00           .     NOP
FF63  00           .     NOP
FF64  00           .     NOP
FF65  00           .     NOP
FF66  00           .     NOP
FF67  00           .     NOP
FF68  00           .     NOP
FF69  00           .     NOP
FF6A  00           .     NOP
FF6B  00           .     NOP
FF6C  00           .     NOP
FF6D  00           .     NOP
FF6E  00           .     NOP
FF6F  00           .     NOP
FF70  00           .     NOP
FF71  00           .     NOP
FF72  00           .     NOP
FF73  00           .     NOP
FF74  00           .     NOP
FF75  00           .     NOP
FF76  00           .     NOP
FF77  00           .     NOP
FF78  00           .     NOP
FF79  00           .     NOP
FF7A  00           .     NOP
FF7B  00           .     NOP
FF7C  00           .     NOP
FF7D  00           .     NOP
FF7E  00           .     NOP
FF7F  00           .     NOP

; -----------------------------------------------------------------------------
; Stack
; -----------------------------------------------------------------------------

.escape_flag
FF80  00           .     NOP				; ESCAPE flag

.term_flag
FF81  00           .     NOP				; TERM flag

.faultptr
FF82  00 01        ..    DW $0100			; Fault pointer

.defaulterrorptr
FF84  B2 FA        ..    DW $FAB2			; Default error handler

FF86  02           .     LD (BC), A
FF87  14           .     INC D
FF88  95           .     SUB L
FF89  00           .     NOP
FF8A  01 00 00     ...   LD BC, $0000
FF8D  3C           <     INC A
FF8E  1A           .     LD A, (DE)
FF8F  FF           .     RST 38H
FF90  FF           .     RST 38H
FF91  01 00 00     ...   LD BC, $0000
FF94  00           .     NOP
FF95  00           .     NOP
FF96  00           .     NOP
FF97  00           .     NOP
FF98  00           .     NOP
FF99  00           .     NOP
FF9A  74           t     LD (HL), H
FF9B  4C           L     LD C, H
FF9C  D6 5E        .^    SUB $5E

FF9E  C3 71 F6     .q.   JP $F671			; Print a character to OSWRCH or TERMOUT
FFA1  C3 AE F5     ...   JP $F5AE			; Initialise OSWORD $FF code in the host processor
FFA4  C3 5C F5     .\.   JP $F55C			; Repeated OSWORD $7F call
FFA7  C3 3B F5     .;.   JP $F53B			; Load CCP and BDOS
FFAA  C3 76 F4     .v.   JP $F476			; Print A in hex
FFAD  C3 71 F4     .q.   JP $F471			; Print HL in hex
FFB0  C3 FD FA     ...   JP $FAFD			; User interrupt routine
FFB3  C3 0E F6     ...   JP $F60E			; OSWRSC Print message to output stream
FFB6  C3 0E FE     ...   JP $FE0E			; OSWRCC Send C to TERMOUT
FFB9  C3 CE F2     ...   JP $F2CE			; OSRDRM
FFBC  C3 A4 FA     ...   JP $FAA4			; RST_38 Default error handler
FFBF  C3 5E F6     .^.   JP $F65E			; OSEVEN
FFC2  C3 1B F6     ...   JP $F61B			; GSINIT
FFC5  C3 3F F6     .?.   JP $F63F			; GSREAD
FFC8  C3 DE FD     ...   JP $FDDE			; NVRDCH / TERM
FFCB  C3 E8 F8     ...   JP $F8E8			; NVWRCH
FFCE  C3 D2 F9     ...   JP $F9D2			; OSFIND
FFD1  C3 4E FA     .N.   JP $FA4E			; OSGBPB
FFD4  C3 FC F9     ...   JP $F9FC			; OSBPUT
FFD7  C3 F0 F9     ...   JP $F9F0			; OSBGET
FFDA  C3 9F F9     ...   JP $F99F			; OSARGS
FFDD  C3 10 FA     ...   JP $FA10			; OSFILE
FFE0  C3 90 F6     ...   JP $F690			; OSRDCH
FFE3  FE 0D        ..    CP $0D				; OSASCI
FFE5  20 07         .    JR NZ os
FFE7  3E 0A        >.    LD A, $0A			; OSNEWL
FFE9  CD EE FF     ...   CALL oswrch
FFEC  3E 0D        >.    LD A, $0D
FFEE  C3 71 F6     .q.   JP $F671			; OSWRCH
FFF1  C3 EF F8     ...   JP $F8EF			; OSWORD
FFF4  C3 8E F8     ...   JP $F88E			; OSBYTE
FFF7  C3 B7 F6     ...   JP $F6B7			; OSCLI
FFFA  AC FA        ..    DW $FAAC			; BRKV
FFFC  70 F6        p.    DW $F670			; EVENTV
FFFE  82 FA        ..    DW $FA82			; IRQV
