+ added helper functions get_x86_string_op_si_param and get_x86_string_op_di_param

* use get_x86_string_op_si_param in the nasm writer

git-svn-id: trunk@37450 -
This commit is contained in:
nickysn 2017-10-12 15:12:40 +00:00
parent 5a5cd65559
commit e3ca2a3043
2 changed files with 37 additions and 10 deletions

View File

@ -989,16 +989,7 @@ interface
else if is_x86_parameterized_string_instruction_op(fixed_opcode) then
begin
writer.AsmWrite(#9#9);
case fixed_opcode of
A_MOVS,A_OUTS:
i:=1;
A_CMPS,A_LODS:
i:=0;
A_SCAS,A_STOS,A_INS:
i:=-1;
else
internalerror(2017101102);
end;
i:=get_x86_string_op_si_param(fixed_opcode);
if (i<>-1) and (taicpu(hp).oper[i]^.typ=top_ref) and
(taicpu(hp).oper[i]^.ref^.segment<>NR_NO) then
writer.AsmWrite(std_regname(taicpu(hp).oper[i]^.ref^.segment)+' ');

View File

@ -325,6 +325,12 @@ uses
function is_x86_parameterized_string_instruction_op(op: TAsmOp): boolean;
function x86_param2paramless_string_op(op: TAsmOp): TAsmOp;
function get_x86_string_op_size(op: TAsmOp): TOpSize;
{ returns the 0-based operand number (intel syntax) of the ds:[si] param of
a x86 string instruction }
function get_x86_string_op_si_param(op: TAsmOp):shortint;
{ returns the 0-based operand number (intel syntax) of the es:[di] param of
a x86 string instruction }
function get_x86_string_op_di_param(op: TAsmOp):shortint;
{$ifdef i8086}
{ return whether we need to add an extra FWAIT instruction before the given
@ -752,6 +758,36 @@ implementation
end;
function get_x86_string_op_si_param(op: TAsmOp):shortint;
begin
case op of
A_MOVS,A_OUTS:
result:=1;
A_CMPS,A_LODS:
result:=0;
A_SCAS,A_STOS,A_INS:
result:=-1;
else
internalerror(2017101102);
end;
end;
function get_x86_string_op_di_param(op: TAsmOp):shortint;
begin
case op of
A_MOVS,A_SCAS,A_STOS,A_INS:
result:=0;
A_CMPS:
result:=1;
A_LODS,A_OUTS:
result:=-1;
else
internalerror(2017101202);
end;
end;
{$ifdef i8086}
function requires_fwait_on_8087(op: TAsmOp): boolean;
begin