mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-15 19:19:24 +02:00
* support sizeof()
* fix typecasting a constant like dword(4)
This commit is contained in:
parent
71073744e4
commit
1da9e24cee
@ -44,7 +44,7 @@ Unit Ra386int;
|
||||
AS_ALIGN,AS_DB,AS_DW,AS_DD,AS_END,
|
||||
{------------------ Assembler Operators --------------------}
|
||||
AS_BYTE,AS_WORD,AS_DWORD,AS_QWORD,AS_TBYTE,AS_DQWORD,AS_NEAR,AS_FAR,
|
||||
AS_HIGH,AS_LOW,AS_OFFSET,AS_SEG,AS_TYPE,AS_PTR,AS_MOD,AS_SHL,AS_SHR,AS_NOT,
|
||||
AS_HIGH,AS_LOW,AS_OFFSET,AS_SIZEOF,AS_SEG,AS_TYPE,AS_PTR,AS_MOD,AS_SHL,AS_SHR,AS_NOT,
|
||||
AS_AND,AS_OR,AS_XOR);
|
||||
|
||||
type
|
||||
@ -70,7 +70,7 @@ Unit Ra386int;
|
||||
procedure BuildOperand(oper: tx86operand);
|
||||
procedure BuildConstantOperand(oper: tx86operand);
|
||||
procedure BuildOpCode(instr : tx86instruction);
|
||||
procedure BuildConstant(constsize: longint);
|
||||
procedure BuildConstant(constsize: byte);
|
||||
end;
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ Unit Ra386int;
|
||||
{ context sensitive. }
|
||||
_asmoperators : array[0.._count_asmoperators] of tasmkeyword = (
|
||||
'BYTE','WORD','DWORD','QWORD','TBYTE','DQWORD','NEAR','FAR','HIGH',
|
||||
'LOW','OFFSET','SEG','TYPE','PTR','MOD','SHL','SHR','NOT','AND',
|
||||
'LOW','OFFSET','SIZEOF','SEG','TYPE','PTR','MOD','SHL','SHR','NOT','AND',
|
||||
'OR','XOR');
|
||||
|
||||
token2str : array[tasmtoken] of string[10] = (
|
||||
@ -126,7 +126,7 @@ Unit Ra386int;
|
||||
';','identifier','register','opcode','/',
|
||||
'','','','','END',
|
||||
'','','','','','','','','',
|
||||
'','','','type','ptr','mod','shl','shr','not',
|
||||
'','','sizeof','','type','ptr','mod','shl','shr','not',
|
||||
'and','or','xor'
|
||||
);
|
||||
|
||||
@ -747,6 +747,9 @@ Unit Ra386int;
|
||||
end;
|
||||
AS_RPAREN:
|
||||
Begin
|
||||
{ Keep the AS_PAREN in actasmtoken, it is maybe a typecast }
|
||||
if parenlevel=0 then
|
||||
break;
|
||||
Consume(AS_RPAREN);
|
||||
expr:=expr + ')';
|
||||
dec(parenlevel);
|
||||
@ -828,11 +831,12 @@ Unit Ra386int;
|
||||
if actasmtoken<>AS_ID then
|
||||
Message(asmr_e_offset_without_identifier);
|
||||
end;
|
||||
AS_SIZEOF,
|
||||
AS_TYPE:
|
||||
begin
|
||||
l:=0;
|
||||
hasparen:=false;
|
||||
Consume(AS_TYPE);
|
||||
Consume(actasmtoken);
|
||||
if actasmtoken=AS_LPAREN then
|
||||
begin
|
||||
hasparen:=true;
|
||||
@ -1509,13 +1513,10 @@ Unit Ra386int;
|
||||
case actasmtoken of
|
||||
|
||||
AS_OFFSET,
|
||||
AS_SIZEOF,
|
||||
AS_TYPE,
|
||||
AS_NOT,
|
||||
AS_STRING :
|
||||
Begin
|
||||
BuildConstantOperand(oper);
|
||||
end;
|
||||
|
||||
AS_STRING,
|
||||
AS_PLUS,
|
||||
AS_MINUS,
|
||||
AS_LPAREN,
|
||||
@ -1844,7 +1845,7 @@ Unit Ra386int;
|
||||
end;
|
||||
|
||||
|
||||
Procedure ti386intreader.BuildConstant(constsize: longint);
|
||||
Procedure ti386intreader.BuildConstant(constsize: byte);
|
||||
var
|
||||
asmsymtyp : tasmsymtype;
|
||||
asmsym,
|
||||
@ -2037,7 +2038,11 @@ begin
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.82 2004-11-29 18:50:15 peter
|
||||
Revision 1.83 2004-12-22 17:09:55 peter
|
||||
* support sizeof()
|
||||
* fix typecasting a constant like dword(4)
|
||||
|
||||
Revision 1.82 2004/11/29 18:50:15 peter
|
||||
* os2 fixes for import
|
||||
* asmsymtype support for intel reader
|
||||
|
||||
|
@ -55,7 +55,7 @@ unit raatt;
|
||||
AS_ASCIIZ,AS_LCOMM,AS_COMM,AS_SINGLE,AS_DOUBLE,AS_EXTENDED,
|
||||
AS_DATA,AS_TEXT,AS_END,
|
||||
{------------------ Assembler Operators --------------------}
|
||||
AS_TYPE,AS_MOD,AS_SHL,AS_SHR,AS_NOT,AS_AND,AS_OR,AS_XOR,AS_NOR,AS_AT,
|
||||
AS_TYPE,AS_SIZEOF,AS_MOD,AS_SHL,AS_SHR,AS_NOT,AS_AND,AS_OR,AS_XOR,AS_NOR,AS_AT,
|
||||
AS_LO,AS_HI);
|
||||
|
||||
tasmkeyword = string[10];
|
||||
@ -76,14 +76,14 @@ unit raatt;
|
||||
'.align','.balign','.p2align','.ascii',
|
||||
'.asciz','.lcomm','.comm','.single','.double','.tfloat',
|
||||
'.data','.text','END',
|
||||
'TYPE','%','<<','>>','!','&','|','^','~','@','lo','hi');
|
||||
'TYPE','SIZEOF','%','<<','>>','!','&','|','^','~','@','lo','hi');
|
||||
|
||||
type
|
||||
tattreader = class(tasmreader)
|
||||
actasmtoken : tasmtoken;
|
||||
prevasmtoken : tasmtoken;
|
||||
procedure SetupTables;
|
||||
procedure BuildConstant(constsize: longint);
|
||||
procedure BuildConstant(constsize: byte);
|
||||
procedure BuildConstantOperand(oper : toperand);
|
||||
procedure BuildRealConstant(typ : tfloattype);
|
||||
procedure BuildStringConstant(asciiz: boolean);
|
||||
@ -354,6 +354,11 @@ unit raatt;
|
||||
actasmtoken:=AS_TYPE;
|
||||
exit;
|
||||
end;
|
||||
if actasmpattern = 'SIZEOF' then
|
||||
Begin
|
||||
actasmtoken:=AS_SIZEOF;
|
||||
exit;
|
||||
end;
|
||||
if is_register(actasmpattern) then
|
||||
begin
|
||||
actasmtoken:=AS_REGISTER;
|
||||
@ -756,7 +761,7 @@ unit raatt;
|
||||
end;
|
||||
|
||||
|
||||
Procedure tattreader.BuildConstant(constsize: longint);
|
||||
Procedure tattreader.BuildConstant(constsize: byte);
|
||||
var
|
||||
asmsymtyp : TAsmSymType;
|
||||
asmsym,
|
||||
@ -784,6 +789,8 @@ unit raatt;
|
||||
AS_PLUS,
|
||||
AS_MINUS,
|
||||
AS_LPAREN,
|
||||
AS_TYPE,
|
||||
AS_SIZEOF,
|
||||
AS_NOT,
|
||||
AS_ID :
|
||||
Begin
|
||||
@ -1319,10 +1326,11 @@ unit raatt;
|
||||
expr:=expr + tempstr;
|
||||
Consume(AS_STRING);
|
||||
end;
|
||||
AS_SIZEOF,
|
||||
AS_TYPE:
|
||||
begin
|
||||
l:=0;
|
||||
Consume(AS_TYPE);
|
||||
Consume(actasmtoken);
|
||||
if actasmtoken<>AS_ID then
|
||||
Message(asmr_e_type_without_identifier)
|
||||
else
|
||||
@ -1514,7 +1522,11 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.15 2004-11-29 18:50:15 peter
|
||||
Revision 1.16 2004-12-22 17:09:55 peter
|
||||
* support sizeof()
|
||||
* fix typecasting a constant like dword(4)
|
||||
|
||||
Revision 1.15 2004/11/29 18:50:15 peter
|
||||
* os2 fixes for import
|
||||
* asmsymtype support for intel reader
|
||||
|
||||
|
@ -427,7 +427,7 @@ begin
|
||||
Case Expr[I] OF
|
||||
'(' : OpPush('(',false);
|
||||
')' : begin
|
||||
While OpStack[OpTop].ch <> '(' DO
|
||||
While (OpTop>0) and (OpStack[OpTop].ch <> '(') DO
|
||||
Begin
|
||||
OpPop(opr);
|
||||
RPNCalc(opr.ch,opr.is_prefix);
|
||||
@ -1620,7 +1620,11 @@ end;
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.98 2004-12-12 10:50:34 florian
|
||||
Revision 1.99 2004-12-22 17:09:55 peter
|
||||
* support sizeof()
|
||||
* fix typecasting a constant like dword(4)
|
||||
|
||||
Revision 1.98 2004/12/12 10:50:34 florian
|
||||
* fixed operand size calculation for sse operands
|
||||
+ all nasm assembler targets to help page output added
|
||||
|
||||
|
@ -48,12 +48,12 @@ Implementation
|
||||
{ helpers }
|
||||
cutils,
|
||||
{ global }
|
||||
globtype,globals,verbose,
|
||||
globtype,verbose,
|
||||
systems,
|
||||
{ aasm }
|
||||
aasmbase,aasmtai,aasmcpu,
|
||||
{ symtable }
|
||||
symconst,symsym,
|
||||
symconst,
|
||||
{ parser }
|
||||
scanner,
|
||||
procinfo,
|
||||
@ -775,7 +775,11 @@ Implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.8 2004-11-21 15:35:23 peter
|
||||
Revision 1.9 2004-12-22 17:09:55 peter
|
||||
* support sizeof()
|
||||
* fix typecasting a constant like dword(4)
|
||||
|
||||
Revision 1.8 2004/11/21 15:35:23 peter
|
||||
* float routines all use internproc and compilerproc helpers
|
||||
|
||||
Revision 1.7 2004/11/08 22:09:59 peter
|
||||
|
Loading…
Reference in New Issue
Block a user