mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 12:19:18 +02:00
* fixes for 'asm sti end;'
This commit is contained in:
parent
a53f6ba9d4
commit
1b481e1cca
@ -3538,7 +3538,7 @@ const
|
|||||||
Begin
|
Begin
|
||||||
Message(assem_e_invalid_or_missing_opcode);
|
Message(assem_e_invalid_or_missing_opcode);
|
||||||
{ error recovery }
|
{ error recovery }
|
||||||
While not (actasmtoken in [AS_SEPARATOR,AS_COMMA]) do
|
While not (actasmtoken in [AS_SEPARATOR,AS_COMMA,AS_END]) do
|
||||||
Consume(actasmtoken);
|
Consume(actasmtoken);
|
||||||
exit;
|
exit;
|
||||||
end
|
end
|
||||||
@ -3551,14 +3551,13 @@ const
|
|||||||
Message1(assem_e_invalid_prefix_and_opcode,actasmpattern);
|
Message1(assem_e_invalid_prefix_and_opcode,actasmpattern);
|
||||||
Consume(AS_OPCODE);
|
Consume(AS_OPCODE);
|
||||||
{ // Zero operand opcode ? // }
|
{ // Zero operand opcode ? // }
|
||||||
if actasmtoken = AS_SEPARATOR then
|
if actasmtoken in [AS_SEPARATOR,AS_END] then
|
||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
operandnum := 1;
|
operandnum := 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
While actasmtoken <> AS_SEPARATOR do
|
repeat
|
||||||
Begin
|
|
||||||
case actasmtoken of
|
case actasmtoken of
|
||||||
{ // Operand delimiter // }
|
{ // Operand delimiter // }
|
||||||
AS_COMMA: Begin
|
AS_COMMA: Begin
|
||||||
@ -3569,11 +3568,12 @@ const
|
|||||||
Consume(AS_COMMA);
|
Consume(AS_COMMA);
|
||||||
end;
|
end;
|
||||||
{ // End of asm operands for this opcode // }
|
{ // End of asm operands for this opcode // }
|
||||||
AS_SEPARATOR: ;
|
AS_SEPARATOR,
|
||||||
|
AS_END : break;
|
||||||
else
|
else
|
||||||
BuildOperand(instr);
|
BuildOperand(instr);
|
||||||
end; { end case }
|
end; { end case }
|
||||||
end; { end while }
|
until false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -3612,8 +3612,8 @@ const
|
|||||||
labellist.init;
|
labellist.init;
|
||||||
c:=current_scanner^.asmgetchar;
|
c:=current_scanner^.asmgetchar;
|
||||||
actasmtoken:=gettoken;
|
actasmtoken:=gettoken;
|
||||||
while actasmtoken<>AS_END do
|
|
||||||
Begin
|
repeat
|
||||||
case actasmtoken of
|
case actasmtoken of
|
||||||
AS_LLABEL: Begin
|
AS_LLABEL: Begin
|
||||||
labelptr := labellist.search(actasmpattern);
|
labelptr := labellist.search(actasmpattern);
|
||||||
@ -3832,7 +3832,7 @@ const
|
|||||||
{ let us go back to the first operand }
|
{ let us go back to the first operand }
|
||||||
operandnum := 0;
|
operandnum := 0;
|
||||||
end;
|
end;
|
||||||
AS_END: ; { end assembly block }
|
AS_END: break; { end assembly block }
|
||||||
else
|
else
|
||||||
Begin
|
Begin
|
||||||
Message(assem_e_assemble_node_syntax_error);
|
Message(assem_e_assemble_node_syntax_error);
|
||||||
@ -3840,7 +3840,8 @@ const
|
|||||||
Consume(actasmtoken);
|
Consume(actasmtoken);
|
||||||
end;
|
end;
|
||||||
end; { end case }
|
end; { end case }
|
||||||
end; { end while }
|
until false;
|
||||||
|
|
||||||
{ check if there were undefined symbols. }
|
{ check if there were undefined symbols. }
|
||||||
{ if so, then list each of those undefined }
|
{ if so, then list each of those undefined }
|
||||||
{ labels. }
|
{ labels. }
|
||||||
@ -3870,7 +3871,6 @@ var
|
|||||||
old_exit: pointer;
|
old_exit: pointer;
|
||||||
|
|
||||||
procedure ra386att_exit;{$ifndef FPC}far;{$endif}
|
procedure ra386att_exit;{$ifndef FPC}far;{$endif}
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if assigned(iasmops) then
|
if assigned(iasmops) then
|
||||||
dispose(iasmops);
|
dispose(iasmops);
|
||||||
@ -3880,18 +3880,20 @@ var
|
|||||||
|
|
||||||
Begin
|
Begin
|
||||||
previous_was_id := FALSE;
|
previous_was_id := FALSE;
|
||||||
|
line:='';
|
||||||
{ you will get range problems here }
|
{ you will get range problems here }
|
||||||
if lastop_in_table > last_instruction_in_cache then
|
if lastop_in_table > last_instruction_in_cache then
|
||||||
Internalerror(2111);
|
Internalerror(2111);
|
||||||
line:=''; { Initialization of line variable.
|
|
||||||
No 255 char const string in version 0.9.1 MVC}
|
|
||||||
old_exit := exitproc;
|
old_exit := exitproc;
|
||||||
exitproc := @ra386att_exit;
|
exitproc := @ra386att_exit;
|
||||||
end.
|
end.
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.21 1998-11-16 15:38:54 peter
|
Revision 1.22 1998-11-29 12:47:21 peter
|
||||||
|
* fixes for 'asm sti end;'
|
||||||
|
|
||||||
|
Revision 1.21 1998/11/16 15:38:54 peter
|
||||||
* fixed instruct not in table msg
|
* fixed instruct not in table msg
|
||||||
|
|
||||||
Revision 1.20 1998/11/13 15:40:27 pierre
|
Revision 1.20 1998/11/13 15:40:27 pierre
|
||||||
|
@ -2245,8 +2245,8 @@ var
|
|||||||
Begin
|
Begin
|
||||||
basetypename := '';
|
basetypename := '';
|
||||||
firstpass := TRUE;
|
firstpass := TRUE;
|
||||||
{ // .ID[REG].ID ... // }
|
{ .ID[REG].ID ... }
|
||||||
{ // .ID.ID... // }
|
{ .ID.ID... }
|
||||||
Consume(AS_DOT);
|
Consume(AS_DOT);
|
||||||
Repeat
|
Repeat
|
||||||
case actasmtoken of
|
case actasmtoken of
|
||||||
@ -2255,7 +2255,7 @@ var
|
|||||||
{ will give us the size of the operand. }
|
{ will give us the size of the operand. }
|
||||||
{ instr.opsize := S_NO;}
|
{ instr.opsize := S_NO;}
|
||||||
InitAsmRef(instr);
|
InitAsmRef(instr);
|
||||||
{ // var_name.typefield.typefield // }
|
{ var_name.typefield.typefield }
|
||||||
if (varname <> '') then
|
if (varname <> '') then
|
||||||
Begin
|
Begin
|
||||||
if GetVarOffsetSize(varname,actasmpattern,toffset,tsize) then
|
if GetVarOffsetSize(varname,actasmpattern,toffset,tsize) then
|
||||||
@ -2543,26 +2543,26 @@ var
|
|||||||
{ Consume the scaling number }
|
{ Consume the scaling number }
|
||||||
Consume(actasmtoken);
|
Consume(actasmtoken);
|
||||||
case actasmtoken of
|
case actasmtoken of
|
||||||
{ // [...*SCALING-expr] ... // }
|
{ [...*SCALING-expr] ... }
|
||||||
AS_MINUS: Begin
|
AS_MINUS: Begin
|
||||||
if instr.operands[operandnum].ref.offset <> 0 then
|
if instr.operands[operandnum].ref.offset <> 0 then
|
||||||
Message(assem_f_internal_error_in_buildscale);
|
Message(assem_f_internal_error_in_buildscale);
|
||||||
instr.operands[operandnum].ref.offset :=
|
instr.operands[operandnum].ref.offset :=
|
||||||
BuildRefExpression;
|
BuildRefExpression;
|
||||||
end;
|
end;
|
||||||
{ // [...*SCALING+expr] ... // }
|
{ [...*SCALING+expr] ... }
|
||||||
AS_PLUS: Begin
|
AS_PLUS: Begin
|
||||||
if instr.operands[operandnum].ref.offset <> 0 then
|
if instr.operands[operandnum].ref.offset <> 0 then
|
||||||
Message(assem_f_internal_error_in_buildscale);
|
Message(assem_f_internal_error_in_buildscale);
|
||||||
instr.operands[operandnum].ref.offset :=
|
instr.operands[operandnum].ref.offset :=
|
||||||
BuildRefExpression;
|
BuildRefExpression;
|
||||||
end;
|
end;
|
||||||
{ // [...*SCALING] ... // }
|
{ [...*SCALING] ... }
|
||||||
AS_RBRACKET: Consume(AS_RBRACKET);
|
AS_RBRACKET: Consume(AS_RBRACKET);
|
||||||
else
|
else
|
||||||
Message(assem_e_invalid_scaling_value);
|
Message(assem_e_invalid_scaling_value);
|
||||||
end;
|
end;
|
||||||
{ // .Field.Field ... or separator/comma // }
|
{ .Field.Field ... or separator/comma }
|
||||||
Case actasmtoken of
|
Case actasmtoken of
|
||||||
AS_DOT: BuildRecordOffset(instr,'');
|
AS_DOT: BuildRecordOffset(instr,'');
|
||||||
AS_COMMA, AS_SEPARATOR: ;
|
AS_COMMA, AS_SEPARATOR: ;
|
||||||
@ -2622,8 +2622,8 @@ var
|
|||||||
{ we process this type of syntax immediately... }
|
{ we process this type of syntax immediately... }
|
||||||
case actasmtoken of
|
case actasmtoken of
|
||||||
|
|
||||||
{ // REG:[REG].Field.Field ... // }
|
{ REG:[REG].Field.Field ... }
|
||||||
{ // REG:[REG].Field[REG].Field... // }
|
{ REG:[REG].Field[REG].Field... }
|
||||||
AS_RBRACKET: Begin
|
AS_RBRACKET: Begin
|
||||||
Consume(AS_RBRACKET);
|
Consume(AS_RBRACKET);
|
||||||
{ check for record fields }
|
{ check for record fields }
|
||||||
@ -2634,7 +2634,7 @@ var
|
|||||||
else
|
else
|
||||||
Message(assem_e_syn_reference);
|
Message(assem_e_syn_reference);
|
||||||
end;
|
end;
|
||||||
{ // REG:[REG +/- ...].Field.Field ... // }
|
{ REG:[REG +/- ...].Field.Field ... }
|
||||||
AS_PLUS,AS_MINUS: Begin
|
AS_PLUS,AS_MINUS: Begin
|
||||||
if actasmtoken = AS_MINUS then
|
if actasmtoken = AS_MINUS then
|
||||||
Begin
|
Begin
|
||||||
@ -2647,7 +2647,7 @@ var
|
|||||||
expr := '+';
|
expr := '+';
|
||||||
end;
|
end;
|
||||||
Consume(actasmtoken);
|
Consume(actasmtoken);
|
||||||
{ // REG:[REG+REG+/-...].Field.Field // }
|
{ REG:[REG+REG+/-...].Field.Field }
|
||||||
if actasmtoken = AS_REGISTER then
|
if actasmtoken = AS_REGISTER then
|
||||||
Begin
|
Begin
|
||||||
if negative then
|
if negative then
|
||||||
@ -2657,7 +2657,7 @@ var
|
|||||||
instr.operands[operandnum].ref.index := findregister(actasmpattern);
|
instr.operands[operandnum].ref.index := findregister(actasmpattern);
|
||||||
Consume(AS_REGISTER);
|
Consume(AS_REGISTER);
|
||||||
case actasmtoken of
|
case actasmtoken of
|
||||||
AS_RBRACKET: { // REG:[REG+REG].Field.Field... // }
|
AS_RBRACKET: { REG:[REG+REG].Field.Field... }
|
||||||
Begin
|
Begin
|
||||||
Consume(AS_RBRACKET);
|
Consume(AS_RBRACKET);
|
||||||
Case actasmtoken of
|
Case actasmtoken of
|
||||||
@ -2667,7 +2667,7 @@ var
|
|||||||
Message(assem_e_syntax_error);
|
Message(assem_e_syntax_error);
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
AS_PLUS,AS_MINUS: { // REG:[REG+REG+/-expr... // }
|
AS_PLUS,AS_MINUS: { REG:[REG+REG+/-expr... }
|
||||||
Begin
|
Begin
|
||||||
if instr.operands[operandnum].ref.offset <> 0 then
|
if instr.operands[operandnum].ref.offset <> 0 then
|
||||||
Message(assem_f_internal_error_in_buildreference);
|
Message(assem_f_internal_error_in_buildreference);
|
||||||
@ -2680,7 +2680,7 @@ var
|
|||||||
Message(assem_e_syntax_error);
|
Message(assem_e_syntax_error);
|
||||||
end; { end case }
|
end; { end case }
|
||||||
end;
|
end;
|
||||||
AS_STAR: Begin { // REG:[REG+REG*SCALING...].Field.Field... // }
|
AS_STAR: Begin { REG:[REG+REG*SCALING...].Field.Field... }
|
||||||
BuildScaling(instr);
|
BuildScaling(instr);
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
@ -2690,12 +2690,12 @@ var
|
|||||||
end; { end case }
|
end; { end case }
|
||||||
end
|
end
|
||||||
else if actasmtoken = AS_STAR then
|
else if actasmtoken = AS_STAR then
|
||||||
{ // REG:[REG*SCALING ... ] // }
|
{ REG:[REG*SCALING ... ] }
|
||||||
Begin
|
Begin
|
||||||
BuildScaling(instr);
|
BuildScaling(instr);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
{ // REG:[REG+expr].Field.Field // }
|
{ REG:[REG+expr].Field.Field }
|
||||||
Begin
|
Begin
|
||||||
if instr.operands[operandnum].ref.offset <> 0 then
|
if instr.operands[operandnum].ref.offset <> 0 then
|
||||||
Message(assem_f_internal_error_in_buildreference);
|
Message(assem_f_internal_error_in_buildreference);
|
||||||
@ -2708,7 +2708,7 @@ var
|
|||||||
end; { end case }
|
end; { end case }
|
||||||
end; { end if }
|
end; { end if }
|
||||||
end; { end this case }
|
end; { end this case }
|
||||||
{ // REG:[REG*scaling] ... // }
|
{ REG:[REG*scaling] ... }
|
||||||
AS_STAR: Begin
|
AS_STAR: Begin
|
||||||
BuildScaling(instr);
|
BuildScaling(instr);
|
||||||
end;
|
end;
|
||||||
@ -2735,7 +2735,7 @@ var
|
|||||||
Consume(AS_LBRACKET);
|
Consume(AS_LBRACKET);
|
||||||
initAsmRef(instr);
|
initAsmRef(instr);
|
||||||
Case actasmtoken of
|
Case actasmtoken of
|
||||||
{ // Constant reference expression OR variable reference expression // }
|
{ Constant reference expression OR variable reference expression }
|
||||||
AS_ID: Begin
|
AS_ID: Begin
|
||||||
if actasmpattern[1] = '@' then
|
if actasmpattern[1] = '@' then
|
||||||
Message(assem_e_local_symbol_not_allowed_as_ref);
|
Message(assem_e_local_symbol_not_allowed_as_ref);
|
||||||
@ -2816,7 +2816,7 @@ var
|
|||||||
else
|
else
|
||||||
Message1(assem_e_invalid_symbol_name,actasmpattern);
|
Message1(assem_e_invalid_symbol_name,actasmpattern);
|
||||||
end;
|
end;
|
||||||
{ // Constant reference expression // }
|
{ Constant reference expression // }
|
||||||
AS_INTNUM,AS_BINNUM,AS_OCTALNUM,
|
AS_INTNUM,AS_BINNUM,AS_OCTALNUM,
|
||||||
AS_HEXNUM: Begin
|
AS_HEXNUM: Begin
|
||||||
{ if there was a variable prefix then }
|
{ if there was a variable prefix then }
|
||||||
@ -2836,7 +2836,7 @@ var
|
|||||||
Message(assem_e_syntax_error);
|
Message(assem_e_syntax_error);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{ // Constant reference expression // }
|
{ Constant reference expression // }
|
||||||
AS_MINUS,AS_NOT,AS_LPAREN:
|
AS_MINUS,AS_NOT,AS_LPAREN:
|
||||||
Begin
|
Begin
|
||||||
{ if there was a variable prefix then }
|
{ if there was a variable prefix then }
|
||||||
@ -2852,7 +2852,7 @@ var
|
|||||||
if not (actasmtoken in [AS_SEPARATOR,AS_COMMA]) then
|
if not (actasmtoken in [AS_SEPARATOR,AS_COMMA]) then
|
||||||
Message(assem_e_invalid_operand_in_bracket_expression);
|
Message(assem_e_invalid_operand_in_bracket_expression);
|
||||||
end;
|
end;
|
||||||
{ // Constant reference expression // }
|
{ Constant reference expression // }
|
||||||
AS_INTNUM,AS_OCTALNUM,AS_BINNUM,AS_HEXNUM: Begin
|
AS_INTNUM,AS_OCTALNUM,AS_BINNUM,AS_HEXNUM: Begin
|
||||||
{ if there was a variable prefix then }
|
{ if there was a variable prefix then }
|
||||||
{ add to offset instead. }
|
{ add to offset instead. }
|
||||||
@ -2867,7 +2867,7 @@ var
|
|||||||
if not (actasmtoken in [AS_SEPARATOR,AS_COMMA]) then
|
if not (actasmtoken in [AS_SEPARATOR,AS_COMMA]) then
|
||||||
Message(assem_e_invalid_operand_in_bracket_expression);
|
Message(assem_e_invalid_operand_in_bracket_expression);
|
||||||
end;
|
end;
|
||||||
{ // Variable reference expression // }
|
{ Variable reference expression }
|
||||||
AS_REGISTER: BuildReference(instr);
|
AS_REGISTER: BuildReference(instr);
|
||||||
else
|
else
|
||||||
Begin
|
Begin
|
||||||
@ -2894,7 +2894,7 @@ var
|
|||||||
tempstr := '';
|
tempstr := '';
|
||||||
expr := '';
|
expr := '';
|
||||||
case actasmtoken of
|
case actasmtoken of
|
||||||
{ // Constant expression // }
|
{ Constant expression // }
|
||||||
AS_PLUS,AS_MINUS,AS_NOT,AS_LPAREN:
|
AS_PLUS,AS_MINUS,AS_NOT,AS_LPAREN:
|
||||||
Begin
|
Begin
|
||||||
if not (instr.operands[operandnum].operandtype in [OPR_NONE,OPR_CONSTANT]) then
|
if not (instr.operands[operandnum].operandtype in [OPR_NONE,OPR_CONSTANT]) then
|
||||||
@ -2902,7 +2902,7 @@ var
|
|||||||
instr.operands[operandnum].operandtype := OPR_CONSTANT;
|
instr.operands[operandnum].operandtype := OPR_CONSTANT;
|
||||||
instr.operands[operandnum].val :=BuildExpression;
|
instr.operands[operandnum].val :=BuildExpression;
|
||||||
end;
|
end;
|
||||||
{ // Constant expression // }
|
{ Constant expression // }
|
||||||
AS_STRING: Begin
|
AS_STRING: Begin
|
||||||
if not (instr.operands[operandnum].operandtype in [OPR_NONE]) then
|
if not (instr.operands[operandnum].operandtype in [OPR_NONE]) then
|
||||||
Message(assem_e_invalid_operand_type);
|
Message(assem_e_invalid_operand_type);
|
||||||
@ -2920,7 +2920,7 @@ var
|
|||||||
Message(assem_e_invalid_string_expression);
|
Message(assem_e_invalid_string_expression);
|
||||||
end; { end case }
|
end; { end case }
|
||||||
end;
|
end;
|
||||||
{ // Constant expression // }
|
{ Constant expression // }
|
||||||
AS_INTNUM,AS_BINNUM,
|
AS_INTNUM,AS_BINNUM,
|
||||||
AS_OCTALNUM,
|
AS_OCTALNUM,
|
||||||
AS_HEXNUM: Begin
|
AS_HEXNUM: Begin
|
||||||
@ -2929,10 +2929,10 @@ var
|
|||||||
instr.operands[operandnum].operandtype := OPR_CONSTANT;
|
instr.operands[operandnum].operandtype := OPR_CONSTANT;
|
||||||
instr.operands[operandnum].val :=BuildExpression;
|
instr.operands[operandnum].val :=BuildExpression;
|
||||||
end;
|
end;
|
||||||
{ // A constant expression, or a Variable ref. // }
|
{ A constant expression, or a Variable ref. }
|
||||||
AS_ID: Begin
|
AS_ID: Begin
|
||||||
if actasmpattern[1] = '@' then
|
if actasmpattern[1] = '@' then
|
||||||
{ // Label or Special symbol reference // }
|
{ Label or Special symbol reference }
|
||||||
Begin
|
Begin
|
||||||
if actasmpattern = '@RESULT' then
|
if actasmpattern = '@RESULT' then
|
||||||
Begin
|
Begin
|
||||||
@ -2999,7 +2999,7 @@ var
|
|||||||
end
|
end
|
||||||
else { is it a label variable ? }
|
else { is it a label variable ? }
|
||||||
Begin
|
Begin
|
||||||
{ // ID[ , ID.Field.Field or simple ID // }
|
{ ID[ , ID.Field.Field or simple ID }
|
||||||
{ check if this is a label, if so then }
|
{ check if this is a label, if so then }
|
||||||
{ emit it as a label. }
|
{ emit it as a label. }
|
||||||
if SearchLabel(actasmpattern,hl) then
|
if SearchLabel(actasmpattern,hl) then
|
||||||
@ -3048,7 +3048,7 @@ var
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{ // Register, a variable reference or a constant reference // }
|
{ Register, a variable reference or a constant reference }
|
||||||
AS_REGISTER: Begin
|
AS_REGISTER: Begin
|
||||||
{ save the type of register used. }
|
{ save the type of register used. }
|
||||||
tempstr := actasmpattern;
|
tempstr := actasmpattern;
|
||||||
@ -3065,7 +3065,7 @@ var
|
|||||||
BuildBracketExpression(instr,false);
|
BuildBracketExpression(instr,false);
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
{ // Simple register // }
|
{ Simple register }
|
||||||
else if (actasmtoken = AS_SEPARATOR) or (actasmtoken = AS_COMMA) then
|
else if (actasmtoken = AS_SEPARATOR) or (actasmtoken = AS_COMMA) then
|
||||||
Begin
|
Begin
|
||||||
if not (instr.operands[operandnum].operandtype in [OPR_NONE,OPR_REGISTER]) then
|
if not (instr.operands[operandnum].operandtype in [OPR_NONE,OPR_REGISTER]) then
|
||||||
@ -3076,11 +3076,11 @@ var
|
|||||||
else
|
else
|
||||||
Message1(assem_e_syn_register,tempstr);
|
Message1(assem_e_syn_register,tempstr);
|
||||||
end;
|
end;
|
||||||
{ // a variable reference, register ref. or a constant reference // }
|
{ a variable reference, register ref. or a constant reference }
|
||||||
AS_LBRACKET: Begin
|
AS_LBRACKET: Begin
|
||||||
BuildBracketExpression(instr,false);
|
BuildBracketExpression(instr,false);
|
||||||
end;
|
end;
|
||||||
{ // Unsupported // }
|
{ Unsupported }
|
||||||
AS_SEG,AS_OFFSET: Begin
|
AS_SEG,AS_OFFSET: Begin
|
||||||
Message(assem_e_SEG_and_OFFSET_not_supported);
|
Message(assem_e_SEG_and_OFFSET_not_supported);
|
||||||
Consume(actasmtoken);
|
Consume(actasmtoken);
|
||||||
@ -3172,10 +3172,6 @@ var
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Procedure BuildOpCode;
|
Procedure BuildOpCode;
|
||||||
{*********************************************************************}
|
{*********************************************************************}
|
||||||
{ PROCEDURE BuildOpcode; }
|
{ PROCEDURE BuildOpcode; }
|
||||||
@ -3185,8 +3181,8 @@ var
|
|||||||
{ EXIT CONDITION: On exit the routine should point to AS_SEPARATOR. }
|
{ EXIT CONDITION: On exit the routine should point to AS_SEPARATOR. }
|
||||||
{ On ENTRY: Token should point to AS_OPCODE }
|
{ On ENTRY: Token should point to AS_OPCODE }
|
||||||
{*********************************************************************}
|
{*********************************************************************}
|
||||||
var asmtok: tasmop;
|
var
|
||||||
op: tasmop;
|
asmtok,op : tasmop;
|
||||||
expr : string;
|
expr : string;
|
||||||
segreg : tregister;
|
segreg : tregister;
|
||||||
Begin
|
Begin
|
||||||
@ -3194,8 +3190,8 @@ var
|
|||||||
asmtok := A_NONE; { assmume no prefix }
|
asmtok := A_NONE; { assmume no prefix }
|
||||||
segreg := R_NO; { assume no segment override }
|
segreg := R_NO; { assume no segment override }
|
||||||
|
|
||||||
{ // prefix seg opcode // }
|
{ prefix seg opcode }
|
||||||
{ // prefix opcode // }
|
{ prefix opcode }
|
||||||
if findprefix(actasmpattern,asmtok) then
|
if findprefix(actasmpattern,asmtok) then
|
||||||
Begin
|
Begin
|
||||||
{ standard opcode prefix }
|
{ standard opcode prefix }
|
||||||
@ -3208,10 +3204,9 @@ var
|
|||||||
Message(assem_w_repeat_prefix_and_seg_override);
|
Message(assem_w_repeat_prefix_and_seg_override);
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
{ seg prefix opcode }
|
||||||
{ // seg prefix opcode // }
|
{ seg opcode }
|
||||||
{ // seg opcode // }
|
else if findoverride(actasmpattern,segreg) then
|
||||||
if findoverride(actasmpattern,segreg) then
|
|
||||||
Begin
|
Begin
|
||||||
Consume(AS_OPCODE);
|
Consume(AS_OPCODE);
|
||||||
if findprefix(actasmpattern,asmtok) then
|
if findprefix(actasmpattern,asmtok) then
|
||||||
@ -3223,12 +3218,13 @@ var
|
|||||||
Consume(AS_OPCODE);
|
Consume(AS_OPCODE);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{ // opcode // }
|
|
||||||
|
{ opcode }
|
||||||
if (actasmtoken <> AS_OPCODE) then
|
if (actasmtoken <> AS_OPCODE) then
|
||||||
Begin
|
Begin
|
||||||
Message(assem_e_invalid_or_missing_opcode);
|
Message(assem_e_invalid_or_missing_opcode);
|
||||||
{ error recovery }
|
{ error recovery }
|
||||||
While not (actasmtoken in [AS_SEPARATOR,AS_COMMA]) do
|
While not (actasmtoken in [AS_SEPARATOR,AS_COMMA,AS_END]) do
|
||||||
Consume(actasmtoken);
|
Consume(actasmtoken);
|
||||||
exit;
|
exit;
|
||||||
end
|
end
|
||||||
@ -3236,33 +3232,45 @@ var
|
|||||||
Begin
|
Begin
|
||||||
op := findopcode(actasmpattern);
|
op := findopcode(actasmpattern);
|
||||||
instr.addinstr(op);
|
instr.addinstr(op);
|
||||||
{ // Valid combination of prefix and instruction ? // }
|
{ Valid combination of prefix and instruction ? }
|
||||||
if (asmtok <> A_NONE) and (NOT CheckPrefix(asmtok,op)) then
|
if (asmtok <> A_NONE) and (NOT CheckPrefix(asmtok,op)) then
|
||||||
Message1(assem_e_invalid_prefix_and_opcode,actasmpattern);
|
Message1(assem_e_invalid_prefix_and_opcode,actasmpattern);
|
||||||
{ // Valid combination of segment override // }
|
{ Valid combination of segment override }
|
||||||
if (segreg <> R_NO) and (NOT CheckOverride(segreg,instr)) then
|
if (segreg <> R_NO) and (NOT CheckOverride(segreg,instr)) then
|
||||||
Message1(assem_e_invalid_override_and_opcode,actasmpattern);
|
Message1(assem_e_invalid_override_and_opcode,actasmpattern);
|
||||||
Consume(AS_OPCODE);
|
Consume(AS_OPCODE);
|
||||||
{ // Zero operand opcode ? // }
|
{ Zero operand opcode ? }
|
||||||
if actasmtoken = AS_SEPARATOR then
|
if actasmtoken in [AS_END,AS_SEPARATOR] then
|
||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
operandnum := 1;
|
operandnum := 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
While actasmtoken <> AS_SEPARATOR do
|
repeat
|
||||||
Begin
|
|
||||||
case actasmtoken of
|
case actasmtoken of
|
||||||
{ // Operand delimiter // }
|
|
||||||
AS_COMMA: Begin
|
{ End of asm operands for this opcode }
|
||||||
|
AS_END,
|
||||||
|
AS_SEPARATOR :
|
||||||
|
break;
|
||||||
|
|
||||||
|
{ Operand delimiter }
|
||||||
|
AS_COMMA :
|
||||||
|
Begin
|
||||||
if operandnum > MaxOperands then
|
if operandnum > MaxOperands then
|
||||||
Message(assem_e_too_many_operands)
|
Message(assem_e_too_many_operands)
|
||||||
else
|
else
|
||||||
Inc(operandnum);
|
Inc(operandnum);
|
||||||
Consume(AS_COMMA);
|
Consume(AS_COMMA);
|
||||||
end;
|
end;
|
||||||
{ // Typecast, Constant Expression, Type Specifier // }
|
|
||||||
AS_DWORD,AS_BYTE,AS_WORD,AS_TBYTE,AS_QWORD: Begin
|
{ Typecast, Constant Expression, Type Specifier }
|
||||||
|
AS_DWORD,
|
||||||
|
AS_BYTE,
|
||||||
|
AS_WORD,
|
||||||
|
AS_TBYTE,
|
||||||
|
AS_QWORD :
|
||||||
|
Begin
|
||||||
{ tell that the instruction was overriden }
|
{ tell that the instruction was overriden }
|
||||||
{ so we will NEVER override the opsize }
|
{ so we will NEVER override the opsize }
|
||||||
instr.operands[operandnum].overriden := TRUE;
|
instr.operands[operandnum].overriden := TRUE;
|
||||||
@ -3275,15 +3283,17 @@ var
|
|||||||
end;
|
end;
|
||||||
Consume(actasmtoken);
|
Consume(actasmtoken);
|
||||||
Case actasmtoken of
|
Case actasmtoken of
|
||||||
{ // Reference // }
|
{ Reference }
|
||||||
AS_PTR: Begin
|
AS_PTR :
|
||||||
|
Begin
|
||||||
initAsmRef(instr);
|
initAsmRef(instr);
|
||||||
Consume(AS_PTR);
|
Consume(AS_PTR);
|
||||||
BuildOperand(instr);
|
BuildOperand(instr);
|
||||||
end;
|
end;
|
||||||
{ // Possibly a typecast or a constant // }
|
{ Possibly a typecast or a constant }
|
||||||
{ // expression. // }
|
{ expression. }
|
||||||
AS_LPAREN: Begin
|
AS_LPAREN :
|
||||||
|
Begin
|
||||||
if actasmtoken = AS_ID then
|
if actasmtoken = AS_ID then
|
||||||
Begin
|
Begin
|
||||||
{ Case vartype of }
|
{ Case vartype of }
|
||||||
@ -3294,11 +3304,8 @@ var
|
|||||||
{ Check if next token = RPAREN }
|
{ Check if next token = RPAREN }
|
||||||
{ otherwise syntax error. }
|
{ otherwise syntax error. }
|
||||||
initAsmRef(instr);
|
initAsmRef(instr);
|
||||||
if not CreateVarInstr(instr,actasmpattern,
|
if not CreateVarInstr(instr,actasmpattern,operandnum) then
|
||||||
operandnum) then
|
|
||||||
Begin
|
|
||||||
Message1(assem_e_unknown_id,actasmpattern);
|
Message1(assem_e_unknown_id,actasmpattern);
|
||||||
end;
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -3310,8 +3317,11 @@ var
|
|||||||
BuildOperand(instr);
|
BuildOperand(instr);
|
||||||
end; { end case }
|
end; { end case }
|
||||||
end;
|
end;
|
||||||
{ // Type specifier // }
|
|
||||||
AS_NEAR,AS_FAR: Begin
|
{ Type specifier }
|
||||||
|
AS_NEAR,
|
||||||
|
AS_FAR :
|
||||||
|
Begin
|
||||||
if actasmtoken = AS_NEAR then
|
if actasmtoken = AS_NEAR then
|
||||||
Message(assem_w_near_ignored)
|
Message(assem_w_near_ignored)
|
||||||
else
|
else
|
||||||
@ -3324,17 +3334,18 @@ var
|
|||||||
end;
|
end;
|
||||||
BuildOperand(instr);
|
BuildOperand(instr);
|
||||||
end;
|
end;
|
||||||
{ // End of asm operands for this opcode // }
|
|
||||||
AS_SEPARATOR: ;
|
{ Constant expression }
|
||||||
{ // Constant expression // }
|
AS_LPAREN :
|
||||||
AS_LPAREN: Begin
|
Begin
|
||||||
instr.operands[operandnum].operandtype := OPR_CONSTANT;
|
instr.operands[operandnum].operandtype := OPR_CONSTANT;
|
||||||
instr.operands[operandnum].val := BuildExpression;
|
instr.operands[operandnum].val := BuildExpression;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
else
|
else
|
||||||
BuildOperand(instr);
|
BuildOperand(instr);
|
||||||
end; { end case }
|
end; { end case }
|
||||||
end; { end while }
|
until false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -3367,10 +3378,11 @@ var
|
|||||||
labellist.init;
|
labellist.init;
|
||||||
c:=current_scanner^.asmgetchar;
|
c:=current_scanner^.asmgetchar;
|
||||||
actasmtoken:=gettoken;
|
actasmtoken:=gettoken;
|
||||||
while actasmtoken<>AS_END do
|
|
||||||
Begin
|
repeat
|
||||||
case actasmtoken of
|
case actasmtoken of
|
||||||
AS_LLABEL: Begin
|
AS_LLABEL :
|
||||||
|
Begin
|
||||||
labelptr := labellist.search(actasmpattern);
|
labelptr := labellist.search(actasmpattern);
|
||||||
if not assigned(labelptr) then
|
if not assigned(labelptr) then
|
||||||
Begin
|
Begin
|
||||||
@ -3396,27 +3408,36 @@ var
|
|||||||
end;
|
end;
|
||||||
Consume(AS_LLABEL);
|
Consume(AS_LLABEL);
|
||||||
end;
|
end;
|
||||||
AS_LABEL: Begin
|
|
||||||
|
AS_LABEL :
|
||||||
|
Begin
|
||||||
if SearchLabel(actasmpattern,hl) then
|
if SearchLabel(actasmpattern,hl) then
|
||||||
ConcatLabel(p,A_LABEL, hl)
|
ConcatLabel(p,A_LABEL, hl)
|
||||||
else
|
else
|
||||||
Message1(assem_e_unknown_label_identifer,actasmpattern);
|
Message1(assem_e_unknown_label_identifer,actasmpattern);
|
||||||
Consume(AS_LABEL);
|
Consume(AS_LABEL);
|
||||||
end;
|
end;
|
||||||
AS_DW: Begin
|
|
||||||
|
AS_DW :
|
||||||
|
Begin
|
||||||
Consume(AS_DW);
|
Consume(AS_DW);
|
||||||
BuildConstant($ffff);
|
BuildConstant($ffff);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
AS_DB: Begin
|
AS_DB :
|
||||||
|
Begin
|
||||||
Consume(AS_DB);
|
Consume(AS_DB);
|
||||||
BuildConstant($ff);
|
BuildConstant($ff);
|
||||||
end;
|
end;
|
||||||
AS_DD: Begin
|
|
||||||
|
AS_DD :
|
||||||
|
Begin
|
||||||
Consume(AS_DD);
|
Consume(AS_DD);
|
||||||
BuildConstant($ffffffff);
|
BuildConstant($ffffffff);
|
||||||
end;
|
end;
|
||||||
AS_OPCODE: Begin
|
|
||||||
|
AS_OPCODE :
|
||||||
|
Begin
|
||||||
instr.init;
|
instr.init;
|
||||||
BuildOpcode;
|
BuildOpcode;
|
||||||
instr.numops := operandnum;
|
instr.numops := operandnum;
|
||||||
@ -3426,12 +3447,17 @@ var
|
|||||||
ConcatOpCode(instr);
|
ConcatOpCode(instr);
|
||||||
instr.done;
|
instr.done;
|
||||||
end;
|
end;
|
||||||
AS_SEPARATOR:Begin
|
|
||||||
|
AS_SEPARATOR :
|
||||||
|
Begin
|
||||||
Consume(AS_SEPARATOR);
|
Consume(AS_SEPARATOR);
|
||||||
{ let us go back to the first operand }
|
{ let us go back to the first operand }
|
||||||
operandnum := 0;
|
operandnum := 0;
|
||||||
end;
|
end;
|
||||||
AS_END: ; { end assembly block }
|
|
||||||
|
AS_END :
|
||||||
|
break; { end assembly block }
|
||||||
|
|
||||||
else
|
else
|
||||||
Begin
|
Begin
|
||||||
Message(assem_e_assemble_node_syntax_error);
|
Message(assem_e_assemble_node_syntax_error);
|
||||||
@ -3439,7 +3465,8 @@ var
|
|||||||
Consume(actasmtoken);
|
Consume(actasmtoken);
|
||||||
end;
|
end;
|
||||||
end; { end case }
|
end; { end case }
|
||||||
end; { end while }
|
until false;
|
||||||
|
|
||||||
{ check if there were undefined symbols. }
|
{ check if there were undefined symbols. }
|
||||||
{ if so, then list each of those undefined }
|
{ if so, then list each of those undefined }
|
||||||
{ labels. }
|
{ labels. }
|
||||||
@ -3467,7 +3494,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
procedure ra386int_exit;{$ifndef FPC}far;{$endif}
|
procedure ra386int_exit;{$ifndef FPC}far;{$endif}
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if assigned(iasmops) then
|
if assigned(iasmops) then
|
||||||
dispose(iasmops);
|
dispose(iasmops);
|
||||||
@ -3484,7 +3510,10 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.14 1998-11-16 15:38:56 peter
|
Revision 1.15 1998-11-29 12:47:22 peter
|
||||||
|
* fixes for 'asm sti end;'
|
||||||
|
|
||||||
|
Revision 1.14 1998/11/16 15:38:56 peter
|
||||||
* fixed instruct not in table msg
|
* fixed instruct not in table msg
|
||||||
|
|
||||||
Revision 1.13 1998/11/15 14:37:16 peter
|
Revision 1.13 1998/11/15 14:37:16 peter
|
||||||
|
Loading…
Reference in New Issue
Block a user