• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisión8c92d125e7281bbadfe9c004d7de233e203eec39 (tree)
Tiempo2019-06-18 23:01:17
AutorRichard Henderson <richard.henderson@lina...>
CommiterYoshinori Sato

Log Message

target/rx: Collect all bytes during disassembly

Collected, to be used in the next patch.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Message-Id: <20190607091116.49044-23-ysato@users.sourceforge.jp>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Cambiar Resumen

Diferencia incremental

--- a/target/rx/disas.c
+++ b/target/rx/disas.c
@@ -25,43 +25,59 @@ typedef struct DisasContext {
2525 disassemble_info *dis;
2626 uint32_t addr;
2727 uint32_t pc;
28+ uint8_t len;
29+ uint8_t bytes[8];
2830 } DisasContext;
2931
3032
3133 static uint32_t decode_load_bytes(DisasContext *ctx, uint32_t insn,
32- int i, int n)
34+ int i, int n)
3335 {
34- bfd_byte buf;
36+ uint32_t addr = ctx->addr;
37+
38+ g_assert(ctx->len == i);
39+ g_assert(n <= ARRAY_SIZE(ctx->bytes));
40+
3541 while (++i <= n) {
36- ctx->dis->read_memory_func(ctx->addr++, &buf, 1, ctx->dis);
37- insn |= buf << (32 - i * 8);
42+ ctx->dis->read_memory_func(addr++, &ctx->bytes[i - 1], 1, ctx->dis);
43+ insn |= ctx->bytes[i - 1] << (32 - i * 8);
3844 }
45+ ctx->addr = addr;
46+ ctx->len = n;
47+
3948 return insn;
4049 }
4150
4251 static int32_t li(DisasContext *ctx, int sz)
4352 {
44- int32_t addr;
45- bfd_byte buf[4];
46- addr = ctx->addr;
53+ uint32_t addr = ctx->addr;
54+ uintptr_t len = ctx->len;
4755
4856 switch (sz) {
4957 case 1:
58+ g_assert(len + 1 <= ARRAY_SIZE(ctx->bytes));
5059 ctx->addr += 1;
51- ctx->dis->read_memory_func(addr, buf, 1, ctx->dis);
52- return (int8_t)buf[0];
60+ ctx->len += 1;
61+ ctx->dis->read_memory_func(addr, ctx->bytes + len, 1, ctx->dis);
62+ return (int8_t)ctx->bytes[len];
5363 case 2:
64+ g_assert(len + 2 <= ARRAY_SIZE(ctx->bytes));
5465 ctx->addr += 2;
55- ctx->dis->read_memory_func(addr, buf, 2, ctx->dis);
56- return ldsw_le_p(buf);
66+ ctx->len += 2;
67+ ctx->dis->read_memory_func(addr, ctx->bytes + len, 2, ctx->dis);
68+ return ldsw_le_p(ctx->bytes + len);
5769 case 3:
70+ g_assert(len + 3 <= ARRAY_SIZE(ctx->bytes));
5871 ctx->addr += 3;
59- ctx->dis->read_memory_func(addr, buf, 3, ctx->dis);
60- return (int8_t)buf[2] << 16 | lduw_le_p(buf);
72+ ctx->len += 3;
73+ ctx->dis->read_memory_func(addr, ctx->bytes + len, 3, ctx->dis);
74+ return (int8_t)ctx->bytes[len + 2] << 16 | lduw_le_p(ctx->bytes + len);
6175 case 0:
76+ g_assert(len + 4 <= ARRAY_SIZE(ctx->bytes));
6277 ctx->addr += 4;
63- ctx->dis->read_memory_func(addr, buf, 4, ctx->dis);
64- return ldl_le_p(buf);
78+ ctx->len += 4;
79+ ctx->dis->read_memory_func(addr, ctx->bytes + len, 4, ctx->dis);
80+ return ldl_le_p(ctx->bytes + len);
6581 default:
6682 g_assert_not_reached();
6783 }
@@ -110,7 +126,7 @@ static const char psw[] = {
110126 static void rx_index_addr(DisasContext *ctx, char out[8], int ld, int mi)
111127 {
112128 uint32_t addr = ctx->addr;
113- uint8_t buf[2];
129+ uintptr_t len = ctx->len;
114130 uint16_t dsp;
115131
116132 switch (ld) {
@@ -119,14 +135,18 @@ static void rx_index_addr(DisasContext *ctx, char out[8], int ld, int mi)
119135 out[0] = '\0';
120136 return;
121137 case 1:
138+ g_assert(len + 1 <= ARRAY_SIZE(ctx->bytes));
122139 ctx->addr += 1;
123- ctx->dis->read_memory_func(addr, buf, 1, ctx->dis);
124- dsp = buf[0];
140+ ctx->len += 1;
141+ ctx->dis->read_memory_func(addr, ctx->bytes + len, 1, ctx->dis);
142+ dsp = ctx->bytes[len];
125143 break;
126144 case 2:
145+ g_assert(len + 2 <= ARRAY_SIZE(ctx->bytes));
127146 ctx->addr += 2;
128- ctx->dis->read_memory_func(addr, buf, 2, ctx->dis);
129- dsp = lduw_le_p(buf);
147+ ctx->len += 2;
148+ ctx->dis->read_memory_func(addr, ctx->bytes + len, 2, ctx->dis);
149+ dsp = lduw_le_p(ctx->bytes + len);
130150 break;
131151 default:
132152 g_assert_not_reached();
@@ -1392,8 +1412,10 @@ int print_insn_rx(bfd_vma addr, disassemble_info *dis)
13921412 DisasContext ctx;
13931413 uint32_t insn;
13941414 int i;
1415+
13951416 ctx.dis = dis;
13961417 ctx.pc = ctx.addr = addr;
1418+ ctx.len = 0;
13971419
13981420 insn = decode_load(&ctx);
13991421 if (!decode(&ctx, insn)) {