aboutsummaryrefslogtreecommitdiff
path: root/src/base.h
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-23 00:53:44 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-23 00:53:44 +0100
commit20030e364cd869e5651b2e2fb63cfb8881fbf5b7 (patch)
treeb9504cc200bcc7e8ded341efe2c9ebd66f0b0514 /src/base.h
parent00f3b3bf2111cc27543958b5c9fdae23cba420c9 (diff)
downloadovm-20030e364cd869e5651b2e2fb63cfb8881fbf5b7.tar.gz
ovm-20030e364cd869e5651b2e2fb63cfb8881fbf5b7.tar.bz2
ovm-20030e364cd869e5651b2e2fb63cfb8881fbf5b7.zip
Moved macros to extract nth (byte|hword) from a word to base.h
Diffstat (limited to 'src/base.h')
-rw-r--r--src/base.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/base.h b/src/base.h
index a135061..dbeec80 100644
--- a/src/base.h
+++ b/src/base.h
@@ -56,6 +56,10 @@ typedef enum
#define HWORD_SIZE sizeof(hword)
#define WORD_SIZE sizeof(word)
+// Macros to extract the nth byte or nth hword from a word
+#define WORD_NTH_BYTE(WORD, N) (((WORD) >> ((N)*8)) & 0xff)
+#define WORD_NTH_HWORD(WORD, N) (((WORD) >> ((N)*2)) & 0xFFFFFFFF)
+
// Assume array contains 4 bytes.
hword convert_bytes_to_hword(byte *);
void convert_hword_to_bytes(hword, byte *);