       ORG 0H
INITA: LD  HL,FILEO
       LD  C,MAXFIL*FELEN
       XOR A
INIT2: LD  (HL),A
       INC HL
       DEC C
       JP  NZ,INIT2
SYS8:  LD  SP,AREA+18
       CALL READ
       INC HL
       LD  A,(HL)
       CP  '9'+1
       JP  C,LINE
       CALL VALC
       CALL COMM
EOR:   CALL CRLF
       JP  SYS8
READ:  LD  HL,IBUF
       LD   (ADDS),HL
       LD  E,2
NEXT:  CALL IN8
       LD  A,B
       CP  24
       JP  NZ,CR
       CALL CRLF
       JP  READ
CR:    CP  ASCR
       JP  NZ,DEL
       LD  A,L
       CP  IBUF.AND.00FFH
       JP  Z,READ
       LD  (HL),ASCR
       INC HL
       LD  (HL),1
       INC HL
       LD  A,IBUF+83.AND.00FFH
       CALL CLER
       LD  HL,IBUF-1
       LD  (HL),E
       RET
DEL:   CP  127
       JP  NZ,CHAR
       LD  A,IBUF.AND.00FFH
       CP  L
       JP  Z,NEXT
       DEC HL
       DEC E
BSPA:  LD  B,6FH
       CALL OUT8
       JP  NEXT
CHAR:  CP  ' '
       JP  C,NEXT
       CP  'Z'+1
       JP  NC,NEXT
       LD  B,A
       CALL OUT8
       LD  (HL),A
       LD  A,IBUF+81.AND.00FFH
       CP  L
       JP  Z,BSPA
       INC HL
       INC E
       JP  NEXT
CLER:  CP  L
       RET Z
       LD  (HL),' '
       INC HL
       JP  CLER
IN8:   IN  A,(USTA)
       AND 100Q
       JP  Z,IN8
       IN  A,(UDAI)
       AND 127
       LD  B,A
       RET
OUT8:  IN  A,(USTA)
       AND 80H
       JP  Z,OUT8
OK:    LD  A,B
       OUT (UDAO),A
       RET
CRLF:  LD  B,13
       CALL OUT8
LF:    LD  B,10
       CALL OUT8
       LD  B,127
       CALL OUT8
       CALL OUT8
       RET
EXEC:  CALL VCHK
       CALL CRLF
       LD    HL,(BBUF)
       JP   (HL)
COMM:  LD  DE,CTAB
       LD  B,NCOM
       LD  A,4
       LD  (NCHR),A
       CALL COMS
       JP  NZ,WHAT
       JP   (HL)
COMS:  LD   HL,(ADDS)
       LD  A,(NCHR)
       LD  C,A
       CALL SEAR
       LD   A,(DE)
       LD  H,A
       INC DE
       LD   A,(DE)
       LD  L,A
       RET Z
       INC DE
       DEC B
       JP  NZ,COMS
       INC B
       RET
SEAR:  LD   A,(DE)
       CP  (HL)
       JP  NZ,INCA
       INC HL
       INC DE
       DEC C
       JP  NZ,SEAR
       RET
INCA:  INC DE
       DEC C
       JP  NZ,INCA
       INC C
       RET
ZBUF:  XOR A
       LD  DE,ABUF+12
       LD  B,12
ZBU1:  DEC DE
       LD  (DE),A
       DEC B
       JP  NZ,ZBU1
       RET
VALC:  CALL ETRA
       JP  C,WHAT
       RET
ETRA:  LD  HL,0
       LD   (BBUF+2),HL
       LD   (FBUF),HL
       CALL ZBUF
       LD  HL,IBUF-1
VAL1:  INC HL
       LD  A,(HL)
       CP  ' '
       CCF
       RET NC
       JP  NZ,VAL1
       LD   (PNTR),HL
       CALL SBLK
       CCF
       RET NC
       CP  '/'
       JP  NZ,VAL5
       LD  DE,FBUF
       LD  C,NMLEN
VAL2:  INC HL
       LD  A,(HL)
       CP  '/'
       JP  Z,VAL3
       DEC C
       JP  M,WHAT
       LD  (DE),A
       NOP
       INC DE
       JP  VAL2
VAL3:  LD  A,' '
VAL4:  DEC C
       JP  M,DONE
       LD  (DE),A
       INC DE
       JP  VAL4
DONE:  CALL SBL2
       CCF
       RET NC
VAL5:  LD  DE,ABUF
       CALL ALPS
       LD  A,B
       CP  5
       CCF
       RET C
       LD  BC,ABUF
       CALL AHEX
       RET C
       LD   (BBUF),HL
       LD  HL,ABUF
       CALL NORM
       CALL SBLK
       CCF
       RET NC
       LD  DE,ABUF+4
       CALL ALPS
       LD  A,B
       CP  5
       CCF
       RET C
       LD  BC,ABUF+4
       CALL AHEX
       RET C
       LD   (BBUF+2),HL
       LD  HL,ABUF+4
       CALL NORM
       OR  A
       RET
ADEC:  LD  HL,0
ADE1:  LD  A,(BC)
       OR  A
       RET Z
       LD  D,H
       LD  E,L
       ADD HL,HL
       ADD HL,HL
       ADD HL,DE
       ADD HL,HL
       SUB 48
       CP  10
       CCF
       RET C
       LD  E,A
       LD  D,0
       ADD HL,DE
       INC BC
       JP  ADE1
