bf
This commit is contained in:
parent
0136084aa3
commit
f1e5bfa845
@ -111,8 +111,8 @@ namespace PIC_Simulator.PIC
|
|||||||
|
|
||||||
public int PCCounter = 0; // -> nächster befehl
|
public int PCCounter = 0; // -> nächster befehl
|
||||||
public int Stepcount = 0;
|
public int Stepcount = 0;
|
||||||
public uint Register_W = 0;
|
public byte Register_W = 0;
|
||||||
public uint[] Register = new uint[0x100];
|
public byte[] Register = new byte[0x100];
|
||||||
public Stack<uint> Stack = new Stack<uint>();
|
public Stack<uint> Stack = new Stack<uint>();
|
||||||
public bool IsSleeping = false;
|
public bool IsSleeping = false;
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ namespace PIC_Simulator.PIC
|
|||||||
uint a = GetRegister(aktueller_befehl.parameter_f);
|
uint a = GetRegister(aktueller_befehl.parameter_f);
|
||||||
uint b = Register_W;
|
uint b = Register_W;
|
||||||
|
|
||||||
uint Result = a + b;
|
var Result = a + b;
|
||||||
bool dc = AdditionDigitCarry(a, b);
|
bool dc = AdditionDigitCarry(a, b);
|
||||||
|
|
||||||
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, (Result % 0x100) == 0);
|
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, (Result % 0x100) == 0);
|
||||||
@ -258,7 +258,7 @@ namespace PIC_Simulator.PIC
|
|||||||
if (aktueller_befehl.parameter_d != 0)
|
if (aktueller_befehl.parameter_d != 0)
|
||||||
SetRegister(aktueller_befehl.parameter_f, Result);
|
SetRegister(aktueller_befehl.parameter_f, Result);
|
||||||
else
|
else
|
||||||
Register_W = Result;
|
Register_W = (byte)Result;
|
||||||
}
|
}
|
||||||
else if (aktueller_befehl.befehl == ANDWF)
|
else if (aktueller_befehl.befehl == ANDWF)
|
||||||
{
|
{
|
||||||
@ -267,7 +267,7 @@ namespace PIC_Simulator.PIC
|
|||||||
// ter.If 'd' is 1 the result is stored back in
|
// ter.If 'd' is 1 the result is stored back in
|
||||||
// register 'f'
|
// register 'f'
|
||||||
|
|
||||||
uint Result = Register_W & GetRegister(aktueller_befehl.parameter_f);
|
byte Result = (byte)(Register_W & GetRegister(aktueller_befehl.parameter_f));
|
||||||
|
|
||||||
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, Result == 0);
|
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, Result == 0);
|
||||||
|
|
||||||
@ -289,7 +289,7 @@ namespace PIC_Simulator.PIC
|
|||||||
// W register is cleared.Zero bit (Z) is
|
// W register is cleared.Zero bit (Z) is
|
||||||
// set.
|
// set.
|
||||||
|
|
||||||
Register_W = 0;
|
Register_W = 0;
|
||||||
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, true);
|
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, true);
|
||||||
}
|
}
|
||||||
else if (aktueller_befehl.befehl == COMF)
|
else if (aktueller_befehl.befehl == COMF)
|
||||||
@ -299,7 +299,7 @@ namespace PIC_Simulator.PIC
|
|||||||
// W.If 'd' is 1 the result is stored back in
|
// W.If 'd' is 1 the result is stored back in
|
||||||
// register 'f'.
|
// register 'f'.
|
||||||
|
|
||||||
uint Result = ~GetRegister(aktueller_befehl.parameter_f);
|
byte Result = (byte)~GetRegister(aktueller_befehl.parameter_f);
|
||||||
|
|
||||||
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, Result == 0);
|
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, Result == 0);
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ namespace PIC_Simulator.PIC
|
|||||||
if (aktueller_befehl.parameter_d != 0)
|
if (aktueller_befehl.parameter_d != 0)
|
||||||
SetRegister(aktueller_befehl.parameter_f, Result);
|
SetRegister(aktueller_befehl.parameter_f, Result);
|
||||||
else
|
else
|
||||||
Register_W = Result;
|
Register_W = (byte)Result;
|
||||||
}
|
}
|
||||||
else if (aktueller_befehl.befehl == DECFSZ)
|
else if (aktueller_befehl.befehl == DECFSZ)
|
||||||
{
|
{
|
||||||
@ -351,7 +351,7 @@ namespace PIC_Simulator.PIC
|
|||||||
if (aktueller_befehl.parameter_d != 0)
|
if (aktueller_befehl.parameter_d != 0)
|
||||||
SetRegister(aktueller_befehl.parameter_f, Result);
|
SetRegister(aktueller_befehl.parameter_f, Result);
|
||||||
else
|
else
|
||||||
Register_W = Result;
|
Register_W = (byte)Result;
|
||||||
|
|
||||||
if (Cond)
|
if (Cond)
|
||||||
{
|
{
|
||||||
@ -376,7 +376,7 @@ namespace PIC_Simulator.PIC
|
|||||||
if (aktueller_befehl.parameter_d != 0)
|
if (aktueller_befehl.parameter_d != 0)
|
||||||
SetRegister(aktueller_befehl.parameter_f, Result);
|
SetRegister(aktueller_befehl.parameter_f, Result);
|
||||||
else
|
else
|
||||||
Register_W = Result;
|
Register_W = (byte)Result;
|
||||||
}
|
}
|
||||||
else if (aktueller_befehl.befehl == INCFSZ)
|
else if (aktueller_befehl.befehl == INCFSZ)
|
||||||
{
|
{
|
||||||
@ -400,7 +400,7 @@ namespace PIC_Simulator.PIC
|
|||||||
if (aktueller_befehl.parameter_d != 0)
|
if (aktueller_befehl.parameter_d != 0)
|
||||||
SetRegister(aktueller_befehl.parameter_f, Result);
|
SetRegister(aktueller_befehl.parameter_f, Result);
|
||||||
else
|
else
|
||||||
Register_W = Result;
|
Register_W = (byte)Result;
|
||||||
|
|
||||||
if (Cond)
|
if (Cond)
|
||||||
{
|
{
|
||||||
@ -414,7 +414,7 @@ namespace PIC_Simulator.PIC
|
|||||||
// W register.If 'd' is 1 the result is placed
|
// W register.If 'd' is 1 the result is placed
|
||||||
// back in register 'f'.
|
// back in register 'f'.
|
||||||
|
|
||||||
uint Result = Register_W | GetRegister(aktueller_befehl.parameter_f);
|
byte Result = (byte)(Register_W | GetRegister(aktueller_befehl.parameter_f));
|
||||||
|
|
||||||
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, Result == 0);
|
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, Result == 0);
|
||||||
|
|
||||||
@ -439,7 +439,7 @@ namespace PIC_Simulator.PIC
|
|||||||
if (aktueller_befehl.parameter_d != 0)
|
if (aktueller_befehl.parameter_d != 0)
|
||||||
SetRegister(aktueller_befehl.parameter_f, Result);
|
SetRegister(aktueller_befehl.parameter_f, Result);
|
||||||
else
|
else
|
||||||
Register_W = Result;
|
Register_W = (byte)Result;
|
||||||
}
|
}
|
||||||
else if (aktueller_befehl.befehl == MOVWF)
|
else if (aktueller_befehl.befehl == MOVWF)
|
||||||
{
|
{
|
||||||
@ -475,7 +475,7 @@ namespace PIC_Simulator.PIC
|
|||||||
if (aktueller_befehl.parameter_d != 0)
|
if (aktueller_befehl.parameter_d != 0)
|
||||||
SetRegister(aktueller_befehl.parameter_f, Result);
|
SetRegister(aktueller_befehl.parameter_f, Result);
|
||||||
else
|
else
|
||||||
Register_W = Result;
|
Register_W = (byte)Result;
|
||||||
}
|
}
|
||||||
else if (aktueller_befehl.befehl == RRF)
|
else if (aktueller_befehl.befehl == RRF)
|
||||||
{
|
{
|
||||||
@ -500,7 +500,7 @@ namespace PIC_Simulator.PIC
|
|||||||
if (aktueller_befehl.parameter_d != 0)
|
if (aktueller_befehl.parameter_d != 0)
|
||||||
SetRegister(aktueller_befehl.parameter_f, Result);
|
SetRegister(aktueller_befehl.parameter_f, Result);
|
||||||
else
|
else
|
||||||
Register_W = Result;
|
Register_W = (byte)Result;
|
||||||
}
|
}
|
||||||
else if (aktueller_befehl.befehl == SUBWF)
|
else if (aktueller_befehl.befehl == SUBWF)
|
||||||
{
|
{
|
||||||
@ -532,7 +532,7 @@ namespace PIC_Simulator.PIC
|
|||||||
if (aktueller_befehl.parameter_d != 0)
|
if (aktueller_befehl.parameter_d != 0)
|
||||||
SetRegister(aktueller_befehl.parameter_f, Result);
|
SetRegister(aktueller_befehl.parameter_f, Result);
|
||||||
else
|
else
|
||||||
Register_W = Result;
|
Register_W = (byte)Result;
|
||||||
}
|
}
|
||||||
else if (aktueller_befehl.befehl == SWAPF)
|
else if (aktueller_befehl.befehl == SWAPF)
|
||||||
{
|
{
|
||||||
@ -551,7 +551,7 @@ namespace PIC_Simulator.PIC
|
|||||||
if (aktueller_befehl.parameter_d != 0)
|
if (aktueller_befehl.parameter_d != 0)
|
||||||
SetRegister(aktueller_befehl.parameter_f, Result);
|
SetRegister(aktueller_befehl.parameter_f, Result);
|
||||||
else
|
else
|
||||||
Register_W = Result;
|
Register_W = (byte)Result;
|
||||||
}
|
}
|
||||||
else if (aktueller_befehl.befehl == XORWF)
|
else if (aktueller_befehl.befehl == XORWF)
|
||||||
{
|
{
|
||||||
@ -560,7 +560,7 @@ namespace PIC_Simulator.PIC
|
|||||||
// result is stored in the W register.If 'd' is
|
// result is stored in the W register.If 'd' is
|
||||||
// 1 the result is stored back in register 'f'.
|
// 1 the result is stored back in register 'f'.
|
||||||
|
|
||||||
uint Result = Register_W ^ GetRegister(aktueller_befehl.parameter_f);
|
byte Result = (byte)(Register_W ^ GetRegister(aktueller_befehl.parameter_f));
|
||||||
|
|
||||||
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, Result == 0);
|
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, Result == 0);
|
||||||
|
|
||||||
@ -626,7 +626,7 @@ namespace PIC_Simulator.PIC
|
|||||||
|
|
||||||
Result %= 0x100;
|
Result %= 0x100;
|
||||||
|
|
||||||
Register_W = Result;
|
Register_W = (byte)Result;
|
||||||
}
|
}
|
||||||
else if (aktueller_befehl.befehl == ANDLW)
|
else if (aktueller_befehl.befehl == ANDLW)
|
||||||
{
|
{
|
||||||
@ -638,7 +638,7 @@ namespace PIC_Simulator.PIC
|
|||||||
|
|
||||||
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, Result == 0);
|
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, Result == 0);
|
||||||
|
|
||||||
Register_W = Result;
|
Register_W = (byte)Result;
|
||||||
}
|
}
|
||||||
else if (aktueller_befehl.befehl == CALL)
|
else if (aktueller_befehl.befehl == CALL)
|
||||||
{
|
{
|
||||||
@ -681,7 +681,7 @@ namespace PIC_Simulator.PIC
|
|||||||
|
|
||||||
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, Result == 0);
|
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, Result == 0);
|
||||||
|
|
||||||
Register_W = Result;
|
Register_W = (byte)Result;
|
||||||
}
|
}
|
||||||
else if (aktueller_befehl.befehl == MOVLW)
|
else if (aktueller_befehl.befehl == MOVLW)
|
||||||
{
|
{
|
||||||
@ -689,7 +689,7 @@ namespace PIC_Simulator.PIC
|
|||||||
// register.The don’t cares will assemble
|
// register.The don’t cares will assemble
|
||||||
// as 0’s.
|
// as 0’s.
|
||||||
|
|
||||||
Register_W = aktueller_befehl.parameter_k;
|
Register_W = (byte)aktueller_befehl.parameter_k;
|
||||||
}
|
}
|
||||||
else if (aktueller_befehl.befehl == RETFIE)
|
else if (aktueller_befehl.befehl == RETFIE)
|
||||||
{
|
{
|
||||||
@ -709,7 +709,7 @@ namespace PIC_Simulator.PIC
|
|||||||
// loaded from the top of the stack(the
|
// loaded from the top of the stack(the
|
||||||
// return address). This is a two cycle
|
// return address). This is a two cycle
|
||||||
// instruction.
|
// instruction.
|
||||||
Register_W = aktueller_befehl.parameter_k;
|
Register_W = (byte)aktueller_befehl.parameter_k;
|
||||||
PCCounter = (int) Stack.Pop();
|
PCCounter = (int) Stack.Pop();
|
||||||
}
|
}
|
||||||
else if (aktueller_befehl.befehl == RETURN)
|
else if (aktueller_befehl.befehl == RETURN)
|
||||||
@ -768,7 +768,7 @@ namespace PIC_Simulator.PIC
|
|||||||
|
|
||||||
Result %= 0x100;
|
Result %= 0x100;
|
||||||
|
|
||||||
Register_W = Result;
|
Register_W = (byte)Result;
|
||||||
}
|
}
|
||||||
else if (aktueller_befehl.befehl == XORLW)
|
else if (aktueller_befehl.befehl == XORLW)
|
||||||
{
|
{
|
||||||
@ -781,7 +781,7 @@ namespace PIC_Simulator.PIC
|
|||||||
|
|
||||||
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, Result == 0);
|
SetRegisterOhneBank(ADDR_STATUS, STATUS_BIT_Z, Result == 0);
|
||||||
|
|
||||||
Register_W = Result; ;
|
Register_W = (byte)Result; ;
|
||||||
}
|
}
|
||||||
|
|
||||||
PCCounter++;
|
PCCounter++;
|
||||||
@ -811,14 +811,14 @@ namespace PIC_Simulator.PIC
|
|||||||
|
|
||||||
if (index == ADDR_INDF) // indirekte adresierung
|
if (index == ADDR_INDF) // indirekte adresierung
|
||||||
{
|
{
|
||||||
if (Register[ADDR_FSR] % 0x80 != 0) Register[Register[ADDR_FSR]] = wert;
|
if (Register[ADDR_FSR] % 0x80 != 0) Register[Register[ADDR_FSR]] = (byte)(wert & 0xFF);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Register[index] = wert;
|
Register[index] = (byte)(wert & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint GetRegisterOhneBank(uint index)
|
public byte GetRegisterOhneBank(uint index)
|
||||||
{
|
{
|
||||||
if (index == ADDR_UNIMPL_A) return 0;
|
if (index == ADDR_UNIMPL_A) return 0;
|
||||||
if (index == ADDR_UNIMPL_B) return 0;
|
if (index == ADDR_UNIMPL_B) return 0;
|
||||||
@ -839,7 +839,7 @@ namespace PIC_Simulator.PIC
|
|||||||
return Register[index];
|
return Register[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
private uint GetRegister(uint index)
|
private byte GetRegister(uint index)
|
||||||
{
|
{
|
||||||
if ((Register[ADDR_STATUS] & STATUS_BIT_RP0) == STATUS_BIT_RP0)
|
if ((Register[ADDR_STATUS] & STATUS_BIT_RP0) == STATUS_BIT_RP0)
|
||||||
{
|
{
|
||||||
|
@ -13,10 +13,10 @@
|
|||||||
[X] Breakpoints
|
[X] Breakpoints
|
||||||
[X] Hardwareansteuerung
|
[X] Hardwareansteuerung
|
||||||
[X] Testprogramm 1 (Literalbefehle)
|
[X] Testprogramm 1 (Literalbefehle)
|
||||||
[ ] Testprogramm 2 (CALL, GOTO etc)
|
[X] Testprogramm 2 (CALL, GOTO etc)
|
||||||
[ ] Testprogramm 3 (Byte Befehle ohne 4).
|
[X] Testprogramm 3 (Byte Befehle ohne 4).
|
||||||
[ ] Testprogramm 4 (DECFSZ, RLF, RRF...
|
[X] Testprogramm 4 (DECFSZ, RLF, RRF...
|
||||||
[ ] Testprogramm 5 (Bitbefehle)
|
[X] Testprogramm 5 (Bitbefehle)
|
||||||
[ ] Testprogramm 6 (indirekte Adressierung)
|
[ ] Testprogramm 6 (indirekte Adressierung)
|
||||||
[ ] Testprogramm 7 (Timer 0 )
|
[ ] Testprogramm 7 (Timer 0 )
|
||||||
[X] Ext. Taktgeber an RA4 + IO-Pin
|
[X] Ext. Taktgeber an RA4 + IO-Pin
|
||||||
|
Loading…
Reference in New Issue
Block a user