mkbytes.red 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. % Create bytes.h out of opcodes.red
  2. symbolic;
  3. global '(s!:opcodelist);
  4. off lower;
  5. in "../cslbase/opcodes.red"$
  6. on lower;
  7. begin
  8. scalar o, oo, n;
  9. o := open("../cslbase/bytes.h", 'output);
  10. oo := wrs o;
  11. printc "/* bytes.h Copyright (C) Codemist 1993-99 */";
  12. terpri();
  13. printc "/* Signature: 38cd8141 31-Mar-1993 */";
  14. terpri();
  15. printc "/*";
  16. printc " * Bytecode interpreter support.";
  17. printc " *";
  18. printc " * April 1993";
  19. printc " */";
  20. terpri();
  21. printc "#define JUMP_BACK 0x01 /* select direction of jump */";
  22. printc "#define JUMP_LONG 0x02 /* select 16 vs 8 bit offset */";
  23. terpri();
  24. n := 0;
  25. for each v in s!:opcodelist do <<
  26. princ "#define OP_";
  27. princ v;
  28. ttab 32;
  29. princ "0x";
  30. if n < 16 then princ "0";
  31. prinhex n;
  32. terpri();
  33. n := n + 1 >>;
  34. terpri();
  35. printc "/* end of bytes.h */";
  36. terpri();
  37. wrs oo;
  38. close o;
  39. o := open("../cslbase/opnames.c", 'output);
  40. oo := wrs o;
  41. printc "/* opnames.c Copyright (C) Codemist 1993-99 */";
  42. terpri();
  43. printc "/* Signature: 38cd8141 31-Mar-1993 */";
  44. terpri();
  45. terpri();
  46. printc "static char *opnames[256] =";
  47. printc "{";
  48. n := 0;
  49. for each v in s!:opcodelist do <<
  50. princ " "; princ '!";
  51. princ v; princ '!";
  52. princ ",";
  53. ttab 32;
  54. princ "/* 0x";
  55. if n < 16 then princ "0";
  56. prinhex n;
  57. printc " */";
  58. n := n + 1 >>;
  59. while n < 256 do <<
  60. princ " "; princ '!"; princ "xxxx"; princ '!";
  61. if n neq 255 then princ ",";
  62. ttab 32;
  63. princ "/* 0x";
  64. if n < 16 then princ "0";
  65. prinhex n;
  66. printc " */";
  67. n := n + 1 >>;
  68. printc "};";
  69. terpri();
  70. wrs oo;
  71. close o;
  72. return "bytes.h and opcodes.c made"
  73. end;
  74. bye;