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 <laur...@vivier.eu>
---
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~