예제 #1
0
파일: jmp_Jd.java 프로젝트: agimat/JPC
 public Branch execute(Processor cpu) {
   cpu.eip += blockLength;
   int tmpEip = cpu.eip + jmp;
   cpu.cs.checkAddress(tmpEip);
   cpu.eip = tmpEip;
   return Branch.T1;
 }
예제 #2
0
파일: test_Ed_Id.java 프로젝트: agimat/JPC
 public Branch execute(Processor cpu) {
   Reg op1 = cpu.regs[op1Index];
   cpu.of = cpu.af = cpu.cf = false;
   cpu.flagResult = (op1.get32() & immd);
   cpu.flagStatus = SZP;
   return Branch.None;
 }
예제 #3
0
파일: bt_Ew_Gw.java 프로젝트: agimat/JPC
 public Branch execute(Processor cpu) {
   Reg op1 = cpu.regs[op1Index];
   Reg op2 = cpu.regs[op2Index];
   cpu.zf(cpu.zf());
   cpu.cf(((op1.get16() & (1 << (op2.get16() & (16 - 1)))) != 0));
   return Branch.None;
 }
예제 #4
0
 public Branch execute(Processor cpu) {
   cpu.flagOp1 = cpu.r_eax.get32();
   cpu.flagOp2 = immd;
   cpu.flagResult = (cpu.flagOp1 - cpu.flagOp2);
   cpu.flagIns = UCodes.SUB32;
   cpu.flagStatus = OSZAPC;
   return Branch.None;
 }
예제 #5
0
 public Branch execute(Processor cpu) {
   cpu.flagOp1 = (byte) op1.get8(cpu);
   cpu.flagOp2 = (byte) immb;
   cpu.flagResult = (byte) (cpu.flagOp1 - cpu.flagOp2);
   cpu.flagIns = UCodes.SUB8;
   cpu.flagStatus = OSZAPC;
   return Branch.None;
 }
예제 #6
0
 public Branch execute(Processor cpu) {
   cpu.flagOp1 = cpu.r_eax.get16();
   cpu.flagOp2 = immw;
   cpu.flagResult = (short) (cpu.flagOp1 - cpu.flagOp2);
   cpu.flagIns = UCodes.SUB16;
   cpu.flagStatus = OSZAPC;
   return Branch.None;
 }
예제 #7
0
파일: neg_Ed_mem.java 프로젝트: agimat/JPC
 public Branch execute(Processor cpu) {
   cpu.flagOp1 = op1.get32(cpu);
   cpu.flagResult = (-cpu.flagOp1);
   op1.set32(cpu, cpu.flagResult);
   cpu.flagIns = UCodes.NEG32;
   cpu.flagStatus = OSZAPC;
   return Branch.None;
 }
예제 #8
0
 public Branch execute(Processor cpu) {
   Reg op1 = cpu.regs[op1Index];
   cpu.of = cpu.af = cpu.cf = false;
   cpu.flagResult = (byte) (op1.get8() ^ op2.get8(cpu));
   op1.set8((byte) cpu.flagResult);
   cpu.flagStatus = SZP;
   return Branch.None;
 }
예제 #9
0
 public Branch execute(Processor cpu) {
   cpu.flagOp1 = (short) op1.get16(cpu);
   cpu.flagOp2 = (short) immw;
   cpu.flagResult = (short) (cpu.flagOp1 - cpu.flagOp2);
   op1.set16(cpu, (short) cpu.flagResult);
   cpu.flagIns = UCodes.SUB16;
   cpu.flagStatus = OSZAPC;
   return Branch.None;
 }
예제 #10
0
파일: btr_Ew_Gw.java 프로젝트: agimat/JPC
 public Branch execute(Processor cpu) {
   Reg op1 = cpu.regs[op1Index];
   Reg op2 = cpu.regs[op2Index];
   int bit = 1 << (op2.get16() & (16 - 1));
   cpu.cf = (0 != (op1.get16() & bit));
   cpu.flagStatus &= NCF;
   op1.set16((short) (op1.get16() & ~bit));
   return Branch.None;
 }
예제 #11
0
 public Branch execute(Processor cpu) {
   Reg op1 = cpu.regs[op1Index];
   if (op2.get16(cpu) == 0) {
     cpu.zf(true);
   } else {
     cpu.zf(false);
     op1.set16(31 - StaticOpcodes.numberOfLeadingZeros(0xFFFF & op2.get16(cpu)));
   }
   return Branch.None;
 }