AHEX:  LD  HL,0
AHE1: LD A,(BC)
       OR  A
       RET Z
       ADD HL,HL
       ADD HL,HL
       ADD HL,HL
       ADD HL,HL
       CALL AHS1
       CP  10H
       CCF
       RET C
       ADD A,L
       LD  L,A
       INC BC
       JP  AHE1
AHS1:  SUB 48
       CP  10
       RET C
       SUB 7
       RET
HOUT:  CALL BINH
       LD  HL,HCON
CHOT:  LD  B,(HL)
       CALL OUT8
       INC HL
       LD  B,(HL)
       CALL OUT8
       RET
HOTB:  CALL HOUT
       CALL BLK1
       RET
DOUT:  CALL BIND
       CALL HOUT+3
       INC HL
       LD  B,(HL)
       CALL OUT8
       RET
BLK1:  LD  B,' '
       CALL OUT8
       RET
ACHK:  LD    HL,(BBUF)
       LD  A,(BBUF+3)
       CP  H
       JP  NZ,ACH1
       LD  A,(BBUF+2)
       CP  L
       JP  NZ,ACH1
       SCF
ACH1:  INC HL
       LD   (BBUF),HL
       RET
SCRN:  LD  B,(HL)
       LD  A,13
       CP  B
       RET Z
       CALL OUT8
       INC HL
       JP  SCRN
BINH:  LD  HL,HCON
       LD  B,A
       RRA
       RRA
       RRA
       RRA
       CALL BIN1
       LD  (HL),A
       INC HL
       LD  A,B
       CALL BIN1
       LD  (HL),A
       RET
BIN1:  AND 0FH
       ADD A,48
       CP  58
       RET C
       ADD A,7
       RET
BIND:  LD  HL,HCON
       LD  B,100
       CALL BID1
       LD  B,10
       CALL BID1
       ADD A,'0'
       LD  (HL),A
       RET
BID1:  LD  (HL),'0'-1
       INC (HL)
       SUB B
       JP  NC,BID1+2
       ADD A,B
       INC HL
       RET
CTAB:  DEFM 'DUMP'
       DEFB DUMP.SHR.8
       DEFB DUMP.AND.00FFH
       DEFM 'EXEC'
       DEFB EXEC.SHR.8
       DEFB EXEC.AND.00FFH
       DEFM 'ENTR'
       DEFB ENTR.SHR.8
       DEFB ENTR.AND.00FFH
       DEFM 'FILE'
       DEFB FILE.SHR.8
       DEFB FILE.AND.00FFH
       DEFM 'LIST'
       DEFB LIST.SHR.8
       DEFB LIST.AND.00FFH
       DEFM 'DELT'
       DEFB DELL.SHR.8
       DEFB DELL.AND.00FFH
       DEFM 'ASSM'
       DEFB ASSM.SHR.8
       DEFB ASSM.AND.00FFH
       DEFM 'PAGE'
       DEFB PAGE.SHR.8
       DEFB PAGE.AND.00FFH
       DEFM 'PROM'
       DEFB PROM.SHR.8
       DEFB PROM.AND.00FFH
       DEFM 'CUST'
       DEFW 0E000H
VCHK:  LD  A,(ABUF)
       OR  A
       JP  Z,WHAT
       RET
DUMP:  CALL VCHK
       LD  A,16
       LD  (SCNT),A
DUMS:  CALL CRLF
       LD  A,(BBUF+1)
       CALL HOUT
       LD  A,(BBUF)
       CALL HOTB
       LD  A,(SCNT)
DUM1:  LD  (DCNT),A
       LD    HL,(BBUF)
       LD  A,L
       OUT (PADO),A
       LD  A,H
       CP  0EFH
       LD  A,(HL)
       JP  NZ,DUM2
       IN  A,(PDAI)
DUM2:  CALL HOTB
       CALL ACHK
       RET C
       LD  A,(DCNT)
       DEC A
       JP  NZ,DUM1
       JP  DUMS
PAGE:  CALL VCHK
       LD  A,(ABUF+4)
       OR  A
       JP  Z,WHAT
       LD    HL,(BBUF)
       EX  DE,HL
       LD    HL,(BBUF+2)
       LD  B,0
PAG1:  LD  A,E
       OUT (PADO),A
       LD  A,D
       CP  0FFH
       LD   A,(DE)
       JP  NZ,PAG2
       IN  A,(PDAI)
PAG2:  LD  (HL),A
       INC HL
       INC DE
       DEC B
       JP  NZ,PAG1
       RET
FILE:  CALL CRLF
       LD  A,(FBUF)
       OR  A
       JP  Z,FOUT
       CALL FSEA
       EX  DE,HL
       JP  NZ,TEST
       LD  A,(ABUF)
       OR  A
       JP  Z,WHA1
       LD  A,(FEF)
       OR  A
       JP  NZ,ROOM
       LD  HL,EMES1
       JP  MESS
TEST:  LD  A,(ABUF)
       OR  A
       JP  Z,SWAPS
       LD    HL,(BBUF)
       LD  A,H
       OR  L
       JP  Z,SWAPS
       LD  HL,EMES2
       JP  MESS
ROOM:  LD  HL,(FREAD)
       EX  DE,HL
       LD  HL,FBUF
       PUSH DE
       LD  C,NMLEN
