source: trunk/src/binutils/bfd/cpu-ns32k.c@ 1767

Last change on this file since 1767 was 610, checked in by bird, 22 years ago

This commit was generated by cvs2svn to compensate for changes in r609,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 24.9 KB
Line 
1/* BFD support for the ns32k architecture.
2 Copyright 1990, 1991, 1994, 1995, 1998, 2000, 2001, 2002
3 Free Software Foundation, Inc.
4 Almost totally rewritten by Ian Dall from initial work
5 by Andrew Cagney.
6
7 This file is part of BFD, the Binary File Descriptor library.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23#include "bfd.h"
24#include "sysdep.h"
25#include "libbfd.h"
26#include "ns32k.h"
27
28#define N(machine, printable, d, next) \
29{ 32, 32, 8, bfd_arch_ns32k, machine, "ns32k",printable,3,d,bfd_default_compatible,bfd_default_scan, next, }
30
31static const bfd_arch_info_type arch_info_struct[] =
32{
33 N(32532,"ns32k:32532",TRUE, 0), /* The word ns32k will match this too. */
34};
35
36const bfd_arch_info_type bfd_ns32k_arch =
37 N(32032,"ns32k:32032",FALSE, &arch_info_struct[0]);
38
39static bfd_reloc_status_type do_ns32k_reloc
40 PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR, asection *,
41 bfd *, char **,
42 bfd_vma (*) (bfd_byte *, int),
43 void (*) (bfd_vma, bfd_byte *, int)));
44
45bfd_vma
46_bfd_ns32k_get_displacement (buffer, size)
47 bfd_byte *buffer;
48 int size;
49{
50 bfd_signed_vma value;
51
52 switch (size)
53 {
54 case 1:
55 value = ((*buffer & 0x7f) ^ 0x40) - 0x40;
56 break;
57
58 case 2:
59 value = ((*buffer++ & 0x3f) ^ 0x20) - 0x20;
60 value = (value << 8) | (0xff & *buffer);
61 break;
62
63 case 4:
64 value = ((*buffer++ & 0x3f) ^ 0x20) - 0x20;
65 value = (value << 8) | (0xff & *buffer++);
66 value = (value << 8) | (0xff & *buffer++);
67 value = (value << 8) | (0xff & *buffer);
68 break;
69
70 default:
71 abort ();
72 return 0;
73 }
74
75 return value;
76}
77
78void
79_bfd_ns32k_put_displacement (value, buffer, size)
80 bfd_vma value;
81 bfd_byte *buffer;
82 int size;
83{
84 switch (size)
85 {
86 case 1:
87 value &= 0x7f;
88 *buffer++ = value;
89 break;
90
91 case 2:
92 value &= 0x3fff;
93 value |= 0x8000;
94 *buffer++ = (value >> 8);
95 *buffer++ = value;
96 break;
97
98 case 4:
99 value |= (bfd_vma) 0xc0000000;
100 *buffer++ = (value >> 24);
101 *buffer++ = (value >> 16);
102 *buffer++ = (value >> 8);
103 *buffer++ = value;
104 break;
105 }
106 return;
107}
108
109bfd_vma
110_bfd_ns32k_get_immediate (buffer, size)
111 bfd_byte *buffer;
112 int size;
113{
114 bfd_vma value = 0;
115
116 switch (size)
117 {
118 case 4:
119 value = (value << 8) | (*buffer++ & 0xff);
120 value = (value << 8) | (*buffer++ & 0xff);
121 case 2:
122 value = (value << 8) | (*buffer++ & 0xff);
123 case 1:
124 value = (value << 8) | (*buffer++ & 0xff);
125 break;
126 default:
127 abort ();
128 }
129 return value;
130}