예제 #12
0
 public Branch execute(Processor cpu) {
   Reg op1 = cpu.regs[op1Index];
   cpu.flagOp1 = op1.get32();
   cpu.flagOp2 = op2.get32(cpu);
   cpu.flagResult = (cpu.flagOp1 - cpu.flagOp2);
   op1.set32(cpu.flagResult);
   cpu.flagIns = UCodes.SUB32;
   cpu.flagStatus = OSZAPC;
   return Branch.None;
 }
예제 #13
0
파일: jno_Jb.java 프로젝트: agimat/JPC
 public Branch execute(Processor cpu) {
   if (!cpu.of()) {
     int tmpEip = cpu.eip + jmp + blockLength;
     cpu.cs.checkAddress(tmpEip);
     cpu.eip = tmpEip;
     return Branch.T1;
   } else {
     cpu.eip += blockLength;
     return Branch.T2;
   }
 }
예제 #14
0
파일: add_Eb_Gb.java 프로젝트: agimat/JPC
 public Branch execute(Processor cpu) {
   Reg op1 = cpu.regs[op1Index];
   Reg op2 = cpu.regs[op2Index];
   cpu.flagOp1 = (byte) op1.get8();
   cpu.flagOp2 = (byte) op2.get8();
   cpu.flagResult = (byte) (cpu.flagOp1 + cpu.flagOp2);
   op1.set8((byte) cpu.flagResult);
   cpu.flagIns = UCodes.ADD8;
   cpu.flagStatus = OSZAPC;
   return Branch.None;
 }
예제 #15
0
파일: jcxz_Jw.java 프로젝트: agimat/JPC
 public Branch execute(Processor cpu) {
   if (cpu.r_cx.get16() == 0) {
     int target = (cpu.eip + jmp + blockLength) & 0xffff;
     cpu.cs.checkAddress(target);
     cpu.eip = target;
     return Branch.T1;
   } else {
     cpu.eip += blockLength;
     return Branch.T2;
   }
 }
예제 #16
0
 public Branch execute(Processor cpu) {
   int shift = 1 & 0x1f;
   shift %= 16 + 1;
   long val = 0xFFFF & op1.get16(cpu);
   val |= cpu.cf() ? 1L << 16 : 0;
   val = (val << shift) | (val >>> (16 + 1 - shift));
   op1.set16(cpu, (short) (int) val);
   boolean bit31 = (val & (1L << (16 - 1))) != 0;
   boolean bit32 = (val & (1L << (16))) != 0;
   cpu.cf(bit32);
   if (shift == 1) cpu.of(bit31 ^ bit32);
   return Branch.None;
 }
예제 #17
0
파일: imul_Ew.java 프로젝트: agimat/JPC
 public Branch execute(Processor cpu) {
   Reg op1 = cpu.regs[op1Index];
   int iop1 = (short) op1.get16();
   int iop2 = (short) cpu.r_eax.get16();
   int res32 = (((int) (short) iop1) * ((short) iop2));
   cpu.r_eax.set16((short) res32);
   cpu.r_edx.set16((short) (res32 >> 16));
   cpu.setOSZAPC_Logic16(res32);
   if (res32 != (short) res32) {
     cpu.of(true);
     cpu.cf(true);
   }
   return Branch.None;
 }
예제 #18
0
 public Branch execute(Processor cpu) {
   int shift = immb & (32 - 1);
   int reg0 = op1.get32(cpu);
   int res = (reg0 >>> shift) | (reg0 << (32 - shift));
   op1.set32(cpu, res);
   boolean bit30 = (res & (1 << (32 - 2))) != 0;
   boolean bit31 = (res & (1 << (32 - 1))) != 0;
   if (shift > 0) {
     cpu.cf = bit31;
     cpu.of = bit30 ^ bit31;
     cpu.flagStatus &= NOFCF;
   }
   return Branch.None;
 }
예제 #19
0
 public Branch execute(Processor cpu) {
   int shift = cpu.r_cl.get8() & (16 - 1);
   int reg0 = 0xFFFF & op1.get16(cpu);
   int res = (reg0 << shift) | (reg0 >>> (16 - shift));
   op1.set16(cpu, (short) res);
   boolean bit0 = (res & 1) != 0;
   boolean bit31 = (res & (1 << (16 - 1))) != 0;
   if ((0x1F & cpu.r_cl.get8()) > 0) {
     cpu.cf = bit0;
     cpu.of = bit0 ^ bit31;
     cpu.flagStatus &= NOFCF;
   }
   return Branch.None;
 }