MOV23: LD  A,(HL)
       LD  (DE),A
       INC DE
       DEC C
       JP  PATCH
P3:    POP DE
SWAPS: LD  HL,FILEO
       LD  C,FELEN
SWAP:  LD   A,(DE)
       LD  B,(HL)
       LD  (HL),A
       LD  A,B
       LD  (DE),A
       INC DE
       INC HL
       DEC C
       JP  NZ,SWAP
       LD  A,(ABUF)
       OR  A
       JP  Z,FOOT
       LD    HL,(BBUF)
       LD  (BOFP),HL
       LD  (EOFP),HL
       LD  A,L
       OR  H
       JP  Z,FIL35
FIL30: LD  (HL),1
FIL35: XOR A
       LD  (MAXL),A
       JP  FOOT
FOUT:  LD  A,(IBUF+4)
       CP  'S'
       LD  C,MAXFIL
       JP  Z,FOUL
FOOT:  LD  C,1
FOUL:  LD  HL,FILEO
       LD  A,C
FINE:  LD  (FOCNT),A
       PUSH HL
       LD  DE,NMLEN
       ADD HL,DE
       LD  A,(HL)
       OR  A
       JP  NZ,FOOD
       INC HL
       ADD A,(HL)
       INC HL
       JP  NZ,FOOD
       INC SP
       INC SP
       INC HL
       INC HL
       JP  FEET
FOOD:  POP HL
       LD  C,NMLEN
FAST:  LD  B,(HL)
       CALL OUT8
       DEC C
       INC HL
       JP  NZ,FAST
       CALL FOOL
       CALL FOOL
       CALL CRLF
FEET:  LD  DE,FELEN-NMLEN-4
       ADD HL,DE
       LD  A,(FOCNT)
       DEC A
       JP  NZ,FINE
       RET
FOOL:  CALL BLK1
       INC HL
       LD  A,(HL)
       DEC HL
       PUSH HL
       CALL HOUT
       POP HL
       LD  A,(HL)
       INC HL
       INC HL
       PUSH HL
       CALL HOTB
       POP HL
       RET
FSEA:  XOR A
       LD  (FEF),A
       LD  B,MAXFIL
       LD  DE,FILEO
FSE10: LD  HL,FBUF
       LD  C,NMLEN
       CALL SEAR
       PUSH AF
       PUSH DE
       LD   A,(DE)
       OR  A
       JP  NZ,FSE20
       INC DE
       LD   A,(DE)
       OR  A
       JP  NZ,FSE20
       EX  DE,HL
       LD  DE,-NMLEN-1
       ADD HL,DE
       LD  (FREAD),HL
       LD  A,D
       LD  (FEF),A
       POP HL
       POP AF
FSE15: LD  DE,FELEN-NMLEN
       ADD HL,DE
       EX  DE,HL
       DEC B
       RET Z
       JP  FSE10
FSE20: POP HL
       POP AF
       JP  NZ,FSE15
       LD  DE,-NMLEN
       ADD HL,DE
       LD  A,D
       OR  A
       RET
WHAT:  CALL CRLF
WHA1:  LD  HL,EMES
MESS:  CALL SCRN
       JP  EOR
EMES:  DEFM 'WHAT?'
       DEFB 13
EMES1: DEFM 'FULL'
       DEFB 13
EMES2: DEFM 'NO NO'
       DEFB 13
ENTR:  CALL VCHK
       CALL ENTS
       JP  C,WHAT
       CALL CRLF
       RET
EEND   EQU '/'
ENTS:  CALL CRLF
       CALL READ
       LD  HL,IBUF
       LD   (PNTR),HL
ENT1:  CALL ZBUF
       CALL SBLK
       JP  C,ENTS
       CP  EEND
       RET Z
       CALL ALPS
       LD  A,B
       CP  3
       CCF
       RET C
       LD  BC,ABUF
       CALL AHEX
       RET C
       LD  A,L
       LD    HL,(BBUF)
       LD  (HL),A
       CALL ACH1
       JP  ENT1
LINE:  LD  C,4
       LD  HL,IBUF-1
LICK:  INC HL
       LD  A,(HL)
       CP  '0'
       JP  C,WHAT
       CP  '9'+1
       JP  NC,WHAT
       DEC C
       JP  NZ,LICK
       LD   (ADDS),HL
       LD  DE,MAXL+3
       CALL COMO
       JP  NC,INSR
       INC HL
       CALL LODM
       LD  HL,MAXL+3
       CALL STOM
       LD  DE,IBUF-1
       LD  HL,(EOFP)
       LD  C,1
       CALL LMOV
SEOF:  LD  (HL),C
       LD  (EOFP),HL
       JP  EOR
INSR:  CALL FIN1
       LD  C,2
       JP  Z,EQUL
       DEC C
EQUL:  LD  B,(HL)
       DEC HL
       LD  (HL),2
       LD  (INSP),HL
       LD  A,(IBUF-1)
       DEC C
       JP  Z,LT
       SUB B
       JP  Z,ZERO
       JP  C,GT
LT:    LD  HL,(EOFP)
       LD  D,H
       LD  E,L
       CALL ADR
       LD  (EOFP),HL
       LD  C,2
       CALL RMOV
       JP  ZERO
