summaryrefslogtreecommitdiff
path: root/nasmlib.c
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2009-10-31 20:02:14 +0300
committerCyrill Gorcunov <gorcunov@gmail.com>2009-10-31 20:02:14 +0300
commitbafd877d48b25e576a4c905a14f1301502cca69c (patch)
tree31dc41dbd7cb24d3020dd6a092797f410d50d231 /nasmlib.c
parent41208028ff52d190044ee7532bf14c5aca0f899a (diff)
downloadnasm-bafd877d48b25e576a4c905a14f1301502cca69c.tar.gz
nasmlib: Introduce idata_bytes helper
This allow us to eliminate code duplication Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'nasmlib.c')
-rw-r--r--nasmlib.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/nasmlib.c b/nasmlib.c
index 0dea39ec..b4ca34e4 100644
--- a/nasmlib.c
+++ b/nasmlib.c
@@ -689,3 +689,41 @@ char *nasm_zap_spaces_rev(char *p)
*p-- = 0x0;
return p;
}
+
+/*
+ * initialized data bytes length from opcode
+ */
+int idata_bytes(int opcode)
+{
+ int ret;
+ switch (opcode) {
+ case I_DB:
+ ret = 1;
+ break;
+ case I_DW:
+ ret = 2;
+ break;
+ case I_DD:
+ ret = 4;
+ break;
+ case I_DQ:
+ ret = 8;
+ break;
+ case I_DT:
+ ret = 10;
+ break;
+ case I_DO:
+ ret = 16;
+ break;
+ case I_DY:
+ ret = 32;
+ break;
+ case I_none:
+ ret = -1;
+ break;
+ default:
+ ret = 0;
+ break;
+ }
+ return ret;
+}