qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for-2.5 03/30] m68k: introduce read_imXX() funct


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH for-2.5 03/30] m68k: introduce read_imXX() functions
Date: Tue, 11 Aug 2015 20:54:58 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0

On 08/09/2015 01:13 PM, Laurent Vivier wrote:
Read a 8, 16 or 32bit immediat constant.

An Immediat constant is stored in the instruction opcode and
can be in one or two extension words.

Signed-off-by: Laurent Vivier <address@hidden>
---
  target-m68k/translate.c | 73 ++++++++++++++++++++++++-------------------------
  1 file changed, 35 insertions(+), 38 deletions(-)

diff --git a/target-m68k/translate.c b/target-m68k/translate.c
index f190f19..3b87b0c 100644
--- a/target-m68k/translate.c
+++ b/target-m68k/translate.c
@@ -260,16 +260,30 @@ static TCGv gen_ldst(DisasContext *s, int opsize, TCGv 
addr, TCGv val,
      }
  }

-/* Read a 32-bit immediate constant.  */
-static inline uint32_t read_im32(CPUM68KState *env, DisasContext *s)
+/* Read an 8-bit immediate constant */
+static inline uint32_t read_im8(CPUM68KState *env, DisasContext *s)
  {
      uint32_t im;
-    im = ((uint32_t)cpu_lduw_code(env, s->pc)) << 16;
+    im = cpu_ldsb_code(env, s->pc + 1);
      s->pc += 2;
-    im |= cpu_lduw_code(env, s->pc);
+    return im;
+}
+/* Read a 16-bit immediate constant */
+static inline uint32_t read_im16(CPUM68KState *env, DisasContext *s)
+{
+    uint32_t im;
+    im = cpu_ldsw_code(env, s->pc);
      s->pc += 2;
      return im;
  }
+/* Read a 32-bit immediate constant.  */
+static inline uint32_t read_im32(CPUM68KState *env, DisasContext *s)
+{
+    uint32_t im;
+    im = read_im16(env, s) << 16;
+    im |= 0xffff & read_im16(env, s);
+    return im;
+}

Watch the spacing between functions. It's probably better to have the return types match the function -- int8_t, int16_t, int32_t. Finally, read_im8 might as well call read_im16 and truncate the result via return type.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]