GT:    CPL
       INC A
       LD  D,H
       LD  E,L
       CALL ADR
       EX  DE,HL
       CALL LMOV
       LD  (HL),1
       LD  (EOFP),HL
ZERO:  LD  HL,(INSP)
       LD  (HL),ASCR
       INC HL
       LD  DE,IBUF-1
       LD  C,1
       CALL LMOV
       JP  EOR
FIND:  LD  HL,ABUF+3
       LD   (ADDS),HL
FIN1:  LD  HL,(BOFP)
F11:   CALL EO1
       EX  DE,HL
       LD   HL,(ADDS)
       EX  DE,HL
       LD  A,4
       CALL ADR
       CALL COMO
       RET C
       RET Z
F12:   LD  A,(HL)
       CALL ADR
       JP  F11
EOF:   INC HL
EO1:   LD  A,1
       CP  (HL)
       RET NZ
       JP  EOR
ADR:   ADD A,L
       LD  L,A
       RET NC
       INC H
       RET
LMOV:  LD   A,(DE)
       INC DE
       CP  C
       RET Z
       LD  (HL),A
       INC HL
       JP  LMOV
RMOV:  LD   A,(DE)
       DEC DE
       CP  C
       RET Z
       LD  (HL),A
       DEC HL
       JP  RMOV
LODM:  LD  B,(HL)
       INC HL
       LD  C,(HL)
       INC HL
       LD  D,(HL)
       INC HL
       LD  E,(HL)
       RET
STOM:  LD  (HL),E
       DEC HL
       LD  (HL),D
       DEC HL
       LD  (HL),C
       DEC HL
       LD  (HL),B
       RET
COMO:  LD  B,1
       LD  C,4
       OR  A
CO1:   LD   A,(DE)
       SBC A,(HL)
       JP  Z,CO2
       INC B
CO2:   DEC DE
       DEC HL
       DEC C
       JP  NZ,CO1
       DEC B
       RET
COM1:  LD  C,4
       LD   A,(DE)
       SUB 1
       JP  CO1+1
NORM:  CALL LODM
       XOR A
       CP  B
       RET Z
NOR1:  CP  E
       CALL NZ,STOM
       RET NZ
       LD  E,D
       LD  D,C
       LD  C,B
       LD  B,'0'
       JP  NOR1
LIST:  CALL CRLF
       CALL FIND
       INC HL
LIS1:  CALL SCRN
       CALL CRLF
       CALL EOF
       IN  A,(SWCH)
       AND 80H
       RET NZ
       INC HL
       JP  LIS1
PROM:  CALL VCHK
PRO1:  CALL CRLF
       LD  A,(BBUF)
       CALL HOTB
       LD  D,3
       LD    HL,(BBUF)
PRO2:  LD  A,L
       OUT (PADO),A
       LD  A,(HL)
       OUT (PADO),A
       LD  A,2
       OUT (PCTO),A
       CALL DLAY
       XOR A
       OUT (PCTO),A
       IN  A,(PDAI)
       CP  (HL)
       JP  Z,PRO3
       LD  B,'?'
       CALL OUT8
       DEC D
       JP  NZ,PRO2
       RET
PRO3:  CALL ACHK
       RET C
       JP  PRO1
DLAY:  LD  E,150
DLA1:  XOR A
DLA2:  DEC A
       JP  NZ,DLA2
       DEC E
       JP  NZ,DLA1
       RET
DELL:  CALL VCHK
       CALL FIND
       LD  (DELP),HL
       LD  HL,ABUF+7
       LD  A,(HL)
       OR  A
       JP  NZ,DEL1
       LD  HL,ABUF+3
DEL1:  LD   (ADDS),HL
       EX  DE,HL
       LD  HL,MAXL+3
       CALL COMO
       LD  HL,(DELP)
       JP  C,NOVR
       LD  (EOFP),HL
       LD  (HL),1
       EX  DE,HL
       LD  HL,(BOFP)
       EX  DE,HL
       LD  B,13
       DEC HL
DEL2:  LD  A,L
       SUB E
       LD  A,H
       SBC A,D
       LD  A,ASCR
       JP  C,DEL4
       DEC B
       DEC HL
       CP  (HL)
       JP  NZ,DEL2
       DEC HL
       LD  A,L
       SUB E
       LD  A,H
       SBC A,D
       JP  C,DEL5
       CP  (HL)
       INC HL
       INC HL
       JP  Z,DEL3
       INC HL
DEL3:  CALL LODM
       LD  HL,MAXL+3
       CALL STOM
       RET
DEL4:  CP  B
DEL5:  EX  DE,HL
       JP  NZ,DEL3-1
       LD  (MAXL),A
       RET
NOVR:  CALL F11
       CALL Z,F12
NOV1:  EX  DE,HL
       LD  HL,(DELP)
       LD  C,1
       CALL LMOV
       LD  (EOFP),HL
       LD  (HL),1
       RET
ASSM:  CALL VCHK
       LD  A,(ABUF+4)
       OR  A
       JP  NZ,ASM4
       LD    HL,(BBUF)
       LD   (BBUF+2),HL
ASM4:  LD  A,(IBUF+4)
       CP  'E'
       JP  NZ,ASM5
       XOR A
ASM5:  LD  (AERR),A
       XOR A
       LD  (NOLA),A
ASM3:  LD  (PASI),A
       LD    HL,(BBUF)
       LD  (ASPC),HL
       LD  HL,(BOFP)
       LD  (APNT),HL
