From 0b434e7c6c589a8e60f7577975d147d392aa6c1b Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Fri, 21 Feb 2014 01:29:13 +0000 Subject: [PATCH] [FAST486] Add a macro ALIGNMENT_CHECK that checks for unaligned pointers and generates an exception. svn path=/branches/ntvdm/; revision=62279 --- lib/fast486/common.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/fast486/common.h b/lib/fast486/common.h index a97f1c5ac2d..1bfdb311ef2 100644 --- a/lib/fast486/common.h +++ b/lib/fast486/common.h @@ -55,6 +55,15 @@ if (State->PrefixFlags & FAST486_PREFIX_LOCK)\ #define SWAP(x, y) { (x) ^= (y); (y) ^= (x); (x) ^= (y); } +#define ALIGNMENT_CHECK(x, a) if (State->Flags.Ac \ + && (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_AM)\ + && (State->Cpl == 3)\ + && (((x) % (a)) != 0))\ +{\ + Fast486Exception(State, FAST486_EXCEPTION_AC);\ + return FALSE;\ +} + #define PAGE_ALIGN(x) ((x) & 0xFFFFF000) #define PAGE_OFFSET(x) ((x) & 0x00000FFF) #define GET_ADDR_PDE(x) ((x) >> 22)