home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cc-61.0.1 / cc / config / tm-att386.h < prev    next >
C/C++ Source or Header  |  1991-06-03  |  7KB  |  233 lines

  1. /* Definitions for AT&T assembler syntax for the Intel 80386.
  2.    Copyright (C) 1988 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. #define TARGET_VERSION fprintf (stderr, " (80386, ATT syntax)");
  22.  
  23. /* Define the syntax of instructions and addresses.  */
  24.  
  25. /* Define some concatenation macros to concatenate an opcode
  26.    and one, two or three operands.  In other assembler syntaxes
  27.    they may alter the order of ther operands.  */
  28.  
  29. #ifdef __STDC__
  30. #define AS2(a,b,c) #a " " #b "," #c
  31. #define AS3(a,b,c,d) #a " " #b "," #c "," #d
  32. #define AS1(a,b) #a " " #b
  33. #else
  34. #define AS1(a,b) "a b"
  35. #define AS2(a,b,c) "a b,c"
  36. #define AS3(a,b,c,d) "a b,c,d"
  37. #endif  
  38.  
  39. /* Output the size-letter for an opcode.
  40.    CODE is the letter used in an operand spec (L, B, W, S or Q).
  41.    CH is the corresponding lower case letter
  42.      (except if CODE is L then CH is `l').  */
  43. #define PUT_OP_SIZE(CODE,CH,FILE) putc (CH,(FILE))
  44.  
  45. /* Opcode suffix for fullword insn.  */
  46. #define L_SIZE "l"
  47.  
  48. /* Prefix for register names in this syntax.  */
  49. #define RP "%"
  50.  
  51. /* Prefix for immediate operands in this syntax.  */
  52. #define IP "$"
  53.  
  54. /* Prefix for internally generated assembler labels.  */
  55. #define LPREFIX ".L"
  56.  
  57. /* Output the prefix for an immediate operand, or for an offset operand.  */
  58. #define PRINT_IMMED_PREFIX(FILE)  fputs ("$", (FILE))
  59. #define PRINT_OFFSET_PREFIX(FILE)  fputs ("$", (FILE))
  60.  
  61. /* Indirect call instructions should use `*'.  */
  62. #define USE_STAR 1
  63.  
  64. /* Prefix for a memory-operand X.  */
  65. #define PRINT_PTR(X, FILE)
  66.  
  67. /* Delimiters that surround base reg and index reg.  */
  68. #define ADDR_BEG(FILE) putc('(', (FILE))
  69. #define ADDR_END(FILE) putc(')', (FILE))
  70.  
  71. /* Print an index register (whose rtx is IREG).  */
  72. #define PRINT_IREG(FILE,IREG) \
  73.   do                                \
  74.   { fputs (",", (FILE)); PRINT_REG ((IREG), 0, (FILE)); }    \
  75.   while (0)
  76.   
  77. /* Print an index scale factor SCALE.  */
  78. #define PRINT_SCALE(FILE,SCALE) \
  79.   if ((SCALE) != 1) fprintf ((FILE), ",%d", (SCALE))
  80.  
  81. /* Print a base/index combination.
  82.    BREG is the base reg rtx, IREG is the index reg rtx,
  83.    and SCALE is the index scale factor (an integer).  */
  84.  
  85. #define PRINT_B_I_S(BREG,IREG,SCALE,FILE) \
  86.   { ADDR_BEG (FILE);                 \
  87.     if (BREG) PRINT_REG ((BREG), 0, (FILE));    \
  88.     if ((IREG) != 0)                \
  89.       { PRINT_IREG ((FILE), (IREG));        \
  90.         PRINT_SCALE ((FILE), (SCALE)); }    \
  91.     ADDR_END (FILE); }
  92.  
  93. /* Define the syntax of pseudo-ops, labels and comments.  */
  94.  
  95. /* Assembler pseudos to introduce constants of various size.  */
  96.  
  97. #define ASM_BYTE_OP "\t.byte "
  98. #define ASM_SHORT "\t.value "
  99. #define ASM_LONG "\t.long "
  100. #define ASM_DOUBLE "\t.double "
  101.  
  102. /* String containing the assembler's comment-starter.  */
  103.  
  104. #define ASM_COMMENT_START "/"
  105. #define COMMENT_BEGIN "/"
  106.  
  107. /* Output at beginning of assembler file.  */
  108. /* The .file command should always begin the output.  */
  109.  
  110. #undef ASM_FILE_START
  111. #define ASM_FILE_START(FILE)                    \
  112.   do { output_file_directive ((FILE), main_input_filename);    \
  113.        if (optimize) ASM_FILE_START_1 (FILE);            \
  114.      } while (0)
  115.  
  116. #define ASM_FILE_START_1(FILE) fprintf (FILE, "\t.optim\n")
  117.  
  118. /* Output to assembler file text saying following lines
  119.    may contain character constants, extra white space, comments, etc.  */
  120.  
  121. #define ASM_APP_ON "/APP\n"
  122.  
  123. /* Output to assembler file text saying following lines
  124.    no longer contain unusual constructs.  */
  125.  
  126. #define ASM_APP_OFF "/NO_APP\n"
  127.  
  128. /* This is how to output an assembler line
  129.    that says to advance the location counter
  130.    to a multiple of 2**LOG bytes.  */
  131.  
  132. #define ASM_OUTPUT_ALIGN(FILE,LOG)    \
  133.     if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
  134.  
  135. /* This is how to output an assembler line
  136.    that says to advance the location counter by SIZE bytes.  */
  137.  
  138. #define ASM_OUTPUT_SKIP(FILE,SIZE)  \
  139.   fprintf ((FILE), "\t.set .,.+%u\n", (SIZE))
  140.  
  141. /* Can't use ASM_OUTPUT_SKIP in text section; it doesn't leave 0s.  */
  142.  
  143. #define ASM_NO_SKIP_IN_TEXT 1
  144.  
  145. /* Output before read-only data.  */
  146.  
  147. #define TEXT_SECTION_ASM_OP ".text"
  148.  
  149. /* Output before writable data.  */
  150.  
  151. #define DATA_SECTION_ASM_OP ".data"
  152.  
  153. /* Output before uninitialized data.  */
  154.  
  155. #define BSS_SECTION_ASM_OP ".bss"
  156.  
  157. #define EXTRA_SECTIONS in_bss
  158.  
  159. #define EXTRA_SECTION_FUNCTIONS                    \
  160. void                                \
  161. bss_section ()                            \
  162. {                                \
  163.   if (in_section != in_bss)                    \
  164.     {                                \
  165.       fprintf (asm_out_file, "%s\n", BSS_SECTION_ASM_OP);    \
  166.       in_section = in_bss;                    \
  167.     }                                \
  168. }
  169.  
  170. /* Define the syntax of labels and symbol definitions/declarations.  */
  171.  
  172. /* This says how to output an assembler line
  173.    to define a global common symbol.  */
  174. /* We don't use ROUNDED because the standard compiler doesn't,
  175.    and the linker gives error messages if a common symbol
  176.    has more than one length value.  */
  177.  
  178. #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)  \
  179. ( fputs (".comm ", (FILE)),            \
  180.   assemble_name ((FILE), (NAME)),        \
  181.   fprintf ((FILE), ",%u\n", (SIZE)))
  182.  
  183. /* This says how to output an assembler line
  184.    to define a local common symbol.  */
  185.  
  186. /* Note that using bss_section here caused errors
  187.    in building shared libraries on system V.3.  */
  188. #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)    \
  189.   do {                            \
  190.     int align = exact_log2 (ROUNDED);            \
  191.     if (align > 2) align = 2;                \
  192.     data_section ();                    \
  193.     ASM_OUTPUT_ALIGN ((FILE), align == -1 ? 2 : align);    \
  194.     ASM_OUTPUT_LABEL ((FILE), (NAME));            \
  195.     fprintf ((FILE), "\t.set .,.+%u\n", (ROUNDED));    \
  196.   } while (0)
  197.  
  198. /* This is how to store into the string BUF
  199.    the symbol_ref name of an internal numbered label where
  200.    PREFIX is the class of label and NUM is the number within the class.
  201.    This is suitable for output with `assemble_name'.  */
  202.  
  203. #define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER)    \
  204.   sprintf ((BUF), ".%s%d", (PREFIX), (NUMBER))
  205.  
  206. /* This is how to output a reference to a user-level label named NAME.  */
  207.  
  208. #define ASM_OUTPUT_LABELREF(FILE,NAME)    \
  209.   fprintf (FILE, "%s", NAME)
  210.  
  211. /* This is how to output an internal numbered label where
  212.    PREFIX is the class of label and NUM is the number within the class.  */
  213.  
  214. #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)    \
  215.   fprintf (FILE, ".%s%d:\n", PREFIX, NUM)
  216.  
  217. /* This is how to output a command to make the user-level label named NAME
  218.    defined for reference from other files.  */
  219.  
  220. #define ASM_GLOBALIZE_LABEL(FILE,NAME)    \
  221.   (fputs (".globl ", FILE), assemble_name (FILE, NAME), fputs ("\n", FILE))
  222.  
  223. /* How to output an ASCII string constant.  */
  224.  
  225. #define ASM_OUTPUT_ASCII(FILE, p, size) \
  226. { int i=0;                         \
  227.   while (i < size)                    \
  228.     { if (i%10 == 0) { if (i!=0) fprintf (FILE, "\n");    \
  229.                fprintf (FILE, ASM_BYTE_OP); }    \
  230.       else fprintf (FILE, ",");                \
  231.     fprintf (FILE, "0x%x",(p[i++] & 0377)) ;}    \
  232.       fprintf (FILE, "\n"); }
  233.