ASM1:  LD  HL,(APNT)
       LD  SP,AREA+18
       LD  A,(HL)
       CP  1
       JP  Z,EASS
       EX  DE,HL
       INC DE
       LD  HL,OBUF
       LD  A,IBUF-5.AND.00FFH
       CALL CLER
       LD  C,ASCR
       CALL LMOV
       LD  (HL),C
       EX  DE,HL
       LD  (APNT),HL
       LD  A,(PASI)
       OR  A
       JP  NZ,ASM2
       CALL PAS1
       JP  ASM1
ASM2:  CALL PAS2
       LD  HL,OBUF
       CALL AOUT
       JP  ASM1
AOUT:  LD  A,(AERR)
       OR  A
       JP  NZ,AOU1
AOU2:  LD  A,(OBUF+18)
       CP  ' '
       RET Z
AOU1:  LD  HL,OBUF
       CALL CRLF
       CALL SCRN
       RET
PAS1:  CALL ZBUF
       LD  (PASI),A
       LD  HL,IBUF
       LD   (PNTR),HL
       LD  A,(HL)
       CP  ' '
       JP  Z,OPC
       CP  '*'
       RET Z
       CALL SLAB
       JP  C,OP5
       JP  Z,ERRD
       CALL LCHK
       JP  NZ,OP5
       LD  C,LLAB
       LD  HL,ABUF
MLAB:  LD  A,(HL)
       LD  (DE),A
       INC DE
       INC HL
       DEC C
       JP  NZ,MLAB
       EX  DE,HL
       LD  (TABA),HL
       LD  A,(ASPC+1)
       LD  (HL),A
       INC HL
       LD  A,(ASPC)
       LD  (HL),A
       LD  HL,NOLA
       INC (HL)
OPC:   CALL ZBUF
       CALL SBLK
       JP  C,OERR
       CALL ALPS
       CP  ' '
       JP  C,OPCD
       JP  NZ,OERR
       JP  OPCD
LCHK:  LD  HL,(PNTR)
       LD  A,(HL)
       CP  ' '
       RET Z
       CP  ':'
       RET NZ
       INC HL
       LD   (PNTR),HL
       RET
PSU1:  CALL SBLK
       LD   A,(DE)
       OR  A
       JP  Z,ORG1
       JP  M,DAT21
       JP  PO,EQU1
       CP  5
       JP  C,RES1
       JP  NZ,EASS
ACO1:  LD  C,2
       XOR A
       JP  OCN1
ORG1:  CALL ASCN
       LD  A,(OBUF+18)
       CP  ' '
       RET NZ
       LD  (ASPC),HL
       LD  A,(IBUF)
       CP  ' '
       RET Z
       JP  EQUS
EQU1:  CALL ASCN
       LD  A,(IBUF)
       CP  ' '
       JP  Z,ERRM
EQUS:  EX  DE,HL
       LD  HL,(TABA)
       LD  (HL),D
       INC HL
       LD  (HL),E
       JP  AOU2
RES1:  CALL ASCN
       LD  B,H
       LD  C,L
       JP  RES21
DAT1:  JP  OP2
PAS2:  LD  HL,OBUF
       LD  A,(ASPC+1)
       CALL BINH+3
       INC HL
       LD  A,(ASPC)
       CALL BINH+3
       LD  (OIND),HL
       CALL ZBUF
       LD  HL,IBUF
PABL:  LD   (PNTR),HL
       LD  A,(HL)
       CP  ' '
       JP  Z,OPC
       CP  '*'
       RET Z
       CALL SLAB
       JP  C,ERRL
       CALL LCHK
       JP  NZ,ERRL
       JP  OPC
PSU2:  LD   A,(DE)
       OR  A
       JP  Z,ORG2
       JP  M,DAT2
       RET PO
       CP  5
       JP  C,RES2
       JP  NZ,EASS
ACO2:  CALL TYS6
       JP  ACO1
RES2:  CALL ASBL
       LD  B,H
       LD  C,L
       LD    HL,(BBUF+2)
       ADD HL,BC
       LD   (BBUF+2),HL
RES21: XOR A
       JP  OCN2
DAT2:  CALL TY55
DAT21: XOR A
       LD  C,1
       JP  OCN1
ORG2:  CALL ASBL
       LD  A,(OBUF+18)
       CP  ' '
       RET NZ
       EX  DE,HL
       LD  HL,(ASPC)
       EX  DE,HL
       LD  (ASPC),HL
       LD  A,L
       SUB E
       LD  E,A
       LD  A,H
       SBC A,D
       LD  D,A
       LD    HL,(BBUF+2)
       ADD HL,DE
       LD   (BBUF+2),HL
       RET
TYP1:  CALL ASTO
       RET
TYP2:  CALL ASBL
       CALL NZ,ERRR
       LD  A,L
       OR  A
       JP  Z,TY31
       CP  2
       CALL NZ,ERRR
       JP  TY31
TYP3:  CALL ASBL
       CALL NZ,ERRR
       LD  A,L
       RRCA
       CALL C,ERRR
       RLA
       CP  8
       CALL NC,ERRR
TY31:  RLCA
       RLA
       RLA
TY32:  LD  B,A
       LD   A,(DE)
       ADD A,B
       CP  118
       CALL Z,ERRR
       JP  TYP1
