rename idiv to sdiv

This commit is contained in:
Peter McGoron 2023-02-11 20:51:03 +00:00
parent 5f3275cf2d
commit 70720b8a16
4 changed files with 9 additions and 9 deletions

View File

@ -91,7 +91,7 @@ class Instruction(Enum):
ADD = 3, ArgType.REG, ArgType.VAL, ArgType.VAL ADD = 3, ArgType.REG, ArgType.VAL, ArgType.VAL
MUL = 4, ArgType.REG, ArgType.VAL, ArgType.VAL MUL = 4, ArgType.REG, ArgType.VAL, ArgType.VAL
DIV = 5, ArgType.REG, ArgType.VAL, ArgType.VAL DIV = 5, ArgType.REG, ArgType.VAL, ArgType.VAL
IDIV = 6, ArgType.REG, ArgType.VAL, ArgType.VAL SDIV = 6, ArgType.REG, ArgType.VAL, ArgType.VAL
JL = 7, ArgType.LAB, ArgType.VAL, ArgType.VAL JL = 7, ArgType.LAB, ArgType.VAL, ArgType.VAL
CLB = 8, ArgType.LAB CLB = 8, ArgType.LAB
SYS = 9, ArgType.VAL SYS = 9, ArgType.VAL

View File

@ -267,16 +267,16 @@ class DivTest(unittest.TestCase):
ex = ffi.Environment(p()) ex = ffi.Environment(p())
self.assertEqual(ex(), ffi.RunRet.DIVIDE_BY_ZERO) self.assertEqual(ex(), ffi.RunRet.DIVIDE_BY_ZERO)
def test_idiv_by_zero(self): def test_sdiv_by_zero(self):
p = Program() p = Program()
p.parse_asm_line("idiv r0 8 0") p.parse_asm_line("sdiv r0 8 0")
ex = ffi.Environment(p()) ex = ffi.Environment(p())
self.assertEqual(ex(), ffi.RunRet.DIVIDE_BY_ZERO) self.assertEqual(ex(), ffi.RunRet.DIVIDE_BY_ZERO)
def test_div_neg(self): def test_sdiv_neg(self):
p = Program() p = Program()
p.parse_asm_line("idiv r0 16 -4") p.parse_asm_line("sdiv r0 16 -4")
p.parse_asm_line("idiv r1 r0 -4") p.parse_asm_line("sdiv r1 r0 -4")
ex = ffi.Environment(p()) ex = ffi.Environment(p())
self.assertEqual(ex(), ffi.RunRet.STOP) self.assertEqual(ex(), ffi.RunRet.STOP)
self.assertEqual(ex.getreg(0), -4) self.assertEqual(ex.getreg(0), -4)

View File

@ -35,7 +35,7 @@ static const struct {
defop(ADD, 3, TYPE_REG, TYPE_VAL, TYPE_VAL), defop(ADD, 3, TYPE_REG, TYPE_VAL, TYPE_VAL),
defop(MUL, 3, TYPE_REG, TYPE_VAL, TYPE_VAL), defop(MUL, 3, TYPE_REG, TYPE_VAL, TYPE_VAL),
defop(DIV, 3, TYPE_REG, TYPE_VAL, TYPE_VAL), defop(DIV, 3, TYPE_REG, TYPE_VAL, TYPE_VAL),
defop(IDIV, 3, TYPE_REG, TYPE_VAL, TYPE_VAL), defop(SDIV, 3, TYPE_REG, TYPE_VAL, TYPE_VAL),
defop(JL, 3, TYPE_LAB, TYPE_VAL, TYPE_VAL), defop(JL, 3, TYPE_LAB, TYPE_VAL, TYPE_VAL),
defop(CLB, 1, TYPE_LAB, TYPE_NONE, TYPE_NONE), defop(CLB, 1, TYPE_LAB, TYPE_NONE, TYPE_NONE),
defop(SYS, 1, TYPE_VAL, TYPE_NONE, TYPE_NONE) defop(SYS, 1, TYPE_VAL, TYPE_NONE, TYPE_NONE)
@ -548,7 +548,7 @@ enum creole_run_ret creole_step(struct creole_env *env, creole_word *sc)
return CREOLE_DIV_BY_ZERO; return CREOLE_DIV_BY_ZERO;
check(creole_reg_write(env, ins->w[0], a1 / a2)); check(creole_reg_write(env, ins->w[0], a1 / a2));
break; break;
case CREOLE_IDIV: case CREOLE_SDIV:
check(read_val(env, ins, 1, &a1)); check(read_val(env, ins, 1, &a1));
check(read_val(env, ins, 2, &a2)); check(read_val(env, ins, 2, &a2));
if (a2 == 0) if (a2 == 0)

View File

@ -23,7 +23,7 @@ enum creole_opcode {
CREOLE_ADD = 3, CREOLE_ADD = 3,
CREOLE_MUL = 4, CREOLE_MUL = 4,
CREOLE_DIV = 5, CREOLE_DIV = 5,
CREOLE_IDIV = 6, CREOLE_SDIV = 6,
CREOLE_JL = 7, CREOLE_JL = 7,
CREOLE_CLB = 8, CREOLE_CLB = 8,
CREOLE_SYS = 9, CREOLE_SYS = 9,