1 REM Ins{nd av Kurt Malm <3065>    1988-02-19 20.17.25 (DUMP)
       TITLE DBUGROM 2-88
HELP   EQU   25600
       ORG   65256
INIT   LD    BC,1022
       LD    HL,30720 Bildarea
       LD    DE,30721
       LD    A,32
       LD    (HL),A
       LDIR
       XOR   A
       LD    (HL),A   CURXY bild II
       INC   L
       LD    (HL),A
       RET
       ORG   23040
LAY    EQU   $+2304+125 JR alltid i page
JPTAB  DW    ADMP   A Hex,Hex Asciidump
       DW    BILD   B Bildbyte
       DW    CSUM   C Hex,Hex Checksum
       DW    DMPHEX D Hex,Hex Hexdump
       DW    EXBUF  E S Save R Restore
       DW    FILL   F Hex,Hex,Hexbyte
       DW    GO     Se Rut
       DW    H_DEC  H Hex Hex till Deci
       DW    INPO   I Hexbyte Inport
       DW    JUST   J From,To,CP area
       DW    KH_H   K Hex,Hex +-
       DW    LOAD   L Filnamn.ext ITH
       DW    MOVE   M From,To,Dest.adr
       DW    N_HEX  N Decimal  Hex o Bin
       DW    OUTP   O Port,Value Utport
       DW    PEPO   P Adr R - ' ' Hex
       DW    QUIT   Q Quit Hex LD HL
       DW    REG    Se Rut
       DW    SAVE  S From,To(RET)Fil.ITH
       DW    TYPE  T From(RET)typememRET
       DW    USER   U CALL HELP Hex Eget
       DW    VAS\K  V From,To(RET)String
       DW    WHS\K  W  -"-   Hexb,Hexb,,
       DW    ERR8
       DW    ERR8   Framtida exp.
       DW    ERR8
       DW    TBENT  TB int
       DW    BRYT   PIO int
REGTXT DB    10,13,' BC   DE   HL  A  '
       DM    'SZ-H-VNC I  R',10,13,4
DEV    JP    KALL  Kallstart
       JP    FEL   Onerrorgoto adr.
       JP    BRYT  Brytpunkt (CALL HIT)
       JP    VARMB Basic (Q-kom)
       JP    VARMA Retaddr vid (U-kom)
       JP    WRCH
       JP    INCH
       JP    CRLF
       JP    THRU
       JP    HKONV
WHERE  CALL  $+3   Relokerbar Rut
       POP   BC
       RET
SYSREG DB    10,13,' IX   IY   PC   SP'
       DB    10,13,4
INDEX  DM    'IY',3,'IX',5
IRREG  DM    'IR',207,206,'AF',209,208
       DM    'HL',147,146,'DE',149,148
       DM    'BC',151,150
SPPC   DM    'SP',25,'PC',28
REGS   DM    'AF',199,198,'HL',137,136
       DM    'DE',139,138,'BC',141,140
VOMMEN DB    10,13,'DBUG RAM Ver 1.1',4
TERROR DM    ' ERROR ',7,4
IN3HXW INC   C
       CALL  IN2HXW
       CALL  CRLF
       POP   BC
       POP   DE
       POP   HL
       RET
IN1HXW LD    C,1
IN2HXW LD    HL,0
       CALL  GETEKA
       LD    B,A
       CALL  HEX?
       JR    C,$+10
       ADD   HL,HL
       ADD   HL,HL
       ADD   HL,HL
       ADD   HL,HL
       OR    L
       LD    L,A
       JR    $-15
       EX    (SP),HL
       PUSH  HL
       LD    A,B
       CALL  DELIM+3
       JR    NC,$+4
       DEC   C
       RET   Z
       JP    NZ,ERGO
       DEC   C
       JR    NZ,IN2HXW
       RET
HX2?W  LD    C,1
       LD    HL,0
       JR    $-36
POLL   IN    A,(56)
       CP    155     Ctrl-[
       JP    Z,VARMA
       CP    160     Space Listbroms
       RET   NZ
       IN    A,(56)
       BIT   7,A
       JR    NZ,$-4
       IN    A,(56)
       CP    155
       JP    Z,VARMA
       CP    32
       JR    Z,$-9
       IN    A,(56)
       BIT   7,A
       JR    NZ,$-4
       RET
POLLA  CALL  THRU
       JR    NC,POLL
       POP   DE
       RET
THRU   INC   HL
       LD    A,H
       OR    L
       SCF
       RET   Z
       LD    A,E
       SUB   L
       LD    A,D
       SBC   A,H
       RET
H_DEC  CALL  IN1HXW
       CALL  SPACE
       POP   HL
       PUSH  HL
       CALL  HKONV
       CALL  ADJWR
       CALL  WTOHX
       POP   HL
       JP    WBIN
KH_H   CALL  INHHCR
       PUSH  HL
       ADD   HL,DE
       CALL  WTOHX
       POP   HL
       AND   A
       SBC   HL,DE
WBIASC LD    A,H
       CALL  BIASC
       LD    A,L
BIASC  PUSH  AF
       RRCA
       RRCA
       RRCA
       RRCA
       CALL  ADJWR
       POP   AF
ADJWR  CALL  DADJ
       JP    WRCH
DADJ   AND   15
       ADD   A,144
       DAA
       ADC   A,64
       DAA
       LD    C,A
       RET
HX?IN  LD    A,(HL)
       INC   HL
HEX?   SUB   48
       RET   C
       CP    23
       CCF
       RET   C
       CP    10
       CCF
       RET   NC
       SUB   7
       CP    10
       RET
N_HEX  CALL  DECIN
       JR    C,ERGO
       CALL  SPACE
       CALL  WTOHX
       JP    WBIN
TOGET  LD    C,45
       CALL  WRCH
DELIM  CALL  GETEKA
       CP    45
       RET   Z
       CP    44
       RET   Z
       CP    13
       SCF
       RET   Z
       CCF
       RET
WTO4   PUSH  BC
       LD    A,(HL)
       CP    4
       JR    Z,$+9
       LD    C,A
       CALL  WRCH
       INC   HL
       JR    $-10
       POP   BC
       RET
ADRBYT CALL  CRLF
       CALL  WTOHX
       LD    A,(HL)
       JR    BIASC
       CALL  DELIM
       RET   C
ERGO   CALL  MIXERR
VARMA  LD    SP,(RTSP)
       JP    TECKEN
VALUE  CALL  HEX?
       RET   C
       ADD   A,A
       ADD   A,A
       ADD   A,A
       ADD   A,A
       LD    C,A
       CALL  GETEKA
       CALL  HEX?
       RET   C
       OR    C
       RET
GETEKA CALL  INCH
       CP    13
       RET   Z
       PUSH  BC
       LD    C,A
       CALL  WRCH
       POP   BC
       CP    64
       RET   C
       CP    126
       RET   NC
       AND   95
       RET
WTOFIL LD    A,H
       CALL  BTOFIL
       LD    A,L
BTOFIL LD    E,A
       ADD   A,D
       LD    D,A
       LD    A,E
       RRCA
       RRCA
       RRCA
       RRCA
       CALL  DADJ
       CALL  FILWR
       LD    A,E
       CALL  DADJ
FILWR  PUSH  HL
       PUSH  DE
       PUSH  BC
       LD    BC,1
       LD    H,B
       LD    L,B
       ADD   HL,SP
       CALL  27
       POP   BC
       POP   DE
       POP   HL
       RET
INCH   PUSH  DE
       PUSH  IX
       CALL  2
       POP   IX
       POP   DE
       RET
INHHCR CALL  IN2HXW
       POP   DE
       POP   HL
CRLF   LD    C,10
       CALL  WRCH
       LD    C,13
       JR    WRCH
       CALL  CRLF
WTOHX  CALL  WBIASC
SPACE  LD    C,32
WRCH   PUSH  HL
       PUSH  DE
       PUSH  BC
       LD    BC,1
       LD    H,B
       LD    L,B
       ADD   HL,SP
       CALL  11
       POP   BC
       POP   DE
       POP   HL
       LD    A,C
       RET
KALL   XOR   A
       LD    (MASK),A
       LD    C,12
       CALL  WRCH
       LD    HL,VOMMEN
       CALL  WTO4
VARMB  LD    A,54
       OUT   (59),A
       LD    A,52
       OUT   (57),A
       LD    HL,0
       LD    (IYSAV),IY
       LD    (PCGO),HL
       PUSH  IX
       LD    (SPSAV),SP
       LD    (SPGO),SP
       LD    B,11
       PUSH  HL
       DJNZ  $-1
       ADD   HL,SP
       LD    (RTSP),HL
       LD    DE,13
       ADD   HL,DE
       CALL  WHERE
       LD    (HL),B    I-reg
TECKEN LD    DE,TECKEN
       PUSH  DE
       CALL  CRLF
       CALL  659
       LD    BC,62     > Promt
       XOR   A
       LD    I,A
       CALL  WRCH
       CALL  GETEKA
       CP    26        Ctrl-Z Step
       JR    Z,STEP
       SUB   65
       RET   M
       CP    23        Ant kommandon
       RET   NC
       ADD   A,A
       LD    B,0
       LD    C,A
       LD    HL,JPTAB
       ADD   HL,BC
       LD    E,(HL)
       INC   HL
       LD    D,(HL)
       EX    DE,HL
       CALL  SPACE
       LD    C,2
       JP    (HL)
GO     CALL  DELIM
       JR    C,GOSTEP G Free run
       JR    Z,STEP   G- Step
       CALL  HX2?W
       POP   HL
       LD    A,B
       CP    13
       JR    Z,GOSTEP-3 G Free run LD PC
       LD    (BREAK),HL G Hex- Breakadr
STEP   DI               Single-step
       LD    HL,(PCGO)
       DEC   HL
       LD    A,(HL)
       LD    D,A
       LD    (OLDBYT),A
       LD    A,251
       LD    (ROMSAV+1),A
       LD    (HL),A
       LD    A,(HL)
       CP    251
       JR    NZ,ROM
       CP    D
       JR    NZ,RAM
ROM    LD    DE,LAY
       PUSH  DE
       LD    A,251
       LD    (DE),A
       INC   DE
       INC   HL
       LD    A,(HL)
       CP    251
       JR    Z,$+6
       CP    243
       JR    NZ,$+3
       INC   HL
       LD    (ROMSAV),HL
       LD    BC,4
       LDIR
       POP   HL
RAM    LD    (OLDPC),HL
       LD    A,151
       OUT   (59),A
       OUT   (58),A
       CPL
       OUT   (59),A
       OUT   (58),A
       LD    (MASK),A
       LD    (PCGO),HL
GOSTEP LD    A,195
       LD    (JPKOD),A
       CALL  659
       POP   BC
       POP   IY
       POP   IX
       POP   AF
       POP   HL
       POP   DE
       POP   BC
       EX    AF,AF'
       EXX
       POP   AF
       LD    I,A
       POP   AF
       POP   HL
       POP   DE
       POP   BC
       LD    SP,(SPGO)
       JP    JPKOD
ERR8   LD    B,8
       JP    WERR
TBENT  PUSH  AF
       IN    A,(56)
       CP    128      Ctrl-@ TB Break
       JP    NZ,799
       POP   AF
BRYT   EX    (SP),HL
       LD    (PCGO),HL
       PUSH  AF
       PUSH  DE
       LD    A,H
       CP    LAY/256
       JR    Z,ROMJR
       LD    A,(ROMSAV+1)
       CP    251
       JR    Z,EJCALL
       LD    HL,0
       ADD   HL,SP
       LD    DE,7
       ADD   HL,DE
       LD    DE,(SPGO)
       SBC   HL,DE
       JR    NC,EJCALL
       LD    A,(LAY+1) Stack med retadr
       CP    196
       JR    C,EJCALL
       LD    HL,(ROMSAV)
       JR    Z,ROMCAL
       CP    199
       JR    Z,ROMCAL+2
       CP    204
       JR    Z,ROMCAL
       CP    205
       JR    Z,ROMCAL
       CP    207
       JR    Z,ROMCAL+2
       CP    212
       JR    Z,ROMCAL
       CP    215
       JR    Z,ROMCAL+2
       CP    220
       JR    Z,ROMCAL
       CP    223
       JR    Z,ROMCAL+2
       CP    228
       JR    Z,ROMCAL
       CP    231
       JR    Z,ROMCAL+2
       CP    236
       JR    Z,ROMCAL
       CP    239
       JR    Z,ROMCAL+2
       CP    244
       JR    Z,ROMCAL
       CP    247
       JR    Z,ROMCAL+2
       CP    255
       JR    Z,ROMCAL+2
       CP    252
       JR    NZ,EJCALL
ROMCAL INC   HL         CALL
       INC   HL
       INC   HL         RST
       EX    DE,HL
       DEC   HL
       LD    (HL),D     RETadr i rom
       DEC   HL         ej i LAY
       LD    (HL),E
       JR    EJCALL
ROMJR  LD    DE,LAY+1
       SBC   HL,DE
       EX    DE,HL
       LD    HL,(ROMSAV)
       LD    A,H
       CP    251
       JR    Z,EJCALL
       ADD   HL,DE
       LD    (PCGO),HL Instr JR ej i LAY
EJCALL POP   DE
       POP   AF
       LD    HL,$+6
       EX    (SP),HL
       RETI
       LD    (SPGO),SP
       PUSH  BC
       PUSH  DE
       PUSH  HL
       PUSH  AF
       LD    A,I
       LD    B,A
       LD    A,R
       LD    C,A
       PUSH  BC
       LD    A,52
       OUT   (57),A
       EX    AF,AF'
       EXX
       PUSH  BC
       PUSH  DE
       PUSH  HL
       PUSH  AF
       PUSH  IX
       PUSH  IY
       LD    (RTSP),SP
       CALL  659
       EX    DE,HL
       RES   7,(HL)
       LD    HL,TECKEN
       PUSH  HL
       LD    A,(MASK)
       AND   A
       JR    Z,SE4KOD
       LD    HL,(OLDPC)
       LD    A,(OLDBYT)
       LD    (HL),A
       XOR   A
       LD    (MASK),A
       LD    A,251
       LD    (ROMSAV+1),A
       LD    HL,(BREAK)
       LD    A,H
       OR    L
       JR    Z,SE4KOD   Ej Break
       LD    DE,(PCGO)
       SBC   HL,DE
       JP    NZ,STEP    Ej Framme
       XOR   A
       LD    (BREAK),A
       LD    (BREAK+1),A
       LD    A,3
       OUT   (59),A
       JP    TECKEN+7
SE4KOD LD    HL,(PCGO)  Skriv regs
       CALL  WTOHX
       LD    B,4
       LD    A,(HL)
       INC   HL
       CALL  BIASC
       CALL  SPACE
       DJNZ  $-8
SEREG  XOR   A
       EX    AF,AF'
       LD    HL,REGTXT
       CALL  WTO4
       LD    HL,23
       ADD   HL,SP
SEEXX  LD    B,3
       CALL  STKWR
       LD    A,(HL)
       DEC   HL
       CALL  BIASC
       LD    E,(HL)
       DEC   HL
       CALL  BBIN
       AND   A
       EX    AF,AF'
       JR    NZ,$+23
       CALL  SPACE
       LD    A,(HL)
       DEC   HL
       CALL  BIASC
       CALL  SPACE
       LD    A,(HL)
       DEC   HL
       CALL  BIASC
       CALL  CRLF
       JR    SEEXX
       PUSH  HL
       LD    HL,SYSREG
       CALL  WTO4
       POP   HL
       LD    B,2
       CALL  STKWR
       LD    HL,PCGO+1
       LD    B,1
       CALL  STKWR
       LD    B,1
       DEC   HL
STKWR  LD    D,(HL)
       DEC   HL
       LD    E,(HL)
       DEC   HL
       EX    DE,HL
       CALL  WTOHX
       EX    DE,HL
       DJNZ  STKWR
       RET
ERRDO  JP    ERGO
REG    CALL  DELIM
       JR    C,SEREG  Se alla
       LD    HL,INDEX
       LD    BC,32
       LD    D,0
       CP    65
       JR    C,ERRDO
       LD    E,A
       CALL  DELIM
       JR    C,S\KREG Se Unikreg
       CP    39       Ev. EXX
       JR    Z,$+16
       CP    65
       JR    C,ERRDO
       LD    D,A
       CALL  DELIM
       JR    C,S\KREG
       CP    39
       JR    NZ,ERRDO
       CALL  DELIM
       JR    NC,ERRDO
       LD    C,16
       LD    HL,REGS
S\KREG LD    A,E
       CPIR
       JP    PO,ERRDO
       LD    A,D
       AND   A
       JR    NZ,$+9
       INC   HL
       BIT   7,(HL)
       JR    Z,S\KREG
       JR    $+10
       CP    (HL)
       JR    NZ,S\KREG
       INC   HL
       BIT   6,(HL)
       JR    NZ,ERRDO
       LD    A,(HL)
       AND   31
       CP    25
       JR    Z,SESP
       CP    28
       JR    Z,SEPC
       LD    L,A
       LD    H,0
       ADD   HL,SP
SENREG LD    C,61  =
       CALL  WRCH
       XOR   A
       CP    D
       JR    Z,$+7
       LD    A,(HL)
       CALL  BIASC
       DEC   HL
       LD    A,(HL)
       CALL  BIASC
       CALL  TOGET
       RET   C
       PUSH  HL
       CALL  HX2?W
       POP   BC
       POP   HL
       LD    (HL),C
       XOR   A
       CP    D
       RET   Z
       INC   HL
       LD    (HL),B
       RET
SESP   LD    HL,SPGO+1
       JR    SENREG
SEPC   LD    HL,PCGO+1
       JR    SENREG
PEPO   CALL  IN1HXW
       POP   HL
PLOOP  CALL  ADRBYT
       CALL  TOGET
       RET   C
       JR    Z,NEXT+2 - , Bak}tlist
       CP    82       R Hexw Relativhopp
       JR    Z,NEXT+5
       CP    32       Framm}t list
       JR    Z,NEXT
       CALL  VALUE
       LD    B,17
       JR    C,ERWRI
       LD    (HL),A
       LD    B,104
       CP    (HL)
       CALL  NZ,WERR