TYP4:  CALL ASBL
       CALL NZ,ERRR
       LD  A,L
       CP  8
       CALL NC,ERRR
       LD   A,(DE)
       CP  64
       JP  Z,TY41
       CP  199
       LD  A,L
       JP  Z,TY31
       JP  M,TY32
       JP  TY31
TY41: ADD HL,HL
       ADD HL,HL
       ADD HL,HL
       ADD A,L
       LD  (DE),A
       CALL MPNT
       CALL ASCN
       CALL NZ,ERRR
       LD  A,L
       CP  8
       CALL NC,ERRR
       JP  TY32
TYP5:  CP  6
       CALL Z,TY56
       CALL ASTO
TY55:  CALL ASBL
       INC A
       CP  2
       CALL NC,ERRV
       LD  A,L
       JP  TYP1
TY56:  CALL ASBL
       CALL NZ,ERRR
       LD  A,L
       CP  8
       CALL NC,ERRR
       ADD HL,HL
       ADD HL,HL
       ADD HL,HL
       LD   A,(DE)
       ADD A,L
       LD  E,A
MPNT:  LD  HL,(PNTR)
       LD  A,(HL)
       CP  ','
       INC HL
       LD   (PNTR),HL
       JP  NZ,ERRS
       LD  A,E
       RET
TYP6:  CP  1
       JP  NZ,TY6
       CALL TY56
       AND 08H
       CALL NZ,ERRR
       LD  A,E
       AND 0F7H
TY6:   CALL ASTO
TYS6:  CALL ASBL
       LD  A,L
       LD  D,H
       CALL ASTO
       LD  A,D
       JP  TYP1
       RET
ASTO:  LD    HL,(BBUF+2)
       LD  (HL),A
       INC HL
       LD   (BBUF+2),HL
       LD  HL,(OIND)
       INC HL
       INC HL
       CALL BINH+3
       LD  (OIND),HL
       RET
EASS:  LD  A,(PASI)
       OR  A
       JP  NZ,EOR
       CALL CRLF
       LD  A,1
       JP  ASM3
SBLK:  LD  HL,(PNTR)
SBL1:  LD  A,(HL)
       CP  ' '
       RET NZ
SBL2:  INC HL
       LD   (PNTR),HL
       JP  SBL1
COND:  LD  HL,ABUF+1
       LD   (ADDS),HL
       LD  B,2
       CALL COPC
       RET
OTAB: DEFM 'ORG'
       DEFB 0
       DEFB 0
       DEFM 'EQU'
       DEFB 0
       DEFB 1
       DEFM 'DB'
       DEFB 0
       DEFB 0
       DEFB -1
       DEFM 'DS'
       DEFB 0
       DEFB 0
       DEFB 3
       DEFM 'DW'
       DEFB 0
       DEFB 0
       DEFB 5
       DEFM 'END'
       DEFB 0
       DEFB 6
       DEFB 0
       DEFM 'HLT'
       DEFB 118
       DEFM 'RLC'
       DEFB 7
       DEFM 'RRC'
       DEFB 15
       DEFM 'RAL'
       DEFB 23
       DEFM 'RAR'
       DEFB 31
       DEFM 'RET'
       DEFB 201
       DEFM 'CMA'
       DEFB 47
       DEFM 'STC'
       DEFB 55
       DEFM 'DAA'
       DEFB 39
       DEFM 'CMC'
       DEFB 63
       DEFM 'EI'
       DEFB 0
       DEFB 251
       DEFM 'DI'
       DEFB 0
       DEFB 243
       DEFM 'NOP'
       DEFB 0
       DEFB 0
       DEFM 'XCHG'
       DEFB 235
       DEFM 'XTHL'
       DEFB 227
       DEFM 'SPHL'
       DEFB 249
       DEFM 'PCHL'
       DEFB 223
       DEFB 0
       DEFM 'STAX'
       DEFB 2
       DEFM 'LDAX'
       DEFB 10
       DEFB 0
       DEFM 'PUSH'
       DEFB 197
       DEFM 'POP'
       DEFB 0
       DEFB 193
       DEFM 'INX'
       DEFB 0
       DEFB 3
       DEFM 'DCX'
       DEFB 0
       DEFB 11
       DEFM 'DAD'
       DEFB 0
       DEFB 9
       DEFB 0
       DEFM 'INR'
       DEFB 4
       DEFM 'DCR'
       DEFB 5
       DEFM 'MOV'
       DEFB 64
       DEFM 'ADD'
       DEFB 128
       DEFM 'ADC'
       DEFB 136
       DEFM 'SUB'
       DEFB 144
       DEFM 'SBB'
       DEFB 152
       DEFM 'ANA'
       DEFB 160
       DEFM 'XRA'
       DEFB 168
       DEFM 'ORA'
       DEFB 176
       DEFM 'CMP'
       DEFB 184
       DEFM 'RST'
       DEFB 199
       DEFB 0
       DEFM 'ADI'
       DEFB 198
       DEFM 'ACI'
       DEFB 206
       DEFM 'SUI'
       DEFB 214
       DEFM 'SBI'
       DEFB 222
       DEFM 'ANI'
       DEFB 230
       DEFM 'XRI'
       DEFB 238
       DEFM 'ORI'
       DEFB 246
       DEFM 'CPI'
       DEFB 254
       DEFM 'IN'
       DEFB 0
       DEFB 219
       DEFM 'OUT'
       DEFB 211
       DEFM 'MVI'
       DEFB 6
       DEFB 0
       DEFM 'JMP'
       DEFB 0
       DEFB 195
       DEFM 'CALL'
       DEFB 205
       DEFM 'LXI'
       DEFB 0
       DEFB 1
       DEFM 'LDA'
       DEFB 0
       DEFB 58
       DEFM 'STA'
       DEFB 0
       DEFB 50
       DEFM 'SHLD'
       DEFB 34
       DEFM 'LHLD'
       DEFB 42
       DEFB 0
