aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2025-11-09 20:04:47 +0100
committerXavier Del Campo Romero <xavi92@disroot.org>2025-11-09 20:04:47 +0100
commit806824b23c28d2d81ffd588c555be82fa5a14004 (patch)
treea6e86a595f9f9b374973a8f0a45ded8a62ee1bab
parent015c7edfa0e0460b7978fcfd724699af8fb6ec21 (diff)
Add i32.lt_u
-rw-r--r--private_include/nw/ops.h1
-rw-r--r--src/interp/ops.c2
-rw-r--r--src/op/CMakeLists.txt1
-rw-r--r--src/op/i32_lt_u.c23
4 files changed, 26 insertions, 1 deletions
diff --git a/private_include/nw/ops.h b/private_include/nw/ops.h
index 9646c5c..373da07 100644
--- a/private_include/nw/ops.h
+++ b/private_include/nw/ops.h
@@ -53,6 +53,7 @@ void nwp_op_i32_eqz(struct nw_interp *i);
void nwp_op_i32_eq(struct nw_interp *i);
void nwp_op_i32_ne(struct nw_interp *i);
void nwp_op_i32_lt_s(struct nw_interp *i);
+void nwp_op_i32_lt_u(struct nw_interp *i);
void nwp_op_i32_ge_s(struct nw_interp *i);
void nwp_op_i32_ge_u(struct nw_interp *i);
void nwp_op_i32_shl(struct nw_interp *i);
diff --git a/src/interp/ops.c b/src/interp/ops.c
index 871b07e..de69126 100644
--- a/src/interp/ops.c
+++ b/src/interp/ops.c
@@ -87,7 +87,7 @@ static void (*const ops[])(struct nw_interp *) =
nwp_op_i32_eq, /* OP_I32_EQ */
nwp_op_i32_ne, /* OP_I32_NE */
nwp_op_i32_lt_s, /* OP_I32_LT_S */
- NULL, /* OP_I32_LT_U */
+ nwp_op_i32_lt_u, /* OP_I32_LT_U */
NULL, /* OP_I32_GT_S */
NULL, /* OP_I32_GT_U */
NULL, /* OP_I32_LE_S */
diff --git a/src/op/CMakeLists.txt b/src/op/CMakeLists.txt
index 15c28f3..4b4a531 100644
--- a/src/op/CMakeLists.txt
+++ b/src/op/CMakeLists.txt
@@ -25,6 +25,7 @@ target_sources(${PROJECT_NAME} PRIVATE
i32_load.c
i32_load8_u.c
i32_lt_s.c
+ i32_lt_u.c
i32_mul.c
i32_ne.c
i32_or.c
diff --git a/src/op/i32_lt_u.c b/src/op/i32_lt_u.c
new file mode 100644
index 0000000..f321892
--- /dev/null
+++ b/src/op/i32_lt_u.c
@@ -0,0 +1,23 @@
+/*
+ * nanowasm, a tiny WebAssembly/Wasm interpreter
+ * Copyright (C) 2023-2025 Xavier Del Campo Romero
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
+ */
+
+#include <nanowasm/nw.h>
+#include <nw/routines.h>
+
+static int lt_u(const struct nw_i_sm_arithm_out *const o,
+ union nw_value *const res)
+{
+ res->i32 = (unsigned long)o->left.i32 < (unsigned long)o->right.i32;
+ return 0;
+}
+
+void nwp_op_i32_lt_u(struct nw_interp *const i)
+{
+ nwp_arithm(i, NW_TYPE_I32, lt_u);
+}