Changeset 7 for trunk/Z80/InstructionSetGen.pas
- Timestamp:
- Apr 19, 2026, 12:16:19 PM (8 days ago)
- File:
-
- 1 edited
-
trunk/Z80/InstructionSetGen.pas (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Z80/InstructionSetGen.pas
r6 r7 4 4 5 5 uses 6 Classes, SysUtils ;6 Classes, SysUtils, Common, Z80InstructionInfo, TypInfo; 7 7 8 8 type … … 28 28 InitInstructions: TStringList; 29 29 Combined: TStringList; 30 Info: TStringList; 30 31 Cell: string; 31 32 Source: string; … … 34 35 Bytes: string; 35 36 Cycles: string; 37 CyclesFalseCond: string; 36 38 FlagC: string; 37 39 FlagN: string; … … 43 45 Ident: string; 44 46 Prefix: string; 47 NameOnly: string; 48 Params: string; 49 ParamsPart: string; 50 InfoParams: string; 51 ParamType: TParamType; 52 NewCycles: string; 45 53 const 46 54 CellStart = '<td >'; … … 68 76 InitInstructions := TStringList.Create; 69 77 InitInstructions.Add('procedure TCpuZ80.InitInstructions;'); 70 InitInstructions.Add('begin;'); 78 InitInstructions.Add('begin'); 79 Info := TStringList.Create; 80 Info.Add('constructor TInstructionSet.Create;'); 81 Info.Add('begin'); 71 82 repeat 72 83 Cell := GetBlock(Source, CellStart, CellEnd); … … 74 85 Name := GetBlock(Cell, CodeStart, CodeEnd).Trim; 75 86 if Name = '' then Continue; 87 Name := StringReplace(Name, '<var>', '', [rfReplaceAll]); 88 Name := StringReplace(Name, '</var>', '', [rfReplaceAll]); 89 Params := Name; 90 NameOnly := GetStringPart(Params, ' '); 91 76 92 Ident := StringReplace(Name.ToUpper, ' ', '_', [rfReplaceAll]); 77 93 Ident := StringReplace(Ident, ',', '_', [rfReplaceAll]); 78 Ident := StringReplace(Ident, '<VAR>', '', [rfReplaceAll]);79 Ident := StringReplace(Ident, '</VAR>', '', [rfReplaceAll]);80 94 Ident := StringReplace(Ident, '''', '_Pair', [rfReplaceAll]); 81 95 Ident := StringReplace(Ident, '+', '_Plus_', [rfReplaceAll]); … … 89 103 Opcode := Copy(Opcode, 3, MaxInt).Trim; 90 104 if Prefix = 'CB' then Opcode := '1' + Opcode 91 else if Prefix = ' ED' then Opcode := '2' + Opcode92 else if Prefix = ' DD' then Opcode := '3' + Opcode105 else if Prefix = 'DD' then Opcode := '2' + Opcode 106 else if Prefix = 'ED' then Opcode := '3' + Opcode 93 107 else if Prefix = 'FD' then Opcode := '4' + Opcode; 94 108 end; 95 109 Bytes := GetBlock(Cell, DataStart, DataEnd).Trim; 96 110 Cycles := GetBlock(Cell, DataStart, DataEnd).Trim; 111 if Pos('/', Cycles) >= 1 then begin 112 NewCycles := GetStringPart(Cycles, '/'); 113 CyclesFalseCond := Cycles; 114 Cycles := NewCycles; 115 end else CyclesFalseCond := '0'; 116 97 117 FlagC := GetBlock(Cell, DataStart, DataEnd).Trim; 98 118 FlagN := GetBlock(Cell, DataStart, DataEnd).Trim; … … 102 122 FlagS := GetBlock(Cell, DataStart, DataEnd).Trim; 103 123 Description := GetBlock(Cell, DataStart, DataEnd).Trim; 124 Description := StringReplace(Description, '<var>', '', [rfReplaceAll]); 125 Description := StringReplace(Description, '</var>', '', [rfReplaceAll]); 126 127 InfoParams := ''; 128 Params := Params.ToUpper; 129 while Params <> '' do begin 130 ParamsPart := GetStringPart(Params, ','); 131 ParamType := StrToParamType(ParamsPart); 132 if ParamType <> ptNone then 133 InfoParams := InfoParams + ', ' + GetEnumName(TypeInfo(TParamType), Integer(ParamType)); 134 end; 135 if Copy(InfoParams, 1, 2) = ', ' then Delete(InfoParams, 1, 2); 136 137 Info.Add(' AddNew(in_' + Ident + ', ''' + NameOnly.ToUpper + ''', [' + InfoParams + '], ''' + 138 StringReplace(Description, '''', '''''', [rfReplaceAll]) + ''', ' + 139 Cycles + ', ' + CyclesFalseCond + ');'); 104 140 Instruction.Add(' in_' + Ident + ' = $' + Opcode + ','); 105 141 InitInstructions.Add(' Instructions[in_' + Ident + '] := ' + Ident + ';'); 106 Head.Add(' procedure ' + Ident + ';');142 Head.Add(' procedure ' + Ident + ';'); 107 143 Body.Add('procedure TCpuZ80.' + Ident + ';'); 108 144 Body.Add('begin'); 145 Body.Add(' NotImplemented;'); 109 146 Body.Add('end;'); 110 147 Body.Add(''); … … 113 150 Instruction.Add(' );'); 114 151 Head.Add('end;'); 115 InitInstructions.Add('end;') 116 ; 152 InitInstructions.Add('end;'); 153 Info.Add('end;'); 154 117 155 ForceDirectories(Generated); 118 156 Instruction.SaveToFile(Generated + DirectorySeparator + 'Instruction.pas'); 119 157 Head.SaveToFile(Generated + DirectorySeparator + 'Head.pas'); 120 158 Body.SaveToFile(Generated + DirectorySeparator + 'Body.pas'); 121 InitInstructions.SaveToFile(Generated + DirectorySeparator + 'Body.pas'); 159 InitInstructions.SaveToFile(Generated + DirectorySeparator + 'InitInstructions.pas'); 160 Info.SaveToFile(Generated + DirectorySeparator + 'Info.pas'); 122 161 123 162 Combined.Add(Instruction.Text); … … 133 172 Body.Free; 134 173 InitInstructions.Free; 174 Info.Free; 135 175 Lines.Free; 136 176 end;
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)