public void executeSwp(InstructionARM inst, boolean exec) {
        int rn = inst.getRnField();
        int rd = inst.getRdField();
        int rm = inst.getRmField();
        int left, right, rot;
        int vaddr, paddr;

        if (!exec) {
            printDisasm(inst,
                    String.format("swp%s", inst.getCondFieldName()),
                    String.format("%s, %s, [%s]",
                            getRegName(rd), getRegName(rm), getRegName(rn)));
            return;
        }

        if (!inst.satisfiesCond(getCPSR())) {
            return;
        }

        left = getReg(rm);
        rot = getReg(rn) & 0x3;

        vaddr = getReg(rn);
        paddr = getMMU().translate(vaddr, 4, false, getCPSR().isPrivMode(), false);
        if (getMMU().isFault()) {
            getMMU().clearFault();
            return;
        }

        if (!tryRead_a32(paddr, 4) || !tryWrite_a32(paddr, 4)) {
            raiseException(ARMv5.EXCEPT_ABT_DATA,
                    String.format("swp [%08x]", paddr));
            return;
        }
        right = read32_a32(paddr);

        switch (rot) {
        case 0:
            //do nothing
            break;
        case 1:
            right = Integer.rotateRight(right, 8);
            break;
        case 2:
            right = Integer.rotateRight(right, 16);
            break;
        case 3:
            right = Integer.rotateRight(right, 24);
            break;
        default:
            throw new IllegalArgumentException("Illegal address " +
                    String.format("inst:0x%08x, rn:%d, rot:%d.",
                            inst.getInst(), rn, rot));
        }

        write32_a32(paddr, left);
        setReg(rd, right);
    }