mach.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. #ifndef NORCSID
  6. static char rcsid[] = "$Id$" ;
  7. #endif
  8. con_part(sz, w)
  9. register int sz;
  10. word w;
  11. {
  12. while (part_size % sz) part_size++;
  13. if (part_size == TEM_WSIZE)
  14. part_flush();
  15. if (sz == 1 || sz == 2) {
  16. w &= (sz == 1 ? 0xFF : 0xFFFF);
  17. w <<= 8 * part_size;
  18. part_word |= w;
  19. } else {
  20. assert(sz == 4);
  21. part_word = w;
  22. }
  23. part_size += sz;
  24. }
  25. con_mult(sz)
  26. word sz;
  27. {
  28. if (sz != 4)
  29. fatal("bad icon/ucon size");
  30. fprintf(codefile,".data4\t%s\n",str);
  31. }
  32. #ifdef REGVARS
  33. full lbytes;
  34. struct regadm {
  35. char *ra_str;
  36. long ra_off;
  37. } regadm[4];
  38. int n_regvars;
  39. regscore(off,size,typ,score,totyp) long off; {
  40. /*This function is copied from pdp/ncg
  41. */
  42. /*
  43. * This function is full of magic constants.
  44. * They are a result of experimentation.
  45. */
  46. if (size != 2)
  47. return(-1);
  48. score -= 1; /* allow for save/restore */
  49. if (off>=0)
  50. score -= 2;
  51. if (typ==reg_pointer)
  52. score *= 17;
  53. else if (typ==reg_loop)
  54. score = 10*score+50; /* Guestimate */
  55. else
  56. score *= 10;
  57. return(score); /* 10 * estimated # of words of profit */
  58. }
  59. i_regsave() {
  60. n_regvars=0;
  61. }
  62. f_regsave(){
  63. register i;
  64. register int c = ' ';
  65. fprintf(codefile, "enter [");
  66. for (i=0; i<n_regvars; i++) {
  67. fprintf(codefile,"%c%s", c, regadm[i].ra_str);
  68. c = ',';
  69. }
  70. fprintf(codefile, "], %ld\n", lbytes);
  71. for (i=0;i<n_regvars;i++)
  72. if (regadm[i].ra_off>=0)
  73. fprintf(codefile, "movd %ld(fp), %s",
  74. regadm[i].ra_off, regadm[i].ra_str);
  75. }
  76. regsave(regstr,off,size) char *regstr; long off; {
  77. fprintf(codefile,"\t! Local %ld into %s\n",off,regstr);
  78. regadm[n_regvars].ra_str = regstr;
  79. regadm[n_regvars].ra_off = off;
  80. n_regvars++;
  81. }
  82. regreturn() {
  83. register int i;
  84. register int c = ' ';
  85. fprintf(codefile, "exit [");
  86. for (i=1; i<n_regvars; i++) {
  87. fprintf(codefile,"%c%s", c, regadm[i].ra_str);
  88. c = ',';
  89. }
  90. fprintf(codefile, "]\n");
  91. }
  92. #endif
  93. mes(type) word type ; {
  94. int argt ;
  95. switch ( (int)type ) {
  96. case ms_ext :
  97. for (;;) {
  98. switch ( argt=getarg(
  99. ptyp(sp_cend)|ptyp(sp_pnam)|sym_ptyp) ) {
  100. case sp_cend :
  101. return ;
  102. default:
  103. strarg(argt) ;
  104. fprintf(codefile,".define %s\n",argstr) ;
  105. break ;
  106. }
  107. }
  108. default :
  109. while ( getarg(any_ptyp) != sp_cend ) ;
  110. break ;
  111. }
  112. }
  113. prolog(nlocals) full nlocals; {
  114. #ifndef REGVARS
  115. fprintf(codefile, "enter[], %ld\n",nlocals);
  116. #else
  117. lbytes = nlocals;
  118. #endif
  119. }
  120. char *segname[] = {
  121. ".sect .text",
  122. ".sect .data",
  123. ".sect .rom",
  124. ".sect .bss"
  125. };
  126. con_float() {
  127. static int warning_given;
  128. int i;
  129. if (! warning_given) {
  130. fprintf(stderr, "warning: dummy floating point constant\n");
  131. warning_given = 1;
  132. }
  133. for (i = argval; i > 0; i -= 4) {
  134. fputs(".data4 0 ! dummy float\n", codefile);
  135. }
  136. }