NEXT   INC   HL
       INC   HL
       DEC   HL
       JR    PLOOP
       PUSH  HL
       CALL  SPACE
       CALL  IN1HXW
       POP   HL
       POP   DE
       XOR   A
       SBC   HL,DE
       EX    DE,HL
       DEC   DE
       BIT   7,E
       JR    Z,$+3
       INC   D
       CP    D
       LD    B,103
       JR    NZ,ERWRI
       LD    (HL),E
       CALL  ADRBYT
       JR    NEXT
ERWRI  CALL  WERR
       JR    PLOOP
DMPHEX CALL  INHHCR
       PUSH  HL
       CALL  WTOHX-3
       CALL  SPACE
       LD    A,(HL)
       CALL  BIASC
       CALL  THRU
       JR    C,$+7
       LD    A,L
       AND   7
       JR    NZ,$-15
       LD    A,31
       LD    (65012),A
       POP   HL
       CALL  PUNKT
       CALL  POLLA
       LD    A,L
       AND   7
       JR    NZ,$-9
       JR    $-38
PUNKT  LD    A,(HL)
       BIT   7,A
       JR    NZ,$+6
       CP    32
       JR    NC,$+4
       LD    A,46
       LD    C,A
       JP    WRCH
ADMP   CALL  INHHCR
       CALL  WTOHX-3
       LD    B,32
       CALL  PUNKT
       CALL  POLLA
       DJNZ  $-6
       JR    $-13
