dec20-asm.red 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. % 20-ASM.RED - Dec-20 specific information for LAP-TO-ASM
  2. %
  3. % Author: Eric Benson
  4. % Symbolic Computation Group
  5. % Computer Science Dept.
  6. % University of Utah
  7. % Date: 5 January 1982
  8. % Copyright (c) 1982 University of Utah
  9. %
  10. % <PSL.20-COMP>20-ASM.RED.1, 25-Feb-82 16:46:44, Edit by BENSON
  11. % Converted from VAX version
  12. fluid '(CodeFileNameFormat!*
  13. DataFileNameFormat!*
  14. InputSymFile!*
  15. OutputSymFile!*
  16. CommentFormat!*
  17. LabelFormat!*
  18. ExternalDeclarationFormat!*
  19. ExportedDeclarationFormat!*
  20. FullWordFormat!*
  21. DoubleFloatFormat!*
  22. ReserveZeroBlockFormat!*
  23. ReserveDataBlockFormat!*
  24. DefinedFunctionCellFormat!*
  25. UndefinedFunctionCellInstructions!*
  26. MainEntryPointName!*
  27. !*MainFound
  28. CodeOut!*
  29. DataOut!*
  30. !*Lower
  31. ASMOpenParen!*
  32. ASMCloseParen!*
  33. NumericRegisterNames!*);
  34. CodeFileNameFormat!* := "%w.mac";
  35. DataFileNameFormat!* := "d%w.mac";
  36. InputSymFile!* := "20.sym";
  37. OutputSymFile!* := "20.sym";
  38. GlobalDataFileName!* := "global-data.red"$
  39. MainEntryPointName!* := 'MAIN!.;
  40. NumericRegisterNames!* := '[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15];
  41. CommentFormat!* := "; %p%n";
  42. LabelFormat!* := "%w:";
  43. ExternalDeclarationFormat!* := " extern %w%n";
  44. ExportedDeclarationFormat!* := " intern %w%n";
  45. FullWordFormat!* := " %e%n"; % FullWord expects %e for parameter
  46. DoubleFloatFormat!* := " %w%n 0%n";
  47. ReserveZeroBlockFormat!* := "%w: block %e%n";
  48. ReserveDataBlockFormat!* := " block %e%n";
  49. DefinedFunctionCellFormat!* := " jrst %w##%n";
  50. UndefinedFunctionCellInstructions!* :=
  51. '((jsp (reg t5) (Entry UndefinedFunction)));
  52. ASMOpenParen!* := '!<;
  53. ASMCloseParen!* := '!>;
  54. DefList('((LAnd !&)
  55. (LOr !!)
  56. (LXor !^!!)
  57. (LSH !_)), 'BinaryASMOp);
  58. put('LNot, 'UnaryASMOp, '!^!-);
  59. DefList('((t1 6)
  60. (t2 7)
  61. (t3 8)
  62. (t4 9)
  63. (t5 10)
  64. (t6 11)
  65. (nil 0)
  66. (st 15)), 'RegisterName);
  67. put('MkItem, 'ASMExpressionFormat, "<%e_31>+%e");
  68. lisp procedure CodeFileHeader();
  69. CodePrintF " search monsym%n radix 10%n";
  70. lisp procedure DataFileHeader();
  71. DataPrintF " radix 10%n";
  72. lisp procedure CodeFileTrailer();
  73. CodePrintF(if !*MainFound then " end MAIN.%n" else " end%n");
  74. lisp procedure DataFileTrailer();
  75. DataPrintF " end%n";
  76. lisp procedure CodeBlockHeader();
  77. NIL;
  78. lisp procedure CodeBlockTrailer();
  79. NIL;
  80. lisp procedure DataAlignFullWord();
  81. NIL;
  82. lisp procedure PrintString S;
  83. begin scalar N;
  84. N := Size S;
  85. PrintF " byte(7)";
  86. for I := 0 step 1 until N do
  87. << PrintExpression Indx(S, I);
  88. Prin2 '!, >>;
  89. PrintExpression 0;
  90. TerPri();
  91. end;
  92. lisp procedure PrintByteList L;
  93. if null L then NIL else
  94. << PrintF " byte(7)";
  95. while cdr L do
  96. << PrintExpression car L;
  97. Prin2 '!,;
  98. L := cdr L >>;
  99. PrintExpression car L;
  100. TerPri() >>;
  101. lisp procedure PrintByte X;
  102. << PrintF " byte(7)";
  103. PrintExpression X;
  104. TerPri() >>;
  105. lisp procedure PrintHalfWordList L;
  106. if null L then NIL else
  107. << PrintF " byte(18)";
  108. while cdr L do
  109. << PrintExpression car L;
  110. Prin2 '!,;
  111. L := cdr L >>;
  112. PrintExpression car L;
  113. TerPri() >>;
  114. lisp procedure PrintOpcode X;
  115. Prin2 X;
  116. lisp procedure SpecialActionForMainEntryPoint();
  117. CodePrintF " intern MAIN.%nMAIN.:";
  118. lisp procedure ASMSymbolP X;
  119. Radix50SymbolP(if IDP X then ID2String X else X);
  120. lisp procedure Radix50SymbolP X;
  121. begin scalar N, C, I;
  122. N := Size X;
  123. if N > 5 then return NIL;
  124. C := Indx(X, 0);
  125. if not (C >= char A and C <= char Z
  126. or C = char !% or C = char !. or C = char !$) then return NIL;
  127. I := 1;
  128. Loop:
  129. if I > N then return T;
  130. C := Indx(X, I);
  131. if not (C >= char A and C <= char Z
  132. or C >= char !0 and C <= char !9
  133. or C = char !% or C = char !. or C = char !$) then return NIL;
  134. I := I + 1;
  135. goto Loop;
  136. end;
  137. lisp procedure PrintNumericOperand X;
  138. if ImmediateP X then Prin2 X else PrintF("[%w]", X);
  139. lisp procedure OperandPrintIndirect X;
  140. << Prin2 '!@;
  141. PrintOperand cadr X >>;
  142. put('Indirect, 'OperandPrintFunction, 'OperandPrintIndirect);
  143. lisp procedure OperandPrintIndexed X;
  144. << X := cdr X;
  145. PrintExpression cadr X;
  146. Prin2 '!(;
  147. PrintOperand car X;
  148. Prin2 '!) >>;
  149. put('Indexed, 'OperandPrintFunction, 'OperandPrintIndexed);
  150. macro procedure Immediate X; % immediate does nothing on the 20
  151. cadr X;
  152. lisp procedure ASMPseudoFieldPointer U;
  153. %
  154. % (FieldPointer Operand StartingBit Length)
  155. %
  156. << U := cdr U;
  157. Prin2 "point ";
  158. PrintExpression third U;
  159. Prin2 '!, ;
  160. PrintOperand first U;
  161. Prin2 '!, ;
  162. PrintExpression list('difference, list('plus2, second U, third U), 1) >>;
  163. put('FieldPointer, 'ASMExpressionFunction, 'ASMPseudoFieldPointer);
  164. procedure MCPrint(x); % Echo of MC's
  165. CodePrintF("; %p%n",x);
  166. procedure InstructionPrint(x);
  167. CodePrintF( "; %p%n",x);
  168. procedure !*cerror x;
  169. begin scalar i;
  170. i:=wrs Nil;
  171. printf( "%n *** CERROR: %r %n ",x);
  172. wrs i;
  173. return list list('cerror,x);
  174. end;
  175. put('cerror,'asmpseudoop,'printcomment);
  176. DefCmacro !*cerror;
  177. END;