Changeset 10
- Timestamp:
- Apr 20, 2026, 9:52:45 PM (6 days ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
Disassembler.pas (modified) (2 diffs)
-
Z80/InstructionSetGen.pas (modified) (1 diff)
-
Z80/Z80.pas (modified) (20 diffs)
-
Z80/Z80InstructionInfo.pas (modified) (12 diffs)
-
Z80/Z80Instructions.pas (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Disassembler.pas
r7 r10 103 103 Value := Memory.ReadByte; 104 104 DecodedInstruction.AddOpcode(Value); 105 if Value = $ cbthen begin105 if Value = $CB then begin 106 106 Value := Memory.ReadByte; 107 107 DecodedInstruction.AddOpcode(Value); 108 108 Value := $100 or Value; 109 109 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; 114 118 end else 115 if Value = $ edthen begin119 if Value = $ED then begin 116 120 Value := Memory.ReadByte; 117 121 DecodedInstruction.AddOpcode(Value); 118 122 Value := $300 or Value; 119 123 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; 124 132 end; 125 133 if (Value >= 0) and (Value <= Integer(High(TInstruction))) then begin … … 153 161 DecodedInstruction.Parameters := DecodedInstruction.Parameters + '(' + IntToHex(Value, 4) + ')'; 154 162 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 155 168 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, 160 174 pt00, pt08, pt10, pt18, pt20, pt28, pt30, pt38, 161 175 pt0, pt1, pt2, pt3, pt4, pt5, pt6, pt7] then begin -
trunk/Z80/InstructionSetGen.pas
r7 r10 129 129 while Params <> '' do begin 130 130 ParamsPart := GetStringPart(Params, ','); 131 ParamType := StrToParamType(ParamsPart );131 ParamType := StrToParamType(ParamsPart, NameOnly); 132 132 if ParamType <> ptNone then 133 133 InfoParams := InfoParams + ', ' + GetEnumName(TypeInfo(TParamType), Integer(ParamType)); -
trunk/Z80/Z80.pas
r9 r10 57 57 MessageText: string; 58 58 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); 59 67 procedure SetRunning(AValue: Boolean); 60 68 function DoRead(Address: Word): Byte; … … 72 80 procedure Call(Address: Word); 73 81 procedure CallCond(Address: Word; Condition: Boolean); 74 procedure Cp (Data: Byte);82 procedure CpByte(Data: Byte); 75 83 procedure Jr(Condition: Boolean); 76 84 procedure Jp(Condition: Boolean); … … 808 816 RegI: Byte; 809 817 RegR: Byte; 810 Carry: Boolean;811 Zero: Boolean;812 ParityOverflow: Boolean;813 SignNegative: Boolean;814 818 Memory: TMemory; 815 819 Ticks: Cardinal; … … 823 827 constructor Create; 824 828 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; 825 834 property Thread: TCpuThread read FThread; 826 835 property Running: Boolean read FRunning write SetRunning; … … 858 867 DoMessage(Message + ' on address ' + IntToHex(Word(PC), 4)); 859 868 Halt; 869 end; 870 871 function TCpuZ80.GetCarry: Boolean; 872 begin 873 Result := (AF.F and $1) <> 0; 874 end; 875 876 function TCpuZ80.GetParityOverflow: Boolean; 877 begin 878 Result := (AF.F and $4) <> 0; 879 end; 880 881 function TCpuZ80.GetSignNegative: Boolean; 882 begin 883 Result := (AF.F and $80) <> 0; 884 end; 885 886 function TCpuZ80.GetZero: Boolean; 887 begin 888 Result := (AF.F and $40) <> 0; 889 end; 890 891 procedure TCpuZ80.SetCarry(AValue: Boolean); 892 begin 893 AF.F := (AF.F and $fe) or Byte(AValue); 894 end; 895 896 procedure TCpuZ80.SetParityOverflow(AValue: Boolean); 897 begin 898 AF.F := (AF.F and $fb) or (Byte(AValue) shl 2); 899 end; 900 901 procedure TCpuZ80.SetSignNegative(AValue: Boolean); 902 begin 903 AF.F := (AF.F and $7f) or (Byte(AValue) shl 7); 904 end; 905 906 procedure TCpuZ80.SetZero(AValue: Boolean); 907 begin 908 AF.F := (AF.F and $bf) or (Byte(AValue) shl 6); 860 909 end; 861 910 … … 968 1017 end; 969 1018 970 procedure TCpuZ80.Cp (Data: Byte);1019 procedure TCpuZ80.CpByte(Data: Byte); 971 1020 var 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; 1022 begin 1023 Temp := AF.A; 1024 SubByte(Temp, Data); 977 1025 end; 978 1026 … … 1011 1059 1012 1060 procedure TCpuZ80.AddByte(var Target: Byte; Second: Byte); 1013 begin 1014 Target := Byte(Target + Second); 1061 var 1062 Temp: Word; 1063 begin 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); 1015 1071 end; 1016 1072 1017 1073 procedure TCpuZ80.AddWord(var Target: Word; Second: Word); 1018 begin 1019 Target := Word(Target + Second); 1074 var 1075 Temp: Cardinal; 1076 begin 1077 Temp := Target + Second; 1078 Carry := Temp > $ffff; 1079 Target := Word(Temp + Second); 1020 1080 end; 1021 1081 1022 1082 procedure TCpuZ80.AdcByte(var Target: Byte; Second: Byte); 1023 begin 1024 Target := Target + Second; 1083 var 1084 Temp: Word; 1085 begin 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); 1025 1093 end; 1026 1094 1027 1095 procedure TCpuZ80.AdcWord(var Target: Word; Second: Word); 1028 begin 1029 Target := Target - Second; 1096 var 1097 Temp: Cardinal; 1098 begin 1099 Temp := Target + Second + Byte(Carry); 1100 Carry := Temp > $ffff; 1101 Target := Word(Temp + Second); 1030 1102 end; 1031 1103 1032 1104 procedure TCpuZ80.SubByte(var Target: Byte; Second: Byte); 1033 begin 1034 Target := Byte(Target - Second); 1105 var 1106 Temp: SmallInt; 1107 begin 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); 1035 1115 end; 1036 1116 1037 1117 procedure TCpuZ80.SbcByte(var Target: Byte; Second: Byte); 1038 begin 1039 Target := Target - Second; 1118 var 1119 Temp: SmallInt; 1120 begin 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); 1040 1128 end; 1041 1129 1042 1130 procedure TCpuZ80.SbcWord(var Target: Word; Second: Word); 1043 begin 1044 Target := Target - Second; 1131 var 1132 Temp: Integer; 1133 begin 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); 1045 1141 end; 1046 1142 … … 1048 1144 begin 1049 1145 Target := Target xor Second; 1146 Carry := False; 1147 Zero := Target = 0; 1148 ParityOverflow := not Odd(Target); 1149 SignNegative := (Target and $80) <> 0; 1050 1150 end; 1051 1151 … … 1053 1153 begin 1054 1154 Target := Target or Second; 1155 Carry := False; 1156 Zero := Target = 0; 1157 ParityOverflow := not Odd(Target); 1158 SignNegative := (Target and $80) <> 0; 1055 1159 end; 1056 1160 … … 1058 1162 begin 1059 1163 Target := Target and Second; 1164 Carry := False; 1165 Zero := Target = 0; 1166 ParityOverflow := not Odd(Target); 1167 SignNegative := (Target and $80) <> 0; 1060 1168 end; 1061 1169 1062 1170 procedure TCpuZ80.IncByte(var Reg: Byte); 1063 1171 begin 1172 ParityOverflow := Reg = $7f; 1173 1064 1174 if Reg = High(Reg) then Reg := 0 1065 1175 else Inc(Reg); 1176 1177 Zero := Reg = 0; 1178 SignNegative := (Reg and $80) <> 0; 1066 1179 end; 1067 1180 … … 1074 1187 procedure TCpuZ80.DecByte(var Reg: Byte); 1075 1188 begin 1189 ParityOverflow := Reg = $80; 1190 1076 1191 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; 1078 1196 end; 1079 1197 … … 1081 1199 begin 1082 1200 if Reg = 0 then Reg := High(Reg) 1083 else Dec(Reg) 1201 else Dec(Reg); 1084 1202 end; 1085 1203 … … 1087 1205 begin 1088 1206 Carry := (Data and $80) <> 0; 1089 Data := ( Data shl 1) or Byte(Carry);1207 Data := ((Data shl 1) and $ff) or Byte(Carry); 1090 1208 end; 1091 1209 … … 1884 2002 Temp: ShortInt; 1885 2003 begin 1886 Dec(BC.B); 2004 if BC.B = 0 then BC.B := $ff 2005 else Dec(BC.B); 1887 2006 Temp := ShortInt(ReadByte); 1888 2007 if BC.B <> 0 then … … 2743 2862 procedure TCpuZ80.CP_B; 2744 2863 begin 2745 Cp (BC.B);2864 CpByte(BC.B); 2746 2865 end; 2747 2866 2748 2867 procedure TCpuZ80.CP_C; 2749 2868 begin 2750 Cp (BC.C);2869 CpByte(BC.C); 2751 2870 end; 2752 2871 2753 2872 procedure TCpuZ80.CP_D; 2754 2873 begin 2755 Cp (DE.D);2874 CpByte(DE.D); 2756 2875 end; 2757 2876 2758 2877 procedure TCpuZ80.CP_E; 2759 2878 begin 2760 Cp (DE.E);2879 CpByte(DE.E); 2761 2880 end; 2762 2881 2763 2882 procedure TCpuZ80.CP_H; 2764 2883 begin 2765 Cp (HL.H);2884 CpByte(HL.H); 2766 2885 end; 2767 2886 2768 2887 procedure TCpuZ80.CP_L; 2769 2888 begin 2770 Cp (HL.L);2889 CpByte(HL.L); 2771 2890 end; 2772 2891 2773 2892 procedure TCpuZ80.CP_HL_Indirect; 2774 2893 begin 2775 C P(DoRead(HL.Value));2894 CpByte(DoRead(HL.Value)); 2776 2895 end; 2777 2896 2778 2897 procedure TCpuZ80.CP_A; 2779 2898 begin 2780 C P(AF.A);2899 CpByte(AF.A); 2781 2900 end; 2782 2901 … … 3091 3210 procedure TCpuZ80.CP_N; 3092 3211 begin 3093 Cp (ReadByte);3212 CpByte(ReadByte); 3094 3213 end; 3095 3214 … … 3121 3240 procedure TCpuZ80.NEG; 3122 3241 begin 3242 ParityOverflow := AF.A = $80; 3243 Carry := AF.A <> $0; 3123 3244 AF.A := AF.A xor $ff; 3124 3245 IncByte(AF.A); 3246 SignNegative := (AF.A and $80) <> 1; 3247 Zero := AF.A = 0; 3125 3248 end; 3126 3249 … … 3312 3435 procedure TCpuZ80.CPI; 3313 3436 begin 3314 Cp (DoRead(HL.Value));3437 CpByte(DoRead(HL.Value)); 3315 3438 IncWord(HL.Value); 3316 3439 DecWord(BC.Value); … … 3341 3464 procedure TCpuZ80.CPD; 3342 3465 begin 3343 Cp (DoRead(HL.Value));3466 CpByte(DoRead(HL.Value)); 3344 3467 DecWord(HL.Value); 3345 3468 DecWord(BC.Value); … … 5372 5495 Opcode := ReadByte; 5373 5496 if Opcode = $CB then begin 5497 Opcode := ReadByte; 5374 5498 Instruction := TInstruction($100 or ReadByte); 5375 5499 end 5376 5500 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); 5378 5506 end 5379 5507 else if Opcode = $ED then begin 5380 Instruction := TInstruction($300 or ReadByte); 5508 Opcode := ReadByte; 5509 Instruction := TInstruction($300 or Opcode); 5381 5510 end 5382 5511 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); 5384 5517 end 5385 5518 else Instruction := TInstruction(Opcode); -
trunk/Z80/Z80InstructionInfo.pas
r7 r10 8 8 type 9 9 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, 15 16 pt00, pt08, pt10, pt18, pt20, pt28, pt30, pt38, 16 17 pt0, pt1, pt2, pt3, pt4, pt5, pt6, pt7); … … 41 42 42 43 43 function StrToParamType(Text : string): TParamType;44 function StrToParamType(Text, InstructionName: string): TParamType; 44 45 45 46 const 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', 49 54 '00H', '08H', '10H', '18H', '20h', '28H', '30H', '38H', 50 55 '0', '1', '2', '3', '4', '5', '6', '7'); … … 106 111 end; 107 112 108 function StrToParamType(Text : string): TParamType;113 function StrToParamType(Text, InstructionName: string): TParamType; 109 114 var 110 115 ParamType: TParamType; 111 116 begin 117 Result := ptNone; 112 118 Text := Text.ToLower; 113 119 for ParamType := Low(TParamType) to High(TParamType) do 114 120 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; 116 124 Break; 117 125 end; … … 129 137 AddNew(in_LD_B_N, 'LD', [ptRegB, ptNumberByte], 'Loads n into B.', 7, 0); 130 138 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); 132 140 AddNew(in_ADD_HL_BC, 'ADD', [ptRegHL, ptRegBC], 'The value of BC is added to HL.', 11, 0); 133 141 AddNew(in_LD_A_BC_Indirect, 'LD', [ptRegA, ptRegBCIndir], 'Loads the value pointed to by BC into A.', 7, 0); … … 137 145 AddNew(in_LD_C_N, 'LD', [ptRegC, ptNumberByte], 'Loads n into C.', 7, 0); 138 146 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', [pt RegD], '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); 140 148 AddNew(in_LD_DE_NN, 'LD', [ptRegDE, ptNumberWord], 'Loads nn into DE.', 10, 0); 141 149 AddNew(in_LD_DE_Indirect_A, 'LD', [ptRegDEIndir, ptRegA], 'Stores A into the memory location pointed to by DE.', 7, 0); … … 145 153 AddNew(in_LD_D_N, 'LD', [ptRegD, ptNumberByte], 'Loads n into D.', 7, 0); 146 154 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', [pt RegD], '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); 148 156 AddNew(in_ADD_HL_DE, 'ADD', [ptRegHL, ptRegDE], 'The value of DE is added to HL.', 11, 0); 149 157 AddNew(in_LD_A_DE_Indirect, 'LD', [ptRegA, ptRegDEIndir], 'Loads the value pointed to by DE into A.', 7, 0); … … 153 161 AddNew(in_LD_E_N, 'LD', [ptRegE, ptNumberByte], 'Loads n into E.', 7, 0); 154 162 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, pt RegD], '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); 156 164 AddNew(in_LD_HL_NN, 'LD', [ptRegHL, ptNumberWord], 'Loads nn into HL.', 10, 0); 157 165 AddNew(in_LD_NN_Indirect_HL, 'LD', [ptNumberWordIndir, ptRegHL], 'Stores HL into the memory location pointed to by nn.', 16, 0); … … 161 169 AddNew(in_LD_H_N, 'LD', [ptRegH, ptNumberByte], 'Loads n into H.', 7, 0); 162 170 AddNew(in_DAA, 'DAA', [], 'Adjusts A for BCD addition and subtraction operations.', 4, 0); 163 AddNew(in_JR_Z_D, 'JR', [ptFlagZ, pt RegD], '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); 164 172 AddNew(in_ADD_HL_HL, 'ADD', [ptRegHL, ptRegHL], 'The value of HL is added to HL.', 11, 0); 165 173 AddNew(in_LD_HL_NN_Indirect, 'LD', [ptRegHL, ptNumberWordIndir], 'Loads the value pointed to by nn into HL.', 16, 0); … … 169 177 AddNew(in_LD_L_N, 'LD', [ptRegL, ptNumberByte], 'Loads n into L.', 7, 0); 170 178 AddNew(in_CPL, 'CPL', [], 'The contents of A are inverted (one''s complement).', 4, 0); 171 AddNew(in_JR_NC_D, 'JR', [ptFlagNC, pt RegD], '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); 172 180 AddNew(in_LD_SP_NN, 'LD', [ptRegSP, ptNumberWord], 'Loads nn into SP.', 10, 0); 173 181 AddNew(in_LD_NN_Indirect_A, 'LD', [ptNumberWordIndir, ptRegA], 'Stores A into the memory location pointed to by nn.', 13, 0); … … 177 185 AddNew(in_LD_HL_Indirect_N, 'LD', [ptRegHLIndir, ptNumberByte], 'Loads n into (HL).', 10, 0); 178 186 AddNew(in_SCF, 'SCF', [], 'Sets the carry flag.', 4, 0); 179 AddNew(in_JR_C_D, 'JR', [ptRegC, pt RegD], '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); 180 188 AddNew(in_ADD_HL_SP, 'ADD', [ptRegHL, ptRegSP], 'The value of SP is added to HL.', 11, 0); 181 189 AddNew(in_LD_A_NN_Indirect, 'LD', [ptRegA, ptNumberWordIndir], 'Loads the value pointed to by nn into A.', 13, 0); … … 351 359 AddNew(in_AND_N, 'AND', [ptNumberByte], 'Bitwise AND on A with n.', 7, 0); 352 360 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); 354 362 AddNew(in_JP_HL_Indirect, 'JP', [ptRegHLIndir], 'Loads the value of HL into PC.', 4, 0); 355 AddNew(in_JP_PE_NN, 'JP', [pt NumberWord], '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); 356 364 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', [pt NumberWord], '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); 358 366 AddNew(in_XOR_N, 'XOR', [ptNumberByte], 'Bitwise XOR on A with n.', 7, 0); 359 367 AddNew(in_RST_28H, 'RST', [pt28], 'The current PC value plus one is pushed onto the stack, then is loaded with 40.', 11, 0); 360 368 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); 362 370 AddNew(in_JP_P_NN, 'JP', [ptFlagP, ptNumberWord], 'If the sign flag is unset, nn is copied to PC.', 10, 0); 363 371 AddNew(in_DI, 'DI', [], 'Resets both interrupt flip-flops, thus preventing maskable interrupts from triggering.', 4, 0); 364 372 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); 366 374 AddNew(in_OR_N, 'OR', [ptNumberByte], 'Bitwise OR on A with n.', 7, 0); 367 375 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); 369 377 AddNew(in_LD_SP_HL, 'LD', [ptRegSP, ptRegHL], 'Loads the value of HL into SP.', 6, 0); 370 AddNew(in_JP_M_NN, 'JP', [pt NumberWord], '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); 371 379 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', [pt NumberWord], '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); 373 381 AddNew(in_CP_N, 'CP', [ptNumberByte], 'Subtracts n from A and affects flags according to the result. A is not modified.', 7, 0); 374 382 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', [ptReg B], '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); 377 385 AddNew(in_SBC_HL_BC, 'SBC', [ptRegHL, ptRegBC], 'Subtracts BC and the carry flag from HL.', 15, 0); 378 386 AddNew(in_LD_NN_Indirect_BC, 'LD', [ptNumberWordIndir, ptRegBC], 'Stores BC into the memory location pointed to by nn.', 20, 0); … … 380 388 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); 381 389 AddNew(in_IM_0, 'IM', [pt0], 'Sets interrupt mode 0.', 8, 0); 382 AddNew(in_LD_I_A, 'LD', [ptReg A], '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); 385 393 AddNew(in_ADC_HL_BC, 'ADC', [ptRegHL, ptRegBC], 'Adds BC and the carry flag to HL.', 15, 0); 386 394 AddNew(in_LD_BC_NN_Indirect, 'LD', [ptRegBC, ptNumberWordIndir], 'Loads the value pointed to by nn into BC.', 20, 0); 387 395 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', [ptReg A], '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', [ptReg D], '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); 391 399 AddNew(in_SBC_HL_DE, 'SBC', [ptRegHL, ptRegDE], 'Subtracts DE and the carry flag from HL.', 15, 0); 392 400 AddNew(in_LD_NN_Indirect_DE, 'LD', [ptNumberWordIndir, ptRegDE], 'Stores DE into the memory location pointed to by nn.', 20, 0); 393 401 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', [ptReg E], '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); 397 405 AddNew(in_ADC_HL_DE, 'ADC', [ptRegHL, ptRegDE], 'Adds DE and the carry flag to HL.', 15, 0); 398 406 AddNew(in_LD_DE_NN_Indirect, 'LD', [ptRegDE, ptNumberWordIndir], 'Loads the value pointed to by nn into DE.', 20, 0); 399 407 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', [ptReg H], '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); 403 411 AddNew(in_SBC_HL_HL, 'SBC', [ptRegHL, ptRegHL], 'Subtracts HL and the carry flag from HL.', 15, 0); 404 412 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', [ptReg L], '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); 407 415 AddNew(in_ADC_HL_HL, 'ADC', [ptRegHL, ptRegHL], 'Adds HL and the carry flag to HL.', 15, 0); 408 416 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); 409 417 AddNew(in_SBC_HL_SP, 'SBC', [ptRegHL, ptRegSP], 'Subtracts SP and the carry flag from HL.', 15, 0); 410 418 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', [ptReg A], '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); 413 421 AddNew(in_ADC_HL_SP, 'ADC', [ptRegHL, ptRegSP], 'Adds SP and the carry flag to HL.', 15, 0); 414 422 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 7 7 8 8 type 9 TInstructionTable = (itBase, itCB, itDD, itED, itFD );9 TInstructionTable = (itBase, itCB, itDD, itED, itFD, itDDCB, itFDCB); 10 10 11 11 TInstruction = (
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/mzxemu/chrome/site/your_project_logo.png)