*@200-10
*
**************
*    8080    *
*DISASSEMBLER*
**************
*
* PRODUCES PRINTED LISTING
* OF AN OBJECT PROGRAM IN
* STORAGE.
*
* OPTIONALLY WRITES A FILE
* INTO MEMORY, COMPATIBLE WITH
* THE PROCESSOR TECHNOLOGY PACKAGE |
* AND ALS-8 ASSEMBLER FILE FORMAT.
*
* GENERATING INSTRUCTIONS VERSUS DB'S
* IS SELECTED BY SENSE SWITCHES DURING
* THE EXECUTION OF THE DISASSEMBLER.
*
PSW   EQU  6
SP    EQU  6
*
* DEFINE KEYBOARD INPUT PORT ADDR
* (USED ONLY FOR CTL-X CHECK TO STOP
* WRITING FILE INTO MEMORY)
KEYB  EQU  1       KEYBOARD DATA INPUT PORT
*
* DEFINE ROUTINE TO TYPE ASCII CHAR IN A.
TYPE  EQU  409CH   ASCII OUTPUT ROUTINE
*
* DEFINE ADDRESS TO EXIT FROM DISASSEMBLER
SPVR  EQU  401FH   RETURN ADDR TO SUPERVISOR
*
* DEFINE A LOCATION WHICH CONTAINS THE ADDRESS
* OF WHERE THE FILE CAN BE BUILT IN MEMORY.
* (NOTE USERS OF PROC. TECH. PACKAGE 1 -
* THIS AREA IS ACTUALLY FILE+5, THE LOCATION
* AT WHICH THE START OF CURRENT FILE IS STORED)
FILE  EQU  3805H   ADDRESS OF ADDRESS OF FILE
*
* DEFINE A LOCATION WHICH CONTAINS THE ADDRESS
* OF WHERE THE DISASSEMBLY IS TO START
* (NOTE USERS OF PROC. TECH. PACKAGE 1 -
* THIS AREA IS ACTUALLY BBUF+2, THE LOCATION
* AT WHICH THE PARAMETER xxxx IS STORED WHEN
* YOU USE THE COMMAND 'EXEC wwww xxxx')
BBUF EQU 3868H	ADDR OF BINARY PARM BUFFER
*
* DEFINE LOCATION FOR SYMBOL TABLE (IF USED)
SYMTB EQU  0C002H  SYMBOL TABLE
*
* DEFIHE THE PAGE ADDRESS (I.E. HIGH 8 BITS OF
* THE ADDRESS) AT WHICH WRITING A FILE INTO
* MEMORY IS TO SHUT DOWN, TO PREVENT OVERLAYING
* OTHER PROGRAMS OR DATA.
HIFIL EQU  30H
*
*SEE ACCOMPANYING DOCUMENTATION FOR
*OPERATIONS AND PROGRAM LOGIC
*================================*
*===START OF PROGRAM EXECUTION===*
*================================*
START IN   -1      READ SSW
      ANI  4       BUILD SYM TABLE?
      JZ   NOSYM
      XRA  A       GET 0
      STA  SYMTB   INIT SYM TABLE
*---> START EXECUTION HERE IF YOU WANT
* TO KEEP PREV SYM TBL, SUCH AS TO ADD TO IT
NOSYM LHLD FILE    LOAD FILE START ADDR
      INX  H
      IN   -1      READ SSW
      ANI  80H	   FILE BEING BUILT?
      JZ   NOSTR   NO, SO DON'T SET END ADDR
      SHLD FILE+2  SET END OF FILE ADDR
NOSTR LHLD BBUF	   HL=START ADDR TO DISASM
DISAM CALL LINE	   DISASSEMBLE 1 LINE
      JMP  DISASM  LOOP UNTIL STOPPED
