aboutsummaryrefslogtreecommitdiff
path: root/src/base.h
diff options
context:
space:
mode:
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 *);