From 7230c83abcf764da504b69b3433d3c9c1668e262 Mon Sep 17 00:00:00 2001 From: Andrew Chambers Date: Sat, 16 Oct 2021 14:53:48 +1300 Subject: More documentation. --- main.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 9ad714b..212e320 100644 --- a/main.c +++ b/main.c @@ -207,15 +207,7 @@ static uint8_t regbits(AsmKind k) { return (k - (ASM_REG_BEGIN + 1)) % 16; } static uint8_t isreg64(AsmKind k) { return k >= ASM_RAX && k <= ASM_R15; } -/* Register that requires the use of a rex prefix. */ -static uint8_t isrexreg(AsmKind k) { - return k > ASM_REG_BEGIN && k < ASM_REG_END && - (regbits(k) & (1 << 3) || k == ASM_SPL || k == ASM_BPL || - k == ASM_SIL || k == ASM_DIL); -} - -/* Compose a rex prefix - See intel manual. */ - +/* Rex opcode prefix. */ typedef struct Rex { uint8_t required : 1; uint8_t w : 1; @@ -224,6 +216,13 @@ typedef struct Rex { uint8_t b : 1; } Rex; +/* Register that requires the use of a rex prefix. */ +static uint8_t isrexreg(AsmKind k) { + return k > ASM_REG_BEGIN && k < ASM_REG_END && + (regbits(k) & (1 << 3) || k == ASM_SPL || k == ASM_BPL || + k == ASM_SIL || k == ASM_DIL); +} + static uint8_t rexbyte(Rex rex) { return ((1 << 6) | (rex.w << 3) | (rex.r << 2) | (rex.x << 1) | rex.b); } -- cgit v1.2.3