Esempio n. 1
0
bool LDAAbsXInstr::exp(asmjit::X86Assembler& a, MemoryMapper& m) {
	auto temp = asmjit::x86::rax;
	a.mov(temp, this->base);
	a.add(temp, REG_X);
	auto tmpPtr = asmjit::x86::byte_ptr(temp);

	{
		auto NotZero = a.newLabel();
		auto Exit = a.newLabel();
		a.cmp(tmpPtr, 0);
		a.jne(NotZero);
		// Value was 0
		a.bts(REG_S, S_ZERO);
		a.jmp(Exit);

		// Value was not 0
		a.bind(NotZero);
		a.btr(REG_S, S_ZERO);
		//No jmp required, just fall though

		a.bind(Exit);
	}

	a.mov(REG_A, tmpPtr);
	return true;
}
Esempio n. 2
0
bool LDAImmInstr::exp(asmjit::X86Assembler& a, MemoryMapper& m) {
	a.mov(REG_A, this->value);

	// Immediate mode knows the value at compile time, so just emit the right
	// thing
	if(this->value == 0)
		a.bts(REG_S, S_ZERO);
	else
		a.btr(REG_S, S_ZERO);

	if((this->value & 0x80) == 0)
		a.btr(REG_S, S_NEGATIVE);
	else
		a.bts(REG_S, S_NEGATIVE);
	return true;
}
Esempio n. 3
0
bool CMPImm::exp(asmjit::X86Assembler& a, MemoryMapper& m) {
	a.cmp(REG_A, this->operand);

	{
		a.pushfd();
		a.btr(REG_S, S_CARRY);
		a.popfd();
		auto End = a.newLabel();
		a.jnc(End);
		a.pushfd();
		a.bts(REG_S, S_CARRY);
		a.popfd();
		a.bind(End);
	}

	{
		a.pushfd();
		a.btr(REG_S, S_ZERO);
		a.popfd();


		auto End = a.newLabel();
		a.jne(End);
		a.pushfd();
		a.bts(REG_S, S_ZERO);
		a.popfd();
		a.bind(End);
	}

	{
		a.pushfd();
		a.btr(REG_S, S_NEGATIVE);
		a.popfd();


		auto End = a.newLabel();
		a.jns(End);
		a.pushfd();
		a.bts(REG_S, S_NEGATIVE);
		a.popfd();
		a.bind(End);
	}
	return true;
}
Esempio n. 4
0
bool BITZeroP::exp(asmjit::X86Assembler& a, MemoryMapper& m) {
	m.emitLoad(a, operand, asmjit::x86::al);
	// @COMPLETENESS: We should check and set the S_ flags here before the and
	a.push(asmjit::x86::rax);

	a.and_(asmjit::x86::al, REG_A);
	auto Zero = a.newLabel();
	auto Exit = a.newLabel();
	a.jz(Zero);

	//Not zero
	a.btr(REG_S, S_ZERO);
	a.jmp(Exit);
	a.bind(Zero);
	a.bts(REG_S, S_ZERO);
	a.bind(Exit);

	a.pop(asmjit::x86::rax);

	{
		a.btr(REG_S, S_OVERFLOW);
		a.bt(asmjit::x86::al, 6);
		auto End = a.newLabel();
		a.jnc(End);
		a.bts(REG_S, S_OVERFLOW);
		a.bind(End);
	}

	{
		a.btr(REG_S, S_NEGATIVE);
		a.bt(asmjit::x86::al, 7);
		auto End = a.newLabel();
		a.jnc(End);
		a.bts(REG_S, S_NEGATIVE);
		a.bind(End);
	}
	return true;
}
Esempio n. 5
0
bool CLC::exp(asmjit::X86Assembler& a, MemoryMapper& m) {
	a.btr(REG_S, S_CARRY);
	return true;
}
Esempio n. 6
0
bool CLD::exp(asmjit::X86Assembler& a, MemoryMapper& m) {
	a.btr(REG_S, S_DECIMAL);
	return true;
}