diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2009-10-31 20:02:14 +0300 |
---|---|---|
committer | Cyrill Gorcunov <gorcunov@gmail.com> | 2009-10-31 20:02:14 +0300 |
commit | bafd877d48b25e576a4c905a14f1301502cca69c (patch) | |
tree | 31dc41dbd7cb24d3020dd6a092797f410d50d231 /nasmlib.c | |
parent | 41208028ff52d190044ee7532bf14c5aca0f899a (diff) | |
download | nasm-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.c | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -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; +} |