+ added warning if source or destination for x86 string instructions isn't

specified to be (%esi) or (%edi), when using at&t syntax assembler (this is
  not considered an error by intel syntax assemblers, so we're not adding a
  warning there, for now)

git-svn-id: trunk@37458 -
This commit is contained in:
nickysn 2017-10-14 15:27:00 +00:00
parent 4a8aec26bf
commit a8232ac477
4 changed files with 396 additions and 338 deletions

View File

@ -2483,7 +2483,7 @@ cg_f_max_units_reached=06057_F_Maximum number of units ($1) reached for the curr
#
# Assembler reader
#
# 07132 is the last used one
# 07133 is the last used one
#
asmr_d_start_reading=07000_DL_Starting $1 styled assembler parsing
% This informs you that an assembler block is being parsed
@ -2804,6 +2804,11 @@ asmr_w_unable_to_determine_constant_size_using_word=07131_W_No size specified an
% the compiler is unable to determine what size (byte, word, dword, etc.) it
% should use for the constant. Based on its value, WORD is used.
asmr_e_cannot_override_es_segment=07132_E_Cannot override ES segment
% The ES segment in the ES:[EDI] reference of the x86 string instructions
% cannot be overridden.
asmr_w_invalid_reference=07133_W_Reference is not valid here (expected "$1")
% Certain x86 instructions require a fixed source or destination reference
% (e.g. [ESI] or [EDI] for the string instructions source and destination)
#
# Assembler/binary writers
#

View File

@ -814,6 +814,7 @@ const
asmr_w_unable_to_determine_constant_size_using_byte=07130;
asmr_w_unable_to_determine_constant_size_using_word=07131;
asmr_e_cannot_override_es_segment=07132;
asmr_w_invalid_reference=07133;
asmw_f_too_many_asm_files=08000;
asmw_f_assembler_output_not_supported=08001;
asmw_f_comp_not_supported=08002;
@ -1084,9 +1085,9 @@ const
option_info=11024;
option_help_pages=11025;
MsgTxtSize = 80564;
MsgTxtSize = 80616;
MsgIdxMax : array[1..20] of longint=(
27,105,347,124,96,58,133,33,221,67,
27,105,347,124,96,58,134,33,221,67,
60,20,30,1,1,1,1,1,1,1
);

File diff suppressed because it is too large Load Diff

View File

@ -786,7 +786,7 @@ Implementation
var
operandnum : longint;
PrefixOp,OverrideOp: tasmop;
di_param: ShortInt;
di_param, si_param: ShortInt;
Begin
PrefixOp:=A_None;
OverrideOp:=A_None;
@ -901,16 +901,68 @@ Implementation
{ Check for invalid ES: overrides }
if is_x86_parameterized_string_op(instr.opcode) then
begin
si_param:=get_x86_string_op_si_param(instr.opcode);
if si_param<>-1 then
begin
si_param:=x86_parameterized_string_op_param_count(instr.opcode)-si_param;
if si_param<=operandnum then
with instr.operands[si_param] do
if (opr.typ=OPR_REFERENCE) then
begin
if not((((opr.ref.index<>NR_NO) and
(opr.ref.base=NR_NO) and
(getregtype(opr.ref.index)=R_INTREGISTER) and
(getsupreg(opr.ref.index)=RS_ESI)) or
((opr.ref.index=NR_NO) and
(opr.ref.base<>NR_NO) and
(getregtype(opr.ref.base)=R_INTREGISTER) and
(getsupreg(opr.ref.base)=RS_ESI))) and
(opr.ref.offset=0) and
(opr.ref.scalefactor<=1) and
(opr.ref.refaddr=addr_no) and
(opr.ref.symbol=nil) and
(opr.ref.relsymbol=nil)) then
{$if defined(i8086)}
Message1(asmr_w_invalid_reference,'(%si)');
{$elseif defined(i386)}
Message1(asmr_w_invalid_reference,'(%esi)');
{$elseif defined(x86_64)}
Message1(asmr_w_invalid_reference,'(%rsi)');
{$endif}
end;
end;
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);
if (opr.typ=OPR_REFERENCE) then
begin
if (opr.ref.segment<>NR_NO) and
(opr.ref.segment<>NR_ES) then
Message(asmr_e_cannot_override_es_segment);
if not((((opr.ref.index<>NR_NO) and
(opr.ref.base=NR_NO) and
(getregtype(opr.ref.index)=R_INTREGISTER) and
(getsupreg(opr.ref.index)=RS_EDI)) or
((opr.ref.index=NR_NO) and
(opr.ref.base<>NR_NO) and
(getregtype(opr.ref.base)=R_INTREGISTER) and
(getsupreg(opr.ref.base)=RS_EDI))) and
(opr.ref.offset=0) and
(opr.ref.scalefactor<=1) and
(opr.ref.refaddr=addr_no) and
(opr.ref.symbol=nil) and
(opr.ref.relsymbol=nil)) then
{$if defined(i8086)}
Message1(asmr_w_invalid_reference,'(%di)');
{$elseif defined(i386)}
Message1(asmr_w_invalid_reference,'(%edi)');
{$elseif defined(x86_64)}
Message1(asmr_w_invalid_reference,'(%edi)');
{$endif}
end;
end;
end;
end;