Changeset 10


Ignore:
Timestamp:
Apr 20, 2026, 9:52:45 PM (6 days ago)
Author:
chronos
Message:
  • Added: Decoding area of instructions with two prefixes.
  • Modified: Improved parameter handling in disassembler.
  • Modified: Improving handling of flags.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Disassembler.pas

    r7 r10  
    103103    Value := Memory.ReadByte;
    104104    DecodedInstruction.AddOpcode(Value);
    105     if Value = $cb then begin
     105    if Value = $CB then begin
    106106      Value := Memory.ReadByte;
    107107      DecodedInstruction.AddOpcode(Value);
    108108      Value := $100 or Value;
    109109    end else
    110     if Value = $dd then begin
    111       Value := Memory.ReadByte;
    112       DecodedInstruction.AddOpcode(Value);
    113       Value := $200 or Value;
     110    if Value = $DD then begin
     111      Value := Memory.ReadByte;
     112      DecodedInstruction.AddOpcode(Value);
     113      if Value = $CB then begin
     114        Value := Memory.ReadByte;
     115        DecodedInstruction.AddOpcode(Value);
     116        Value := $500 or Value;
     117      end else Value := $200 or Value;
    114118    end else
    115     if Value = $ed then begin
     119    if Value = $ED then begin
    116120      Value := Memory.ReadByte;
    117121      DecodedInstruction.AddOpcode(Value);
    118122      Value := $300 or Value;
    119123    end else
    120     if Value = $fd then begin
    121       Value := Memory.ReadByte;
    122       DecodedInstruction.AddOpcode(Value);
    123       Value := $400 or Value;
     124    if Value = $FD then begin
     125      Value := Memory.ReadByte;
     126      DecodedInstruction.AddOpcode(Value);
     127      if Value = $CB then begin
     128        Value := Memory.ReadByte;
     129        DecodedInstruction.AddOpcode(Value);
     130        Value := $600 or Value;
     131      end else Value := $400 or Value;
    124132    end;
    125133    if (Value >= 0) and (Value <= Integer(High(TInstruction))) then begin
     
    153161            DecodedInstruction.Parameters := DecodedInstruction.Parameters + '(' + IntToHex(Value, 4) + ')';
    154162          end else
     163          if InstructionInfo.Params[J] = ptDisplacement then begin
     164            Value := Memory.ReadByte;
     165            DecodedInstruction.AddOpcode(Value);
     166            DecodedInstruction.Parameters := DecodedInstruction.Parameters + IntToStr(ShortInt(Value));
     167          end else
    155168          if InstructionInfo.Params[J] in [ptRegA, ptRegB, ptRegC, ptRegD,
    156             ptRegE, ptRegH, ptRegL, ptRegBC, ptRegDE, ptRegHL, ptRegSP, ptRegIX,
    157             ptRegIY,
    158             ptFlagZ, ptFlagNZ, ptFlagC, ptFlagNC, ptFlagP, ptFlagPO,
    159             ptRegBCIndir, ptRegDEIndir, ptRegHLIndir, ptRegSPIndir,
     169            ptRegE, ptRegH, ptRegL, ptRegR, ptRegI,
     170            ptRegAF, ptRegBC, ptRegDE, ptRegHL, ptRegSP, ptRegIX, ptRegIY,
     171            ptRegAFPair, ptRegBCPair, ptRegDEPair, ptRegHLPair,
     172            ptFlagZ, ptFlagNZ, ptFlagC, ptFlagNC, ptFlagP, ptFlagPO, ptFlagPE, ptFlagM,
     173            ptRegBCIndir, ptRegDEIndir, ptRegHLIndir, ptRegSPIndir, ptRegCIndir,
    160174            pt00, pt08, pt10, pt18, pt20, pt28, pt30, pt38,
    161175            pt0, pt1, pt2, pt3, pt4, pt5, pt6, pt7] then begin
  • trunk/Z80/InstructionSetGen.pas

    r7 r10  
    129129      while Params <> '' do begin
    130130        ParamsPart := GetStringPart(Params, ',');
    131         ParamType := StrToParamType(ParamsPart);
     131        ParamType := StrToParamType(ParamsPart, NameOnly);
    132132        if ParamType <> ptNone then
    133133          InfoParams := InfoParams + ', ' + GetEnumName(TypeInfo(TParamType), Integer(ParamType));
  • trunk/Z80/Z80.pas

    r9 r10  
    5757    MessageText: string;
    5858    procedure Error(Message: string);
     59    function GetCarry: Boolean;
     60    function GetParityOverflow: Boolean;
     61    function GetSignNegative: Boolean;
     62    function GetZero: Boolean;
     63    procedure SetCarry(AValue: Boolean);
     64    procedure SetParityOverflow(AValue: Boolean);
     65    procedure SetSignNegative(AValue: Boolean);
     66    procedure SetZero(AValue: Boolean);
    5967    procedure SetRunning(AValue: Boolean);
    6068    function DoRead(Address: Word): Byte;
     
    7280    procedure Call(Address: Word);
    7381    procedure CallCond(Address: Word; Condition: Boolean);
    74     procedure Cp(Data: Byte);
     82    procedure CpByte(Data: Byte);
    7583    procedure Jr(Condition: Boolean);
    7684    procedure Jp(Condition: Boolean);
     
    808816    RegI: Byte;
    809817    RegR: Byte;
    810     Carry: Boolean;
    811     Zero: Boolean;
    812     ParityOverflow: Boolean;
    813     SignNegative: Boolean;
    814818    Memory: TMemory;
    815819    Ticks: Cardinal;
     
    823827    constructor Create;
    824828    destructor Destroy; override;
     829    property Carry: Boolean read GetCarry write SetCarry;
     830    property Zero: Boolean read GetZero write SetZero;
     831    property ParityOverflow: Boolean read GetParityOverflow
     832      write SetParityOverflow;
     833    property SignNegative: Boolean read GetSignNegative write SetSignNegative;
    825834    property Thread: TCpuThread read FThread;
    826835    property Running: Boolean read FRunning write SetRunning;
     
    858867  DoMessage(Message + ' on address ' + IntToHex(Word(PC), 4));
    859868  Halt;
     869end;
     870
     871function TCpuZ80.GetCarry: Boolean;
     872begin
     873  Result := (AF.F and $1) <> 0;
     874end;
     875
     876function TCpuZ80.GetParityOverflow: Boolean;
     877begin
     878  Result := (AF.F and $4) <> 0;
     879end;
     880
     881function TCpuZ80.GetSignNegative: Boolean;
     882begin
     883  Result := (AF.F and $80) <> 0;
     884end;
     885
     886function TCpuZ80.GetZero: Boolean;
     887begin
     888  Result := (AF.F and $40) <> 0;
     889end;
     890
     891procedure TCpuZ80.SetCarry(AValue: Boolean);
     892begin
     893  AF.F := (AF.F and $fe) or Byte(AValue);
     894end;
     895
     896procedure TCpuZ80.SetParityOverflow(AValue: Boolean);
     897begin
     898  AF.F := (AF.F and $fb) or (Byte(AValue) shl 2);
     899end;
     900
     901procedure TCpuZ80.SetSignNegative(AValue: Boolean);
     902begin
     903  AF.F := (AF.F and $7f) or (Byte(AValue) shl 7);
     904end;
     905
     906procedure TCpuZ80.SetZero(AValue: Boolean);
     907begin
     908  AF.F := (AF.F and $bf) or (Byte(AValue) shl 6);
    860909end;
    861910
     
    9681017end;
    9691018
    970 procedure TCpuZ80.Cp(Data: Byte);
     1019procedure TCpuZ80.CpByte(Data: Byte);
    9711020var
    972   TempByte: Byte;
    973 begin
    974   Carry := Data > AF.A;
    975   TempByte := Byte(ShortInt(AF.A) - ShortInt(Data));
    976   Zero := TempByte = 0;
     1021  Temp: Byte;
     1022begin
     1023  Temp := AF.A;
     1024  SubByte(Temp, Data);
    9771025end;
    9781026
     
    10111059
    10121060procedure TCpuZ80.AddByte(var Target: Byte; Second: Byte);
    1013 begin
    1014   Target := Byte(Target + Second);
     1061var
     1062  Temp: Word;
     1063begin
     1064  Temp := Target + Second;
     1065  ParityOverflow := ((Target and $80) = (Second and $80)) and
     1066    ((Target and $80) <> (Temp and $80));
     1067  Carry := (Temp and $100) <> 0;
     1068  Zero := Byte(Temp) = 0;
     1069  SignNegative := (Temp and $80) <> 0;
     1070  Target := Byte(Temp);
    10151071end;
    10161072
    10171073procedure TCpuZ80.AddWord(var Target: Word; Second: Word);
    1018 begin
    1019   Target := Word(Target + Second);
     1074var
     1075  Temp: Cardinal;
     1076begin
     1077  Temp := Target + Second;
     1078  Carry := Temp > $ffff;
     1079  Target := Word(Temp + Second);
    10201080end;
    10211081
    10221082procedure TCpuZ80.AdcByte(var Target: Byte; Second: Byte);
    1023 begin
    1024   Target := Target + Second;
     1083var
     1084  Temp: Word;
     1085begin
     1086  Temp := Target + Second + Byte(Carry);
     1087  ParityOverflow := ((Target and $80) = (Second and $80)) and
     1088    ((Target and $80) <> (Temp and $80));
     1089  Carry := (Temp and $100) <> 0;
     1090  Zero := Byte(Temp) = 0;
     1091  SignNegative := (Temp and $80) <> 0;
     1092  Target := Byte(Temp);
    10251093end;
    10261094
    10271095procedure TCpuZ80.AdcWord(var Target: Word; Second: Word);
    1028 begin
    1029   Target := Target - Second;
     1096var
     1097  Temp: Cardinal;
     1098begin
     1099  Temp := Target + Second + Byte(Carry);
     1100  Carry := Temp > $ffff;
     1101  Target := Word(Temp + Second);
    10301102end;
    10311103
    10321104procedure TCpuZ80.SubByte(var Target: Byte; Second: Byte);
    1033 begin
    1034   Target := Byte(Target - Second);
     1105var
     1106  Temp: SmallInt;
     1107begin
     1108  Temp := ShortInt(Target) - ShortInt(Second);
     1109  ParityOverflow := ((Target and $80) <> (Second and $80)) and
     1110    ((Target and $80) <> (Temp and $80));
     1111  Carry := (Temp and $100) <> 0;
     1112  Zero := Byte(Temp) = 0;
     1113  SignNegative := (Temp and $80) <> 0;
     1114  Target := Byte(Temp);
    10351115end;
    10361116
    10371117procedure TCpuZ80.SbcByte(var Target: Byte; Second: Byte);
    1038 begin
    1039   Target := Target - Second;
     1118var
     1119  Temp: SmallInt;
     1120begin
     1121  Temp := ShortInt(Target) - ShortInt(Second) - Byte(Carry);
     1122  ParityOverflow := ((Target and $80) <> (Second and $80)) and
     1123    ((Target and $80) <> (Temp and $80));
     1124  Carry := (Temp and $100) <> 0;
     1125  Zero := Byte(Temp) = 0;
     1126  SignNegative := (Temp and $80) <> 0;
     1127  Target := Byte(Temp);
    10401128end;
    10411129
    10421130procedure TCpuZ80.SbcWord(var Target: Word; Second: Word);
    1043 begin
    1044   Target := Target - Second;
     1131var
     1132  Temp: Integer;
     1133begin
     1134  Temp := SmallInt(Target) - SmallInt(Second);
     1135  ParityOverflow := ((Target and $8000) <> (Second and $8000)) and
     1136    ((Target and $8000) <> (Temp and $8000));
     1137  Carry := (Temp and $10000) <> 0;
     1138  Zero := Word(Temp) = 0;
     1139  SignNegative := (Temp and $8000) <> 0;
     1140  Target := Word(Temp);
    10451141end;
    10461142
     
    10481144begin
    10491145  Target := Target xor Second;
     1146  Carry := False;
     1147  Zero := Target = 0;
     1148  ParityOverflow := not Odd(Target);
     1149  SignNegative := (Target and $80) <> 0;
    10501150end;
    10511151
     
    10531153begin
    10541154  Target := Target or Second;
     1155  Carry := False;
     1156  Zero := Target = 0;
     1157  ParityOverflow := not Odd(Target);
     1158  SignNegative := (Target and $80) <> 0;
    10551159end;
    10561160
     
    10581162begin
    10591163  Target := Target and Second;
     1164  Carry := False;
     1165  Zero := Target = 0;
     1166  ParityOverflow := not Odd(Target);
     1167  SignNegative := (Target and $80) <> 0;
    10601168end;
    10611169
    10621170procedure TCpuZ80.IncByte(var Reg: Byte);
    10631171begin
     1172  ParityOverflow := Reg = $7f;
     1173
    10641174  if Reg = High(Reg) then Reg := 0
    10651175    else Inc(Reg);
     1176
     1177  Zero := Reg = 0;
     1178  SignNegative := (Reg and $80) <> 0;
    10661179end;
    10671180
     
    10741187procedure TCpuZ80.DecByte(var Reg: Byte);
    10751188begin
     1189  ParityOverflow := Reg = $80;
     1190
    10761191  if Reg = 0 then Reg := High(Reg)
    1077     else Dec(Reg)
     1192    else Dec(Reg);
     1193
     1194  Zero := Reg = 0;
     1195  SignNegative := (Reg and $80) <> 0;
    10781196end;
    10791197
     
    10811199begin
    10821200  if Reg = 0 then Reg := High(Reg)
    1083     else Dec(Reg)
     1201    else Dec(Reg);
    10841202end;
    10851203
     
    10871205begin
    10881206  Carry := (Data and $80) <> 0;
    1089   Data := (Data shl 1) or Byte(Carry);
     1207  Data := ((Data shl 1) and $ff) or Byte(Carry);
    10901208end;
    10911209
     
    18842002  Temp: ShortInt;
    18852003begin
    1886   Dec(BC.B);
     2004  if BC.B = 0 then BC.B := $ff
     2005    else Dec(BC.B);
    18872006  Temp := ShortInt(ReadByte);
    18882007  if BC.B <> 0 then
     
    27432862procedure TCpuZ80.CP_B;
    27442863begin
    2745   Cp(BC.B);
     2864  CpByte(BC.B);
    27462865end;
    27472866
    27482867procedure TCpuZ80.CP_C;
    27492868begin
    2750   Cp(BC.C);
     2869  CpByte(BC.C);
    27512870end;
    27522871
    27532872procedure TCpuZ80.CP_D;
    27542873begin
    2755   Cp(DE.D);
     2874  CpByte(DE.D);
    27562875end;
    27572876
    27582877procedure TCpuZ80.CP_E;
    27592878begin
    2760   Cp(DE.E);
     2879  CpByte(DE.E);
    27612880end;
    27622881
    27632882procedure TCpuZ80.CP_H;
    27642883begin
    2765   Cp(HL.H);
     2884  CpByte(HL.H);
    27662885end;
    27672886
    27682887procedure TCpuZ80.CP_L;
    27692888begin
    2770   Cp(HL.L);
     2889  CpByte(HL.L);
    27712890end;
    27722891
    27732892procedure TCpuZ80.CP_HL_Indirect;
    27742893begin
    2775   CP(DoRead(HL.Value));
     2894  CpByte(DoRead(HL.Value));
    27762895end;
    27772896
    27782897procedure TCpuZ80.CP_A;
    27792898begin
    2780   CP(AF.A);
     2899  CpByte(AF.A);
    27812900end;
    27822901
     
    30913210procedure TCpuZ80.CP_N;
    30923211begin
    3093   Cp(ReadByte);
     3212  CpByte(ReadByte);
    30943213end;
    30953214
     
    31213240procedure TCpuZ80.NEG;
    31223241begin
     3242  ParityOverflow := AF.A = $80;
     3243  Carry := AF.A <> $0;
    31233244  AF.A := AF.A xor $ff;
    31243245  IncByte(AF.A);
     3246  SignNegative := (AF.A and $80) <> 1;
     3247  Zero := AF.A = 0;
    31253248end;
    31263249
     
    33123435procedure TCpuZ80.CPI;
    33133436begin
    3314   Cp(DoRead(HL.Value));
     3437  CpByte(DoRead(HL.Value));
    33153438  IncWord(HL.Value);
    33163439  DecWord(BC.Value);
     
    33413464procedure TCpuZ80.CPD;
    33423465begin
    3343   Cp(DoRead(HL.Value));
     3466  CpByte(DoRead(HL.Value));
    33443467  DecWord(HL.Value);
    33453468  DecWord(BC.Value);
     
    53725495  Opcode := ReadByte;
    53735496  if Opcode = $CB then begin
     5497    Opcode := ReadByte;
    53745498    Instruction := TInstruction($100 or ReadByte);
    53755499  end
    53765500  else if Opcode = $DD then begin
    5377     Instruction := TInstruction($200 or ReadByte);
     5501    Opcode := ReadByte;
     5502    if Opcode = $CB then begin
     5503      Opcode := ReadByte;
     5504      Instruction := TInstruction($500 or Opcode);
     5505    end else Instruction := TInstruction($200 or Opcode);
    53785506  end
    53795507  else if Opcode = $ED then begin
    5380     Instruction := TInstruction($300 or ReadByte);
     5508    Opcode := ReadByte;
     5509    Instruction := TInstruction($300 or Opcode);
    53815510  end
    53825511  else if Opcode = $FD then begin
    5383     Instruction := TInstruction($400 or ReadByte);
     5512    Opcode := ReadByte;
     5513    if Opcode = $CB then begin
     5514      Opcode := ReadByte;
     5515      Instruction := TInstruction($600 or Opcode);
     5516    end else Instruction := TInstruction($400 or Opcode);
    53845517  end
    53855518  else Instruction := TInstruction(Opcode);
  • trunk/Z80/Z80InstructionInfo.pas

    r7 r10  
    88type
    99  TParamType = (ptNone, ptNumberByte, ptNumberByteIndir,
    10     ptNumberWord, ptNumberWordIndir, ptRegA,
    11     ptRegB, ptRegC, ptRegD, ptRegE, ptRegH, ptRegL, ptRegBC, ptRegDE, ptRegHL,
    12     ptRegSP, ptRegIX, ptRegIY, ptRegBCIndir, ptRegDEIndir, ptRegHLIndir,
    13     ptRegSPIndir,
    14     ptFlagZ, ptFlagNZ, ptFlagC, ptFlagNC, ptFlagP, ptFlagPO,
     10    ptNumberWord, ptNumberWordIndir, ptDisplacement,
     11    ptRegA, ptRegB, ptRegC, ptRegD, ptRegE, ptRegH, ptRegL, ptRegR, ptRegI,
     12    ptRegAF, ptRegBC, ptRegDE, ptRegHL, ptRegSP, ptRegIX, ptRegIY,
     13    ptRegAFPair, ptRegBCPair, ptRegDEPair, ptRegHLPair,
     14    ptRegBCIndir, ptRegDEIndir, ptRegHLIndir, ptRegSPIndir, ptRegCIndir,
     15    ptFlagZ, ptFlagNZ, ptFlagC, ptFlagNC, ptFlagP, ptFlagPO, ptFlagPE, ptFlagM,
    1516    pt00, pt08, pt10, pt18, pt20, pt28, pt30, pt38,
    1617    pt0, pt1, pt2, pt3, pt4, pt5, pt6, pt7);
     
    4142
    4243
    43 function StrToParamType(Text: string): TParamType;
     44function StrToParamType(Text, InstructionName: string): TParamType;
    4445
    4546const
    46   ParamTypeText: array[TParamType] of string = ('', 'n', '(n)', 'nn', '(nn)', 'A', 'B',
    47     'C', 'D', 'E', 'H', 'L', 'BC', 'DE', 'HL', 'SP', 'IX', 'IY', '(BC)',
    48     '(DE)', '(HL)', '(SP)', 'Z', 'NZ', 'C', 'NC', 'P', 'PO',
     47  ParamTypeText: array[TParamType] of string = (
     48    '', 'n', '(n)', 'nn', '(nn)', 'disp',
     49    'A', 'B', 'C', 'D', 'E', 'H', 'L', 'R', 'I',
     50    'AF', 'BC', 'DE', 'HL', 'SP', 'IX', 'IY',
     51    'AF''', 'BC''', 'DE''', 'HL''',
     52    '(BC)', '(DE)', '(HL)', '(SP)', '(C)',
     53    'Z', 'NZ', 'C', 'NC', 'P', 'PO', 'PE', 'M',
    4954    '00H', '08H', '10H', '18H', '20h', '28H', '30H', '38H',
    5055    '0', '1', '2', '3', '4', '5', '6', '7');
     
    106111end;
    107112
    108 function StrToParamType(Text: string): TParamType;
     113function StrToParamType(Text, InstructionName: string): TParamType;
    109114var
    110115  ParamType: TParamType;
    111116begin
     117  Result := ptNone;
    112118  Text := Text.ToLower;
    113119  for ParamType := Low(TParamType) to High(TParamType) do
    114120    if Text = ParamTypeText[ParamType].ToLower then begin
    115       Result := ParamType;
     121      if (ParamType = ptRegD) and ((InstructionName = 'jr') or (InstructionName = 'djnz')) then
     122        Result := ptDisplacement
     123        else Result := ParamType;
    116124      Break;
    117125    end;
     
    129137  AddNew(in_LD_B_N, 'LD', [ptRegB, ptNumberByte], 'Loads n into B.', 7, 0);
    130138  AddNew(in_RLCA, 'RLCA', [], 'The contents of A are rotated left one bit position. The contents of bit 7 are copied to the carry flag and bit 0.', 4, 0);
    131   AddNew(in_EX_AF_AF_Pair, 'EX', [], 'Exchanges the 16-bit contents of AF and AF''.', 4, 0);
     139  AddNew(in_EX_AF_AF_Pair, 'EX', [ptRegAF, ptRegAFPair], 'Exchanges the 16-bit contents of AF and AF''.', 4, 0);
    132140  AddNew(in_ADD_HL_BC, 'ADD', [ptRegHL, ptRegBC], 'The value of BC is added to HL.', 11, 0);
    133141  AddNew(in_LD_A_BC_Indirect, 'LD', [ptRegA, ptRegBCIndir], 'Loads the value pointed to by BC into A.', 7, 0);
     
    137145  AddNew(in_LD_C_N, 'LD', [ptRegC, ptNumberByte], 'Loads n into C.', 7, 0);
    138146  AddNew(in_RRCA, 'RRCA', [], 'The contents of A are rotated right one bit position. The contents of bit 0 are copied to the carry flag and bit 7.', 4, 0);
    139   AddNew(in_DJNZ_D, 'DJNZ', [ptRegD], 'The B register is decremented, and if not zero, the signed value d is added to PC. The jump is measured from the start of the instruction opcode.', 13, 8);
     147  AddNew(in_DJNZ_D, 'DJNZ', [ptDisplacement], 'The B register is decremented, and if not zero, the signed value d is added to PC. The jump is measured from the start of the instruction opcode.', 13, 8);
    140148  AddNew(in_LD_DE_NN, 'LD', [ptRegDE, ptNumberWord], 'Loads nn into DE.', 10, 0);
    141149  AddNew(in_LD_DE_Indirect_A, 'LD', [ptRegDEIndir, ptRegA], 'Stores A into the memory location pointed to by DE.', 7, 0);
     
    145153  AddNew(in_LD_D_N, 'LD', [ptRegD, ptNumberByte], 'Loads n into D.', 7, 0);
    146154  AddNew(in_RLA, 'RLA', [], 'The contents of A are rotated left one bit position. The contents of bit 7 are copied to the carry flag and the previous contents of the carry flag are copied to bit 0.', 4, 0);
    147   AddNew(in_JR_D, 'JR', [ptRegD], 'The signed value d is added to PC. The jump is measured from the start of the instruction opcode.', 12, 0);
     155  AddNew(in_JR_D, 'JR', [ptDisplacement], 'The signed value d is added to PC. The jump is measured from the start of the instruction opcode.', 12, 0);
    148156  AddNew(in_ADD_HL_DE, 'ADD', [ptRegHL, ptRegDE], 'The value of DE is added to HL.', 11, 0);
    149157  AddNew(in_LD_A_DE_Indirect, 'LD', [ptRegA, ptRegDEIndir], 'Loads the value pointed to by DE into A.', 7, 0);
     
    153161  AddNew(in_LD_E_N, 'LD', [ptRegE, ptNumberByte], 'Loads n into E.', 7, 0);
    154162  AddNew(in_RRA, 'RRA', [], 'The contents of A are rotated right one bit position. The contents of bit 0 are copied to the carry flag and the previous contents of the carry flag are copied to bit 7.', 4, 0);
    155   AddNew(in_JR_NZ_D, 'JR', [ptFlagNZ, ptRegD], 'If the zero flag is unset, the signed value d is added to PC. The jump is measured from the start of the instruction opcode.', 12, 7);
     163  AddNew(in_JR_NZ_D, 'JR', [ptFlagNZ, ptDisplacement], 'If the zero flag is unset, the signed value d is added to PC. The jump is measured from the start of the instruction opcode.', 12, 7);
    156164  AddNew(in_LD_HL_NN, 'LD', [ptRegHL, ptNumberWord], 'Loads nn into HL.', 10, 0);
    157165  AddNew(in_LD_NN_Indirect_HL, 'LD', [ptNumberWordIndir, ptRegHL], 'Stores HL into the memory location pointed to by nn.', 16, 0);
     
    161169  AddNew(in_LD_H_N, 'LD', [ptRegH, ptNumberByte], 'Loads n into H.', 7, 0);
    162170  AddNew(in_DAA, 'DAA', [], 'Adjusts A for BCD addition and subtraction operations.', 4, 0);
    163   AddNew(in_JR_Z_D, 'JR', [ptFlagZ, ptRegD], 'If the zero flag is set, the signed value d is added to PC. The jump is measured from the start of the instruction opcode.', 12, 7);
     171  AddNew(in_JR_Z_D, 'JR', [ptFlagZ, ptDisplacement], 'If the zero flag is set, the signed value d is added to PC. The jump is measured from the start of the instruction opcode.', 12, 7);
    164172  AddNew(in_ADD_HL_HL, 'ADD', [ptRegHL, ptRegHL], 'The value of HL is added to HL.', 11, 0);
    165173  AddNew(in_LD_HL_NN_Indirect, 'LD', [ptRegHL, ptNumberWordIndir], 'Loads the value pointed to by nn into HL.', 16, 0);
     
    169177  AddNew(in_LD_L_N, 'LD', [ptRegL, ptNumberByte], 'Loads n into L.', 7, 0);
    170178  AddNew(in_CPL, 'CPL', [], 'The contents of A are inverted (one''s complement).', 4, 0);
    171   AddNew(in_JR_NC_D, 'JR', [ptFlagNC, ptRegD], 'If the carry flag is unset, the signed value d is added to PC. The jump is measured from the start of the instruction opcode.', 12, 7);
     179  AddNew(in_JR_NC_D, 'JR', [ptFlagNC, ptDisplacement], 'If the carry flag is unset, the signed value d is added to PC. The jump is measured from the start of the instruction opcode.', 12, 7);
    172180  AddNew(in_LD_SP_NN, 'LD', [ptRegSP, ptNumberWord], 'Loads nn into SP.', 10, 0);
    173181  AddNew(in_LD_NN_Indirect_A, 'LD', [ptNumberWordIndir, ptRegA], 'Stores A into the memory location pointed to by nn.', 13, 0);
     
    177185  AddNew(in_LD_HL_Indirect_N, 'LD', [ptRegHLIndir, ptNumberByte], 'Loads n into (HL).', 10, 0);
    178186  AddNew(in_SCF, 'SCF', [], 'Sets the carry flag.', 4, 0);
    179   AddNew(in_JR_C_D, 'JR', [ptRegC, ptRegD], 'If the carry flag is set, the signed value d is added to PC. The jump is measured from the start of the instruction opcode.', 12, 7);
     187  AddNew(in_JR_C_D, 'JR', [ptRegC, ptDisplacement], 'If the carry flag is set, the signed value d is added to PC. The jump is measured from the start of the instruction opcode.', 12, 7);
    180188  AddNew(in_ADD_HL_SP, 'ADD', [ptRegHL, ptRegSP], 'The value of SP is added to HL.', 11, 0);
    181189  AddNew(in_LD_A_NN_Indirect, 'LD', [ptRegA, ptNumberWordIndir], 'Loads the value pointed to by nn into A.', 13, 0);
     
    351359  AddNew(in_AND_N, 'AND', [ptNumberByte], 'Bitwise AND on A with n.', 7, 0);
    352360  AddNew(in_RST_20H, 'RST', [pt20], 'The current PC value plus one is pushed onto the stack, then is loaded with 32.', 11, 0);
    353   AddNew(in_RET_PE, 'RET', [], 'If the parity/overflow flag is set, the top stack entry is popped into PC.', 11, 5);
     361  AddNew(in_RET_PE, 'RET', [ptFlagPE], 'If the parity/overflow flag is set, the top stack entry is popped into PC.', 11, 5);
    354362  AddNew(in_JP_HL_Indirect, 'JP', [ptRegHLIndir], 'Loads the value of HL into PC.', 4, 0);
    355   AddNew(in_JP_PE_NN, 'JP', [ptNumberWord], 'If the parity/overflow flag is set, nn is copied to PC.', 10, 0);
     363  AddNew(in_JP_PE_NN, 'JP', [ptFlagPE, ptNumberWord], 'If the parity/overflow flag is set, nn is copied to PC.', 10, 0);
    356364  AddNew(in_EX_DE_HL, 'EX', [ptRegDE, ptRegHL], 'Exchanges the 16-bit contents of DE and HL.', 4, 0);
    357   AddNew(in_CALL_PE_NN, 'CALL', [ptNumberWord], 'If the parity/overflow flag is set, the current PC value plus three is pushed onto the stack, then is loaded with nn.', 17, 10);
     365  AddNew(in_CALL_PE_NN, 'CALL', [ptFlagPE, ptNumberWord], 'If the parity/overflow flag is set, the current PC value plus three is pushed onto the stack, then is loaded with nn.', 17, 10);
    358366  AddNew(in_XOR_N, 'XOR', [ptNumberByte], 'Bitwise XOR on A with n.', 7, 0);
    359367  AddNew(in_RST_28H, 'RST', [pt28], 'The current PC value plus one is pushed onto the stack, then is loaded with 40.', 11, 0);
    360368  AddNew(in_RET_P, 'RET', [ptFlagP], 'If the sign flag is unset, the top stack entry is popped into PC.', 11, 5);
    361   AddNew(in_POP_AF, 'POP', [], 'The memory location pointed to by SP is stored into F and SP is incremented. The memory location pointed to by SP is stored into A and SP is incremented again.', 10, 0);
     369  AddNew(in_POP_AF, 'POP', [ptRegAF], 'The memory location pointed to by SP is stored into F and SP is incremented. The memory location pointed to by SP is stored into A and SP is incremented again.', 10, 0);
    362370  AddNew(in_JP_P_NN, 'JP', [ptFlagP, ptNumberWord], 'If the sign flag is unset, nn is copied to PC.', 10, 0);
    363371  AddNew(in_DI, 'DI', [], 'Resets both interrupt flip-flops, thus preventing maskable interrupts from triggering.', 4, 0);
    364372  AddNew(in_CALL_P_NN, 'CALL', [ptFlagP, ptNumberWord], 'If the sign flag is unset, the current PC value plus three is pushed onto the stack, then is loaded with nn.', 17, 10);
    365   AddNew(in_PUSH_AF, 'PUSH', [], 'SP is decremented and A is stored into the memory location pointed to by SP. SP is decremented again and F is stored into the memory location pointed to by SP.', 11, 0);
     373  AddNew(in_PUSH_AF, 'PUSH', [ptRegAF], 'SP is decremented and A is stored into the memory location pointed to by SP. SP is decremented again and F is stored into the memory location pointed to by SP.', 11, 0);
    366374  AddNew(in_OR_N, 'OR', [ptNumberByte], 'Bitwise OR on A with n.', 7, 0);
    367375  AddNew(in_RST_30H, 'RST', [pt30], 'The current PC value plus one is pushed onto the stack, then is loaded with 48.', 11, 0);
    368   AddNew(in_RET_M, 'RET', [], 'If the sign flag is set, the top stack entry is popped into PC.', 11, 5);
     376  AddNew(in_RET_M, 'RET', [ptFlagM], 'If the sign flag is set, the top stack entry is popped into PC.', 11, 5);
    369377  AddNew(in_LD_SP_HL, 'LD', [ptRegSP, ptRegHL], 'Loads the value of HL into SP.', 6, 0);
    370   AddNew(in_JP_M_NN, 'JP', [ptNumberWord], 'If the sign flag is set, nn is copied to PC.', 10, 0);
     378  AddNew(in_JP_M_NN, 'JP', [ptFlagM, ptNumberWord], 'If the sign flag is set, nn is copied to PC.', 10, 0);
    371379  AddNew(in_EI, 'EI', [], 'Sets both interrupt flip-flops, thus allowing maskable interrupts to occur. An interrupt will not occur until after the immediately following instruction.', 4, 0);
    372   AddNew(in_CALL_M_NN, 'CALL', [ptNumberWord], 'If the sign flag is set, the current PC value plus three is pushed onto the stack, then is loaded with nn.', 17, 10);
     380  AddNew(in_CALL_M_NN, 'CALL', [ptFlagM, ptNumberWord], 'If the sign flag is set, the current PC value plus three is pushed onto the stack, then is loaded with nn.', 17, 10);
    373381  AddNew(in_CP_N, 'CP', [ptNumberByte], 'Subtracts n from A and affects flags according to the result. A is not modified.', 7, 0);
    374382  AddNew(in_RST_38H, 'RST', [pt38], 'The current PC value plus one is pushed onto the stack, then is loaded with 56.', 11, 0);
    375   AddNew(in_IN_B_C_Indirect, 'IN', [ptRegB], 'A byte from the port at the 16-bit address contained in the BC register pair is written to B.', 12, 0);
    376   AddNew(in_OUT_C_Indirect_B, 'OUT', [ptRegB], 'The value of B is written to the port at the 16-bit address contained in the BC register pair.', 12, 0);
     383  AddNew(in_IN_B_C_Indirect, 'IN', [ptRegB, ptRegCIndir], 'A byte from the port at the 16-bit address contained in the BC register pair is written to B.', 12, 0);
     384  AddNew(in_OUT_C_Indirect_B, 'OUT', [ptRegCIndir, ptRegB], 'The value of B is written to the port at the 16-bit address contained in the BC register pair.', 12, 0);
    377385  AddNew(in_SBC_HL_BC, 'SBC', [ptRegHL, ptRegBC], 'Subtracts BC and the carry flag from HL.', 15, 0);
    378386  AddNew(in_LD_NN_Indirect_BC, 'LD', [ptNumberWordIndir, ptRegBC], 'Stores BC into the memory location pointed to by nn.', 20, 0);
     
    380388  AddNew(in_RETN, 'RETN', [], 'Used at the end of a non-maskable interrupt service routine (located at 0066h) to pop the top stack entry into PC. The value of IFF2 is copied to IFF1 so that maskable interrupts are allowed to continue as before. NMIs are not enabled on the TI.', 14, 0);
    381389  AddNew(in_IM_0, 'IM', [pt0], 'Sets interrupt mode 0.', 8, 0);
    382   AddNew(in_LD_I_A, 'LD', [ptRegA], 'Stores the value of A into register I.', 9, 0);
    383   AddNew(in_IN_C_C_Indirect, 'IN', [ptRegC], 'A byte from the port at the 16-bit address contained in the BC register pair is written to C.', 12, 0);
    384   AddNew(in_OUT_C_Indirect_C, 'OUT', [ptRegC], 'The value of C is written to the port at the 16-bit address contained in the BC register pair.', 12, 0);
     390  AddNew(in_LD_I_A, 'LD', [ptRegI, ptRegA], 'Stores the value of A into register I.', 9, 0);
     391  AddNew(in_IN_C_C_Indirect, 'IN', [ptRegC, ptRegCIndir], 'A byte from the port at the 16-bit address contained in the BC register pair is written to C.', 12, 0);
     392  AddNew(in_OUT_C_Indirect_C, 'OUT', [ptRegCIndir, ptRegC], 'The value of C is written to the port at the 16-bit address contained in the BC register pair.', 12, 0);
    385393  AddNew(in_ADC_HL_BC, 'ADC', [ptRegHL, ptRegBC], 'Adds BC and the carry flag to HL.', 15, 0);
    386394  AddNew(in_LD_BC_NN_Indirect, 'LD', [ptRegBC, ptNumberWordIndir], 'Loads the value pointed to by nn into BC.', 20, 0);
    387395  AddNew(in_RETI, 'RETI', [], 'Used at the end of a maskable interrupt service routine. The top stack entry is popped into PC, and signals an I/O device that the interrupt has finished, allowing nested interrupts (not a consideration on the TI).', 14, 0);
    388   AddNew(in_LD_R_A, 'LD', [ptRegA], 'Stores the value of A into register R.', 9, 0);
    389   AddNew(in_IN_D_C_Indirect, 'IN', [ptRegD], 'A byte from the port at the 16-bit address contained in the BC register pair is written to D.', 12, 0);
    390   AddNew(in_OUT_C_Indirect_D, 'OUT', [ptRegD], 'The value of D is written to the port at the 16-bit address contained in the BC register pair.', 12, 0);
     396  AddNew(in_LD_R_A, 'LD', [ptRegR, ptRegA], 'Stores the value of A into register R.', 9, 0);
     397  AddNew(in_IN_D_C_Indirect, 'IN', [ptRegD, ptRegCIndir], 'A byte from the port at the 16-bit address contained in the BC register pair is written to D.', 12, 0);
     398  AddNew(in_OUT_C_Indirect_D, 'OUT', [ptRegCIndir, ptRegD], 'The value of D is written to the port at the 16-bit address contained in the BC register pair.', 12, 0);
    391399  AddNew(in_SBC_HL_DE, 'SBC', [ptRegHL, ptRegDE], 'Subtracts DE and the carry flag from HL.', 15, 0);
    392400  AddNew(in_LD_NN_Indirect_DE, 'LD', [ptNumberWordIndir, ptRegDE], 'Stores DE into the memory location pointed to by nn.', 20, 0);
    393401  AddNew(in_IM_1, 'IM', [pt1], 'Sets interrupt mode 1.', 8, 0);
    394   AddNew(in_LD_A_I, 'LD', [ptRegA], 'Stores the value of register I into A.', 9, 0);
    395   AddNew(in_IN_E_C_Indirect, 'IN', [ptRegE], 'A byte from the port at the 16-bit address contained in the BC register pair is written to E.', 12, 0);
    396   AddNew(in_OUT_C_Indirect_E, 'OUT', [ptRegE], 'The value of E is written to the port at the 16-bit address contained in the BC register pair.', 12, 0);
     402  AddNew(in_LD_A_I, 'LD', [ptRegA, ptRegI], 'Stores the value of register I into A.', 9, 0);
     403  AddNew(in_IN_E_C_Indirect, 'IN', [ptRegE, ptRegCIndir], 'A byte from the port at the 16-bit address contained in the BC register pair is written to E.', 12, 0);
     404  AddNew(in_OUT_C_Indirect_E, 'OUT', [ptRegCIndir, ptRegE], 'The value of E is written to the port at the 16-bit address contained in the BC register pair.', 12, 0);
    397405  AddNew(in_ADC_HL_DE, 'ADC', [ptRegHL, ptRegDE], 'Adds DE and the carry flag to HL.', 15, 0);
    398406  AddNew(in_LD_DE_NN_Indirect, 'LD', [ptRegDE, ptNumberWordIndir], 'Loads the value pointed to by nn into DE.', 20, 0);
    399407  AddNew(in_IM_2, 'IM', [pt2], 'Sets interrupt mode 2.', 8, 0);
    400   AddNew(in_LD_A_R, 'LD', [ptRegA], 'Stores the value of register R into A.', 9, 0);
    401   AddNew(in_IN_H_C_Indirect, 'IN', [ptRegH], 'A byte from the port at the 16-bit address contained in the BC register pair is written to H.', 12, 0);
    402   AddNew(in_OUT_C_Indirect_H, 'OUT', [ptRegH], 'The value of H is written to the port at the 16-bit address contained in the BC register pair.', 12, 0);
     408  AddNew(in_LD_A_R, 'LD', [ptRegA, ptRegR], 'Stores the value of register R into A.', 9, 0);
     409  AddNew(in_IN_H_C_Indirect, 'IN', [ptRegH, ptRegCIndir], 'A byte from the port at the 16-bit address contained in the BC register pair is written to H.', 12, 0);
     410  AddNew(in_OUT_C_Indirect_H, 'OUT', [ptRegCIndir, ptRegH], 'The value of H is written to the port at the 16-bit address contained in the BC register pair.', 12, 0);
    403411  AddNew(in_SBC_HL_HL, 'SBC', [ptRegHL, ptRegHL], 'Subtracts HL and the carry flag from HL.', 15, 0);
    404412  AddNew(in_RRD, 'RRD', [], 'The contents of the low-order nibble of (HL) are copied to the low-order nibble of A. The previous contents are copied to the high-order nibble of (HL). The previous contents are copied to the low-order nibble of (HL).', 18, 0);
    405   AddNew(in_IN_L_C_Indirect, 'IN', [ptRegL], 'A byte from the port at the 16-bit address contained in the BC register pair is written to L.', 12, 0);
    406   AddNew(in_OUT_C_Indirect_L, 'OUT', [ptRegL], 'The value of L is written to the port at the 16-bit address contained in the BC register pair.', 12, 0);
     413  AddNew(in_IN_L_C_Indirect, 'IN', [ptRegL, ptRegCIndir], 'A byte from the port at the 16-bit address contained in the BC register pair is written to L.', 12, 0);
     414  AddNew(in_OUT_C_Indirect_L, 'OUT', [ptRegCIndir, ptRegL], 'The value of L is written to the port at the 16-bit address contained in the BC register pair.', 12, 0);
    407415  AddNew(in_ADC_HL_HL, 'ADC', [ptRegHL, ptRegHL], 'Adds HL and the carry flag to HL.', 15, 0);
    408416  AddNew(in_RLD, 'RLD', [], 'The contents of the low-order nibble of (HL) are copied to the high-order nibble of (HL). The previous contents are copied to the low-order nibble of A. The previous contents are copied to the low-order nibble of (HL).', 18, 0);
    409417  AddNew(in_SBC_HL_SP, 'SBC', [ptRegHL, ptRegSP], 'Subtracts SP and the carry flag from HL.', 15, 0);
    410418  AddNew(in_LD_NN_Indirect_SP, 'LD', [ptNumberWordIndir, ptRegSP], 'Stores SP into the memory location pointed to by nn.', 20, 0);
    411   AddNew(in_IN_A_C_Indirect, 'IN', [ptRegA], 'A byte from the port at the 16-bit address contained in the BC register pair is written to A.', 12, 0);
    412   AddNew(in_OUT_C_Indirect_A, 'OUT', [ptRegA], 'The value of A is written to the port at the 16-bit address contained in the BC register pair.', 12, 0);
     419  AddNew(in_IN_A_C_Indirect, 'IN', [ptRegA, ptRegCIndir], 'A byte from the port at the 16-bit address contained in the BC register pair is written to A.', 12, 0);
     420  AddNew(in_OUT_C_Indirect_A, 'OUT', [ptRegCIndir, ptRegA], 'The value of A is written to the port at the 16-bit address contained in the BC register pair.', 12, 0);
    413421  AddNew(in_ADC_HL_SP, 'ADC', [ptRegHL, ptRegSP], 'Adds SP and the carry flag to HL.', 15, 0);
    414422  AddNew(in_LD_SP_NN_Indirect, 'LD', [ptRegSP, ptNumberWordIndir], 'Loads the value pointed to by nn into SP.', 20, 0);
  • trunk/Z80/Z80Instructions.pas

    r7 r10  
    77
    88type
    9   TInstructionTable = (itBase, itCB, itDD, itED, itFD);
     9  TInstructionTable = (itBase, itCB, itDD, itED, itFD, itDDCB, itFDCB);
    1010
    1111  TInstruction = (
Note: See TracChangeset for help on using the changeset viewer.