my bad, then I was mislead by "Which is, in general, what you want for implementing a custom instruction". Also the code around me is full of gen instructions, so I thought that's what I should use.
So, when reading the doc I found out about the cpu_{ld,st}*_mmu functions. That sounds more what I want for a direct action, No? Regards BitFriends Richard Henderson <richard.hender...@linaro.org> schrieb am So., 2. Okt. 2022, 16:40: > On 10/2/22 02:20, BitFriends wrote: > > I now came up with this code: > > > > TCGv_i64 res = 0; > > TCGv_i64 addr = (TCGv_i64)(env->regs[R_EDI]); > > > > tcg_gen_qemu_ld_i64(res, addr, 0, MO_LEUQ); > > > > env->regs[R_EAX] = (target_ulong)res; > > > > However this crashes afterwards in test_bit. Maybe this is caused by an > invalid access? > > Anything wrong about the code? This still gives some warnings, like > TCGv_i32 expected (and > > when you use TCGv_i32, it says TCGv_i64 expected) plus some casting > warnings. > > It is as if you did not read the second paragraph of my response at all. > tcg_gen_qemu_ld_i64 is for generating code, not performing a direct action. > Can you see how your code differs from *all* of the code around it? > > r~ > > > > > Am Sa., 1. Okt. 2022 um 22:23 Uhr schrieb Richard Henderson < > richard.hender...@linaro.org > > <mailto:richard.hender...@linaro.org>>: > > > > On 10/1/22 13:10, BitFriends wrote: > > > Hello, > > > > > > I am trying to create a custom instruction that accesses guest > memory specified by an > > > address in a register. I specifically want to read from that > address. So I tried to do > > > that using "tcg_gen_qemu_ld_i64(&res, env->regs[R_EDI], 0, > MO_LEUQ);", but that > > doesn't > > > save any result in res. > > > > This statement should have given you compilation errors, so I don't > know what you mean by > > "doesn't save any result". There's clearly a disconnect between > what you describe and > > what you actually attempted. > > > > Anyway, by the name you can see that function "gen"erates a "tcg" > operation, which is > > then > > later compiled by the jit, the output of which is later executed to > produce a result. > > Which is, in general, what you want for implementing a custom > instruction. > > > > > > r~ > > > >