diff options
author | Richard Sandiford <rdsandiford@googlemail.com> | 2003-07-14 06:27:24 +0000 |
---|---|---|
committer | Richard Sandiford <rdsandiford@googlemail.com> | 2003-07-14 06:27:24 +0000 |
commit | 2808c7aac49eec873c21ea6e2b95f732f38c8626 (patch) | |
tree | 1e8609405e3cd0ce870e41c15b33299bfbd6208e /bfd | |
parent | 542df965d095023ea24571cba661245ebb46fc7f (diff) | |
download | binutils-2808c7aac49eec873c21ea6e2b95f732f38c8626.zip binutils-2808c7aac49eec873c21ea6e2b95f732f38c8626.tar.gz binutils-2808c7aac49eec873c21ea6e2b95f732f38c8626.tar.bz2 |
Missing from 2003-07-11 commit.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/cpu-h8300.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/bfd/cpu-h8300.c b/bfd/cpu-h8300.c index 6ed0fff..1a4f4d7 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 (); + } +} |