From dd9b5eb2aa01f00726f19b481d2084e302be937a Mon Sep 17 00:00:00 2001 From: nickysn Date: Sat, 14 Oct 2017 00:48:46 +0000 Subject: [PATCH] + added the 'Cannot override ES' message in the at&t assembler reader as well git-svn-id: trunk@37456 - --- .gitattributes | 5 +++++ compiler/x86/rax86att.pas | 16 ++++++++++++++++ tests/test/tasm13f.pp | 18 ++++++++++++++++++ tests/test/tasm13g.pp | 18 ++++++++++++++++++ tests/test/tasm13h.pp | 18 ++++++++++++++++++ tests/test/tasm13i.pp | 18 ++++++++++++++++++ tests/test/tasm13j.pp | 18 ++++++++++++++++++ 7 files changed, 111 insertions(+) create mode 100644 tests/test/tasm13f.pp create mode 100644 tests/test/tasm13g.pp create mode 100644 tests/test/tasm13h.pp create mode 100644 tests/test/tasm13i.pp create mode 100644 tests/test/tasm13j.pp diff --git a/.gitattributes b/.gitattributes index c7261ab418..feacb7181c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12393,6 +12393,11 @@ tests/test/tasm13b.pp svneol=native#text/plain tests/test/tasm13c.pp svneol=native#text/plain tests/test/tasm13d.pp svneol=native#text/plain tests/test/tasm13e.pp svneol=native#text/plain +tests/test/tasm13f.pp svneol=native#text/plain +tests/test/tasm13g.pp svneol=native#text/plain +tests/test/tasm13h.pp svneol=native#text/plain +tests/test/tasm13i.pp svneol=native#text/plain +tests/test/tasm13j.pp svneol=native#text/plain tests/test/tasm2.inc svneol=native#text/plain tests/test/tasm2.pp svneol=native#text/plain tests/test/tasm2a.pp svneol=native#text/plain diff --git a/compiler/x86/rax86att.pas b/compiler/x86/rax86att.pas index 745a4492af..adb76ac82f 100644 --- a/compiler/x86/rax86att.pas +++ b/compiler/x86/rax86att.pas @@ -786,6 +786,7 @@ Implementation var operandnum : longint; PrefixOp,OverrideOp: tasmop; + di_param: ShortInt; Begin PrefixOp:=A_None; OverrideOp:=A_None; @@ -897,6 +898,21 @@ Implementation opcode:=x86_param2paramless_string_op(opcode); end; end; + { Check for invalid ES: overrides } + if is_x86_parameterized_string_op(instr.opcode) then + begin + di_param:=get_x86_string_op_di_param(instr.opcode); + if di_param<>-1 then + begin + di_param:=x86_parameterized_string_op_param_count(instr.opcode)-di_param; + if di_param<=operandnum then + with instr.operands[di_param] do + if (opr.typ=OPR_REFERENCE) and + (opr.ref.segment<>NR_NO) and + (opr.ref.segment<>NR_ES) then + Message(asmr_e_cannot_override_es_segment); + end; + end; end; diff --git a/tests/test/tasm13f.pp b/tests/test/tasm13f.pp new file mode 100644 index 0000000000..5207492b5d --- /dev/null +++ b/tests/test/tasm13f.pp @@ -0,0 +1,18 @@ +{ %CPU=i8086,i386,x86_64 } +{ %fail } + +{ Tests the 'Cannot override ES segment' error message } + +{$asmmode att} + +begin + asm +{$if defined(cpui8086)} + movsb (%si), %ds:(%di) +{$elseif defined(cpui386)} + movsb (%esi), %ds:(%edi) +{$elseif defined(cpux86_64)} + movsb (%rsi), %fs:(%rdi) +{$endif} + end; +end. diff --git a/tests/test/tasm13g.pp b/tests/test/tasm13g.pp new file mode 100644 index 0000000000..4bbf8530ad --- /dev/null +++ b/tests/test/tasm13g.pp @@ -0,0 +1,18 @@ +{ %CPU=i8086,i386,x86_64 } +{ %fail } + +{ Tests the 'Cannot override ES segment' error message } + +{$asmmode att} + +begin + asm +{$if defined(cpui8086)} + cmpsb %ds:(%di), (%si) +{$elseif defined(cpui386)} + cmpsb %ds:(%edi), (%esi) +{$elseif defined(cpux86_64)} + cmpsb %fs:(%rdi), (%rsi) +{$endif} + end; +end. diff --git a/tests/test/tasm13h.pp b/tests/test/tasm13h.pp new file mode 100644 index 0000000000..83947ad16d --- /dev/null +++ b/tests/test/tasm13h.pp @@ -0,0 +1,18 @@ +{ %CPU=i8086,i386,x86_64 } +{ %fail } + +{ Tests the 'Cannot override ES segment' error message } + +{$asmmode att} + +begin + asm +{$if defined(cpui8086)} + scasb %ds:(%di) +{$elseif defined(cpui386)} + scasb %ds:(%edi) +{$elseif defined(cpux86_64)} + scasb %fs:(%rdi) +{$endif} + end; +end. diff --git a/tests/test/tasm13i.pp b/tests/test/tasm13i.pp new file mode 100644 index 0000000000..bd21f4b9aa --- /dev/null +++ b/tests/test/tasm13i.pp @@ -0,0 +1,18 @@ +{ %CPU=i8086,i386,x86_64 } +{ %fail } + +{ Tests the 'Cannot override ES segment' error message } + +{$asmmode att} + +begin + asm +{$if defined(cpui8086)} + stosb %ds:(%di) +{$elseif defined(cpui386)} + stosb %ds:(%edi) +{$elseif defined(cpux86_64)} + stosb %fs:(%rdi) +{$endif} + end; +end. diff --git a/tests/test/tasm13j.pp b/tests/test/tasm13j.pp new file mode 100644 index 0000000000..5985e76485 --- /dev/null +++ b/tests/test/tasm13j.pp @@ -0,0 +1,18 @@ +{ %CPU=i8086,i386,x86_64 } +{ %fail } + +{ Tests the 'Cannot override ES segment' error message } + +{$asmmode att} + +begin + asm +{$if defined(cpui8086)} + insb %dx,%ds:(%di) +{$elseif defined(cpui386)} + insb %dx,%ds:(%edi) +{$elseif defined(cpux86_64)} + insb %dx,%fs:(%rdi) +{$endif} + end; +end.