wip! translate: implement BR{EQ,NE}0{B,W}

This commit is contained in:
fridtjof 2025-08-20 01:28:49 +02:00
parent f4503efb20
commit 75a4c5793e
2 changed files with 26 additions and 0 deletions

View file

@ -253,6 +253,8 @@ TBIT_mem_abs 0000 0000 0001 0001 1111 .... .... .... .... .... .... .... wid
BRCOND 0001 .... cond:4 .... dest=%br_disp8
BR0 0000 11 word:1 ne:1 dest:4 src:4
JCOND 0000 1010 cond:4 ra:4
EXCP 0000 0000 1100 id:4

View file

@ -1328,6 +1328,30 @@ static bool trans_BRCOND(DisasContext* ctx, arg_BRCOND *a) {
return true;
}
static bool trans_BR0(DisasContext* ctx, arg_BR0* a) {
int disp5 = (a->dest + 1) * 2; // disp*2+
TCGv tmp = tcg_temp_new_i32();
if (a->word == 1) {
tcg_gen_ext16u_i32(tmp, r[a->src]);
} else {
tcg_gen_ext8u_i32(tmp, r[a->src]);
}
TCGLabel* l = gen_new_label();
tcg_gen_brcondi_i32(a->ne == 1 ? TCG_COND_NE : TCG_COND_EQ, tmp, 0, l);
gen_goto(&ctx->base, ctx->base.pc_next, 0);
gen_set_label(l);
vaddr pc_this = ctx->base.pc_next - 2;
gen_goto(&ctx->base, pc_this + disp5, 1);
ctx->base.is_jmp = DISAS_NORETURN;
return true;
}
static bool trans_JCOND(DisasContext* ctx, arg_JCOND *a) {
TCGLabel* l = gen_new_label();