mach.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. */
  6. #ifndef NORCSID
  7. static char rcs_mach[] = "$Id$" ;
  8. static char rcs_h[] = RCS_H ;
  9. #endif
  10. /*
  11. * machine dependent back end routines for the Zilog Z80 (as well as Intel 8080)
  12. */
  13. con_part(sz,w) register sz; word w; {
  14. while (part_size % sz)
  15. part_size++;
  16. if (part_size == TEM_WSIZE)
  17. part_flush();
  18. if (sz == 1) {
  19. w &= 0xFF;
  20. if (part_size)
  21. w <<= 8;
  22. part_word |= w;
  23. } else {
  24. assert(sz == 2);
  25. part_word = w;
  26. }
  27. part_size += sz;
  28. }
  29. con_mult(sz) word sz; {
  30. long atol();
  31. if (argval != 4)
  32. fatal("bad icon/ucon size");
  33. fprintf(codefile, ".data4\t%ld\n", atol(str));
  34. }
  35. con_float() {
  36. static int been_here;
  37. int sz = argval;
  38. if (sz != 4 && sz != 8) {
  39. fatal("bad fcon size");
  40. }
  41. if (! been_here) {
  42. been_here = 1;
  43. fprintf(stderr,"warning: dummy floating constant(s)\n");
  44. }
  45. while (sz) {
  46. fprintf(codefile, ".data4 0 !dummy float\n");
  47. sz -= 4;
  48. }
  49. }
  50. prolog(nlocals) full nlocals; {
  51. fprintf(codefile,"\tpush\tiy\n\tld\thl,0\n\tadd\thl,sp\n\tpush\thl\n\tpop\tiy\n");
  52. switch (nlocals) {
  53. case 8: fprintf(codefile,"\tpush\thl\n");
  54. case 6: fprintf(codefile,"\tpush\thl\n");
  55. case 4: fprintf(codefile,"\tpush\thl\n");
  56. case 2: fprintf(codefile,"\tpush\thl\n");
  57. case 0: break;
  58. default:
  59. fprintf(codefile,"\tld\thl,%d\n\tadd\thl,sp\n\tld\tsp,hl\n",-nlocals);
  60. break;
  61. }
  62. }
  63. mes(type) word type ; {
  64. int argt ;
  65. switch ( (int)type ) {
  66. case ms_ext :
  67. for (;;) {
  68. switch ( argt=getarg(
  69. ptyp(sp_cend)|ptyp(sp_pnam)|sym_ptyp) ) {
  70. case sp_cend :
  71. return ;
  72. default:
  73. strarg(argt) ;
  74. fprintf(codefile,".define %s\n",argstr) ;
  75. break ;
  76. }
  77. }
  78. default :
  79. while ( getarg(any_ptyp) != sp_cend ) ;
  80. break ;
  81. }
  82. }
  83. char *segname[] = {
  84. ".sect .text",
  85. ".sect .data",
  86. ".sect .rom",
  87. ".sect .bss"
  88. };