From 20030e364cd869e5651b2e2fb63cfb8881fbf5b7 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Mon, 23 Oct 2023 00:53:44 +0100 Subject: Moved macros to extract nth (byte|hword) from a word to base.h --- src/base.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/base.h') 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 *); -- cgit v1.2.3-13-gbd6f