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