*
* ROUTINE TO PRINT A LINE OF DISASSEMBLY 
* N-O-T-E THAT THIS ROUTINE IS A
* SUBROUTINE, I.E. MAY BE CALLED
* FROM ANY PROGRAM, WITH HL POINTING
* TO AN INSTRUCTION TO BE DISASSEMBLED.
* THIS SUBROUTINE PRINTS THE LINE, C/R,
* THEN RETURNS, W/HL AT NEXT INSTR.
*
LINE  PUSH H	   SAVE INPUT POINTER
      LHLD FILE+2  LOAD START OF LINE POINTER 
      SHLD LINAD   SAVE
      POP H
      MOV A,H	   PRINT
      CALL XO	   ..THE
      MOV A,L	   ..ADDR
      CALL XOB	   ..IN HEX
*
* PRINT LABEL FROM TABLE IF SS08 ON
*
      MOV  B,H	   SET UP
      MOV  C,L	   ..FOR 'PRTLB' ROUTINE
      IN   -1
      ANI  1
      CNZ  PRTLB   PRINT LABEL
      MVI  A,' '   GET A SPACE
      CALL ZTYPE   PRINT AFTER LABEL
      IN   -1	   READ SSW
      ANI  20H	   SS A13 ON?
      JNZ  PRDB	   ..SAYS PRT DB'S
      PUSH H
      MOV  H,M	   OP CODE TO H
*
* DO TABLE LOOKUP
*
      LXI  B,OPTAB
ULP   LDAX B
      ORA  A	   END OF TABLE?
      JZ   PRDBP   YES, POP H, PRINT DB
      ANA  H	   AND OFF REGISTER BITS
      MOV  L,A	   SAVE REGISTERLESS INSTR.
      INX  B
      LDAX B       GET REGISTERLESS MATCH
      CMP  L	   SAME?
      JZ   FOUND   YEA!
      MOV  A,C	   ..BOO! NO MATCH
      ADI  6	   POINT TO NEXT OP ENTRY
      MOV  C,A
      JNC  ULP
      INR  B	   ..ADD CARRY O'FLO C TO B
      JMP  ULP
*@220-5
*
* OP CODE FOUND IN TABLE
* 
FOUND INX  B	   POINT TO TYPE
      LDAX B	   GET OP CODE TYPE (0-A)
      STA  TYFLG   SAVE INSTR TYPE
      PUSH D
*
* COMPUTE JMP TBL ADDR
*
      MOV  E,A	   MOVE TYPE TO E,
      MVI  D,0	   0 TO E
      LXI  H,JMTBL
      DAD  D	   ADD IN
      DAD  D	   ..3 * INSTR
      DAD  D	   ..TYPE
      POP  D
* PUT JMP TABLE ENTRY AT TOP OF
* STACK, RESTORE HL (PUSHED AT 'NOMOV')
      XTHL
      RET  ,	   ..TO JMP TABLE ENTRY
JMTBL EQU  $
*		  LEN OPERANDS EXAMPLE
      JMP  TYPE0   1  NONE     DAA, EI
      JMP  TYPE1   1  REG      ADD, ANA
      JMP  TYPE2   1  REG      INR, DCR
      JMP  TYPE3   1  XR       STAX, LDAX
      JMP  TYPE4   2  REG,DATA MVI (ONLY)
      JMP  TYPE5   2  DATA     OUT, CPI
      JMP  TYPE6   3  XR,DATA  LXI (ONLY)
      JMP  TYPE7   3  ADDR     LHLD, JMP
      JMP  TYPE8   3  ADDR     JZ, CNC
      JMP  TYPE9   1  NONE     RZ, RC
      JMP  TYPEA   1  RST #    RST (ONLY)
      JMP  TYPEB   1  REG,REG  MOV (ONLY)
*---------------------------*
*
* TYPE 0 - SINGLE BYTE, NO OPERANDS (DAA, RET)
*
TYPE0 CALL PROP	   PRINT OP, RELOAD OP CODE
IXHRT INX  H	   POINT TO NEXT CHAR
      JMP  RET	   END OF LINE
*
* TYPE 1 - 1 BYTE, REG IN .....XXX (ADD, ANA)
*
TYPE1 CALL PROP	   PRINT OP, RELOAD OP CODE
T1B   CALL REG	   PRINT REG
      JMP  IXHRT   INX H, PRINT C/R
