aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2023-02-11 20:51:03 +0000
committerGravatar Peter McGoron 2023-02-11 20:51:03 +0000
commit70720b8a1610a9e8dc43a9735af43b4a481153e9 (patch)
tree28475d2edcce9214a9e8e2e2714f7bd1215735e4
parentadd signed division IDIV (diff)
rename idiv to sdiv
Diffstat (limited to '')
-rw-r--r--asm/creole.py2
-rw-r--r--asm/test.py10
-rw-r--r--creole.c4
-rw-r--r--creole.h2
4 files changed, 9 insertions, 9 deletions
diff --git a/asm/creole.py b/asm/creole.py
index 3746003..1d98051 100644
--- a/asm/creole.py
+++ b/asm/creole.py
@@ -91,7 +91,7 @@ class Instruction(Enum):
ADD = 3, ArgType.REG, ArgType.VAL, ArgType.VAL
MUL = 4, 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
CLB = 8, ArgType.LAB
SYS = 9, ArgType.VAL
diff --git a/asm/test.py b/asm/test.py
index 1274d9c..4b6471c 100644
--- a/asm/test.py
+++ b/asm/test.py
@@ -267,16 +267,16 @@ class DivTest(unittest.TestCase):
ex = ffi.Environment(p())
self.assertEqual(ex(), ffi.RunRet.DIVIDE_BY_ZERO)
- def test_idiv_by_zero(self):
+ def test_sdiv_by_zero(self):
p = Program()
- p.parse_asm_line("idiv r0 8 0")
+ p.parse_asm_line("sdiv r0 8 0")
ex = ffi.Environment(p())
self.assertEqual(ex(), ffi.RunRet.DIVIDE_BY_ZERO)
- def test_div_neg(self):
+ def test_sdiv_neg(self):
p = Program()
- p.parse_asm_line("idiv r0 16 -4")
- p.parse_asm_line("idiv r1 r0 -4")
+ p.parse_asm_line("sdiv r0 16 -4")
+ p.parse_asm_line("sdiv r1 r0 -4")
ex = ffi.Environment(p())
self.assertEqual(ex(), ffi.RunRet.STOP)
self.assertEqual(ex.getreg(0), -4)
diff --git a/creole.c b/creole.c
index 8865939..135576f 100644
--- a/creole.c
+++ b/creole.c
@@ -35,7 +35,7 @@ static const struct {
defop(ADD, 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(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(CLB, 1, TYPE_LAB, 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;
check(creole_reg_write(env, ins->w[0], a1 / a2));
break;
- case CREOLE_IDIV:
+ case CREOLE_SDIV:
check(read_val(env, ins, 1, &a1));
check(read_val(env, ins, 2, &a2));
if (a2 == 0)
diff --git a/creole.h b/creole.h
index 0e84a72..452bc91 100644
--- a/creole.h
+++ b/creole.h
@@ -23,7 +23,7 @@ enum creole_opcode {
CREOLE_ADD = 3,
CREOLE_MUL = 4,
CREOLE_DIV = 5,
- CREOLE_IDIV = 6,
+ CREOLE_SDIV = 6,
CREOLE_JL = 7,
CREOLE_CLB = 8,
CREOLE_SYS = 9,