         Edinburgh IMP77 Compiler - Version 8.4

    1  ! reconstituted from intexts
    2  
    3  %EXTERNALROUTINE RECODE(%INTEGER S, TO, BASE)
    4  %CONSTINTEGERARRAY OPCODES(0 : 255) =    %C
    5+      0(4),
    6+ M'SPM ',M'BALR',M'BCTR',M'BCR ',M'SSK ',M'ISK ',M'SVC ',     0(5),
    7+ M'LPR ',
    8+ M'LNR ',M'LTR ',M'LCR ',M'NR  ',M'CLR ',M'OR  ',M'XR  ',M'LR  ',
    9+ M'CR  ',
   10+ M'AR  ',M'SR  ',M'MR  ',M'DR  ',M'ALR ',M'SLR ',M'LPDR',M'LNDR',
   11+ M'LTDR',
   12+ M'LCDR',M'HDR ',M'LRDR',M'MXR ',M'MXDR',M'LDR ',M'CDR ',M'ADR ',M'SDR ',
   13+ M'MDR ',
   14+ M'DDR ',M'AWR ',M'SWR ',M'LPER',M'LNER',M'LTER',M'LCER',M'HER ',M'LRER',
   15+ M'AXR ',
   16+ M'SXR ',M'LER ',M'CER ',M'AER ',M'SER ',M'MER ',M'DER ',M'AUR ',M'SUR ',
   17+ M'STH ',
   18+ M'LA  ',M'STC ',M'IC  ',M'EX  ',M'BAL ',M'BCT ',M'BC  ',M'LH  ',M'CH  ',
   19+ M'AH  ',
   20+ M'SH  ',M'MH  ',     0,
   21+ M'CVD ',
   22+ M'CVB ',M'ST  ',     0(3),M'N   ',M'CL  ',M'O   ',
   23+ M'X   ',
   24+ M'L   ',M'C   ',M'A   ',M'S   ',M'M   ',M'D   ',M'AL  ',M'SL  ',M'STD ',
   25+      0(6),
   26+ M'MXD ',
   27+ M'LD  ',M'CD  ',M'AD  ',M'SD  ',M'MD  ',M'DD  ',M'AW  ',M'SW  ',
   28+ M'STE ',
   29+      0(7),
   30+ M'LE  ',
   31+ M'CE  ',M'AE  ',M'SE  ',M'ME  ',M'DE  ',M'AU  ',M'SU  ',
   32+ M'SSM',
   33+      0,M'LPSW',M'DIAG',M'WRD ',M'RDD ',M'BXH ',M'BXLE',M'SRL ',M'SLL ',
   34+ M'SRA ',
   35+ M'SLA ',M'SRDL',M'SLDL',M'SRDA',M'SLDA',M'STM ',M'TM  ',M'MVI ',
   36+ M'TS  ',
   37+ M'NI  ',M'CLI ',M'OI  ',M'XI  ',M'LM  ',     0(3),
   38+ M'SIO ',
   39+ M'TIO ',M'HIO ',
   40+ M'TCH ',
   41+      0(49),
   42+ M'MVN ',
   43+ M'MVC ',M'MVZ ',M'NC  ',M'CLC ',M'OC  ',M'XC  ',     0(4),
   44+ M'TR  ',
   45+ M'TRT ',M'ED  ',M'EDMK',     0(17),M'MVO ',M'PACK',M'UNPK',     0(4),
   46+ M'ZAP ',
   47+ M'CP  ',M'AP  ',M'SP  ',M'MP  ',M'DP  ',     0,     0
   48  %INTEGER J, K, L, M
   49  %INTEGER T
   50  %ROUTINESPEC HEX(%INTEGER N)
   51  %ROUTINESPEC HEX8(%INTEGER N)
   52  %ROUTINESPEC PUT(%INTEGER S, C)
   53  
   54  !printstring("RECODE(X'"); HEX8(S)
   55  !printstring("', X'"); HEX8(TO)
   56  !printstring("', X'"); HEX8(BASE)
   57  !printstring("')".snl)
   58            S = S&(\1)
   59  BASE = BASE-S
   60  L1:        NEWLINE
   61            NEWLINE %AND %RETURN %IF S >= TO
   62  PRINT STRING("C ")
   63            HEX8(BASE+S)
   64            SPACES(4)
   65            J = SHORTINTEGER(S);  S = S+2
   66            M = J>>8&255
   67            T = OPCODES(M)
   68            HEX(J)
   69            -> L1 %IF T = 0
   70            %IF M>>6 = 0 %THEN %START;    ! RR
   71               PUT(12,T)
   72               WRITE(J>>4&15,4)
   73               print symbol(',')
   74               WRITE(J&15,2)
   75               -> L1
   76            %FINISH
   77            K = SHORTINTEGER(S);  S = S+2
   78            HEX(K)
   79            %IF M>>6 = 1 %THEN %START;    !  RX
   80               PUT(8,T)
   81               WRITE(J>>4&15,4);  print symbol(',')
   82               WRITE(K&X'FFF',4);  print symbol('(')
   83               WRITE(J&15,2);  print symbol(',')
   84  L3:           WRITE(K>>12&15,2);  print symbol(')')
   85               -> L1
   86            %FINISH
   87            %IF M&X'F8' = X'88' %THEN %START
   88               PUT(8,T)
   89               WRITE(J>>4&15,4);  print symbol(',')
   90  L2:           WRITE(K&X'FFF',4);  print symbol('(')
   91               -> L3
   92            %FINISH
   93            %IF M > 192 %THEN %START
   94               L = SHORTINTEGER(S);  S = S+2
   95               HEX(L)
   96               PUT(4,T)
   97               WRITE(K&X'FFF',5);  print symbol('(')
   98               %IF M>>4&15 # 15 %THEN WRITE(J&255+1,2) %C
   99+                 %ELSE WRITE(J>>4&15,2)
  100               print symbol(',')
  101               WRITE(K>>12&15,2);  print symbol(')');  print symbol(',')
  102               WRITE(L&X'FFF',4);  print symbol('(')
  103               %IF M>>4&15 = 15 %THEN %START
  104                  WRITE(J&15,2);  print symbol(',')
  105               %FINISH
  106               WRITE(L>>12&15,2);  print symbol(')')
  107               -> L1
  108            %FINISH
  109            %IF M = 134 %OR M = 135 %OR M = 144 %OR M = 152 %THEN %START
  110               PUT(8,T)
  111               WRITE(J>>4&15,4);  print symbol(',')
  112               WRITE(J&15,2);  print symbol(',')
  113               -> L2
  114            %FINISH
  115            PUT(8,T)
  116            WRITE(K&X'FFF',5);  print symbol('(')
  117            WRITE(K>>12&15,2);  print symbol(')')
  118            print symbol(',')
  119            WRITE(J&255,2)
  120            -> L1
  121  
  122  %ROUTINE HEX(%INTEGER N)
  123  %CONSTBYTEINTEGERARRAY XSYM(0 : 15) = %C
  124+    '0', '1', '2', '3',
  125+    '4', '5', '6', '7',
  126+    '8', '9', 'A', 'B',
  127+    'C', 'D', 'E', 'F'
  128  %INTEGER J, S
  129            %CYCLE J = 1,1,4; !8
  130               S = (N>>12)&15; !S = N>>28
  131               N = N<<4
  132               PRINTSYMBOL(XSYM(S))
  133            %REPEAT
  134  %END
  135  
  136  %ROUTINE HEX8(%INTEGER N)
  137  %CONSTBYTEINTEGERARRAY XSYM(0 : 15) = %C
  138+    '0', '1', '2', '3',
  139+    '4', '5', '6', '7',
  140+    '8', '9', 'A', 'B',
  141+    'C', 'D', 'E', 'F'
  142  %INTEGER J, S
  143            %CYCLE J = 1,1,8
  144               S = (N>>28)&15
  145               N = N<<4
  146               PRINTSYMBOL(XSYM(S))
  147            %REPEAT
  148  %END
  149  
  150  %ROUTINE PUT(%INTEGER SP, SYMS)
  151  %INTEGER I
  152           SPACES(SP)
  153           %CYCLE I = 1,1,4
  154              PRINT SYMBOL(SYMS>>24&127); SYMS = SYMS << 8
  155           %REPEAT
  156  %END
  157  
  158  %END
  159  
  160  %begin
  161  %end
  162  
  163  %ENDOFFILE

  118 Statements compiled
