* v850-opc.c (v850_operands): Define EP operand.
[deliverable/binutils-gdb.git] / gas / config / tc-v850.c
CommitLineData
c6aa56bc
C
1/* tc-v850.c -- Assembler code for the NEC V850
2
3 Copyright (C) 1996 Free Software Foundation.
4
5 This file is part of GAS, the GNU Assembler.
6
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)
10 any later version.
11
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.
16
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
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22#include <stdio.h>
23#include <ctype.h>
24#include "as.h"
25#include "subsegs.h"
26#include "opcode/v850.h"
27\f
0e8f9bd1
JL
28/* Structure to hold information about predefined registers. */
29struct reg_name
30{
31 const char *name;
32 int value;
33};
34
c6aa56bc
C
35/* Generic assembler global variables which must be defined by all targets. */
36
37/* Characters which always start a comment. */
38const char comment_chars[] = "#";
39
40/* Characters which start a comment at the beginning of a line. */
dcf5d117 41const char line_comment_chars[] = ";#";
c6aa56bc
C
42
43/* Characters which may be used to separate multiple commands on a
44 single line. */
45const char line_separator_chars[] = ";";
46
47/* Characters which are used to indicate an exponent in a floating
48 point number. */
49const char EXP_CHARS[] = "eE";
50
51/* Characters which mean that a number is a floating point constant,
52 as in 0d1.0. */
53const char FLT_CHARS[] = "dD";
54\f
55/* local functions */
56static unsigned long v850_insert_operand
57 PARAMS ((unsigned long insn, const struct v850_operand *operand,
58 offsetT val, char *file, unsigned int line));
0e8f9bd1 59static int reg_name_search PARAMS ((char *name, const struct reg_name *, int));
c6aa56bc 60static boolean register_name PARAMS ((expressionS *expressionP));
0e8f9bd1 61static boolean system_register_name PARAMS ((expressionS *expressionP));
c9f1b2d9 62static boolean cc_name PARAMS ((expressionS *expressionP));
c6aa56bc
C
63static int postfix PARAMS ((char *p));
64static bfd_reloc_code_real_type get_reloc PARAMS ((struct v850_operand *op));
65static unsigned long build_insn PARAMS ((struct v850_opcode *opcode, expressionS *opers));
66
67
68/* fixups */
69#define MAX_INSN_FIXUPS (5)
70struct v850_fixup
71{
72 expressionS exp;
73 int opindex;
74 bfd_reloc_code_real_type reloc;
75};
76struct v850_fixup fixups[MAX_INSN_FIXUPS];
77static int fc;
78\f
79const char *md_shortopts = "";
80struct option md_longopts[] = {
81 {NULL, no_argument, NULL, 0}
82};
83size_t md_longopts_size = sizeof(md_longopts);
84
85/* The target specific pseudo-ops which we support. */
86const pseudo_typeS md_pseudo_table[] =
87{
88 /*
89 { "byte", ppc_byte, 0 },
90 { "long", ppc_elf_cons, 4 },
91 { "word", ppc_elf_cons, 2 },
92 { "short", ppc_elf_cons, 2 },
93 { "rdata", ppc_elf_rdata, 0 },
94 { "rodata", ppc_elf_rdata, 0 },
95 { "lcomm", ppc_elf_lcomm, 0 },
96 */
97 { NULL, NULL, 0 }
98};
99
100/* Opcode hash table. */
101static struct hash_control *v850_hash;
102
1510cd39
C
103/* This table is sorted. Suitable for searching by a binary search. */
104static const struct reg_name pre_defined_registers[] =
c6aa56bc
C
105{
106 { "ep", 30 }, /* ep - element ptr */
107 { "gp", 4 }, /* gp - global ptr */
108 { "lp", 31 }, /* lp - link ptr */
109 { "r0", 0 },
110 { "r1", 1 },
111 { "r10", 10 },
112 { "r11", 11 },
113 { "r12", 12 },
114 { "r13", 13 },
115 { "r14", 14 },
116 { "r15", 15 },
117 { "r16", 16 },
118 { "r17", 17 },
119 { "r18", 18 },
120 { "r19", 19 },
121 { "r2", 2 },
122 { "r20", 20 },
123 { "r21", 21 },
124 { "r22", 22 },
125 { "r23", 23 },
126 { "r24", 24 },
127 { "r25", 25 },
128 { "r26", 26 },
129 { "r27", 27 },
130 { "r28", 28 },
131 { "r29", 29 },
132 { "r3", 3 },
133 { "r30", 30 },
134 { "r31", 31 },
135 { "r4", 4 },
136 { "r5", 5 },
137 { "r6", 6 },
138 { "r7", 7 },
139 { "r8", 8 },
140 { "r9", 9 },
141 { "sp", 3 }, /* sp - stack ptr */
142 { "tp", 5 }, /* tp - text ptr */
143 { "zero", 0 },
144};
1510cd39
C
145#define REG_NAME_CNT (sizeof(pre_defined_registers) / sizeof(struct reg_name))
146
147
148static const struct reg_name system_registers[] =
149{
150 { "eipc", 0 },
151 { "eipsw", 1 },
152 { "fepc", 2 },
153 { "fepsw", 3 },
154 { "ecr", 4 },
155 { "psw", 5 },
156};
0e8f9bd1 157#define SYSREG_NAME_CNT (sizeof(system_registers) / sizeof(struct reg_name))
1510cd39
C
158
159static const struct reg_name cc_names[] =
160{
161 { "c", 0x1 },
162 { "ge", 0xe },
163 { "gt", 0xf },
164 { "h", 0xb },
165 { "l", 0x1 },
166 { "le", 0x7 },
167 { "lt", 0x6 },
168 { "n", 0x4 },
169 { "nc", 0x9 },
170 { "nh", 0x3 },
171 { "nl", 0x9 },
172 { "ns", 0xc },
173 { "nv", 0x8 },
174 { "nz", 0xa },
175 { "p", 0xc },
176 { "s", 0x4 },
177 { "sa", 0xd },
178 { "t", 0x5 },
179 { "v", 0x0 },
180 { "z", 0x2 },
181};
c9f1b2d9 182#define CC_NAME_CNT (sizeof(cc_names) / sizeof(struct reg_name))
c6aa56bc 183
0e8f9bd1
JL
184/* reg_name_search does a binary search of the given register table
185 to see if "name" is a valid regiter name. Returns the register
c6aa56bc
C
186 number from the array on success, or -1 on failure. */
187
188static int
0e8f9bd1 189reg_name_search (name, table, high)
c6aa56bc 190 char *name;
0e8f9bd1
JL
191 const struct reg_name *table;
192 int high;
c6aa56bc 193{
0e8f9bd1 194 int middle, low;
c6aa56bc
C
195 int cmp;
196
197 low = 0;
c6aa56bc
C
198 do
199 {
200 middle = (low + high) / 2;
0e8f9bd1 201 cmp = strcasecmp (name, table[middle].name);
c6aa56bc
C
202 if (cmp < 0)
203 high = middle - 1;
204 else if (cmp > 0)
205 low = middle + 1;
206 else
0e8f9bd1 207 return table[middle].value;
c6aa56bc
C
208 }
209 while (low <= high);
210 return -1;
211}
212
213
214/* Summary of register_name().
215 *
216 * in: Input_line_pointer points to 1st char of operand.
217 *
218 * out: A expressionS.
219 * The operand may have been a register: in this case, X_op == O_register,
220 * X_add_number is set to the register number, and truth is returned.
221 * Input_line_pointer->(next non-blank) char after operand, or is in
222 * its original state.
223 */
224static boolean
225register_name (expressionP)
226 expressionS *expressionP;
227{
228 int reg_number;
229 char *name;
230 char *start;
231 char c;
232
233 /* Find the spelling of the operand */
234 start = name = input_line_pointer;
235
236 c = get_symbol_end ();
0e8f9bd1
JL
237 reg_number = reg_name_search (name, pre_defined_registers, REG_NAME_CNT - 1);
238
239 /* look to see if it's in the register table */
240 if (reg_number >= 0)
241 {
242 expressionP->X_op = O_register;
243 expressionP->X_add_number = reg_number;
244
245 /* make the rest nice */
246 expressionP->X_add_symbol = NULL;
247 expressionP->X_op_symbol = NULL;
248 *input_line_pointer = c; /* put back the delimiting char */
249 return true;
250 }
251 else
252 {
253 /* reset the line as if we had not done anything */
254 *input_line_pointer = c; /* put back the delimiting char */
255 input_line_pointer = start; /* reset input_line pointer */
256 return false;
257 }
258}
259
260/* Summary of system_register_name().
261 *
262 * in: Input_line_pointer points to 1st char of operand.
263 *
264 * out: A expressionS.
265 * The operand may have been a register: in this case, X_op == O_register,
266 * X_add_number is set to the register number, and truth is returned.
267 * Input_line_pointer->(next non-blank) char after operand, or is in
268 * its original state.
269 */
270static boolean
271system_register_name (expressionP)
272 expressionS *expressionP;
273{
274 int reg_number;
275 char *name;
276 char *start;
277 char c;
278
279 /* Find the spelling of the operand */
280 start = name = input_line_pointer;
281
282 c = get_symbol_end ();
283 reg_number = reg_name_search (name, system_registers, SYSREG_NAME_CNT - 1);
c6aa56bc
C
284
285 /* look to see if it's in the register table */
286 if (reg_number >= 0)
287 {
288 expressionP->X_op = O_register;
289 expressionP->X_add_number = reg_number;
290
291 /* make the rest nice */
292 expressionP->X_add_symbol = NULL;
293 expressionP->X_op_symbol = NULL;
294 *input_line_pointer = c; /* put back the delimiting char */
295 return true;
296 }
297 else
298 {
299 /* reset the line as if we had not done anything */
300 *input_line_pointer = c; /* put back the delimiting char */
301 input_line_pointer = start; /* reset input_line pointer */
302 return false;
303 }
304}
305
c9f1b2d9
JL
306/* Summary of cc_name().
307 *
308 * in: Input_line_pointer points to 1st char of operand.
309 *
310 * out: A expressionS.
311 * The operand may have been a register: in this case, X_op == O_register,
312 * X_add_number is set to the register number, and truth is returned.
313 * Input_line_pointer->(next non-blank) char after operand, or is in
314 * its original state.
315 */
316static boolean
317cc_name (expressionP)
318 expressionS *expressionP;
319{
320 int reg_number;
321 char *name;
322 char *start;
323 char c;
324
325 /* Find the spelling of the operand */
326 start = name = input_line_pointer;
327
328 c = get_symbol_end ();
329 reg_number = reg_name_search (name, cc_names, CC_NAME_CNT - 1);
330
331 /* look to see if it's in the register table */
332 if (reg_number >= 0)
333 {
334 expressionP->X_op = O_constant;
335 expressionP->X_add_number = reg_number;
336
337 /* make the rest nice */
338 expressionP->X_add_symbol = NULL;
339 expressionP->X_op_symbol = NULL;
340 *input_line_pointer = c; /* put back the delimiting char */
341 return true;
342 }
343 else
344 {
345 /* reset the line as if we had not done anything */
346 *input_line_pointer = c; /* put back the delimiting char */
347 input_line_pointer = start; /* reset input_line pointer */
348 return false;
349 }
350}
351
c6aa56bc
C
352void
353md_show_usage (stream)
354 FILE *stream;
355{
356 fprintf(stream, "V850 options:\n\
357none yet\n");
358}
359
360int
361md_parse_option (c, arg)
362 int c;
363 char *arg;
364{
365 return 0;
366}
367
368symbolS *
369md_undefined_symbol (name)
370 char *name;
371{
372 return 0;
373}
374
375char *
376md_atof (type, litp, sizep)
377 int type;
378 char *litp;
379 int *sizep;
380{
381 int prec;
382 LITTLENUM_TYPE words[4];
383 char *t;
384 int i;
385
386 switch (type)
387 {
388 case 'f':
389 prec = 2;
390 break;
391
392 case 'd':
393 prec = 4;
394 break;
395
396 default:
397 *sizep = 0;
398 return "bad call to md_atof";
399 }
400
401 t = atof_ieee (input_line_pointer, type, words);
402 if (t)
403 input_line_pointer = t;
404
405 *sizep = prec * 2;
406
407 for (i = prec - 1; i >= 0; i--)
408 {
409 md_number_to_chars (litp, (valueT) words[i], 2);
410 litp += 2;
411 }
412
413 return NULL;
414}
415
416
417void
418md_convert_frag (abfd, sec, fragP)
419 bfd *abfd;
420 asection *sec;
421 fragS *fragP;
422{
423 /* printf ("call to md_convert_frag \n"); */
424 abort ();
425}
426
427valueT
428md_section_align (seg, addr)
429 asection *seg;
430 valueT addr;
431{
432 int align = bfd_get_section_alignment (stdoutput, seg);
433 return ((addr + (1 << align) - 1) & (-1 << align));
434}
435
436void
437md_begin ()
438{
439 char *prev_name = "";
440 register const struct v850_opcode *op;
441 const struct v850_opcode *op_end;
442
443 v850_hash = hash_new();
444
445 /* Insert unique names into hash table. The V850 instruction set
446 has many identical opcode names that have different opcodes based
447 on the operands. This hash table then provides a quick index to
448 the first opcode with a particular name in the opcode table. */
449
450 op = v850_opcodes;
451 op_end = v850_opcodes + v850_num_opcodes;
452
453 for (; op < op_end; op++)
454 {
455 if (strcmp (prev_name, op->name))
456 {
457 prev_name = (char *) op->name;
458 hash_insert (v850_hash, op->name, (char *) op);
459 }
460 }
461}
462
463
464static bfd_reloc_code_real_type
465get_reloc (op)
466 struct v850_operand *op;
467{
468 abort ();
469}
470
471
c6aa56bc
C
472void
473md_assemble (str)
474 char *str;
475{
476 char *s;
477 struct v850_opcode *opcode;
478 struct v850_opcode *next_opcode;
479 const unsigned char *opindex_ptr;
480 int next_opindex;
481 unsigned long insn;
482 char *f;
483 int i;
484 int numops;
485 int match;
486
487 int numopts;
488 expressionS myops[5];
489
490 /* Get the opcode. */
491 for (s = str; *s != '\0' && ! isspace (*s); s++)
492 ;
493 if (*s != '\0')
494 *s++ = '\0';
495
496 /* find the first opcode with the proper name */
497 opcode = (struct v850_opcode *)hash_find (v850_hash, str);
498 if (opcode == NULL)
499 {
500 as_bad ("Unrecognized opcode: `%s'", str);
501 return;
502 }
503
504 str = s;
505 while (isspace (*str))
506 ++str;
507
508 input_line_pointer = str;
509
1510cd39 510 for(;;)
c6aa56bc 511 {
1510cd39
C
512 const char *errmsg = NULL;
513
514 fc = 0;
515 match = 0;
516 next_opindex = 0;
d5974c57 517 insn = opcode->opcode;
1510cd39 518 for (opindex_ptr = opcode->operands; *opindex_ptr != 0; opindex_ptr++)
c6aa56bc 519 {
1510cd39
C
520 const struct v850_operand *operand;
521 char *hold;
522 expressionS ex;
523 char endc;
c6aa56bc 524
1510cd39 525 if (next_opindex == 0)
c6aa56bc 526 {
1510cd39
C
527 operand = &v850_operands[*opindex_ptr];
528 }
529 else
530 {
531 operand = &v850_operands[next_opindex];
532 next_opindex = 0;
c6aa56bc
C
533 }
534
1510cd39
C
535 errmsg = NULL;
536
537 while (*str == ' ' || *str == ',' || *str == '[' || *str == ']')
538 ++str;
539
540 /* Gather the operand. */
541 hold = input_line_pointer;
542 input_line_pointer = str;
543
544 if ((operand->flags & V850_OPERAND_REG) != 0)
c6aa56bc 545 {
1510cd39 546 if (!register_name(&ex))
c6aa56bc 547 {
1510cd39
C
548 errmsg = "invalid register name";
549 goto error;
c6aa56bc
C
550 }
551 }
0e8f9bd1
JL
552 else if ((operand->flags & V850_OPERAND_SRG) != 0)
553 {
554 if (!system_register_name(&ex))
555 {
556 errmsg = "invalid system register name";
557 goto error;
558 }
559 }
c9f1b2d9
JL
560 else if ((operand->flags & V850_OPERAND_CC) != 0)
561 {
562 if (!cc_name(&ex))
563 {
564 errmsg = "invalid condition code name";
565 goto error;
566 }
567 }
1510cd39
C
568 else if (strncmp(input_line_pointer, "lo(", 3) == 0)
569 {
570 input_line_pointer += 3;
571 expression(&ex);
c6aa56bc 572
1510cd39
C
573 if (*input_line_pointer++ != ')')
574 {
575 errmsg = "syntax error: expected `)'";
576 goto error;
577 }
578
579 if (ex.X_op == O_constant)
580 ex.X_add_number &= 0xffff;
581 else
582 {
583 if (fc > MAX_INSN_FIXUPS)
584 as_fatal ("too many fixups");
585
586 fixups[fc].exp = ex;
587 fixups[fc].opindex = *opindex_ptr;
588 fixups[fc].reloc = BFD_RELOC_LO16;
589 fc++;
590 }
591 }
592 else if (strncmp(input_line_pointer, "hi(", 3) == 0)
593 {
594 input_line_pointer += 3;
595 expression(&ex);
c6aa56bc 596
1510cd39
C
597 if (*input_line_pointer++ != ')')
598 {
599 errmsg = "syntax error: expected `)'";
600 goto error;
601 }
602
603 if (ex.X_op == O_constant)
604 ex.X_add_number = (ex.X_add_number >> 16) & 0xffff;
605 else
606 {
607 if (fc > MAX_INSN_FIXUPS)
608 as_fatal ("too many fixups");
609
610 fixups[fc].exp = ex;
611 fixups[fc].opindex = *opindex_ptr;
612 fixups[fc].reloc = BFD_RELOC_HI16;
613 fc++;
614 }
615 }
c9a32d6c
JL
616 else if (register_name (&ex)
617 && (operand->flags & V850_OPERAND_REG) == 0)
618 {
619 errmsg = "syntax error: register not expected";
620 goto error;
621 }
0e8f9bd1
JL
622 else if (system_register_name (&ex)
623 && (operand->flags & V850_OPERAND_SRG) == 0)
624 {
625 errmsg = "syntax error: system register not expected";
626 goto error;
627 }
c9f1b2d9
JL
628 else if (cc_name (&ex)
629 && (operand->flags & V850_OPERAND_CC) == 0)
630 {
631 errmsg = "syntax error: condition code not expected";
632 goto error;
633 }
1510cd39
C
634 else
635 {
636 expression(&ex);
637 }
c6aa56bc 638
1510cd39
C
639 str = input_line_pointer;
640 input_line_pointer = hold;
c6aa56bc 641
1510cd39
C
642 switch (ex.X_op)
643 {
644 case O_illegal:
645 errmsg = "illegal operand";
646 goto error;
647 case O_absent:
648 errmsg = "missing operand";
649 goto error;
650 case O_register:
0e8f9bd1 651 if ((operand->flags & (V850_OPERAND_REG | V850_OPERAND_SRG)) == 0)
1510cd39
C
652 {
653 errmsg = "invalid operand";
654 goto error;
655 }
656
657 insn = v850_insert_operand (insn, operand, ex.X_add_number,
658 (char *) NULL, 0);
659 break;
660
661 case O_constant:
662 insn = v850_insert_operand (insn, operand, ex.X_add_number,
663 (char *) NULL, 0);
664 break;
665
666 default:
667 /* We need to generate a fixup for this expression. */
668 if (fc >= MAX_INSN_FIXUPS)
669 as_fatal ("too many fixups");
670 fixups[fc].exp = ex;
671 fixups[fc].opindex = *opindex_ptr;
672 fixups[fc].reloc = BFD_RELOC_UNUSED;
673 ++fc;
674 break;
675 }
676
677 while (*str == ' ' || *str == ',' || *str == '[' || *str == ']')
678 ++str;
679 }
680 match = 1;
681
682 error:
683 if (match == 0)
684 {
685 next_opcode = opcode + 1;
686 if (next_opcode->opcode != 0 && !strcmp(next_opcode->name, opcode->name))
687 {
688 opcode = next_opcode;
689 continue;
690 }
691
692 as_bad ("%s", errmsg);
693 return;
694 }
695 break;
696 }
697
c6aa56bc
C
698 while (isspace (*str))
699 ++str;
700
701 if (*str != '\0')
702 as_bad ("junk at end of line: `%s'", str);
1510cd39
C
703
704 input_line_pointer = str;
c6aa56bc 705
c9a32d6c
JL
706 f = frag_more (opcode->size);
707 md_number_to_chars (f, insn, opcode->size);
c6aa56bc
C
708}
709
710
711/* if while processing a fixup, a reloc really needs to be created */
712/* then it is done here */
713
714arelent *
715tc_gen_reloc (seg, fixp)
716 asection *seg;
717 fixS *fixp;
718{
719 arelent *reloc;
720 reloc = (arelent *) bfd_alloc_by_size_t (stdoutput, sizeof (arelent));
721 reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym;
722 reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
723 reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
724 if (reloc->howto == (reloc_howto_type *) NULL)
725 {
726 as_bad_where (fixp->fx_file, fixp->fx_line,
727 "reloc %d not supported by object file format", (int)fixp->fx_r_type);
728 return NULL;
729 }
730 reloc->addend = fixp->fx_addnumber;
731 /* printf("tc_gen_reloc: addr=%x addend=%x\n", reloc->address, reloc->addend); */
732 return reloc;
733}
734
735int
736md_estimate_size_before_relax (fragp, seg)
737 fragS *fragp;
738 asection *seg;
739{
740 abort ();
741 return 0;
742}
743
744long
745md_pcrel_from_section (fixp, sec)
746 fixS *fixp;
747 segT sec;
748{
749 return 0;
750 /* return fixp->fx_frag->fr_address + fixp->fx_where; */
751}
752
753int
754md_apply_fix3 (fixp, valuep, seg)
755 fixS *fixp;
756 valueT *valuep;
757 segT seg;
758{
759 abort();
760#if 0
761 valueT value;
762 char *where;
763 unsigned long insn;
764 int op_type;
765
766 if (fixp->fx_addsy == (symbolS *) NULL)
767 {
768 value = *valuep;
769 fixp->fx_done = 1;
770 }
771 else if (fixp->fx_pcrel)
772 value = *valuep;
773 else
774 {
775 value = fixp->fx_offset;
776 if (fixp->fx_subsy != (symbolS *) NULL)
777 {
778 if (S_GET_SEGMENT (fixp->fx_subsy) == absolute_section)
779 value -= S_GET_VALUE (fixp->fx_subsy);
780 else
781 {
782 /* We don't actually support subtracting a symbol. */
783 as_bad_where (fixp->fx_file, fixp->fx_line,
784 "expression too complex");
785 }
786 }
787 }
788
789 /* printf("md_apply_fix: value=0x%x type=%d\n", value, fixp->fx_r_type); */
790
791 op_type = fixp->fx_r_type;
792 fixp->fx_r_type = get_reloc((struct v850_operand *)&v850_operands[op_type]);
793
794 /* printf("reloc=%d\n",fixp->fx_r_type); */
795
796 /* Fetch the instruction, insert the fully resolved operand
797 value, and stuff the instruction back again. */
798 where = fixp->fx_frag->fr_literal + fixp->fx_where;
799 insn = bfd_getb32 ((unsigned char *) where);
800 /* printf(" insn=%x value=%x\n",insn,value); */
801
802 insn = v850_insert_operand (insn, op_type, (offsetT) value);
803
804 /* printf(" new insn=%x\n",insn); */
805
806 bfd_putb32 ((bfd_vma) insn, (unsigned char *) where);
807
808 if (fixp->fx_done)
809 return 1;
810
811 fixp->fx_addnumber = value;
812 return 1;
813#endif
814}
815
816\f
817/* Insert an operand value into an instruction. */
818
819static unsigned long
820v850_insert_operand (insn, operand, val, file, line)
821 unsigned long insn;
822 const struct v850_operand *operand;
823 offsetT val;
824 char *file;
825 unsigned int line;
826{
827 if (operand->bits != 32)
828 {
829 long min, max;
830 offsetT test;
831
1510cd39 832 if ((operand->flags & V850_OPERAND_SIGNED) != 0)
c6aa56bc 833 {
1510cd39 834#if 0
c6aa56bc
C
835 if ((operand->flags & PPC_OPERAND_SIGNOPT) != 0
836 && ppc_size == PPC_OPCODE_32)
837 max = (1 << operand->bits) - 1;
838 else
1510cd39 839#endif
c6aa56bc
C
840 max = (1 << (operand->bits - 1)) - 1;
841 min = - (1 << (operand->bits - 1));
842 }
843 else
c6aa56bc
C
844 {
845 max = (1 << operand->bits) - 1;
846 min = 0;
847 }
848
849#if 0
850 if ((operand->flags & PPC_OPERAND_NEGATIVE) != 0)
851 test = - val;
852 else
853#endif
854 test = val;
855
856
857 if (test < (offsetT) min || test > (offsetT) max)
858 {
859 const char *err =
860 "operand out of range (%s not between %ld and %ld)";
861 char buf[100];
862
863 sprint_value (buf, test);
864 if (file == (char *) NULL)
865 as_warn (err, buf, min, max);
866 else
867 as_warn_where (file, line, err, buf, min, max);
868 }
869 }
870
871 insn |= (((long) val & ((1 << operand->bits) - 1)) << operand->shift);
872 return insn;
873}
This page took 0.059547 seconds and 4 git commands to generate.