Beispiel #1
0
 private void Sbb16Imm16(Reg16 reg)
 {
     registers.Set(reg,
                   (ushort)(registers.Get(reg) - BinaryHelper.Read16Bit(_memory, _ip + 1) -
                            (flagsRegister.HasFlag(Flags.Carry) ? 1 : 0)));
     _ip += 3;
 }
Beispiel #2
0
        private void Mov16Imm16()
        {
            var imm16 = BinaryHelper.Read16Bit(_memory, _ip + 4);

            ModRm((x, y) => imm16, RegisterType.reg16, false);
            _ip += 2;
        }
Beispiel #3
0
        private void RetnImm16()
        {
            var bytes = BinaryHelper.Read16Bit(_memory, _ip + 1);

            Retn();
            registers.Set(Reg16.sp, (ushort)(registers.Get(Reg16.sp) + bytes));
        }
Beispiel #4
0
        private ushort getEffectiveAddressFromModRm(ushort modrm, int ip)
        {
            switch (modrm >> 6)
            {
            case 0x00:
                if ((modrm & 7) == 0x6)
                {
                    var imm16 = BinaryHelper.Read16Bit(memory, ip + 2);
                    IpShift = 4;
                    return(imm16);
                }
                else
                {
                    IpShift = 2;
                    return(getEffectiveAddress(modrm));
                }

            case 0x01:
                var displacement = memory[ip + 2];
                IpShift = 3;
                return((ushort)(getEffectiveAddress(modrm) + displacement));

            case 0x02:
                var disp16 = BinaryHelper.Read16Bit(memory, ip + 2);
                ;
                IpShift = 4;
                return((ushort)(getEffectiveAddress(modrm) + disp16));

            default:
                throw new InvalidOperationException();
            }
        }
Beispiel #5
0
        private void Cmp16Imm16(Reg16 reg)
        {
            var regValue = registers.Get(reg);
            var immValue = BinaryHelper.Read16Bit(_memory, _ip + 1);

            flagsRegister.SetFlagsFromInputAndResult(regValue - immValue, regValue, immValue);
            _ip += 3;
        }
Beispiel #6
0
 private int GetImm(int bytes)
 {
     if (bytes == 1)
     {
         return(_memory[_ip + 2]);
     }
     return(BinaryHelper.Read16Bit(_memory, _ip + 2));
 }
Beispiel #7
0
 private void Xor16Imm16(Reg16 reg)
 {
     registers.Set(reg, (ushort)(registers.Get(reg) ^ BinaryHelper.Read16Bit(_memory, _ip + 1)));
     _ip += 3;
 }
Beispiel #8
0
 private ushort GetUInt16FromMemory(int address)
 {
     return(BinaryHelper.Read16Bit(_memory, address));
 }