コード例 #1
0
ファイル: THUMB_11.java プロジェクト: khaledev/YahGBA
  public static void execute(ARM7TDMI cpu, MemoryInterface memory, int opcode) {
    int rdIndex = (opcode >>> 8) & 0x0007;
    int spValue = cpu.getSP();
    int offset = (opcode & 0x00FF) << 2;

    if ((opcode & 0x0800) == 0) { // STR Rd, [SP, #nn]
      memory.storeWord(spValue + offset, cpu.getRegister(rdIndex));
    } else { // LDR Rd, [SP, #nn]
      cpu.setRegister(rdIndex, memory.loadWord(spValue + offset));
    }
  }
コード例 #2
0
ファイル: THUMB_11.java プロジェクト: khaledev/YahGBA
  public static String disassemble(ARM7TDMI cpu, MemoryInterface memory, int opcode, int offset) {
    int instruction = (opcode >>> 11) & 0x0001;
    String rd = cpu.getRegisterName((opcode >>> 8) & 0x0007);
    String sp = cpu.getRegisterName(13);
    int off = (opcode & 0x00FF) << 2;

    return InstructionName[instruction]
        + " "
        + rd
        + ", ["
        + sp
        + ", "
        + Hex.toHexString(off, Hex.Bit_12)
        + "]";
  }
コード例 #3
0
ファイル: THUMB_16.java プロジェクト: khaledev/YahGBA
  public static void execute(ARM7TDMI cpu, MemoryInterface memory, int opcode) {
    boolean condition;

    switch (opcode & 0x0F00) {
      case 0x0000: // BEQ label
        condition = cpu.getZFlag();
        break;

      case 0x0100: // BNE label
        condition = !cpu.getZFlag();
        break;

      case 0x0200: // BCS label
        condition = cpu.getCFlag();
        break;

      case 0x0300: // BCC label
        condition = !cpu.getCFlag();
        break;

      case 0x0400: // BMI label
        condition = cpu.getNFlag();
        break;

      case 0x0500: // BPL label
        condition = !cpu.getNFlag();
        break;

      case 0x0600: // BVS label
        condition = cpu.getVFlag();
        break;

      case 0x0700: // BVC label
        condition = !cpu.getVFlag();
        break;

      case 0x0800: // BHI label
        condition = (cpu.getCFlag() && !cpu.getZFlag());
        break;

      case 0x0900: // BLS label
        condition = (!cpu.getCFlag() || cpu.getZFlag());
        break;

      case 0x0A00: // BGE label
        condition = (cpu.getNFlag() == cpu.getVFlag());
        break;

      case 0x0B00: // BLT label
        condition = (cpu.getNFlag() != cpu.getVFlag());
        break;

      case 0x0C00: // BGT label
        condition = (!cpu.getZFlag() && (cpu.getNFlag() == cpu.getVFlag()));
        break;

      case 0x0D00: // BLE label
        condition = (cpu.getZFlag() || (cpu.getNFlag() != cpu.getVFlag()));
        break;

      default: // Unknown
        condition = false;
    }

    if (condition) {
      int offset = ((byte) (opcode & 0x00FF)) << 1;
      cpu.setPC(cpu.getPC() + offset);
      cpu.flushTHUMBPipeline();
    }
  }