Skip to content

Commit

Permalink
target/hppa: sar register allows only 5 bits on 32-bit CPU
Browse files Browse the repository at this point in the history
The sar shift amount register is limited to 5 bits when running
a 32-bit CPU. Strip off the remaining bits.

The interesting part is, that this register allows to detect at runtime
if a physical CPU is capable to execute PA2.0 (64-bit) instructions.

Signed-off-by: Helge Deller <deller@gmx.de>
  • Loading branch information
hdeller authored and rth7680 committed Nov 7, 2023
1 parent f13bf34 commit f3618f5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions target/hppa/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2176,7 +2176,7 @@ static bool trans_mtctl(DisasContext *ctx, arg_mtctl *a)
if (ctl == CR_SAR) {
reg = load_gpr(ctx, a->r);
tmp = tcg_temp_new();
tcg_gen_andi_reg(tmp, reg, TARGET_REGISTER_BITS - 1);
tcg_gen_andi_reg(tmp, reg, ctx->is_pa20 ? 63 : 31);
save_or_nullify(ctx, cpu_sar, tmp);

cond_free(&ctx->null_cond);
Expand Down Expand Up @@ -2237,7 +2237,7 @@ static bool trans_mtsarcm(DisasContext *ctx, arg_mtsarcm *a)
TCGv_reg tmp = tcg_temp_new();

tcg_gen_not_reg(tmp, load_gpr(ctx, a->r));
tcg_gen_andi_reg(tmp, tmp, TARGET_REGISTER_BITS - 1);
tcg_gen_andi_reg(tmp, tmp, ctx->is_pa20 ? 63 : 31);
save_or_nullify(ctx, cpu_sar, tmp);

cond_free(&ctx->null_cond);
Expand Down

0 comments on commit f3618f5

Please sign in to comment.