em.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* $Header$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. /* EM CODE OUTPUT ROUTINES */
  7. #include "io.c"
  8. #include "em_private.h"
  9. /*
  10. The C_pt_*() functions serve as formatting functions of the
  11. various EM language constructs.
  12. See "Description of a Machine Architecture for use with
  13. Block Structured Languages" par. 11.2 for the meaning of these
  14. names.
  15. */
  16. C_magic()
  17. {
  18. }
  19. /*** the readable code generating routines ***/
  20. static
  21. wrs(s)
  22. register char *s;
  23. {
  24. while (*s) {
  25. C_putbyte(*s++);
  26. }
  27. }
  28. C_pt_dnam(s)
  29. char *s;
  30. {
  31. wrs(s);
  32. }
  33. C_pt_ilb(l)
  34. label l;
  35. {
  36. char buf[16];
  37. sprint(buf, "*%ld", (long) l);
  38. wrs(buf);
  39. }
  40. extern char em_mnem[][4];
  41. extern char em_pseu[][4];
  42. C_pt_op(x)
  43. {
  44. C_putbyte(' ');
  45. wrs(em_mnem[x - sp_fmnem]);
  46. C_putbyte(' ');
  47. }
  48. C_pt_cst(l)
  49. arith l;
  50. {
  51. char buf[16];
  52. sprint(buf, "%ld", (long) l);
  53. wrs(buf);
  54. }
  55. C_pt_scon(x, y)
  56. char *x;
  57. arith y;
  58. {
  59. char xbuf[1024];
  60. register char *p;
  61. char *bts2str();
  62. C_putbyte('\'');
  63. p = bts2str(x, (int) y, xbuf);
  64. while (*p) {
  65. if (*p == '\'') {
  66. C_putbyte('\\');
  67. }
  68. C_putbyte(*p++);
  69. }
  70. C_putbyte('\'');
  71. }
  72. C_pt_ps(x)
  73. {
  74. C_putbyte(' ');
  75. wrs(em_pseu[x - sp_fpseu]);
  76. C_putbyte(' ');
  77. }
  78. C_pt_dlb(l)
  79. label l;
  80. {
  81. char buf[16];
  82. sprint(buf, ".%ld", (long) l);
  83. wrs(buf);
  84. }
  85. C_pt_doff(l, v)
  86. label l;
  87. arith v;
  88. {
  89. char buf[16];
  90. C_pt_dlb(l);
  91. if (v != 0) {
  92. sprint(buf,"+%ld", (long) v);
  93. wrs(buf);
  94. }
  95. }
  96. C_pt_noff(s, v)
  97. char *s;
  98. arith v;
  99. {
  100. char buf[16];
  101. wrs(s);
  102. if (v != 0) {
  103. sprint(buf,"+%ld", (long) v);
  104. wrs(buf);
  105. }
  106. }
  107. C_pt_pnam(s)
  108. char *s;
  109. {
  110. C_putbyte('$');
  111. wrs(s);
  112. }
  113. C_pt_dfilb(l)
  114. label l;
  115. {
  116. char buf[16];
  117. sprint(buf, "%ld", (long) l);
  118. wrs(buf);
  119. }
  120. C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
  121. int sp;
  122. char *v;
  123. arith sz;
  124. {
  125. int ch = sp == sp_icon ? 'I' : sp == sp_ucon ? 'U' : 'F';
  126. wrs(v);
  127. C_putbyte(ch);
  128. C_pt_cst(sz);
  129. }
  130. C_pt_nl() { C_putbyte('\n'); }
  131. C_pt_comma() { C_putbyte(','); }
  132. C_pt_ccend() { C_putbyte('?'); }