(09-04-2021 04:03 PM)Mike T. Wrote: Thank you!
I was starting to think I was losing it.
All I need to do now is get my head around the strange behaviour of the 'P' register...
You might by the time you finish, which never seems to happen ;-)
for HP67, HP-91, HP-97, HP29c, Spice
A bug in ARC chips cause a problem when the P register wraps around
This might help if you understand Pascal...
Code:
regP: Integer; // P register
Carry: Boolean; // Carry flag
aPCH: Array[0..2] of Integer;
Initialise aPCH = [0][0][0] at switch on
// for each instruction time before decoding instruction
aPCH[2] := aPCH[1];
aPCH[1] := aPCH[0];
aPCH[0] := 0;
// for [if P # N] instruction
Carry := not TestPCH(regP, N);
// for [if P = N] instruction
Carry = TestPCH(regP, N)
// for [p + 1 -> p] instruction
aPCH[0] := 1;
// for [p - 1 -> p] instruction
aPCH[0] := -1;
....
function TestPCHarray(P, N: Integer): Boolean;
begin
if (N = 0) and (aPCH[1] = 1) and (aPCH[2] = 1) then
begin
if (P = 0) or (P = 1) then
Result := False
else
Result := True;
end
else
if (N = 0) and (aPCH[1] = -1) and (aPCH[2] = -1) then
begin
if (P = 0) or (P = 13) then
Result := False
else
Result := True;
end
else
begin
if P = N then
Result := False
else
Result := True;
end;
end;
cheers
Tony