* [binutils-gdb] x86: move get<N>() disassembler helper functions
@ 2023-05-12 6:58 Jan Beulich
0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2023-05-12 6:58 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a675ea09fb6e09cfebbdf8fc5795f4249f50d690
commit a675ea09fb6e09cfebbdf8fc5795f4249f50d690
Author: Jan Beulich <jbeulich@suse.com>
Date: Fri May 12 08:57:37 2023 +0200
x86: move get<N>() disassembler helper functions
... such that none of them would need forward declarations anymore.
Diff:
---
opcodes/i386-dis.c | 146 ++++++++++++++++++++++++++---------------------------
1 file changed, 71 insertions(+), 75 deletions(-)
diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index b529fe705bc..ac69205f26a 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -47,10 +47,6 @@ static void oappend_with_style (instr_info *, const char *,
enum disassembler_style);
static void oappend (instr_info *, const char *);
static void append_seg (instr_info *);
-static bool get32s (instr_info *, bfd_vma *);
-static bool get16 (instr_info *, bfd_vma *);
-static bool get16s (instr_info *, bfd_vma *);
-static bool get8s (instr_info *, bfd_vma *);
static void set_op (instr_info *, bfd_vma, bool);
static bool OP_E (instr_info *, int, int);
@@ -11714,6 +11710,77 @@ print_register (instr_info *ins, unsigned int reg, unsigned int rexmask,
oappend_register (ins, names[reg]);
}
+static bool
+get8s (instr_info *ins, bfd_vma *res)
+{
+ if (!fetch_code (ins->info, ins->codep + 1))
+ return false;
+ *res = (((bfd_vma) *ins->codep++ & 0xff) ^ 0x80) - 0x80;
+ return true;
+}
+
+static bool
+get16 (instr_info *ins, bfd_vma *res)
+{
+ if (!fetch_code (ins->info, ins->codep + 2))
+ return false;
+ *res = (bfd_vma) *ins->codep++ & 0xff;
+ *res |= ((bfd_vma) *ins->codep++ & 0xff) << 8;
+ return true;
+}
+
+static bool
+get16s (instr_info *ins, bfd_vma *res)
+{
+ if (!get16 (ins, res))
+ return false;
+ *res = (*res ^ 0x8000) - 0x8000;
+ return true;
+}
+
+static bool
+get32 (instr_info *ins, bfd_vma *res)
+{
+ if (!fetch_code (ins->info, ins->codep + 4))
+ return false;
+ *res = *ins->codep++ & (bfd_vma) 0xff;
+ *res |= (*ins->codep++ & (bfd_vma) 0xff) << 8;
+ *res |= (*ins->codep++ & (bfd_vma) 0xff) << 16;
+ *res |= (*ins->codep++ & (bfd_vma) 0xff) << 24;
+ return true;
+}
+
+static bool
+get32s (instr_info *ins, bfd_vma *res)
+{
+ if (!get32 (ins, res))
+ return false;
+
+ *res = (*res ^ ((bfd_vma) 1 << 31)) - ((bfd_vma) 1 << 31);
+
+ return true;
+}
+
+static bool
+get64 (instr_info *ins, uint64_t *res)
+{
+ unsigned int a;
+ unsigned int b;
+
+ if (!fetch_code (ins->info, ins->codep + 8))
+ return false;
+ a = *ins->codep++ & 0xff;
+ a |= (*ins->codep++ & 0xff) << 8;
+ a |= (*ins->codep++ & 0xff) << 16;
+ a |= (*ins->codep++ & 0xffu) << 24;
+ b = *ins->codep++ & 0xff;
+ b |= (*ins->codep++ & 0xff) << 8;
+ b |= (*ins->codep++ & 0xff) << 16;
+ b |= (*ins->codep++ & 0xffu) << 24;
+ *res = a + ((uint64_t) b << 32);
+ return true;
+}
+
static bool
OP_E_memory (instr_info *ins, int bytemode, int sizeflag)
{
@@ -12249,77 +12316,6 @@ OP_G (instr_info *ins, int bytemode, int sizeflag)
return true;
}
-static bool
-get64 (instr_info *ins, uint64_t *res)
-{
- unsigned int a;
- unsigned int b;
-
- if (!fetch_code (ins->info, ins->codep + 8))
- return false;
- a = *ins->codep++ & 0xff;
- a |= (*ins->codep++ & 0xff) << 8;
- a |= (*ins->codep++ & 0xff) << 16;
- a |= (*ins->codep++ & 0xffu) << 24;
- b = *ins->codep++ & 0xff;
- b |= (*ins->codep++ & 0xff) << 8;
- b |= (*ins->codep++ & 0xff) << 16;
- b |= (*ins->codep++ & 0xffu) << 24;
- *res = a + ((uint64_t) b << 32);
- return true;
-}
-
-static bool
-get32 (instr_info *ins, bfd_vma *res)
-{
- if (!fetch_code (ins->info, ins->codep + 4))
- return false;
- *res = *ins->codep++ & (bfd_vma) 0xff;
- *res |= (*ins->codep++ & (bfd_vma) 0xff) << 8;
- *res |= (*ins->codep++ & (bfd_vma) 0xff) << 16;
- *res |= (*ins->codep++ & (bfd_vma) 0xff) << 24;
- return true;
-}
-
-static bool
-get32s (instr_info *ins, bfd_vma *res)
-{
- if (!get32 (ins, res))
- return false;
-
- *res = (*res ^ ((bfd_vma) 1 << 31)) - ((bfd_vma) 1 << 31);
-
- return true;
-}
-
-static bool
-get16 (instr_info *ins, bfd_vma *res)
-{
- if (!fetch_code (ins->info, ins->codep + 2))
- return false;
- *res = (bfd_vma) *ins->codep++ & 0xff;
- *res |= ((bfd_vma) *ins->codep++ & 0xff) << 8;
- return true;
-}
-
-static bool
-get16s (instr_info *ins, bfd_vma *res)
-{
- if (!get16 (ins, res))
- return false;
- *res = (*res ^ 0x8000) - 0x8000;
- return true;
-}
-
-static bool
-get8s (instr_info *ins, bfd_vma *res)
-{
- if (!fetch_code (ins->info, ins->codep + 1))
- return false;
- *res = (((bfd_vma) *ins->codep++ & 0xff) ^ 0x80) - 0x80;
- return true;
-}
-
static void
set_op (instr_info *ins, bfd_vma op, bool riprel)
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-12 6:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-12 6:58 [binutils-gdb] x86: move get<N>() disassembler helper functions Jan Beulich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).