*
* TYPE 2 - 1 BYTE, 1 REG IS ..XXX... (INR)
*
TYPE2 CALL PROP	   PRINT OP, RELOAD OP CODE
      CALL REGM	   PRINT REG IN ..XXX...
      JMP  IXHRT   INX H, C/R, RET
*
* TYPE 3 - 1 BYTE, XR IN ..XX.... (STAX)
*
TYPE3 CALL PROP	PRINT OP, RELOAD OP CODE
      CALL XR	   ..THEN XR
      JMP  IXHRT  INX H, C/R
*
* TYPE 4 - MVI (ONLY)
*
TYPE4 CALL PROP
      CALL REGM     PRINT REG IN ..XXX...
      CALL COMMA    ..A COMMA,
      JMP  T52	    ..THEN HEX BYTE
*
* TYPE 5 - 1 BYTE IMMEDIATE, (OUT, CPI)
*
TYPE5 CALL PROP
T52   INX  H	    POINT TO OPERAND
      MOV  A,M      GET IMMEDIATE OPERAND
      CALL X00	    ..OUTPUT
T54   MVI  A,'H'    H FOR HEX
      CALL ZTYPE
      MOV  A,M      RELOAD CHAR
      INX  H
      PUSH B
      MOV  B,A
      IN   -1
      ANI  10H	    SS Al2 ON SAYS
      MOV  A,B
      POP  B
      JZ   RET	    ..TO PRINT ASCII
      CPI  ' '
      JC   RET      UNPRINTABLE
      CPI  'Z'+1
      JNC  RET      UNPRINTABLE
*
* OUTPUT CHAR IN A, IN QUOTES
* IF INSTR IS AN IMMEDIATE INSTR
*
      LDA  TYFLG    GET TYPE FLAG
      CPI  4
      JC   RET	    IF TYPE 0-3
      CPI  6
      JNC  RET	    IF TYPE 6-A
      DCX  H	    BACK UP
      MOV  A,M	    GET CHAR
      INX  H	    RESTORE H