; CONDITION CODE TABLE
       DEFM 'NZ'
       DEFB 0
       DEFM 'Z'
       DEFB 0
       DEFB 8
       DEFM 'NC'
       DEFB 16
       DEFM 'C'
       DEFB 0
       DEFB 24
       DEFM 'PO'
       DEFB 32
       DEFM 'PE'
       DEFB 40
       DEFM 'P'
       DEFB 0
       DEFB 48
       DEFM 'M'
       DEFB 0
       DEFB 56
       DEFB 0
COPC:  LD   HL,(ADDS)
       LD   A,(DE)
       OR  A
       JP  Z,COP1
       LD  C,B
       CALL SEAR
       LD   A,(DE)
       RET Z
       INC DE
       JP  COPC
COP1:  INC A
       INC DE
       RET
OPCD:  LD  HL,ABUF
       LD   (ADDS),HL
       LD  DE,OTAB
       LD  B,4
       CALL COPC
       JP  Z,PSEU
       DEC B
       CALL COPC
       JP  Z,OP1
       INC B
       CALL COPC
OP1:   LD  HL,TYP1
OP2:   LD  C,1
       JP  Z,OCNT
OPC2:  CALL COPC
       LD  HL,TYP2
       JP  Z,OP2
       CALL COPC
       LD  HL,TYP3
       JP  Z,OP2
       DEC B
       CALL COPC
       LD  HL,TYP4
       JP  Z,OP2
OPC3:  CALL COPC
       LD  HL,TYP5
       LD  C,2
       JP  Z,OCNT
       INC B
       CALL COPC
       JP  Z,OP4
       CALL COND
       JP  NZ,OERR
       ADD A,192
       LD  D,A
       LD  B,3
       LD  A,(ABUF)
       LD  C,A
       CP  'R'
       LD  A,D
       JP  Z,OP1
       LD  A,C
       INC D
       INC D
       CP  'J'
       JP  Z,OPAD
       CP  'C'
       JP  NZ,OERR
       INC D
       INC D
OPAD:  LD  A,D
OP4:   LD  HL,TYP6
OP5:   LD  C,3
OCNT:  LD  (TEMP),A
       LD  A,ABUF.AND.00FFH
       ADD A,B
       LD  E,A
       LD  A,ABUF.SHR.8
       ADC A,0
       LD  D,A
       LD   A,(DE)
       OR  A
       JP  NZ,OERR
       LD  A,(PASI)
OCN1:  LD  B,0
       EX  DE,HL
OCN2:  LD  HL,(ASPC)
       ADD HL,BC
       LD  (ASPC),HL
       OR  A
       RET Z
       LD  A,(TEMP)
       EX  DE,HL
       JP   (HL)
OERR:  LD  HL,ERRO
       LD  C,3
       JP  OCN1-3
PSEU:  LD  HL,ABUF+4
       LD  A,(HL)
       OR  A
       JP  NZ,OERR
       LD  A,(PASI)
       OR  A
       JP  Z,PSU1
       JP  PSU2
SLAB:  CP  'A'
       RET C
       CP  'Z'+1
       CCF
       RET C
       CALL ALPS
       LD  HL,ABUF
       LD   (ADDS),HL
       DEC B
       JP  NZ,SLA1
       INC B
       LD  DE,RTAB
       CALL COPC
       JP  NZ,SLA1
       LD  L,A
       LD  H,0
       JP  SLA2
SLA1:  LD  A,(NOLA)
       LD  B,A
       LD  DE,SYMT
       OR  A
       JP  Z,SLA3
       LD  A,LLAB
       LD  (NCHR),A
       CALL COMS
SLA2:  SCF
       CCF
       RET
SLA3:  INC A
       OR  A
       RET
RTAB:  DEFM 'A'
       DEFB 7
       DEFM 'B'
       DEFB 0
       DEFM 'C'
       DEFB 1
       DEFM 'D'
       DEFB 2
       DEFM 'E'
       DEFB 3
       DEFM 'H'
       DEFB 4
       DEFM 'L'
       DEFB 5
       DEFM 'M'
       DEFB 6
       DEFB 0     ;END OF TABLE INDICATOR.
ALPS:  LD  B,0
ALP1:  LD  (DE),A
       INC B
       LD  A,B
       CP  11
       RET NC
       INC DE
       INC HL
       LD   (PNTR),HL
       LD  A,(HL)
       CP  '0'
       RET C
       CP  '9'+1
       JP  C,ALP1
       CP  'A'
       RET C
       CP  'Z'+1
       JP  C,ALP1
       RET
ASBL:  CALL SBLK
ASCN:  LD  HL,0
       LD  (OPRD),HL
       INC H
       LD  (OPRI-1),HL
