|
@@ -887,7 +887,7 @@ Unit Ra386int;
|
|
Consume(AS_RPAREN);
|
|
Consume(AS_RPAREN);
|
|
end;
|
|
end;
|
|
AS_STRING:
|
|
AS_STRING:
|
|
- Begin
|
|
|
|
|
|
+ begin
|
|
l:=0;
|
|
l:=0;
|
|
case Length(actasmpattern) of
|
|
case Length(actasmpattern) of
|
|
1 :
|
|
1 :
|
|
@@ -908,7 +908,7 @@ Unit Ra386int;
|
|
Consume(AS_STRING);
|
|
Consume(AS_STRING);
|
|
end;
|
|
end;
|
|
AS_ID:
|
|
AS_ID:
|
|
- Begin
|
|
|
|
|
|
+ begin
|
|
hs:='';
|
|
hs:='';
|
|
hssymtyp:=AT_DATA;
|
|
hssymtyp:=AT_DATA;
|
|
def:=nil;
|
|
def:=nil;
|
|
@@ -1035,12 +1035,11 @@ Unit Ra386int;
|
|
AS_END,
|
|
AS_END,
|
|
AS_RBRACKET,
|
|
AS_RBRACKET,
|
|
AS_SEPARATOR,
|
|
AS_SEPARATOR,
|
|
- AS_COMMA:
|
|
|
|
- Begin
|
|
|
|
- break;
|
|
|
|
- end;
|
|
|
|
|
|
+ AS_COMMA,
|
|
|
|
+ AS_COLON:
|
|
|
|
+ break;
|
|
else
|
|
else
|
|
- Begin
|
|
|
|
|
|
+ begin
|
|
{ write error only once. }
|
|
{ write error only once. }
|
|
if not errorflag then
|
|
if not errorflag then
|
|
Message(asmr_e_invalid_constant_expression);
|
|
Message(asmr_e_invalid_constant_expression);
|
|
@@ -1441,21 +1440,19 @@ Unit Ra386int;
|
|
Message(asmr_e_invalid_operand_type);
|
|
Message(asmr_e_invalid_operand_type);
|
|
BuildConstSymbolExpression(true,false,l,tempstr,tempsymtyp);
|
|
BuildConstSymbolExpression(true,false,l,tempstr,tempsymtyp);
|
|
if tempstr<>'' then
|
|
if tempstr<>'' then
|
|
- begin
|
|
|
|
- oper.opr.typ:=OPR_SYMBOL;
|
|
|
|
- oper.opr.symofs:=l;
|
|
|
|
- oper.opr.symbol:=objectlibrary.newasmsymbol(tempstr,AB_EXTERNAL,tempsymtyp);
|
|
|
|
- end
|
|
|
|
|
|
+ begin
|
|
|
|
+ oper.opr.typ:=OPR_SYMBOL;
|
|
|
|
+ oper.opr.symofs:=l;
|
|
|
|
+ oper.opr.symbol:=objectlibrary.newasmsymbol(tempstr,AB_EXTERNAL,tempsymtyp);
|
|
|
|
+ end
|
|
else
|
|
else
|
|
- begin
|
|
|
|
- if oper.opr.typ=OPR_NONE then
|
|
|
|
- begin
|
|
|
|
- oper.opr.typ:=OPR_CONSTANT;
|
|
|
|
- oper.opr.val:=l;
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- inc(oper.opr.val,l);
|
|
|
|
- end;
|
|
|
|
|
|
+ if oper.opr.typ=OPR_NONE then
|
|
|
|
+ begin
|
|
|
|
+ oper.opr.typ:=OPR_CONSTANT;
|
|
|
|
+ oper.opr.val:=l;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ inc(oper.opr.val,l);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -1484,7 +1481,7 @@ Unit Ra386int;
|
|
hl : tasmlabel;
|
|
hl : tasmlabel;
|
|
toffset,
|
|
toffset,
|
|
tsize : aint;
|
|
tsize : aint;
|
|
- Begin
|
|
|
|
|
|
+ begin
|
|
expr:='';
|
|
expr:='';
|
|
repeat
|
|
repeat
|
|
if actasmtoken=AS_DOT then
|
|
if actasmtoken=AS_DOT then
|
|
@@ -1536,7 +1533,6 @@ Unit Ra386int;
|
|
end;
|
|
end;
|
|
|
|
|
|
case actasmtoken of
|
|
case actasmtoken of
|
|
-
|
|
|
|
AS_OFFSET,
|
|
AS_OFFSET,
|
|
AS_SIZEOF,
|
|
AS_SIZEOF,
|
|
AS_TYPE,
|
|
AS_TYPE,
|
|
@@ -1687,14 +1683,15 @@ Unit Ra386int;
|
|
|
|
|
|
AS_SEPARATOR,
|
|
AS_SEPARATOR,
|
|
AS_END,
|
|
AS_END,
|
|
- AS_COMMA:
|
|
|
|
|
|
+ AS_COMMA,
|
|
|
|
+ AS_COLON:
|
|
break;
|
|
break;
|
|
|
|
|
|
else
|
|
else
|
|
Message(asmr_e_syn_operand);
|
|
Message(asmr_e_syn_operand);
|
|
end;
|
|
end;
|
|
until not(actasmtoken in [AS_DOT,AS_PLUS,AS_LBRACKET]);
|
|
until not(actasmtoken in [AS_DOT,AS_PLUS,AS_LBRACKET]);
|
|
- if not((actasmtoken in [AS_END,AS_SEPARATOR,AS_COMMA]) or
|
|
|
|
|
|
+ if not((actasmtoken in [AS_END,AS_SEPARATOR,AS_COMMA,AS_COLON]) or
|
|
(oper.hastype and (actasmtoken=AS_RPAREN))) then
|
|
(oper.hastype and (actasmtoken=AS_RPAREN))) then
|
|
begin
|
|
begin
|
|
Message(asmr_e_syntax_error);
|
|
Message(asmr_e_syntax_error);
|
|
@@ -1708,47 +1705,46 @@ Unit Ra386int;
|
|
PrefixOp,OverrideOp: tasmop;
|
|
PrefixOp,OverrideOp: tasmop;
|
|
size,
|
|
size,
|
|
operandnum : longint;
|
|
operandnum : longint;
|
|
- Begin
|
|
|
|
|
|
+ is_far_const:boolean;
|
|
|
|
+ i:byte;
|
|
|
|
+ begin
|
|
PrefixOp:=A_None;
|
|
PrefixOp:=A_None;
|
|
OverrideOp:=A_None;
|
|
OverrideOp:=A_None;
|
|
|
|
+ is_far_const:=false;
|
|
{ prefix seg opcode / prefix opcode }
|
|
{ prefix seg opcode / prefix opcode }
|
|
repeat
|
|
repeat
|
|
if is_prefix(actopcode) then
|
|
if is_prefix(actopcode) then
|
|
- begin
|
|
|
|
|
|
+ with instr do
|
|
|
|
+ begin
|
|
|
|
+ OpOrder:=op_intel;
|
|
|
|
+ PrefixOp:=ActOpcode;
|
|
|
|
+ opcode:=ActOpcode;
|
|
|
|
+ condition:=ActCondition;
|
|
|
|
+ opsize:=ActOpsize;
|
|
|
|
+ ConcatInstruction(curlist);
|
|
|
|
+ consume(AS_OPCODE);
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ if is_override(actopcode) then
|
|
with instr do
|
|
with instr do
|
|
begin
|
|
begin
|
|
OpOrder:=op_intel;
|
|
OpOrder:=op_intel;
|
|
- PrefixOp:=ActOpcode;
|
|
|
|
|
|
+ OverrideOp:=ActOpcode;
|
|
opcode:=ActOpcode;
|
|
opcode:=ActOpcode;
|
|
condition:=ActCondition;
|
|
condition:=ActCondition;
|
|
opsize:=ActOpsize;
|
|
opsize:=ActOpsize;
|
|
ConcatInstruction(curlist);
|
|
ConcatInstruction(curlist);
|
|
- end;
|
|
|
|
- Consume(AS_OPCODE);
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- if is_override(actopcode) then
|
|
|
|
- begin
|
|
|
|
- with instr do
|
|
|
|
- begin
|
|
|
|
- OpOrder:=op_intel;
|
|
|
|
- OverrideOp:=ActOpcode;
|
|
|
|
- opcode:=ActOpcode;
|
|
|
|
- condition:=ActCondition;
|
|
|
|
- opsize:=ActOpsize;
|
|
|
|
- ConcatInstruction(curlist);
|
|
|
|
- end;
|
|
|
|
- Consume(AS_OPCODE);
|
|
|
|
- end
|
|
|
|
|
|
+ consume(AS_OPCODE);
|
|
|
|
+ end
|
|
else
|
|
else
|
|
- break;
|
|
|
|
|
|
+ break;
|
|
{ allow for newline after prefix or override }
|
|
{ allow for newline after prefix or override }
|
|
while actasmtoken=AS_SEPARATOR do
|
|
while actasmtoken=AS_SEPARATOR do
|
|
- Consume(AS_SEPARATOR);
|
|
|
|
|
|
+ consume(AS_SEPARATOR);
|
|
until (actasmtoken<>AS_OPCODE);
|
|
until (actasmtoken<>AS_OPCODE);
|
|
{ opcode }
|
|
{ opcode }
|
|
if (actasmtoken <> AS_OPCODE) then
|
|
if (actasmtoken <> AS_OPCODE) then
|
|
- Begin
|
|
|
|
|
|
+ begin
|
|
Message(asmr_e_invalid_or_missing_opcode);
|
|
Message(asmr_e_invalid_or_missing_opcode);
|
|
RecoverConsume(false);
|
|
RecoverConsume(false);
|
|
exit;
|
|
exit;
|
|
@@ -1769,6 +1765,7 @@ Unit Ra386int;
|
|
end;
|
|
end;
|
|
{ We are reading operands, so opcode will be an AS_ID }
|
|
{ We are reading operands, so opcode will be an AS_ID }
|
|
operandnum:=1;
|
|
operandnum:=1;
|
|
|
|
+ is_far_const:=false;
|
|
Consume(AS_OPCODE);
|
|
Consume(AS_OPCODE);
|
|
{ Zero operand opcode ? }
|
|
{ Zero operand opcode ? }
|
|
if actasmtoken in [AS_SEPARATOR,AS_END] then
|
|
if actasmtoken in [AS_SEPARATOR,AS_END] then
|
|
@@ -1779,7 +1776,6 @@ Unit Ra386int;
|
|
{ Read Operands }
|
|
{ Read Operands }
|
|
repeat
|
|
repeat
|
|
case actasmtoken of
|
|
case actasmtoken of
|
|
-
|
|
|
|
{ End of asm operands for this opcode }
|
|
{ End of asm operands for this opcode }
|
|
AS_END,
|
|
AS_END,
|
|
AS_SEPARATOR :
|
|
AS_SEPARATOR :
|
|
@@ -1787,13 +1783,23 @@ Unit Ra386int;
|
|
|
|
|
|
{ Operand delimiter }
|
|
{ Operand delimiter }
|
|
AS_COMMA :
|
|
AS_COMMA :
|
|
- Begin
|
|
|
|
|
|
+ begin
|
|
if operandnum > Max_Operands then
|
|
if operandnum > Max_Operands then
|
|
Message(asmr_e_too_many_operands)
|
|
Message(asmr_e_too_many_operands)
|
|
else
|
|
else
|
|
Inc(operandnum);
|
|
Inc(operandnum);
|
|
Consume(AS_COMMA);
|
|
Consume(AS_COMMA);
|
|
end;
|
|
end;
|
|
|
|
+ {Far constant, i.e. jmp $0000:$11111111.}
|
|
|
|
+ AS_COLON:
|
|
|
|
+ begin
|
|
|
|
+ is_far_const:=true;
|
|
|
|
+ if operandnum>1 then
|
|
|
|
+ message(asmr_e_too_many_operands)
|
|
|
|
+ else
|
|
|
|
+ inc(operandnum);
|
|
|
|
+ consume(AS_COLON);
|
|
|
|
+ end;
|
|
|
|
|
|
{ Typecast, Constant Expression, Type Specifier }
|
|
{ Typecast, Constant Expression, Type Specifier }
|
|
AS_DWORD,
|
|
AS_DWORD,
|
|
@@ -1802,11 +1808,11 @@ Unit Ra386int;
|
|
AS_TBYTE,
|
|
AS_TBYTE,
|
|
AS_DQWORD,
|
|
AS_DQWORD,
|
|
AS_QWORD :
|
|
AS_QWORD :
|
|
- Begin
|
|
|
|
|
|
+ begin
|
|
{ load the size in a temp variable, so it can be set when the
|
|
{ load the size in a temp variable, so it can be set when the
|
|
operand is read }
|
|
operand is read }
|
|
size:=0;
|
|
size:=0;
|
|
- Case actasmtoken of
|
|
|
|
|
|
+ case actasmtoken of
|
|
AS_DWORD : size:=4;
|
|
AS_DWORD : size:=4;
|
|
AS_WORD : size:=2;
|
|
AS_WORD : size:=2;
|
|
AS_BYTE : size:=1;
|
|
AS_BYTE : size:=1;
|
|
@@ -1839,7 +1845,7 @@ Unit Ra386int;
|
|
{ Type specifier }
|
|
{ Type specifier }
|
|
AS_NEAR,
|
|
AS_NEAR,
|
|
AS_FAR :
|
|
AS_FAR :
|
|
- Begin
|
|
|
|
|
|
+ begin
|
|
if actasmtoken = AS_NEAR then
|
|
if actasmtoken = AS_NEAR then
|
|
begin
|
|
begin
|
|
Message(asmr_w_near_ignored);
|
|
Message(asmr_w_near_ignored);
|
|
@@ -1862,7 +1868,11 @@ Unit Ra386int;
|
|
BuildOperand(instr.Operands[operandnum] as tx86operand);
|
|
BuildOperand(instr.Operands[operandnum] as tx86operand);
|
|
end; { end case }
|
|
end; { end case }
|
|
until false;
|
|
until false;
|
|
- instr.Ops:=operandnum;
|
|
|
|
|
|
+ instr.ops:=operandnum;
|
|
|
|
+ if is_far_const then
|
|
|
|
+ for i:=1 to operandnum do
|
|
|
|
+ if instr.operands[i].opr.typ<>OPR_CONSTANT then
|
|
|
|
+ message(asmr_e_expr_illegal);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|