QCHAR PUSH PSW
      CALL OQ	    OUTPUT QUOTE, CHAR
      POP  PSW
      MVI  A,''''
      CALL ZTYPE   TYPE CLOSING QUOTE
      JMP  RET	   END OF LINE
*
* TYPE 6 - LXI (ONLY)
*
TYPE6 CALL PROP
      MOV A,M
      CALL XR
      CALL COMMA
      JMP  TYP6H   ALWAYS PRINT HEX FOR LXI
*
* PRINT 2 BYTE HEX OPERAND
*
PRT2X CALL SYMBO   PRINT FR TBL IF SS10 ON
      JC   RET
TYP6H INX  H
      MOV  B,M	   SAVE FIRST CHAR
      INX  H
      MOV  A,M	   GET 2ND CHAR
      CALL X00	   OUTPUT IT FIRST
      MOV  A,B	   GET FIRST CHAR
      CALL XO	   THEN OUTPUT IT
      JMP  T54
*@240-4
*
* TYPE 7 — 2 BYTE ADDR OPERAND (LHLD, JMP)
*
TYPE7 CALL PROP	   PRT OP CODE, RELOAD OP
*** GO DO TABLE LOOKUP OF OPERAND
*** (RET'S CARRY OFF IF NOT USING TABLE)
      CALL SYMBO   PRINT IF In TABLE
      JC   RET	   LABEL CAME FROM TABLE
*** IF SS11 ON, PRINT Lxxxx IF OFF, OxxxxH 
      IN   -1	   READ SSW
      ANI  8
      JZ   PRT2X   PRINT AS HEX
      MVI  A,'L'   LABEL PREFIX
      CALL ZTYPE
      INX  H
      MOV  B,M	   FIRST BYTE
      INX  H
      MOV  A,M	   SECOND BYTE
      CALL XO	   OUTPUT 2ND FIRST
      MOV  A,B	   GET 1ST
      CALL XO	   ..THEN OUTPUT IT
      INX  H
      JMP  RET	   C/R
*
* TYPE 8 — CONDITIONAL JUMP OR CALL 
*
TYPE8 INX  B	   POINT TO OP CODE
      LDAX B	   GET 'J' OR 'C'
      STA  CC1	   STORE IT
      CALL GETCC   GET COND CODE
      JMP  TYPE7   THEN PRINT OPERAND
*
* TYPE 9 — CONDITIONAL RETURN
*
TYPES MVI  A,'R'
      STA  CC1	   INIT OP CODE
      CALL GETCC   GET CONDITION
      JMP  TYPE0   PRINT OP CODE, C/R
*
* TYPE A — RST (ONLY)
*
TYPEA CALL PROP	   PRT OP CODE, RELOAD OP
      RAR
      RAR
      RAR
      ANI  7        ISOLATE RST NUMBER
      ORI  '0'      MAKE PRINTABLE
      CALL ZTYPE    PRINT IT
      JMP  IXHRT    INX H, PRINT C/R
*
* TYPE B - MOV (ONLY)
*
TYPEB CALL PROP	    PRT OP CODE, RELOAD OP
      CALL REGM	    PRINT -XXX... REG
      CALL COMMA    PRINT COMMA
      MOV A,M	    RELOAD OP
      JMP T1B	    PRINT REG, C/R
*
*    --------------------------
*   | DISASSEMBLER SUBROUTINES |
*    --------------------------
*
* PRINT COMMA
*
COMMA MVI  A,','
      JMP  ZTYPE
*
* PRINT DB
*
PRDBP POP  H
PRDB  MVI  A,'D'
      CALL ZTYPE
      MVI  A,'B'
      CALL ZTYPE
      MVI  A,' '
      CALL ZTYPE
      DCX  H 
      IN  -1 
      ANI  30H
      CPI  30H	   SSW A13, Al2 ON?
      JNZ  T52
      INX  H	   YES - PRINT ASCII
      MOV  A,M
      DCX  H
      CPI  ' '
      JC   T52     UNPRINTABLE
      CPI  'Z'+1
      JNC  T52     UNPRINTABLE
      INX  H
      INX  H
      JMP  QCHAR   PRINT QUOTED CHAR
*
* PRINT CONDITION CODE
*
GETCC MOV  A,M	   GET CONDITION CODE
      RAR
      RAR
      ANI 0EH	   ISOLATE COND. CODE
      PUSH H
      LXI  H,CCTAB POINT TO CC TABLE
      CALL ADD     ADD A TO HL
      MOV  A,M
      STA  CC1+1
      INX  H
      MOV  A,M
      STA  CC1+2
      POP  H
      LXI  B,CC1-1
      MVI A,' '	   GET SPACE
      STA CCB	   SAVE AS ' ' AFTER OP CODE
      RET
CCTAB DW   'ZN'	CONDITION CODE TABLE
      DW   'Z'
      DW   'CN'
      DW   ' C'
      DW   'OP'
      DW   'EP'
      DW   ' P'
      DW   ' M'
*
* HEX CONVERSION ROUTINES
*
HEXL  RAR  GET	   LEFT DIGIT
      RAR
      RAR
      RAR
HEXR  ANI  0FH	   GET RIGHT DIGIT
      CPI  10
      JC   HEXRN
      ADI  7	   FUDGE ALPHA HEX
HEXRN ADI  '0'	   MAKE PRINTABLE
      RET
*
* HEX OUTPUT ROUTINE
*
X0    PUSH 6	   SAVE
      CALL HEXL	   GET LEFT NIBBLE
      CALL ZTYPE   PRINT IT
      POP  6	   RESTORE
      CALL HEXR	   GET RIGHT NIBBLE
      JMP  ZTYPE   PRINT IT, RETURN
*
* HEX OUTPUT FOLLOWED BY A BLANK
*
X0BB  CALL X0
      MVI  A,' '
      JMP  ZTYPE
*@260-5
*
* OUTPUT SPACE, QUOTE, CHAR IN A, RETURN
*
OQ    PUSH PSW
      MVI  A,' '
      CALL ZTYPE 
      MVI  Z,''''
      CALL ZTYPE 
      POP  PSW
      JMP  ZTYPE