NXT1:  LD  HL,(PNTR)
       DEC HL
       CALL ZBUF
       LD  (SIGN),A
NXT2:  INC HL
       LD  A,(HL)
       CP  ' '-1
       JP  C,SEND
       CP  ','
       JP  Z,SEND
       CP  '+'
       JP  Z,ASC1
       CP  '-'
       JP  NZ,ASC2
       LD  (SIGN),A
ASC1:  LD  A,(OPRI)
       CP  2
       JP  Z,ERRS
       LD  A,2
       LD  (OPRI),A
       JP  NXT2
ASC2:  LD  C,A
       LD  A,(OPRI)
       OR  A
       JP  Z,ERRS
       LD  A,C
       CP  '$'
       JP  NZ,ASC3
       INC HL
       LD   (PNTR),HL
       LD  HL,(ASPC)
       JP  AVAL
ASC3:  CP  ''''
       JP  NZ,ASC5
       LD  DE,0
       LD  C,3
ASC4:  INC HL
       LD   (PNTR),HL
       LD  A,(HL)
       CP  ASCR
       JP  Z,ERRA
       CP  ''''
       JP  NZ,SSTR
       INC HL
       LD   (PNTR),HL
       LD  A,(HL)
       CP  ''''
       JP  NZ,AVAL+1
SSTR:  DEC C
       JP  Z,ERRA
       LD  D,E
       LD  E,A
       JP  ASC4
ASC5:  CP  '0'
       JP  C,ERRA
       CP  '9'+1
       JP  NC,ALAB
       CALL NUMS
       JP  C,ERRA
AVAL:  EX  DE,HL
       LD  HL,(OPRD)
       XOR A
       LD  (OPRI),A
       LD  A,(SIGN)
       OR  A
       JP  NZ,ASUB
       ADD HL,DE
ASC7:  LD  (OPRD),HL
       JP  NXT1
ASUB:  LD  A,L
       SUB E
       LD  L,A
       LD  A,H
       SBC A,D
       LD  H,A
       JP  ASC7
ALAB:  CALL SLAB
       JP  Z,AVAL
       JP  C,ERRA
       JP  ERRU
SEND:  LD  A,(OPRI)
       OR  A
       JP  NZ,ERRS
       LD  HL,(OPRD)
SEN1:  LD  A,H
       LD  DE,TEMP
       OR  A
       RET
NUMS:  CALL ALPS
       DEC DE
       LD   A,(DE)
       LD  BC,ABUF
       CP  'H'
       JP  Z,NUM2
       CP  'D'
       JP  NZ,NUM1
       XOR A
       LD  (DE),A
NUM1:  CALL ADEC
       RET
NUM2:  XOR A
       LD  (DE),A
       CALL AHEX
       RET
ERRR:  LD  A,'R'
       LD  HL,0
       LD  (OBUF+18),A
       RET
ERRS:  LD  A,'S'
       LD  (OBUF+18),A
       LD  HL,0
       JP  SEN1
ERRU:  LD  A,'U'
       JP  ERRS+2
ERRV:  LD  A,'V'
       JP  ERRR+2
ERRM:  LD  A,'M'
       LD  (OBUF+18),A
       CALL AOU1
       RET
ERRA:  LD  A,'A'
       JP  ERRS+2
ERRO:  LD  A,'0'
       LD  (OBUF+18),A
       LD  A,(PASI)
       OR  A
       RET Z
       LD  C,3
ERO1:  XOR A
       CALL ASTO
       DEC C
       JP  NZ,ERO1
       RET
ERRL:  LD  A,'L'
       JP  ERRO+2
ERRD:  LD  A,'D'
       LD  (OBUF+18),A
       CALL AOU1
       JP  OPC
PATCH: INC HL
       JP  NZ,MOV23
       JP  P3
       ORG $+4H
USTA   EQU     0
UDAI   EQU     1
UDAO   EQU     1
PDAI   EQU     6
PADO   EQU     7
PDAO   EQU     8
PCTO   EQU     9
SWCH   EQU     0FFH
MAXFIL EQU     6
NMLEN  EQU     5
FELEN  EQU     NMLEN+8
FILEO: DEFS NMLEN
BOFP:  DEFS 2
EOFP:  DEFS 2
MAXL:  DEFS 4
FILTB: DEFS (MAXFIL-1)*FELEN
INSP:  DEFS 2
DELP   EQU     INSP
ASCR   EQU     13
HCON:  DEFS 2
ADDS   EQU     HCON
FBUF:  DEFS NMLEN
FREAD: DEFS 2
FEF:   DEFS 1
FOCNT: EQU     FEF
ABUF:  DEFS 12
BBUF:  DEFS 4
SCNT:  DEFS 1
DCNT:  DEFS 1
NCOM   EQU     10
TABA:  DEFS 2
ASPC:  DEFS 2
PASI:  DEFS 1
NCHR:  DEFS 1
PNTR:  DEFS 2
NOLA:  DEFS 1
SIGN:  DEFS 1
OPRD:  DEFS 2
OPRI:  DEFS 1
TEMP:  DEFS 1
APNT   EQU     INSP
AERR   EQU     SCNT
OIND:  DEFS 2
LLAB   EQU     5
AREA:  DEFS 18
OBUF:  DEFS 25
       DEFS 5
IBUF:  DEFS 83
SYMT   EQU     $
       END