TYPE   CALL  IN1HXW
       CALL  CRLF
       LD    C,120
       LD    HL,65088 F|rst|r BUFF
       PUSH  HL
       CALL  5
       POP   HL
       POP   DE
       LD    A,120
       SUB   B
       RET   Z
       LD    C,A
       LD    B,0
       LDIR
       RET
FILL   CALL  IN3HXW
       LD    (HL),C
       CALL  POLLA
       JR    $-4
BILD   LD    BC,1024
       LD    HL,(65011)
       LD    (32766),HL Save CURXY
       LD    HL,31744
       LD    IX,30720   Ex Bild
       LD    D,(HL)
       LD    E,(IX+0)
       LD    (HL),E
       LD    (IX+0),D
       INC   HL
       INC   IX
       DEC   BC
       LD    A,B
       OR    C
       JR    NZ,$-14
       LD    HL,(32766) Rest. CURXY
       LD    (65011),HL
       RET
EXBUF  CALL  GETEKA
       RET   Z
       CP    'S'      Store Pekare+BUFF
       JR    NZ,$+13
       LD    BC,IYSAV+2
       LD    HL,65011
       LD    DE,LAY-1-(IYSAV+2)+65011
       JR    MOVE+3
       CP    'R'
       RET   NZ
       LD    BC,65011 Restore !EJ INIT!
       LD    HL,IYSAV+2
       LD    DE,LAY-1
       JR    MOVE+3
