1 /* tc-z8k.c -- Assemble code for the Zilog Z800n
2 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001, 2002, 2003,
3 2005 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
22 /* Written By Steve Chamberlain <sac@cygnus.com>. */
29 #include "safe-ctype.h"
30 #include "opcodes/z8k-opc.h"
32 const char comment_chars[] = "!";
33 const char line_comment_chars[] = "#";
34 const char line_separator_chars[] = ";";
37 extern int coff_flags;
40 /* This is non-zero if target was set from the command line. */
41 static int z8k_target_from_cmdline;
49 machine = bfd_mach_z8001;
55 machine = bfd_mach_z8002;
61 even (int ignore ATTRIBUTE_UNUSED)
64 record_alignment (now_seg, 1);
78 sval (int ignore ATTRIBUTE_UNUSED)
81 if (*input_line_pointer == '\'')
85 c = *input_line_pointer++;
90 c = (tohex (input_line_pointer[0]) << 4)
91 | tohex (input_line_pointer[1]);
92 input_line_pointer += 2;
94 FRAG_APPEND_1_CHAR (c);
95 c = *input_line_pointer++;
97 demand_empty_rest_of_line ();
101 /* This table describes all the machine specific pseudo-ops the assembler
102 has to support. The fields are:
103 pseudo-op name without dot
104 function to call to execute this pseudo-op
105 Integer arg to pass to the function
108 const pseudo_typeS md_pseudo_table[] = {
110 {"data.b" , cons , 1},
111 {"data.w" , cons , 2},
112 {"data.l" , cons , 4},
113 {"form" , listing_psize , 0},
114 {"heading", listing_title , 0},
115 {"import" , s_ignore , 0},
116 {"page" , listing_eject , 0},
117 {"program", s_ignore , 0},
118 {"z8001" , s_segm , 1},
119 {"z8002" , s_segm , 0},
121 {"segm" , s_segm , 1},
122 {"unsegm" , s_segm , 0},
123 {"unseg" , s_segm , 0},
124 {"name" , s_app_file , 0},
125 {"global" , s_globl , 0},
130 {"rsect" , obj_coff_section, 0},
131 {"sect" , obj_coff_section, 0},
132 {"block" , s_space , 0},
137 const char EXP_CHARS[] = "eE";
139 /* Chars that mean this number is a floating point constant.
142 const char FLT_CHARS[] = "rRsSfFdDxXpP";
144 /* Opcode mnemonics. */
145 static struct hash_control *opcode_hash_control;
150 const opcode_entry_type *opcode;
153 opcode_hash_control = hash_new ();
155 for (opcode = z8k_table; opcode->name; opcode++)
157 /* Only enter unique codes into the table. */
158 if (idx != opcode->idx)
159 hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
163 /* Default to z8002. */
164 if (! z8k_target_from_cmdline)
167 /* Insert the pseudo ops, too. */
168 for (idx = 0; md_pseudo_table[idx].poc_name; idx++)
170 opcode_entry_type *fake_opcode;
171 fake_opcode = (opcode_entry_type *) malloc (sizeof (opcode_entry_type));
172 fake_opcode->name = md_pseudo_table[idx].poc_name;
173 fake_opcode->func = (void *) (md_pseudo_table + idx);
174 fake_opcode->opcode = 250;
175 hash_insert (opcode_hash_control, fake_opcode->name, fake_opcode);
179 typedef struct z8k_op {
188 /* Any other register associated with the mode. */
191 /* Any expression. */
195 static expressionS *da_operand;
196 static expressionS *imm_operand;
201 static int the_flags;
202 static int the_interrupt;
205 whatreg (unsigned int *reg, char *src)
207 if (ISDIGIT (src[1]))
209 *reg = (src[0] - '0') * 10 + src[1] - '0';
214 *reg = (src[0] - '0');
225 WREG r0,r1,r2,r3,r4,r5,r6,r7,fp,sp
233 /* Try to parse a reg name. Return a pointer to the first character
234 in SRC after the reg name. */
237 parse_reg (char *src, int *mode, unsigned int *reg)
242 /* Check for stack pointer "sp" alias. */
243 if ((src[0] == 's' || src[0] == 'S')
244 && (src[1] == 'p' || src[1] == 'P')
245 && (src[2] == 0 || src[2] == ','))
249 *mode = CLASS_REG_LONG;
254 *mode = CLASS_REG_WORD;
260 if (src[0] == 'r' || src[0] == 'R')
262 if (src[1] == 'r' || src[1] == 'R')
264 if (src[2] < '0' || src[2] > '9')
265 return res; /* Assume no register name but a label starting with 'rr'. */
266 *mode = CLASS_REG_LONG;
267 res = whatreg (reg, src + 2);
270 as_bad (_("register rr%d out of range"), regno);
272 as_bad (_("register rr%d does not exist"), regno);
274 else if (src[1] == 'h' || src[1] == 'H')
276 if (src[2] < '0' || src[2] > '9')
277 return res; /* Assume no register name but a label starting with 'rh'. */
278 *mode = CLASS_REG_BYTE;
279 res = whatreg (reg, src + 2);
282 as_bad (_("register rh%d out of range"), regno);
284 else if (src[1] == 'l' || src[1] == 'L')
286 if (src[2] < '0' || src[2] > '9')
287 return res; /* Assume no register name but a label starting with 'rl'. */
288 *mode = CLASS_REG_BYTE;
289 res = whatreg (reg, src + 2);
292 as_bad (_("register rl%d out of range"), regno);
295 else if (src[1] == 'q' || src[1] == 'Q')
297 if (src[2] < '0' || src[2] > '9')
298 return res; /* Assume no register name but a label starting with 'rq'. */
299 *mode = CLASS_REG_QUAD;
300 res = whatreg (reg, src + 2);
303 as_bad (_("register rq%d out of range"), regno);
305 as_bad (_("register rq%d does not exist"), regno);
309 if (src[1] < '0' || src[1] > '9')
310 return res; /* Assume no register name but a label starting with 'r'. */
311 *mode = CLASS_REG_WORD;
312 res = whatreg (reg, src + 1);
315 as_bad (_("register r%d out of range"), regno);
322 parse_exp (char *s, expressionS *op)
324 char *save = input_line_pointer;
327 input_line_pointer = s;
329 if (op->X_op == O_absent)
330 as_bad (_("missing operand"));
331 new = input_line_pointer;
332 input_line_pointer = save;
336 /* The many forms of operand:
351 checkfor (char *ptr, char what)
356 as_bad (_("expected %c"), what);
361 /* Make sure the mode supplied is the size of a word. */
364 regword (int mode, char *string)
371 as_bad (_("register is wrong size for a word %s"), string);
375 /* Make sure the mode supplied is the size of an address. */
378 regaddr (int mode, char *string)
382 ok = segmented_mode ? CLASS_REG_LONG : CLASS_REG_WORD;
385 as_bad (_("register is wrong size for address %s"), string);
394 static struct ctrl_names ctrl_table[] = {
395 { 0x1, "flags" }, /* ldctlb only. */
396 { 0x2, "fcw" }, /* ldctl only. Applies to all remaining control registers. */
408 get_ctrl_operand (char **ptr, struct z8k_op *mode, unsigned int dst ATTRIBUTE_UNUSED)
416 mode->mode = CLASS_CTRL;
417 for (i = 0; ctrl_table[i].name; i++)
419 l = strlen (ctrl_table[i].name);
420 if (! strncasecmp (ctrl_table[i].name, src, l))
422 the_ctrl = ctrl_table[i].value;
423 if (*(src + l) && *(src + l) != ',')
425 *ptr = src + l; /* Valid control name found: "consume" it. */
437 static struct flag_names flag_table[] = {
449 get_flags_operand (char **ptr, struct z8k_op *mode, unsigned int dst ATTRIBUTE_UNUSED)
459 mode->mode = CLASS_FLAGS;
461 for (j = 0; j <= 9; j++)
466 for (i = 0; flag_table[i].name; i++)
468 if (flag_table[i].name[0] == c)
470 the_flags = the_flags | flag_table[i].value;
482 struct interrupt_names {
487 static struct interrupt_names intr_table[] = {
496 get_interrupt_operand (char **ptr, struct z8k_op *mode, unsigned int dst ATTRIBUTE_UNUSED)
504 mode->mode = CLASS_IMM;
509 for (i = 0; intr_table[i].name; i++)
511 l = strlen (intr_table[i].name);
512 if (! strncasecmp (intr_table[i].name, src, l))
514 the_interrupt |= intr_table[i].value;
515 if (*(src + l) && *(src + l) != ',')
519 as_bad (_("unknown interrupt %s"), src);
520 while (**ptr && ! is_end_of_line[(unsigned char) **ptr])
521 (*ptr)++; /* Consume rest of line. */
541 /* No interrupt type specified, opcode won't do anything. */
542 as_warn (_("opcode has no effect"));
551 static struct cc_names table[] = {
586 get_cc_operand (char **ptr, struct z8k_op *mode, unsigned int dst ATTRIBUTE_UNUSED)
594 mode->mode = CLASS_CC;
595 for (i = 0; table[i].name; i++)
597 l = strlen (table[i].name);
598 if (! strncasecmp (table[i].name, src, l))
600 the_cc = table[i].value;
601 if (*(src + l) && *(src + l) != ',')
603 *ptr = src + l; /* Valid cc found: "consume" it. */
607 the_cc = 0x8; /* Not recognizing the cc defaults to t. (Assuming no cc present.) */
611 get_operand (char **ptr, struct z8k_op *mode, unsigned int dst ATTRIBUTE_UNUSED)
622 mode->mode = CLASS_IMM;
623 imm_operand = &(mode->exp);
624 src = parse_exp (src + 1, &(mode->exp));
626 else if (*src == '@')
628 mode->mode = CLASS_IR;
629 src = parse_reg (src + 1, &mode->regsize, &mode->reg);
635 end = parse_reg (src, &mode->mode, ®n);
646 end = parse_reg (src, &nw, &nr);
653 as_bad (_("Missing ) in ra(rb)"));
657 regaddr (mode->mode, "ra(rb) ra");
658 mode->mode = CLASS_BX;
668 src = parse_exp (src, &(mode->exp));
669 src = checkfor (src, ')');
670 mode->mode = CLASS_BA;
673 imm_operand = &(mode->exp);
684 /* No initial reg. */
685 src = parse_exp (src, &(mode->exp));
689 end = parse_reg (src, &(mode->mode), ®n);
690 regword (mode->mode, "addr(Ra) ra");
691 mode->mode = CLASS_X;
694 da_operand = &(mode->exp);
695 src = checkfor (end, ')');
699 /* Just an address. */
700 mode->mode = CLASS_DA;
703 da_operand = &(mode->exp);
711 get_operands (const opcode_entry_type *opcode, char *op_end, op_type *operand)
716 switch (opcode->noperands)
726 if (opcode->arg_info[0] == CLASS_CC)
728 get_cc_operand (&ptr, operand + 0, 0);
731 if (*ptr && ! is_end_of_line[(unsigned char) *ptr])
733 as_bad (_("invalid condition code '%s'"), ptr);
734 while (*ptr && ! is_end_of_line[(unsigned char) *ptr])
735 ptr++; /* Consume rest of line. */
738 else if (opcode->arg_info[0] == CLASS_FLAGS)
740 get_flags_operand (&ptr, operand + 0, 0);
743 if (*ptr && ! is_end_of_line[(unsigned char) *ptr])
745 as_bad (_("invalid flag '%s'"), ptr);
746 while (*ptr && ! is_end_of_line[(unsigned char) *ptr])
747 ptr++; /* Consume rest of line. */
750 else if (opcode->arg_info[0] == (CLASS_IMM + (ARG_IMM2)))
751 get_interrupt_operand (&ptr, operand + 0, 0);
753 get_operand (&ptr, operand + 0, 0);
760 if (opcode->arg_info[0] == CLASS_CC)
762 get_cc_operand (&ptr, operand + 0, 0);
765 if (*ptr != ',' && strchr (ptr + 1, ','))
772 as_bad (_("invalid condition code '%s'"), savptr);
775 else if (opcode->arg_info[0] == CLASS_CTRL)
777 get_ctrl_operand (&ptr, operand + 0, 0);
782 get_operand (&ptr, operand + 0, 0);
788 get_ctrl_operand (&ptr, operand + 1, 1);
795 get_operand (&ptr, operand + 0, 0);
801 get_operand (&ptr, operand + 1, 1);
805 get_operand (&ptr, operand + 0, 0);
808 get_operand (&ptr, operand + 1, 1);
811 get_operand (&ptr, operand + 2, 2);
815 get_operand (&ptr, operand + 0, 0);
818 get_operand (&ptr, operand + 1, 1);
821 get_operand (&ptr, operand + 2, 2);
824 get_cc_operand (&ptr, operand + 3, 3);
834 /* Passed a pointer to a list of opcodes which use different
835 addressing modes. Return the opcode which matches the opcodes
838 static opcode_entry_type *
839 get_specific (opcode_entry_type *opcode, op_type *operands)
841 opcode_entry_type *this_try = opcode;
843 unsigned int noperands = opcode->noperands;
845 int this_index = opcode->idx;
847 while (this_index == opcode->idx && !found)
852 for (i = 0; i < noperands; i++)
854 unsigned int mode = operands[i].mode;
856 if (((mode & CLASS_MASK) == CLASS_IR) && ((this_try->arg_info[i] & CLASS_MASK) == CLASS_IRO))
858 mode = operands[i].mode = (operands[i].mode & ~CLASS_MASK) | CLASS_IRO;
861 if ((mode & CLASS_MASK) != (this_try->arg_info[i] & CLASS_MASK))
863 /* It could be a pc rel operand, if this is a da mode
864 and we like disps, then insert it. */
866 if (mode == CLASS_DA && this_try->arg_info[i] == CLASS_DISP)
868 /* This is the case. */
869 operands[i].mode = CLASS_DISP;
871 else if (mode == CLASS_BA && this_try->arg_info[i])
873 /* Can't think of a way to turn what we've been
874 given into something that's OK. */
877 else if (this_try->arg_info[i] & CLASS_PR)
879 if (mode == CLASS_REG_LONG && segmented_mode)
883 else if (mode == CLASS_REG_WORD && !segmented_mode)
893 switch (mode & CLASS_MASK)
898 if (operands[i].regsize != CLASS_REG_WORD)
899 as_bad (_("invalid indirect register size"));
900 reg[this_try->arg_info[i] & ARG_MASK] = operands[i].reg;
903 if ((segmented_mode && operands[i].regsize != CLASS_REG_LONG)
904 || (!segmented_mode && operands[i].regsize != CLASS_REG_WORD))
905 as_bad (_("invalid indirect register size"));
906 reg[this_try->arg_info[i] & ARG_MASK] = operands[i].reg;
918 reg[this_try->arg_info[i] & ARG_MASK] = operands[i].reg;
921 if (this_try->opcode == OPC_ldctlb && the_ctrl != 1)
922 as_bad (_("invalid control register name"));
937 static char buffer[20];
940 newfix (int ptr, int type, int size, expressionS *operand)
944 /* size is in nibbles. */
946 if (operand->X_add_symbol
947 || operand->X_op_symbol
948 || operand->X_add_number)
957 fix_new_exp (frag_now,
967 apply_fix (char *ptr, int type, expressionS *operand, int size)
969 long n = operand->X_add_number;
971 /* size is in nibbles. */
973 newfix ((ptr - buffer) / 2, type, size + 1, operand);
976 case 8: /* 8 nibbles == 32 bits. */
981 case 4: /* 4 nibbles == 16 bits. */
993 /* Now we know what sort of opcodes it is. Let's build the bytes. */
996 build_bytes (opcode_entry_type *this_try, struct z8k_op *operand ATTRIBUTE_UNUSED)
998 char *output_ptr = buffer;
1001 unsigned int *class_ptr;
1003 frag_wane (frag_now);
1006 memset (buffer, 0, sizeof (buffer));
1007 class_ptr = this_try->byte_info;
1009 for (nibble = 0; (c = *class_ptr++); nibble++)
1012 switch (c & CLASS_MASK)
1018 /* Direct address, we don't cope with the SS mode right now. */
1021 /* da_operand->X_add_number |= 0x80000000; -- Now set at relocation time. */
1022 output_ptr = apply_fix (output_ptr, R_IMM32, da_operand, 8);
1026 output_ptr = apply_fix (output_ptr, R_IMM16, da_operand, 4);
1032 output_ptr = apply_fix (output_ptr, R_JR, da_operand, 2);
1039 output_ptr = apply_fix (output_ptr, R_DISP7, da_operand, 2);
1046 output_ptr = apply_fix (output_ptr, R_DISP7, da_operand, 2);
1047 output_ptr[-2] = 0x8;
1051 case CLASS_BIT_1OR2:
1052 *output_ptr = c & 0xf;
1055 if (imm_operand->X_add_number == 2)
1057 else if (imm_operand->X_add_number != 1)
1058 as_bad (_("immediate must be 1 or 2"));
1061 as_bad (_("immediate 1 or 2 expected"));
1065 *output_ptr++ = the_cc;
1068 if (the_ctrl < 2 || the_ctrl > 7)
1069 as_bad (_("invalid control register name"));
1070 *output_ptr++ = the_ctrl;
1073 if (the_ctrl < 2 || the_ctrl > 7)
1074 as_bad (_("invalid control register name"));
1075 *output_ptr++ = the_ctrl | 0x8;
1078 *output_ptr++ = (~the_interrupt & 0x3);
1081 *output_ptr++ = (~the_interrupt & 0x3) | 0x4;
1084 *output_ptr++ = the_flags;
1088 *output_ptr++ = c & 0xf;
1091 if (reg[c & 0xf] == 0)
1092 as_bad (_("can't use R0 here"));
1095 case CLASS_REG_BYTE:
1096 case CLASS_REG_WORD:
1097 case CLASS_REG_LONG:
1098 case CLASS_REG_QUAD:
1099 /* Insert bit mattern of right reg. */
1100 *output_ptr++ = reg[c & 0xf];
1103 switch (c & ARG_MASK)
1106 output_ptr = apply_fix (output_ptr, R_CALLR, da_operand, 4);
1109 output_ptr = apply_fix (output_ptr, R_REL16, da_operand, 4);
1112 output_ptr = apply_fix (output_ptr, R_IMM16, da_operand, 4);
1119 switch (c & ARG_MASK)
1122 if (imm_operand->X_add_number > 15)
1124 as_bad (_("immediate value out of range"));
1126 imm_operand->X_add_number = -imm_operand->X_add_number;
1127 output_ptr = apply_fix (output_ptr, R_IMM4L, imm_operand, 1);
1129 /*case ARG_IMMNMINUS1: not used. */
1131 imm_operand->X_add_number--;
1134 if (imm_operand->X_add_number > 15)
1136 as_bad (_("immediate value out of range"));
1138 output_ptr = apply_fix (output_ptr, R_IMM4L, imm_operand, 1);
1141 imm_operand->X_add_number = -imm_operand->X_add_number;
1144 output_ptr = apply_fix (output_ptr, R_IMM8, imm_operand, 2);
1147 output_ptr = apply_fix (output_ptr, R_IMM16, imm_operand, 4);
1150 output_ptr = apply_fix (output_ptr, R_IMM32, imm_operand, 8);
1159 /* Copy from the nibble buffer into the frag. */
1161 int length = (output_ptr - buffer) / 2;
1163 char *fragp = frag_more (length);
1165 while (src < output_ptr)
1167 *fragp = (src[0] << 4) | src[1];
1174 /* This is the guts of the machine-dependent assembler. STR points to a
1175 machine dependent instruction. This function is supposed to emit
1176 the frags/bytes it assembles to. */
1179 md_assemble (char *str)
1184 struct z8k_op operand[4];
1185 opcode_entry_type *opcode;
1187 /* Drop leading whitespace. */
1191 /* Find the op code end. */
1192 for (op_start = op_end = str;
1193 *op_end != 0 && *op_end != ' ' && ! is_end_of_line[(unsigned char) *op_end];
1197 if (op_end == op_start)
1199 as_bad (_("can't find opcode "));
1203 *op_end = 0; /* Zero-terminate op code string for hash_find() call. */
1205 opcode = (opcode_entry_type *) hash_find (opcode_hash_control, op_start);
1209 as_bad (_("unknown opcode"));
1213 *op_end = c; /* Restore original string. */
1215 if (opcode->opcode == 250)
1219 char *old = input_line_pointer;
1221 /* Was really a pseudo op. */
1223 input_line_pointer = op_end;
1227 while (*input_line_pointer == ' ')
1228 input_line_pointer++;
1229 p = (pseudo_typeS *) (opcode->func);
1231 (p->poc_handler) (p->poc_val);
1232 input_line_pointer = old;
1237 char *new_input_line_pointer;
1239 new_input_line_pointer = get_operands (opcode, op_end, operand);
1240 if (new_input_line_pointer)
1242 input_line_pointer = new_input_line_pointer;
1243 opcode = get_specific (opcode, operand);
1246 if (new_input_line_pointer == NULL || opcode == NULL)
1248 /* Couldn't find an opcode which matched the operands. */
1249 char *where = frag_more (2);
1254 as_bad (_("Can't find opcode to match operands"));
1258 build_bytes (opcode, operand);
1262 /* We have no need to default values of symbols. */
1265 md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
1270 /* Various routines to kill one day. */
1271 /* Equal to MAX_PRECISION in atof-ieee.c. */
1272 #define MAX_LITTLENUMS 6
1274 /* Turn a string in input_line_pointer into a floating point constant
1275 of type TYPE, and store the appropriate bytes in *LITP. The number
1276 of LITTLENUMS emitted is stored in *SIZEP. An error message is
1277 returned, or NULL on OK. */
1280 md_atof (int type, char *litP, int *sizeP)
1283 LITTLENUM_TYPE words[MAX_LITTLENUMS];
1284 LITTLENUM_TYPE *wordP;
1315 return _("Bad call to MD_ATOF()");
1317 t = atof_ieee (input_line_pointer, type, words);
1319 input_line_pointer = t;
1321 *sizeP = prec * sizeof (LITTLENUM_TYPE);
1322 for (wordP = words; prec--;)
1324 md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE));
1325 litP += sizeof (LITTLENUM_TYPE);
1330 const char *md_shortopts = "z:";
1332 struct option md_longopts[] =
1334 #define OPTION_RELAX (OPTION_MD_BASE)
1335 {"linkrelax", no_argument, NULL, OPTION_RELAX},
1336 {NULL, no_argument, NULL, 0}
1339 size_t md_longopts_size = sizeof (md_longopts);
1342 md_parse_option (int c, char *arg)
1347 if (!strcmp (arg, "8001"))
1349 else if (!strcmp (arg, "8002"))
1353 as_bad (_("invalid architecture -z%s"), arg);
1356 z8k_target_from_cmdline = 1;
1371 md_show_usage (FILE *stream)
1373 fprintf (stream, _("\
1375 -z8001 generate segmented code\n\
1376 -z8002 generate unsegmented code\n\
1377 -linkrelax create linker relaxable code\n"));
1381 md_convert_frag (object_headers *headers ATTRIBUTE_UNUSED,
1382 segT seg ATTRIBUTE_UNUSED,
1383 fragS *fragP ATTRIBUTE_UNUSED)
1385 printf (_("call to md_convert_frag\n"));
1390 md_section_align (segT seg, valueT size)
1392 return ((size + (1 << section_alignment[(int) seg]) - 1)
1393 & (-1 << section_alignment[(int) seg]));
1396 /* Attempt to simplify or eliminate a fixup. To indicate that a fixup
1397 has been eliminated, set fix->fx_done. If fix->fx_addsy is non-NULL,
1398 we will have to generate a reloc entry. */
1400 md_apply_fix (fixS *fixP, valueT *valP, segT segment ATTRIBUTE_UNUSED)
1402 long val = * (long *) valP;
1403 char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
1405 switch (fixP->fx_r_type)
1408 buf[0] = (buf[0] & 0xf0) | (val & 0xf);
1414 fixP->fx_no_overflow = 1;
1420 as_bad_where (fixP->fx_file, fixP->fx_line,
1421 _("cannot branch to odd address"));
1423 if (val > 127 || val < -128)
1424 as_bad_where (fixP->fx_file, fixP->fx_line,
1425 _("relative jump out of range"));
1427 fixP->fx_no_overflow = 1;
1435 fixP->fx_no_overflow = 1;
1441 as_bad_where (fixP->fx_file, fixP->fx_line,
1442 _("cannot branch to odd address"));
1444 if (val > 0 || val < -127)
1445 as_bad_where (fixP->fx_file, fixP->fx_line,
1446 _("relative jump out of range"));
1447 *buf = (*buf & 0x80) | (-val & 0x7f);
1448 fixP->fx_no_overflow = 1;
1456 fixP->fx_no_overflow = 1;
1462 as_bad_where (fixP->fx_file, fixP->fx_line,
1463 _("cannot branch to odd address"));
1464 if (val > 4096 || val < -4095)
1465 as_bad_where (fixP->fx_file, fixP->fx_line,
1466 _("relative call out of range"));
1468 *buf = (*buf & 0xf0) | ((val >> 8) & 0xf);
1470 *buf++ = val & 0xff;
1471 fixP->fx_no_overflow = 1;
1481 *buf++ = (val >> 8);
1486 *buf++ = (val >> 24);
1487 *buf++ = (val >> 16);
1488 *buf++ = (val >> 8);
1493 val = val - fixP->fx_frag->fr_address + fixP->fx_where - fixP->fx_size;
1494 if (val > 32767 || val < -32768)
1495 as_bad_where (fixP->fx_file, fixP->fx_line,
1496 _("relative address out of range"));
1497 *buf++ = (val >> 8);
1499 fixP->fx_no_overflow = 1;
1503 md_number_to_chars (buf, val, fixP->fx_size);
1507 printf(_("md_apply_fix: unknown r_type 0x%x\n"), fixP->fx_r_type);
1511 if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
1516 md_estimate_size_before_relax (fragS *fragP ATTRIBUTE_UNUSED,
1517 segT segment_type ATTRIBUTE_UNUSED)
1519 printf (_("call to md_estimate_size_before_relax\n"));
1523 /* Put number into target byte order. */
1526 md_number_to_chars (char *ptr, valueT use, int nbytes)
1528 number_to_chars_bigendian (ptr, use, nbytes);
1531 /* On the Z8000, a PC-relative offset is relative to the address of the
1532 instruction plus its size. */
1534 md_pcrel_from (fixS *fixP)
1536 return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address;
1540 tc_coff_symbol_emit_hook (symbolS *s ATTRIBUTE_UNUSED)