*
* OUTPUT CHAR IN A, THEN CLOSING QUOTE
*
CQ    CALL ZTYPE
      MVI  A,''''
      JMP  ZTYPE
*
* PRINT 4 BYTE OP CODE FROM TABLE
*
PROP  PUSH 0
      MVI  D,4     OP CODE LENGTH
PROPL INX  B	   OP CODE PTR
      LDAX B	   GET OP CHAR
      CALL ZTYPE   PRINT IT
      DCR  D	   DONE?
      JNZ  PROPL   ..NO
      LDAX B	   SPACE IF
      CPI  ' '     ..LAST CHAR
      MVI  A,' '   ..OP CODE WAS
      CNZ  ZTYPE   ..NOT A SPACE
      POP  D
      MOV  A,M	   RETURN WITH OP
      RET  ,	   CODE IN A
*
* PRINT XR IN BITS ..XXX...
*
XR    RAR  ,       MOVE ..XXX...
      RAR  ,	   ..REGISTER
      RAR  ,       ..TO .....XXX
      ANI  6	   ISOLATE XR VALUE
      CPI  6	   IS IS 6?
      JNZ REG      ..NO
* PRINT 6 FOR PSW OR SP
      MVI  A,'6'   GET A 6,
      JMP  ZTYPE   PRINT IT
*
*PRINT REG IN BITS ..XXX...
*
REGM  rAR  ,	   RIGHT
      RAR  ,	   ..ADJUST
      RAR
*
* PRINT REG IN BITS 	XXX
*
REG   PUSH H
      LXI  H,RTAB  POINT HL TO REG TABLE
      ANI  7	   ISOLATE REG
      CALL ADD	   ADD REG # TO H,L
      MOV  A,M	   GET ASCII REG
      POP  H
      JMP  ZTYPE
*
* ROUTINE TO ADD (A) TO (HL)
*
ADD   ADD  L	   ADD IN A,
      MOV  L,A	   MOVE BACK
      RNC  ,	   RET IF NO CARRY TO H
      INR  H	   ADD CARRY TO H
      RET
*
* REGISTER TABLE
*
RTAB  DW   'CB'
      DW   'ED'
      DW   'LH'
      DN   'AM'
*
* HEX OUTPUT W/ LEADING 0 IF REDID
*
X00   CPI  0A0H
      JC   X0
      PUSH PSW
      MVI  A,'0'
      CALL ZTYPE
      POP  PSW
      JMP  X0
*
* CARRIAGE RETURN ROUTINE
RET   MVI  A,13	   GET C/R, FALL INTO ZTYPE
*
* OUTPUT ROUTINE - LOOKS AT
* SENSE SWITCH AlS TO DETERMINE
* IF A FILE IS BEING BUILT, OR IF
* ONLY A PRINTED LISTING IS DONE.
*
ZTYPE PUSH B
      MOV  B,A
      IN   -1
      RAL
      MOV  A,B
      POP  B
      JNC  TYPE	   IF SS15 IS OFF
*
* SS 15 ON - STORE IN FILE
*
      PUSH H
      LHLD FILE+2  CURR FILE PTR
      MOV  M,A	   SAVE CHAR
      INX  H	   POINT TO NEXT
      SHLD FILE+2  SAVE PTR BACK
      PUSH 6
      CALL TYPE	   TYPE CHAR
      POP  6
      POP  H
*
* IF END OF LINE, UPDATE LINE LENGTH
*
      CPI  13
      RNZ
      PUSH H
*
* COMPUTE LINE LENGTH BY SUBTRACTING
* END OF LINE (STORED IN FILE+2) FROM START
* OF LINE (STORED IN 'LINAD')
*
      LHLD LINAD   GET COUNT
      SHLD LINUM   SAVE ADDR OF LINE
      DCX  H
      MOV  A,H     COMPLEMENT IT,
      CMA  A	   MOVING IT TO 0,E
      MOV  D,A 
      MOV  A,L 
      CMA  A
      MOV  E,A
      INX  D	   TURN 1'S COMPLEMENT INTO 2'S
      LHLD FILE+2
      DAD  D
      MOV  A,L	   GET COMPUTED LINE LENGTH
      LHLD LINAD
      DCX  H
      MOV  M,A
      LHLD FILE+2
      SHLD LINAD INX H
      SHLD FILE+2
      MOV  A,H
*
* HAVE WE RUN OUT OF MEMORY?
*
      CPI  HIFIL
      POP  H
      JNZ  CKX     NO - CHECK CTL-X TO END
*
* END OF FILE
*
END   LHLD FILE+2  GET END OF PROG ADDR
      DCX  H	   BACK UP TO START OF LINE
      MVI  M,1	   STICK EOF CHAR IN MEMORY
      SHLD FILE+2  SAVE UPDATED PTR
*
*MOVE HIGH LINE NUMBER TO FILE TABLE
*
      LHLD LINUM   GET LINE 0 ADDRESS
      MVI  8,4	   4 BYTE LINE #
      LXI  D,FILE+4 HI LINE NUMBER PTR
MOVLN MOV  A,14    GET DIGIT OF LINE NO.
      STAX D	   SAVE IN TABLE
      INX  H
      INX  D
      DCR  B       DONE?
      JNZ  MOVLN   NO
      JMP  SPVR	   <---------- ONLY EXIT FROM PROG
*
* CHECK CONTROL-X TO ABORT
* STORING OF FILE IN MEMORY
*
CKX   IN   KEYB	   <--------- NOTE INPUT
      ANI  7FH	   DELETE PARITY
      CPI  'X'-40H (CIL X)
      RNZ
      JNP  END	   END IF CTL-X TYPED
*@280-2
*
* SYMBO - ROUTINE TO BUILD AND ACCESS THE SYMBOL TABLE
*         SS10 ON - BUILD SYMBOL TABLE
*         SS08 OH - PRINT LABELS FROM SYMBOL TABLE
*
SYMBO IN   -1	   READ SSW
      ANI  5	   EITHER BUILD OR USE REDQD?
      RZ   ,	   NO - HAVE PROGRAM USE DEFAULT LABEL
      ANI  1	   REQ TO USE TABLE?
      JNZ  FRMTB   YES. USE FROM TABLE
*** BUILD LABEL PHASE ***
      CALL SYBLD   PUT ENTRY IN TABLE
      ORA  A	   ENSURE NO CARRY
      RET  ,	   ..THEN RETURN (PGM USE DFLT LBL)
*
* PROGRAM REQUEST TO OUTPUT LABEL
* BASED ON OPERAND POINTED TO BY H,L
FRMTB INX H	   POINT TO OPERAND
      MOV C,M	   GET III BYTE
      INX  H	   POINT TO NEXT BYTE
      MOV  B,H	   GET LO BYTE
      INX  H	   POINT TO NEXT INSTR
      CALL PRTLB   PRINT LBL IF IN TBL
      RC   ,	   RETURN IF PRINTED
      DCX  H	   BACK UP FOR PROG
      DCX  H	   ..TO PRINT LABEL
      DCX  H	   ..BECAUSE WASN'T IN TABLE
      ORA  A	   TURN OFF CARRY
      RET
PRTLB CALL LOOKU   FIND IT
      CMC   ,	   CARRY OFF IF NOT FOUND
      RNC   ,	   RETURN IF NO LABEL FOUND
*
* LABEL FOUND IN SYMBOL TABLE - PRINT IT
*
      MVI  B,5	   MAX LBL LENGTH
SYPLP LDAX D
      INX  D
      ORA  A
      STC  ,	   SO PGM WON'T PRT DFLT LBL
      RZ   ,	   RET IF END OF SHORT LABEL
      CALL ZTYPE   TYPE CHAR
      DCR  B
      STC	   SO PGM WON'T PRT LBL
      RZ   ,	   RET IF ENO OF 5 CHAR LABEL
      JMP  SYPLP   LOOP PRINTING
*
* SYMBOL TABLE BUILD
*
SYBLD INX  H	   BUMP TO OPERAND
      MOV  C,M     LO BYTE
      INX  H
      MOV  B,M	   HI BYTE
      DCX  H	   RESTORE
      DCX  H	   ..HL TO ORIG VALUE
      CALL LOOKU   ALREADY IN TABLE?
      RNC  ,       ..IF ALREADY IN TABLE
*
* ADD NEW ENTRY TO SYMBOL TABLE
* B,C CONTAINS ENTRY
* D,E POINTS TO OPEN SYMBOL TABLE ENTRY •
*
      MVI  A,'L'   DEFAULT TO LABEL 'LXXXX'
      STAX D      
      INX  D
      MOV  A,B     GET HI ORDER
      CALL SYSTX   STORE PRINTABLE HEX
      MOV  A,C     GET LO
      CALL SYSTX   STORE IT
      MOV  A,B     GET HI
      STAX D       STORE IN TABLE
      INX  D
      MOV  A,C     GET LOW
      STAX D       STORE IN TABLE
      XRA  A       GET A XERO, STORE IT
      INX  D       AT START OF NEXT LABEL
      STAX D       TO SHOW END OF TABLE
      STC  ,       SET CARRY SO PROGRAM
      RET  ,       ..WILL PRINT DEFAULT LABEL
*
* ROUTINE TO STORE LABEL IN SYMBOL TABLE
*
SYSTX PUSH PSW
      CALL HEXL    CONV LEFT NIBBLE
      STAX D       ..TO PRINTABLE, AND STORE
      POP  PSW     RESTORE VALUE
      CALL HEXR    CONY RIGHT NIBBLE TO PRINTABLE
      STAX D       SAVE IT
      INX  D       POINT TO NEXT
      RET
*
* SYMBOL TABLE LOOKUP ROUTINE
* B,C = HEX SYMBOL TO FIND
* D,E RETURN POINTING TO SYMBOL
* H,L RESTORED
* IF NOT FOUND, CARRY SET, AND
* D,E POINTS TO OPEN LOCATION
*
LOOKU LXI  D,SYMTB POINT TO SYMBOL TABLE
LULP  LDAX D	   GET PRINTABLE LABEL
      ORA  A	   IS IT ZERO?
      STC  ,	   SET CARRY AND
      RZ   ,       ..RETURN IF NOT FOUND
*** NON BLAB K ENTRY FOUND. DOES IT HATCH? ***
      INX  D       SKIP
      INX  D       ..ASCII
      INX  D       ..LABEL
      INX  D       ..VALUE
      INX  D
      LDAX D
      CMP  B       MATCH?
      INX  D
      JNZ  LUNO    NO MATCH
*** HI MATCHED, CHECK LO ***
      LDAX D
      CMP  C
      JNZ  LUNO	   NO MATCH
*** ENTRY FOUND ***
      DCX  D	   BACK
      DCX  D	   UP
      DCX  D	   TO
      DCX  D	   ASCII
      DCX  D	   PART
      DCX  D	   OF LABEL
      ORA  D	   ENSURE NO CARRY
      RET  ,	   NO CARRY IMPLIES FOUND
*** ENTRY DIDN'T MATCH - POINT TO NEXT ***
LUNO  INX  D	   POINT TO START OF NEXT
      JMP  LULP	   LOOP BACK
*@2A0-3
*
OPTAB DB   -1
      DW   0
      DW   'ON'
      DW   ' P'
      DB   -1
      DW   7
      DW   'LR'
      DW   ' C'
      DB   -1
      DW   OFH
      DW   'RR'
      DW   ' C'
      DB   -1
      DW   17H
      DW   'AR'
      DW   ' L'
      DB   -1
      DW   OEBH
      DW   'CX'
      DW   'GH'
      DB   -1
      DW   1FH
      DW   'AR'
      DW   ' R'
      DB   -1
      DW   722H
      DW   'HS'
      DW   'DL'
      DB   -1
      DW   27H
      DW   'AD'
      DW   ' A'
      DB   -1
      DW   72AH
      DW   'HL'
      DW   'DL'
      DB   -1
      DW   2FH
      DW   'MC'
      DW   ' A'
      DB   -1
      DW   732H
      DW   'TS'
      DW   ' A'
      DB   -1
      DW   37H
      DW   'TS'
      DW   ' C'
      DB   -1
      DW   73AH
      DW   'DL'
      DW   ' A'
      DB   -1
      DW   3FH
      DW   'MC'
      DW   ' C'
      DB   -1
      DW   76H
      DW   'LH'    HLT PRECEEDS MOV TO
      DW   ' T'    PREVENT 'MOV M,M'
      DB   0C0H
      DW   0B40H
      DW   'OM'
      DW   ' V'
      DB   -1
      DW   7C3H
      DW   'MJ'
      DW   ' P'
      DB   -1
      DW   0C9H
      DW   'ER'
      DW   ' T'
      DB   -1
      DW   7CDH
      DW   'AC'
      DW   'LL'
      DB   -1
      DW   5D3H
      DW   'UO'
      DW   ' T'
      DB   -1
      DW   5DBH
      DW   'NI'
      DW   '  '
      DB   -1
      DW   0E3H
      DW   'TX'
      DW   'LH'
      DB   -1
      DW   0E9H
      DW   'CP'
      DW   'LH'
      DB   -1
      DW   OF3H
      DW   'ID'
      DW   '  '
      DB   -1
      DW   0FBH
      DW   'IE'
      DW   '  '
      DB   -1
      DW   0F9H
      DW   'PS'
      DW   'LH'
      DB    -1
      DW   5C6H
      DW   'DA'
      DW   ' I'
      DB   -1
      DW   5CEH
      DW   'CA'
      DW   ' I'
      DB   -1
      DW   5D6H
      DW   'US'
      DW   ' I'
      DB   -1
      DW   5DEH
      DW   'BS'
      DW   ' I'
      DB   -1
      DW   5E6H
      DW   'NA'
      DW   ' I'
      DB   -1
      DW   5EEH
      DW   'RX'
      DW   ' I'
      DB   -1
      DW   5F6H
      DW   'RO'
      DW   ' I'
      DB   -1
      DW   5FEH
      DW   'PC'
      DW   ' I'
      DB   -8
      DW   180H
      DW   'DA'
      DW   ' D'
      DB   -8
      DW   188H
      DW   'DA'
      DW   ' C'
      DB   190H
      DW   'US'
      DW   ' B'
      DW   -8
      DB   1A0H
      DW   'NA'
      DW   ' A'
      DW   -8
      DB   1B0H
      DW   'RO'
      DW   ' A'
      DW   -8
      DB   1B8H
      DW   'MC'
      DW   ' P'
      DW   0C7H
      DB   204H
      DW   'NI'
      DW   ' R'
      DW   0C7H
      DB   205H
      DW   'CD'
      DW   ' R'
      DW   0EFH
      DB   302H
      DW   'TS'
      DW   'XA'
      DB   0EFH
      DW   30AH
      DW   'LD'
      DW   'XA'
      DB   0CFH
      DW   3C1H
      DW   'OP'
      DW   ' P'
      DB   0CFH
      DW   3C5H
      DW   'UP'
      DW   'HS'
      DB   0C7H
      DW   406H
      DW   'VM'
      DW   ' I'
      DB   0CFH
      DW   303H
      DW   'NI'
      DW   ' X'
      DB   0CFH
      DW   309H
      DW   'AD'
      DW   ' D'
      DB   0CFH
      DW   30BH
      DW   'CD'
      DW   ' X'
      DB   0C7H
      DW   8C2H
      DW   '.J'
      DW   '..'
      DB   0C7H
      DW   8C4H
      DW   '.C'
      DW   '..'
      DB   0CFH
      DW   601H
      DW   'XL'
      DW   ' I'
      DB   0C7H
      DW   9C0H
      DW   '.R'
      DW   '..'
      DB   0C7H
      DW   0AC7H
      DW   'SR'
      DW   ' T'
      DB   0       (END OF TABLE)
*----------WORK AREA----------*
* NOTE: DISASSEMBLER IS ROM-ABLE
* (= PROTECTABLE) IF THIS AREA
* IS MOVED TO READ-WRITE MEHORY.

LINAD DS   2       ADDR OF START OF CUR LINE
LINUM DS   2       ADDR OF CUR LINE'S LINE #
TYFLG DS   1       OP CODE TYPE
CC1   DS   3       CONDITION STORED HERE
CCB   DS   1       BLANK FOLLOWING COND CODE
