mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-25 07:09:17 +02:00
+ added strict validation for the param types in z80ins.dat
git-svn-id: branches/z80@44557 -
This commit is contained in:
parent
20eab5582f
commit
4027ad18e0
@ -24,6 +24,50 @@ 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 = (
|
||||||
|
'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)'
|
||||||
|
);
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
{ TZ80InsDatOutputFiles }
|
{ TZ80InsDatOutputFiles }
|
||||||
@ -61,12 +105,23 @@ destructor TZ80InsDatOutputFiles.Destroy;
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function FindParamType(const ParamTypeStr: string): Integer;
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
for I:=Low(ParamTypes) to High(ParamTypes) do
|
||||||
|
if ParamTypes[I]=ParamTypeStr then
|
||||||
|
exit(I);
|
||||||
|
raise Exception.Create('Invalid param type: '''+ParamTypeStr+'''');
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
InsDatFile: TextFile;
|
InsDatFile: TextFile;
|
||||||
OutputFiles: TZ80InsDatOutputFiles=nil;
|
OutputFiles: TZ80InsDatOutputFiles=nil;
|
||||||
S, op: string;
|
S, op, ParamsStr, S_Param: string;
|
||||||
FirstIns: Boolean=true;
|
FirstIns: Boolean=true;
|
||||||
OpCount: Integer=0;
|
OpCount: Integer=0;
|
||||||
|
S_Split, S_Params: TStringArray;
|
||||||
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');
|
||||||
@ -94,6 +149,10 @@ begin
|
|||||||
else if S<>'' then
|
else if S<>'' then
|
||||||
begin
|
begin
|
||||||
Inc(OpCount);
|
Inc(OpCount);
|
||||||
|
S_Split:=S.Split(' ',TStringSplitOptions.ExcludeEmpty);
|
||||||
|
S_Params:=S_Split[0].Split(',',TStringSplitOptions.ExcludeEmpty);
|
||||||
|
for S_Param in S_Params do
|
||||||
|
FindParamType(S_Param);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Writeln(OutputFiles.OpFile,');');
|
Writeln(OutputFiles.OpFile,');');
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
; p - immediate value in [$00,$08,$10,$18,$20,$28,$30,$38]
|
; p - immediate value in [$00,$08,$10,$18,$20,$28,$30,$38]
|
||||||
; e - 8-bit relative jump offset
|
; e - 8-bit relative jump offset
|
||||||
; nn - 16-bit immediate value
|
; nn - 16-bit immediate value
|
||||||
|
; 0 - the immediate value 0
|
||||||
|
; 1 - the immediate value 1
|
||||||
|
; 2 - the immediate value 2
|
||||||
; cc - condition: NZ/Z/NC/C/PO/PE/P/M
|
; cc - condition: NZ/Z/NC/C/PO/PE/P/M
|
||||||
; C - condition C
|
; C - condition C
|
||||||
; NC - condition NC
|
; NC - condition NC
|
||||||
@ -26,13 +29,16 @@
|
|||||||
; AF - 16-bit register pair AF
|
; AF - 16-bit register pair AF
|
||||||
; AF' - alternate register set, 16-bit register pair AF'
|
; AF' - alternate register set, 16-bit register pair AF'
|
||||||
; (C) - implied parameter of the IN and OUT instructions
|
; (C) - implied parameter of the IN and OUT instructions
|
||||||
|
; (n) - 8-bit immediate port number for the IN and OUT instructions
|
||||||
; (nn) - memory contents at address (nn = 16-bit immediate address)
|
; (nn) - memory contents at address (nn = 16-bit immediate address)
|
||||||
; (BC) - memory contents at address in register BC
|
; (BC) - memory contents at address in register BC
|
||||||
; (DE) - memory contents at address in register DE
|
; (DE) - memory contents at address in register DE
|
||||||
; (HL) - memory contents at address in register HL
|
; (HL) - memory contents at address in register HL
|
||||||
; (SP) - memory contents at address in register SP
|
; (SP) - memory contents at address in register SP
|
||||||
|
; (IX) - memory contents at address in register IX
|
||||||
|
; (IY) - memory contents at address in register IY
|
||||||
; (IX+d) - memory contents at address in register IX+d, d is in [-128..127]
|
; (IX+d) - memory contents at address in register IX+d, d is in [-128..127]
|
||||||
; (IY+d) - memory contents at address in register IX+d, d is in [-128..127]
|
; (IY+d) - memory contents at address in register IY+d, d is in [-128..127]
|
||||||
|
|
||||||
[None]
|
[None]
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user