- fix return value in case we failed to write to the destination register.
- pretty-print registers.
This commit is contained in:
parent
f4fdc411c5
commit
358f6940ee
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: emul.c,v 1.1 1997/03/14 23:57:58 christos Exp $ */
|
||||
/* $NetBSD: emul.c,v 1.2 1997/03/15 00:39:51 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
|
||||
@ -56,6 +56,8 @@ static __inline int decodeaddr __P((struct trapframe *, union instr *, void *));
|
||||
static int muldiv __P((struct trapframe *, union instr *, int32_t *, int32_t *,
|
||||
int32_t *));
|
||||
|
||||
#define REGNAME(i) "goli"[i >> 3], i & 7
|
||||
|
||||
|
||||
static __inline int
|
||||
readgpreg(tf, i, val)
|
||||
@ -165,14 +167,14 @@ muldiv(tf, code, rd, rs1, rs2)
|
||||
op.num = code->i_op3.i_op3;
|
||||
|
||||
#ifdef DEBUG_EMUL
|
||||
uprintf("muldiv %x: %c%s%s r%d, r%d, ", code->i_int,
|
||||
uprintf("muldiv %x: %c%s%s %c%d, %c%d, ", code->i_int,
|
||||
"us"[op.bits.sgn], op.bits.div ? "div" : "mul",
|
||||
op.bits.cc ? "cc" : "",
|
||||
code->i_op3.i_rd, code->i_op3.i_rs1);
|
||||
op.bits.cc ? "cc" : "", REGNAME(code->i_op3.i_rd),
|
||||
REGNAME(code->i_op3.i_rs1));
|
||||
if (code->i_loadstore.i_i)
|
||||
uprintf("0x%x\n", *rs2);
|
||||
else
|
||||
uprintf("r%d\n", code->i_asi.i_rs2);
|
||||
uprintf("%c%d\n", REGNAME(code->i_asi.i_rs2));
|
||||
#endif
|
||||
|
||||
if (op.bits.div) {
|
||||
@ -184,7 +186,7 @@ muldiv(tf, code, rd, rs1, rs2)
|
||||
* proc in here.
|
||||
*/
|
||||
DPRINTF(("emulinstr: avoid zerodivide\n"));
|
||||
return SIGFPE;
|
||||
return EINVAL;
|
||||
}
|
||||
*rd = *rs1 / *rs2;
|
||||
DPRINTF(("muldiv: %d / %d = %d\n", *rs1, *rs2, *rd));
|
||||
@ -294,14 +296,14 @@ fixalign(p, tf)
|
||||
rs1 += rs2;
|
||||
|
||||
#ifdef DEBUG_EMUL
|
||||
uprintf("memalign %x: %s%c%c %c%d, r%d, ", code.i_int,
|
||||
uprintf("memalign %x: %s%c%c %c%d, %c%d, ", code.i_int,
|
||||
op.bits.st ? "st" : "ld", "us"[op.bits.sgn],
|
||||
"w*hd"[op.bits.sz], "rf"[op.bits.fl], code.i_op3.i_rd,
|
||||
code.i_op3.i_rs1);
|
||||
"w*hd"[op.bits.sz], op.bits.fl ? 'f' : REGNAME(code.i_op3.i_rd),
|
||||
REGNAME(code.i_op3.i_rs1));
|
||||
if (code.i_loadstore.i_i)
|
||||
uprintf("0x%x\n", rs2);
|
||||
else
|
||||
uprintf("r%d\n", code.i_asi.i_rs2);
|
||||
uprintf("%c%d\n", REGNAME(code.i_asi.i_rs2));
|
||||
#endif
|
||||
#ifdef DIAGNOSTIC
|
||||
if (op.bits.fl && p != fpproc)
|
||||
@ -430,11 +432,13 @@ emulinstr(pc, tf)
|
||||
return SIGILL;
|
||||
}
|
||||
else if ((error = muldiv(tf, &code, &rd, &rs1, &rs2)) != 0)
|
||||
return error;
|
||||
return SIGFPE;
|
||||
}
|
||||
|
||||
if ((error = writegpreg(tf, code.i_op3.i_rd, &rd)) != 0)
|
||||
if ((error = writegpreg(tf, code.i_op3.i_rd, &rd)) != 0) {
|
||||
DPRINTF(("muldiv: write rd %d\n", error));
|
||||
return SIGILL;
|
||||
}
|
||||
|
||||
return error;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user