예제 #20
0
파일: lldt_Ew_mem.java 프로젝트: agimat/JPC
  public Branch execute(Processor cpu) {
    int selector = op1.get16(cpu) & 0xffff;

    if (selector == 0) {
      cpu.ldtr = SegmentFactory.NULL_SEGMENT;
    } else {
      Segment newSegment = cpu.getSegment(selector & ~0x4);
      if (newSegment.getType() != 0x02)
        throw new ProcessorException(ProcessorException.Type.GENERAL_PROTECTION, selector, true);

      if (!(newSegment.isPresent()))
        throw new ProcessorException(ProcessorException.Type.GENERAL_PROTECTION, selector, true);
      cpu.ldtr = newSegment;
    }
    return Branch.None;
  }
예제 #21
0
 public Branch execute(Processor cpu) {
   int shift = cpu.r_cl.get8() & 0x1f;
   if (shift != 0) {
     if (shift <= 16) {
       cpu.flagStatus = OSZPC;
     } else {
       cpu.flagStatus = SZP;
       cpu.of = false;
       cpu.cf = false;
     }
     cpu.af = false;
     cpu.flagOp1 = op1.get32(cpu);
     cpu.flagOp2 = shift;
     cpu.flagResult = (cpu.flagOp1 << cpu.flagOp2);
     op1.set32(cpu, cpu.flagResult);
     cpu.flagIns = UCodes.SHL32;
   }
   return Branch.None;
 }
예제 #22
0
 public Branch execute(Processor cpu) {
   Reg op2 = cpu.regs[op2Index];
   int add = (cpu.cf() ? 1 : 0);
   cpu.flagOp1 = op1.get8(cpu);
   cpu.flagOp2 = op2.get8();
   cpu.flagResult = (byte) (cpu.flagOp1 - (cpu.flagOp2 + add));
   op1.set8(cpu, (byte) cpu.flagResult);
   cpu.flagIns = UCodes.SBB8;
   cpu.flagStatus = OSZAPC;
   return Branch.None;
 }
예제 #23
0
파일: adc_Gb_Eb.java 프로젝트: agimat/JPC
 public Branch execute(Processor cpu) {
   Reg op1 = cpu.regs[op1Index];
   Reg op2 = cpu.regs[op2Index];
   boolean incf = cpu.cf();
   cpu.flagOp1 = op1.get8();
   cpu.flagOp2 = op2.get8();
   cpu.flagResult = (byte) (cpu.flagOp1 + cpu.flagOp2 + (incf ? 1 : 0));
   op1.set8((byte) cpu.flagResult);
   cpu.flagIns = UCodes.ADC8;
   cpu.flagStatus = OSZAPC;
   return Branch.None;
 }
예제 #24
0
파일: adc_Ew_Ib.java 프로젝트: agimat/JPC
 public Branch execute(Processor cpu) {
   Reg op1 = cpu.regs[op1Index];
   boolean incf =
       Processor.getCarryFlag(
           cpu.flagStatus, cpu.cf, cpu.flagOp1, cpu.flagOp2, cpu.flagResult, cpu.flagIns);
   cpu.flagOp1 = op1.get16();
   cpu.flagOp2 = immb;
   cpu.flagResult = (short) (cpu.flagOp1 + cpu.flagOp2 + (incf ? 1 : 0));
   op1.set16((short) cpu.flagResult);
   cpu.flagIns = UCodes.ADC16;
   cpu.flagStatus = OSZAPC;
   return Branch.None;
 }
예제 #25
0
파일: push_Ed_mem.java 프로젝트: agimat/JPC
 public Branch execute(Processor cpu) {
   cpu.push32(op1.get32(cpu));
   return Branch.None;
 }
예제 #26
0
 public void ioPortWriteByte(int address, int data) {
   setGateA20State((data & 0x02) != 0);
   if ((data & 0x01) != 0) cpu.reset();
 }
예제 #27
0
 public Branch execute(Processor cpu) {
   Reg op1 = cpu.regs[op1Index];
   int tmp = op2.get32(cpu);
   if (!cpu.sf()) op1.set32(tmp);
   return Branch.None;
 }
예제 #28
0
 public boolean updated() {
   return ioportRegistered
       && cpu.updated()
       && physicalAddressSpace.updated()
       && linearAddressSpace.updated();
 }
예제 #29
0
 public Branch execute(Processor cpu) {
   Segment seg = cpu.segs[segIndex];
   if (cpu.checkIOPermissions8(cpu.r_dx.get16() & 0xffff)) StaticOpcodes.rep_outsb_a32(cpu, seg);
   else throw ProcessorException.GENERAL_PROTECTION_0;
   return Branch.None;
 }
예제 #30
0
 public Branch execute(Processor cpu) {
   cpu.of = cpu.af = cpu.cf = false;
   cpu.flagResult = (op1.get32(cpu) & immd);
   cpu.flagStatus = SZP;
   return Branch.None;
 }