fix latch
This commit is contained in:
@@ -858,29 +858,53 @@ namespace PIC_Simulator.PIC
|
||||
Zaehler.Reset();
|
||||
}
|
||||
|
||||
Register[index] = (byte)(wert & 0xFF);
|
||||
|
||||
if (index == ADDR_PORT_A || index == ADDR_TRIS_A)
|
||||
if (index == ADDR_PORT_A)
|
||||
{
|
||||
var ra = Register[ADDR_PORT_A];
|
||||
var ta = Register[ADDR_TRIS_A];
|
||||
|
||||
Latch_RA = (byte)(wert & 0xFF);
|
||||
|
||||
for (uint i = 0; i < 8; i++)
|
||||
{
|
||||
if (!GetBit(ta, i)) Latch_RA = (byte)SetBit(Latch_RA, i, GetBit(ra, i));
|
||||
if (!GetBit(ta, i)) Register[ADDR_PORT_A] = SetBit(Register[ADDR_PORT_A], i, GetBit(Latch_RA, i));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (index == ADDR_PORT_B || index == ADDR_TRIS_B)
|
||||
if (index == ADDR_PORT_B)
|
||||
{
|
||||
var rb = Register[ADDR_PORT_B];
|
||||
var tb = Register[ADDR_TRIS_B];
|
||||
|
||||
Latch_RB = (byte)(wert & 0xFF);
|
||||
|
||||
for (uint i = 0; i < 8; i++)
|
||||
{
|
||||
if (!GetBit(tb, i)) Latch_RB = (byte)SetBit(Latch_RB, i, GetBit(rb, i));
|
||||
if (!GetBit(tb, i)) Register[ADDR_PORT_B] = SetBit(Register[ADDR_PORT_B], i, GetBit(Latch_RB, i));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (index == ADDR_TRIS_A)
|
||||
{
|
||||
var ta = (byte)(wert & 0xFF);
|
||||
|
||||
for (uint i = 0; i < 8; i++)
|
||||
{
|
||||
if (!GetBit(ta, i)) Register[ADDR_PORT_A] = SetBit(Register[ADDR_PORT_A], i, GetBit(Latch_RA, i));
|
||||
}
|
||||
}
|
||||
|
||||
if (index == ADDR_TRIS_B)
|
||||
{
|
||||
var tb = (byte)(wert & 0xFF);
|
||||
|
||||
for (uint i = 0; i < 8; i++)
|
||||
{
|
||||
if (!GetBit(tb, i)) Register[ADDR_PORT_B] = SetBit(Register[ADDR_PORT_B], i, GetBit(Latch_RB, i));
|
||||
}
|
||||
}
|
||||
|
||||
Register[index] = (byte)(wert & 0xFF);
|
||||
}
|
||||
|
||||
private void Interrupt_RB(byte alt, byte neu)
|
||||
|
Reference in New Issue
Block a user