summaryrefslogtreecommitdiff
path: root/bfd/cpu-h8300.c
diff options
context:
space:
mode:
authorRichard Sandiford <rsandifo@nildram.co.uk>2003-07-14 06:27:24 +0000
committerRichard Sandiford <rsandifo@nildram.co.uk>2003-07-14 06:27:24 +0000
commit3ab4efb4140eecb229fd03034206a30dab445b63 (patch)
tree2d2dbbf42d1a789510b3827eca51f398623b6a89 /bfd/cpu-h8300.c
parent67f164e760323602726db3bc56063ff2e94c1bb6 (diff)
downloadbinutils-redhat-3ab4efb4140eecb229fd03034206a30dab445b63.tar.gz
Missing from 2003-07-11 commit.
Diffstat (limited to 'bfd/cpu-h8300.c')
-rw-r--r--bfd/cpu-h8300.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/bfd/cpu-h8300.c b/bfd/cpu-h8300.c
index 6ed0fff363..1a4f4d7a06 100644
--- a/bfd/cpu-h8300.c
+++ b/bfd/cpu-h8300.c
@@ -220,3 +220,38 @@ const bfd_arch_info_type bfd_h8300_arch =
h8300_scan,
&h8300h_info_struct
};
+
+/* Pad the given address to 32 bits, converting 16-bit and 24-bit
+ addresses into the values they would have had on a h8s target. */
+
+bfd_vma
+bfd_h8300_pad_address (bfd *abfd, bfd_vma address)
+{
+ /* Cope with bfd_vma's larger than 32 bits. */
+ address &= 0xffffffffu;
+
+ switch (bfd_get_mach (abfd))
+ {
+ case bfd_mach_h8300:
+ case bfd_mach_h8300hn:
+ case bfd_mach_h8300sn:
+ case bfd_mach_h8300sxn:
+ /* Sign extend a 16-bit address. */
+ if (address >= 0x8000)
+ return address | 0xffff0000u;
+ return address;
+
+ case bfd_mach_h8300h:
+ /* Sign extend a 24-bit address. */
+ if (address >= 0x800000)
+ return address | 0xff000000u;
+ return address;
+
+ case bfd_mach_h8300s:
+ case bfd_mach_h8300sx:
+ return address;
+
+ default:
+ abort ();
+ }
+}