direct set PCL

This commit is contained in:
Mike Schwörer 2017-05-11 11:41:36 +02:00
parent 3474c80c07
commit f263a04f0f

View File

@ -760,62 +760,26 @@ namespace PIC_Simulator.PIC
return PCCounter >= befehle.Count; return PCCounter >= befehle.Count;
} }
private uint GetRegister(uint index)
{
// register die nur einmal auf bank1 + 2 existieren
if (index == ADDR_PCL + 0x80) return Register[ADDR_PCL];
if (index == ADDR_STATUS + 0x80) return Register[ADDR_STATUS];
if (index == ADDR_FSR + 0x80) return Register[ADDR_FSR];
if (index == ADDR_PCLATH + 0x80) return Register[ADDR_PCLATH];
if (index == ADDR_INTCON + 0x80) return Register[ADDR_INTCON];
if ((Register[ADDR_STATUS] & STATUS_BIT_RP0) == STATUS_BIT_RP0)
{
return Register[0x80 + index];
}
else
{
return Register[index];
}
}
private void SetRegister(uint index, uint wert)
{
// register die nur einmal auf bank1 + 2 existieren
if (index == ADDR_PCL) { Register[ADDR_PCL] = wert; return; }
if (index == ADDR_STATUS) { Register[ADDR_STATUS] = wert; return; }
if (index == ADDR_FSR) { Register[ADDR_FSR] = wert; return; }
if (index == ADDR_PCLATH) { Register[ADDR_PCLATH] = wert; return; }
if (index == ADDR_INTCON) { Register[ADDR_INTCON] = wert; return; }
if ((Register[ADDR_STATUS] & STATUS_BIT_RP0) == STATUS_BIT_RP0)
{
Register[0x80 + index] = wert;
}
else
{
Register[index] = wert;
}
}
private void SetRegister(uint index, uint bit, bool wert)
{
SetRegister(index, SetBit(GetRegister(index), bit, wert));
}
public void SetRegisterOhneBank(uint index, uint bit, bool wert)
{
Register[index] = SetBit(Register[index], bit, wert);
}
public void SetRegisterOhneBank(uint index, uint wert) public void SetRegisterOhneBank(uint index, uint wert)
{ {
Register[index] = wert; // register die nur einmal auf bank1 + 2 existieren
if (index == ADDR_PCL + 0x80) index -= 0x80;
if (index == ADDR_STATUS + 0x80) index -= 0x80;
if (index == ADDR_FSR + 0x80) index -= 0x80;
if (index == ADDR_PCLATH + 0x80) index -= 0x80;
if (index == ADDR_INTCON + 0x80) index -= 0x80;
if (index == ADDR_PCL) // PC direkt setzen
{
wert &= 0xFF; // Only Low 8 Bit
uint high = GetRegister(ADDR_PCLATH);
high &= 0x1F; // Only Bit <0,1,2,3,4>
high <<= 8;
PCCounter = (int) (high | wert) - 1;
} }
public bool GetRegisterOhneBank(uint index, uint bit) Register[index] = wert;
{
return GetBit(Register[index], bit);
} }
public uint GetRegisterOhneBank(uint index) public uint GetRegisterOhneBank(uint index)
@ -824,15 +788,55 @@ namespace PIC_Simulator.PIC
if (index == ADDR_UNIMPL_B) return 0; if (index == ADDR_UNIMPL_B) return 0;
// register die nur einmal auf bank1 + 2 existieren // register die nur einmal auf bank1 + 2 existieren
if (index == ADDR_PCL + 0x80) return Register[ADDR_PCL]; if (index == ADDR_PCL + 0x80) index -= 0x80;
if (index == ADDR_STATUS + 0x80) return Register[ADDR_STATUS]; if (index == ADDR_STATUS + 0x80) index -= 0x80;
if (index == ADDR_FSR + 0x80) return Register[ADDR_FSR]; if (index == ADDR_FSR + 0x80) index -= 0x80;
if (index == ADDR_PCLATH + 0x80) return Register[ADDR_PCLATH]; if (index == ADDR_PCLATH + 0x80) index -= 0x80;
if (index == ADDR_INTCON + 0x80) return Register[ADDR_INTCON]; if (index == ADDR_INTCON + 0x80) index -= 0x80;
return Register[index]; return Register[index];
} }
private uint GetRegister(uint index)
{
if ((Register[ADDR_STATUS] & STATUS_BIT_RP0) == STATUS_BIT_RP0)
{
return GetRegisterOhneBank(0x80 + index);
}
else
{
return GetRegisterOhneBank(index);
}
}
private void SetRegister(uint index, uint wert)
{
if ((Register[ADDR_STATUS] & STATUS_BIT_RP0) == STATUS_BIT_RP0)
{
SetRegisterOhneBank(0x80 + index, wert);
}
else
{
SetRegisterOhneBank(index, wert);
}
}
public void SetRegisterOhneBank(uint index, uint bit, bool wert)
{
SetRegisterOhneBank(index, SetBit(GetRegisterOhneBank(index), bit, wert));
}
private void SetRegister(uint index, uint bit, bool wert)
{
SetRegister(index, SetBit(GetRegister(index), bit, wert));
}
public bool GetRegisterOhneBank(uint index, uint bit)
{
return GetBit(GetRegisterOhneBank(index), bit);
}
public static bool AdditionDigitCarry(uint a, uint b) public static bool AdditionDigitCarry(uint a, uint b)
{ {
a &= 0x0F; a &= 0x0F;