MOVE   CALL  IN3HXW
       LD    A,(HL)
       LD    (BC),A
       INC   BC
       CALL  POLLA
       JR    $-6
JUST   CALL  IN3HXW
       LD    A,(BC)
       CP    (HL)
       JR    Z,$+18
       PUSH  BC
       CALL  ADRBYT
       CALL  SPACE
       CALL  SPACE
       EX    (SP),HL
       CALL  ADRBYT+3
       EX    (SP),HL
       POP   BC
       INC   BC
       CALL  POLLA
       JR    JUST+3
CSUM   CALL  INHHCR  C JPTAB,S\KB-1
       LD    BC,0
       LD    A,(HL)
       ADD   A,C
       LD    C,A
       JR    NC,$+3
       INC   B
       CALL  THRU
       JR    NC,$-9
       LD    H,B
       LD    L,C
       JP    WBIASC
INPO   CALL  IN1HXW
       POP   BC
       IN    E,(C)
       CALL  SPACE
       LD    A,E
       CALL  BIASC
BBIN   CALL  SPACE
       LD    B,8
       SLA   E
       LD    A,24
       ADC   A,A
       LD    C,A
       CALL  WRCH
       DJNZ  $-9
       RET
OUTP   CALL  IN2HXW
       POP   DE
       POP   BC
       OUT   (C),E
       RET
