Author: aandrejevic Date: Thu Sep 12 00:05:23 2013 New Revision: 60050
URL: http://svn.reactos.org/svn/reactos?rev=60050&view=rev Log: [SOFT386] Implement ARPL.
Modified: branches/ntvdm/lib/soft386/opcodes.c
Modified: branches/ntvdm/lib/soft386/opcodes.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/soft386/opcodes.c?rev=... ============================================================================== --- branches/ntvdm/lib/soft386/opcodes.c [iso-8859-1] (original) +++ branches/ntvdm/lib/soft386/opcodes.c [iso-8859-1] Thu Sep 12 00:05:23 2013 @@ -3583,10 +3583,46 @@
SOFT386_OPCODE_HANDLER(Soft386OpcodeArpl) { - // TODO: NOT IMPLEMENTED - UNIMPLEMENTED; - - return FALSE; + USHORT FirstValue, SecondValue; + SOFT386_MOD_REG_RM ModRegRm; + + if (!(State->ControlRegisters[SOFT386_REG_CR0] & SOFT386_CR0_PE) + || State->PrefixFlags) + { + /* No prefixes allowed, protected mode only */ + Soft386Exception(State, SOFT386_EXCEPTION_UD); + return FALSE; + } + + /* Get the operands */ + if (!Soft386ReadModrmWordOperands(State, + &ModRegRm, + &FirstValue, + &SecondValue)) + { + /* Exception occurred */ + return FALSE; + } + + /* Check if the RPL needs adjusting */ + if ((SecondValue & 3) < (FirstValue & 3)) + { + /* Adjust the RPL */ + SecondValue &= ~3; + SecondValue |= FirstValue & 3; + + /* Set ZF */ + State->Flags.Zf = TRUE; + + /* Write back the result */ + return Soft386WriteModrmWordOperands(State, &ModRegRm, FALSE, SecondValue); + } + else + { + /* Clear ZF */ + State->Flags.Zf = FALSE; + return TRUE; + } }
SOFT386_OPCODE_HANDLER(Soft386OpcodePushImm)