mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-17 04:59:33 +02:00
+ created and included an Z80 instruction table
git-svn-id: branches/z80@44753 -
This commit is contained in:
parent
3ab0f3a93f
commit
be095914ec
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1087,6 +1087,7 @@ compiler/z80/z80nop.inc svneol=native#text/plain
|
||||
compiler/z80/z80op.inc svneol=native#text/plain
|
||||
compiler/z80/z80reg.dat svneol=native#text/plain
|
||||
compiler/z80/z80stdopnames.inc svneol=native#text/plain
|
||||
compiler/z80/z80tab.inc svneol=native#text/plain
|
||||
/fpmake.pp svneol=native#text/plain
|
||||
/fpmake_add1.inc svneol=native#text/plain
|
||||
/fpmake_proc1.inc svneol=native#text/plain
|
||||
|
@ -24,48 +24,48 @@ const
|
||||
Version = '1.0.0';
|
||||
HeaderStr = '{ don''t edit, this file is generated from z80ins.dat; to regenerate, run ''make insdat'' in the compiler directory }';
|
||||
|
||||
ParamTypes: array [0..40] of string = (
|
||||
'void',
|
||||
'r',
|
||||
'r''',
|
||||
'b',
|
||||
'n',
|
||||
'p',
|
||||
'e',
|
||||
'nn',
|
||||
'0',
|
||||
'1',
|
||||
'2',
|
||||
'cc',
|
||||
'C',
|
||||
'NC',
|
||||
'Z',
|
||||
'NZ',
|
||||
'dd',
|
||||
'qq',
|
||||
'pp',
|
||||
'rr',
|
||||
'A',
|
||||
'I',
|
||||
'R',
|
||||
'IX',
|
||||
'IY',
|
||||
'SP',
|
||||
'DE',
|
||||
'HL',
|
||||
'AF',
|
||||
'AF''',
|
||||
'(C)',
|
||||
'(n)',
|
||||
'(nn)',
|
||||
'(BC)',
|
||||
'(DE)',
|
||||
'(HL)',
|
||||
'(SP)',
|
||||
'(IX)',
|
||||
'(IY)',
|
||||
'(IX+d)',
|
||||
'(IY+d)'
|
||||
ParamTypes: array [0..40,0..1] of string = (
|
||||
('void', 'OT_NONE'),
|
||||
('r', 'OT_REG8'),
|
||||
('r''', 'OT_REG8'),
|
||||
('b', 'OT_IMM3'),
|
||||
('n', 'OT_IMM8'),
|
||||
('p', 'OT_IMM_RST'),
|
||||
('e', 'OT_RELJMP8'),
|
||||
('nn', 'OT_IMM16'),
|
||||
('0', 'OT_IMM_VAL0'),
|
||||
('1', 'OT_IMM_VAL1'),
|
||||
('2', 'OT_IMM_VAL2'),
|
||||
('cc', 'OT_COND'),
|
||||
('C', 'OT_COND_C'),
|
||||
('NC', 'OT_COND_NC'),
|
||||
('Z', 'OT_COND_Z'),
|
||||
('NZ', 'OT_COND_NZ'),
|
||||
('dd', 'OT_REG16_BC_DE_HL_SP'),
|
||||
('qq', 'OT_REG16_BC_DE_HL_AF'),
|
||||
('pp', 'OT_REG16_BC_DE_IX_SP'),
|
||||
('rr', 'OT_REG16_BC_DE_IY_SP'),
|
||||
('A', 'OT_REG8_A'),
|
||||
('I', 'OT_REG8_I'),
|
||||
('R', 'OT_REG8_R'),
|
||||
('IX', 'OT_REG16_IX'),
|
||||
('IY', 'OT_REG16_IY'),
|
||||
('SP', 'OT_REG16_SP'),
|
||||
('DE', 'OT_REG16_DE'),
|
||||
('HL', 'OT_REG16_HL'),
|
||||
('AF', 'OT_REG16_AF'),
|
||||
('AF''', 'OT_REG16_AF_'),
|
||||
('(C)', 'OT_REG8_C_PORT'),
|
||||
('(n)', 'OT_IMM_PORT'),
|
||||
('(nn)', 'OT_REF_ADDR16'),
|
||||
('(BC)', 'OT_REF_BC'),
|
||||
('(DE)', 'OT_REF_DE'),
|
||||
('(HL)', 'OT_REF_HL'),
|
||||
('(SP)', 'OT_REF_SP'),
|
||||
('(IX)', 'OT_REF_IX'),
|
||||
('(IY)', 'OT_REF_IY'),
|
||||
('(IX+d)','OT_REF_IX_d'),
|
||||
('(IY+d)','OT_REF_IY_d')
|
||||
);
|
||||
|
||||
type
|
||||
@ -77,6 +77,7 @@ type
|
||||
OpFile: TextFile;
|
||||
NOpFile: TextFile;
|
||||
StdOpNames: TextFile;
|
||||
InsTabFile: TextFile;
|
||||
|
||||
constructor Create;
|
||||
destructor Destroy;override;
|
||||
@ -95,6 +96,10 @@ constructor TZ80InsDatOutputFiles.Create;
|
||||
Rewrite(StdOpNames);
|
||||
Writeln(StdOpNames,HeaderStr);
|
||||
Writeln(StdOpNames,'(');
|
||||
AssignFile(InsTabFile,'z80tab.inc');
|
||||
Rewrite(InsTabFile);
|
||||
Writeln(InsTabFile,HeaderStr);
|
||||
Writeln(InsTabFile,'(');
|
||||
end;
|
||||
|
||||
destructor TZ80InsDatOutputFiles.Destroy;
|
||||
@ -102,6 +107,7 @@ destructor TZ80InsDatOutputFiles.Destroy;
|
||||
CloseFile(OpFile);
|
||||
CloseFile(NOpFile);
|
||||
CloseFile(StdOpNames);
|
||||
CloseFile(InsTabFile);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -110,7 +116,7 @@ var
|
||||
I: Integer;
|
||||
begin
|
||||
for I:=Low(ParamTypes) to High(ParamTypes) do
|
||||
if ParamTypes[I]=ParamTypeStr then
|
||||
if ParamTypes[I,0]=ParamTypeStr then
|
||||
exit(I);
|
||||
raise Exception.Create('Invalid param type: '''+ParamTypeStr+'''');
|
||||
end;
|
||||
@ -118,10 +124,11 @@ end;
|
||||
var
|
||||
InsDatFile: TextFile;
|
||||
OutputFiles: TZ80InsDatOutputFiles=nil;
|
||||
S, op, ParamsStr, S_Param: string;
|
||||
S, op, ParamsStr: string;
|
||||
FirstIns: Boolean=true;
|
||||
OpCount: Integer=0;
|
||||
S_Split, S_Params: TStringArray;
|
||||
ParamIdx: Integer;
|
||||
begin
|
||||
writeln('FPC Z80 Instruction Table Converter Version ',Version);
|
||||
AssignFile(InsDatFile,'../z80/z80ins.dat');
|
||||
@ -149,15 +156,36 @@ begin
|
||||
else if S<>'' then
|
||||
begin
|
||||
Inc(OpCount);
|
||||
if OpCount<>1 then
|
||||
Writeln(OutputFiles.InsTabFile,',');
|
||||
S_Split:=S.Split(' ',TStringSplitOptions.ExcludeEmpty);
|
||||
S_Params:=S_Split[0].Split(',',TStringSplitOptions.ExcludeEmpty);
|
||||
for S_Param in S_Params do
|
||||
FindParamType(S_Param);
|
||||
if (Length(S_Params)=1) and (S_Params[0]='void') then
|
||||
SetLength(S_Params,0);
|
||||
Writeln(OutputFiles.InsTabFile,' (');
|
||||
Writeln(OutputFiles.InsTabFile,' opcode : A_',op,';');
|
||||
Writeln(OutputFiles.InsTabFile,' ops : ',Length(S_Params),';');
|
||||
Write(OutputFiles.InsTabFile, ' optypes : (');
|
||||
for ParamIdx:=0 to 3 do
|
||||
begin
|
||||
if ParamIdx<>0 then
|
||||
Write(OutputFiles.InsTabFile,',');
|
||||
if ParamIdx<=High(S_Params) then
|
||||
Write(OutputFiles.InsTabFile,ParamTypes[FindParamType(S_Params[ParamIdx]),1])
|
||||
else
|
||||
Write(OutputFiles.InsTabFile,'OT_NONE');
|
||||
end;
|
||||
Writeln(OutputFiles.InsTabFile, ');');
|
||||
Writeln(OutputFiles.InsTabFile, ' code : '''';');
|
||||
Writeln(OutputFiles.InsTabFile, ' flags : 0');
|
||||
Write(OutputFiles.InsTabFile, ' )');
|
||||
end;
|
||||
end;
|
||||
Writeln(OutputFiles.OpFile,');');
|
||||
Writeln(OutputFiles.StdOpNames,');');
|
||||
Writeln(OutputFiles.NOpFile,OpCount,';');
|
||||
Writeln(OutputFiles.InsTabFile);
|
||||
Writeln(OutputFiles.InsTabFile,');');
|
||||
finally
|
||||
FreeAndNil(OutputFiles);
|
||||
CloseFile(InsDatFile);
|
||||
|
@ -38,6 +38,7 @@ uses
|
||||
{ "mov reg,reg" source operand number }
|
||||
O_MOV_DEST = 0;
|
||||
|
||||
instabentries = {$i z80nop.inc}
|
||||
maxinfolen = 5;
|
||||
|
||||
type
|
||||
@ -134,6 +135,13 @@ uses
|
||||
|
||||
implementation
|
||||
|
||||
{****************************************************************************
|
||||
Instruction table
|
||||
*****************************************************************************}
|
||||
|
||||
const
|
||||
InsTab:array[0..instabentries-1] of TInsEntry={$i z80tab.inc}
|
||||
|
||||
{*****************************************************************************
|
||||
taicpu Constructors
|
||||
*****************************************************************************}
|
||||
|
1424
compiler/z80/z80tab.inc
Normal file
1424
compiler/z80/z80tab.inc
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user