WBIN   XOR   A
       CP    H
       JR    Z,$+6
       LD    E,H
       CALL  BBIN
       LD    E,L
       JR    BBIN
HKONV  CALL  BTOHX
       LD    C,A
       CALL  BTOHX
       LD    H,A
       LD    A,L
       LD    L,C
       RET
BTOHX  XOR   A
       LD    B,16
       ADD   HL,HL
       ADC   A,A
       DAA
       JR    NC,$+3
       INC   HL
       DJNZ  $-6
       RET
LOAD   LD    A,0
       LD    IX,65521
       ADD   IX,SP
       LD    SP,IX
       CALL  OPNFIL
GETNAM LD    HL,65088
       PUSH  HL
       LD    BC,122
       CALL  21
       POP   HL
       JR    C,FILFEL
       LD    A,(HL)
       INC   HL
       CP    32
       JR    C,GETNAM
       SUB   58
       JR    Z,$+6
       LD    A,37
       JR    FILFEL
       EXX
       LD    C,A
       EXX
       CALL  ITH
       LD    B,A
       CALL  ITH
       LD    D,A
       CALL  ITH
       LD    E,A
       XOR   A
       CP    B
       JR    Z,MENT?
       CALL  ITH
       AND   A
       JR    NZ,$-27
       CALL  ITH
       LD    (DE),A
       INC   DE
       DJNZ  $-5
       CALL  ITH
       JR    Z,GETNAM
       LD    A,35
       JR    FILFEL
