Moved macros to extract nth (byte|hword) from a word to base.h

This commit is contained in:
2023-10-23 00:53:44 +01:00
parent 00f3b3bf21
commit 20030e364c
2 changed files with 4 additions and 4 deletions

View File

@@ -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 *);

View File

@@ -403,10 +403,6 @@ err_t vm_push_word(vm_t *vm, data_t w)
return ERR_OK;
}
#define WORD_NTH_BYTE(WORD, N) (((WORD) >> ((N)*8)) & 0b11111111)
#define WORD_NTH_HWORD(WORD, N) \
(((WORD) >> ((N)*2)) & 0b11111111111111111111111111111111)
err_t vm_push_byte_register(vm_t *vm, byte reg)
{
if (reg >= VM_REGISTERS * 8)