ITH    CALL  HX?IN
       RLCA
       RLCA
       RLCA
       RLCA
       LD    C,A
       CALL  HX?IN
       OR    C
       LD    C,A
       EXX
       ADD   A,C
       LD    C,A
       EXX
       LD    A,C
       RET
MENT?  LD    A,D
       OR    E
       JR    Z,ST[NG
       LD    (PCGO),DE
       JR    ST[NG
MIXERR LD    B,17
WERR   PUSH  HL
       LD    HL,TERROR
       CALL  WTO4
       LD    A,B
       CALL  BIASC
       POP   HL
       RET
FILFEL CALL  EVERR
ST[NG  JR    CLOSE
SAVE   CALL  INHHCR
       EXX
       LD    A,1
       LD    IX,65521
       ADD   IX,SP
       LD    SP,IX
       CALL  OPNFIL
       EXX
NYLIN  LD    BC,58
       CALL  FILWR
       PUSH  DE
       PUSH  HL
       INC   B
       CALL  THRU
       JR    C,KLAR
       LD    A,16
       SUB   B
       JR    NZ,$-9
       POP   HL
       CALL  RESTWR
       POP   DE
       JR    NYLIN
RESTWR LD    D,A
       LD    A,B
       CALL  BTOFIL
       CALL  WTOFIL
       XOR   A
       CALL  BTOFIL
       LD    A,(HL)
       CALL  BTOFIL
       INC   HL
       DJNZ  $-5
       XOR   A
       SUB   D
       CALL  BTOFIL
       LD    C,13
       JP    FILWR
KLAR   POP   HL
       POP   DE
       XOR   A
       CALL  RESTWR
       LD    C,58
       CALL  FILWR
       LD    B,5
       XOR   A
       CALL  BTOFIL
       DJNZ  $-4
       LD    C,13
       CALL  FILWR
CLOSE  CALL  2175
       LD    HL,15
       ADD   HL,SP
       LD    SP,HL
       RET
DECIN  LD    HL,0
       LD    B,L
DECTKN CALL  DELIM
       CCF
       RET   NC
       CALL  HEX?
       RET   C
       CP    10
       CCF
       RET   C
       ADD   HL,HL
       RET   C
       LD    D,H
       LD    E,L
       ADD   HL,HL
       RET   C
       ADD   HL,HL
       RET   C
       LD    C,A
       ADD   HL,BC
       RET   C
       ADD   HL,DE
       RET   C
       JR    DECTKN
VAS\K  LD    A,1
       LD    (S\KB),A
       JR    $+6
WHS\K  XOR   A
       LD    (S\KB),A
       CALL  INHHCR
       EX    DE,HL
       EXX
SUDDA  LD    D,0
       LD    A,(S\KB)
       AND   A
       JR    Z,HS\K
TKN    CALL  INCH
       CP    13
       JR    Z,INOK
       CP    8
       JR    Z,$+9
       CP    32
       JR    C,TKN
       PUSH  AF
       INC   D
       INC   D
       DEC   D
       JP    M,SUDDA
       INC   SP
       LD    C,A
       CALL  WRCH
       JR    TKN
HS\K   CALL  IN1HXW
       POP   HL
       LD    H,L
       PUSH  HL
       INC   SP
       INC   D
       CP    13
       JR    NZ,HS\K
INOK   XOR   A
       CP    D
       JP    Z,ERGO
       LD    H,A
       LD    L,D
       CALL  CRLF
       LD    A,L
       DEC   L
       ADD   HL,SP
       PUSH  HL
       EXX
       PUSH  DE
       AND   A
       SBC   HL,DE
       LD    B,H
       LD    C,L
       LD    D,A
RUNT   POP   HL
       POP   IX
       LD    E,D
       LD    A,(IX+0)
       CPIR
       JP    PO,T\MSTK
       PUSH  IX
       PUSH  HL
       DEC   E
       JR    Z,$+13
       LD    A,(IX-1)
       CP    (HL)
       JR    NZ,RUNT
       INC   HL
       DEC   IX
       JR    $-12
       POP   HL
       PUSH  HL
       DEC   HL
       PUSH  BC
       CALL  WTOHX
       CALL  POLL
       POP   BC
       JR    RUNT
T\MSTK INC   SP
       DEC   E
       JR    NZ,T\MSTK
       RET
USER   CALL  IN1HXW
       POP   HL
       LD    A,H
       OR    L
       JR    NZ,$+15    U Hex Userjp
       LD    HL,(RTSP)
       LD    (65063),HL
       LD    HL,EGETJP  U H{r HELP
       LD    A,195
       CP    (HL)
       RET   NZ
       JP    (HL)
QUIT   CALL  IN1HXW
       LD    HL,17
       ADD   HL,SP
       LD    A,(HL)
       LD    I,A
       POP   HL         Ev LD HL
       LD    SP,(SPSAV)
       LD    IY,(IYSAV)
       POP   IX
       RET
OPNFIL PUSH  AF
       LD    IY,(IYSAV)
       LD    HL,65088
       PUSH  HL
       LD    C,20
       CALL  5
       POP   HL
       POP   AF
       JP    1986
FEL    LD    HL,VARMB
       PUSH  HL
       LD    A,(65080)
EVERR  AND   127
       RET   Z
       LD    L,A
       LD    H,0
       CALL  BTOHX
       LD    B,A
       CALL  CRLF
       JP    WERR
S\KB   DB    0
ROMSAV DW    0
BREAK  DW    0
OLDPC  DW    0
OLDBYT DB    0
EGETJP DB    195
       DW    HELP
MASK   DB    0
SPGO   DW    0
JPKOD  DB    0
PCGO   DW    0
RTSP   DW    0
SPSAV  DW    0
IYSAV  DW    0
       END   INIT

