* support sizeof()

* fix typecasting a constant like dword(4)
This commit is contained in:
peter 2004-12-22 17:09:55 +00:00
parent 71073744e4
commit 1da9e24cee
4 changed files with 48 additions and 23 deletions

View File

@ -44,7 +44,7 @@ Unit Ra386int;
AS_ALIGN,AS_DB,AS_DW,AS_DD,AS_END, AS_ALIGN,AS_DB,AS_DW,AS_DD,AS_END,
{------------------ Assembler Operators --------------------} {------------------ Assembler Operators --------------------}
AS_BYTE,AS_WORD,AS_DWORD,AS_QWORD,AS_TBYTE,AS_DQWORD,AS_NEAR,AS_FAR, 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); AS_AND,AS_OR,AS_XOR);
type type
@ -70,7 +70,7 @@ Unit Ra386int;
procedure BuildOperand(oper: tx86operand); procedure BuildOperand(oper: tx86operand);
procedure BuildConstantOperand(oper: tx86operand); procedure BuildConstantOperand(oper: tx86operand);
procedure BuildOpCode(instr : tx86instruction); procedure BuildOpCode(instr : tx86instruction);
procedure BuildConstant(constsize: longint); procedure BuildConstant(constsize: byte);
end; end;
@ -116,7 +116,7 @@ Unit Ra386int;
{ context sensitive. } { context sensitive. }
_asmoperators : array[0.._count_asmoperators] of tasmkeyword = ( _asmoperators : array[0.._count_asmoperators] of tasmkeyword = (
'BYTE','WORD','DWORD','QWORD','TBYTE','DQWORD','NEAR','FAR','HIGH', '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'); 'OR','XOR');
token2str : array[tasmtoken] of string[10] = ( token2str : array[tasmtoken] of string[10] = (
@ -126,7 +126,7 @@ Unit Ra386int;
';','identifier','register','opcode','/', ';','identifier','register','opcode','/',
'','','','','END', '','','','','END',
'','','','','','','','','', '','','','','','','','','',
'','','','type','ptr','mod','shl','shr','not', '','','sizeof','','type','ptr','mod','shl','shr','not',
'and','or','xor' 'and','or','xor'
); );
@ -747,6 +747,9 @@ Unit Ra386int;
end; end;
AS_RPAREN: AS_RPAREN:
Begin Begin
{ Keep the AS_PAREN in actasmtoken, it is maybe a typecast }
if parenlevel=0 then
break;
Consume(AS_RPAREN); Consume(AS_RPAREN);
expr:=expr + ')'; expr:=expr + ')';
dec(parenlevel); dec(parenlevel);
@ -828,11 +831,12 @@ Unit Ra386int;
if actasmtoken<>AS_ID then if actasmtoken<>AS_ID then
Message(asmr_e_offset_without_identifier); Message(asmr_e_offset_without_identifier);
end; end;
AS_SIZEOF,
AS_TYPE: AS_TYPE:
begin begin
l:=0; l:=0;
hasparen:=false; hasparen:=false;
Consume(AS_TYPE); Consume(actasmtoken);
if actasmtoken=AS_LPAREN then if actasmtoken=AS_LPAREN then
begin begin
hasparen:=true; hasparen:=true;
@ -1509,13 +1513,10 @@ Unit Ra386int;
case actasmtoken of case actasmtoken of
AS_OFFSET, AS_OFFSET,
AS_SIZEOF,
AS_TYPE, AS_TYPE,
AS_NOT, AS_NOT,
AS_STRING : AS_STRING,
Begin
BuildConstantOperand(oper);
end;
AS_PLUS, AS_PLUS,
AS_MINUS, AS_MINUS,
AS_LPAREN, AS_LPAREN,
@ -1844,7 +1845,7 @@ Unit Ra386int;
end; end;
Procedure ti386intreader.BuildConstant(constsize: longint); Procedure ti386intreader.BuildConstant(constsize: byte);
var var
asmsymtyp : tasmsymtype; asmsymtyp : tasmsymtype;
asmsym, asmsym,
@ -2037,7 +2038,11 @@ begin
end. end.
{ {
$Log$ $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 * os2 fixes for import
* asmsymtype support for intel reader * asmsymtype support for intel reader

View File

@ -55,7 +55,7 @@ unit raatt;
AS_ASCIIZ,AS_LCOMM,AS_COMM,AS_SINGLE,AS_DOUBLE,AS_EXTENDED, AS_ASCIIZ,AS_LCOMM,AS_COMM,AS_SINGLE,AS_DOUBLE,AS_EXTENDED,
AS_DATA,AS_TEXT,AS_END, AS_DATA,AS_TEXT,AS_END,
{------------------ Assembler Operators --------------------} {------------------ 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); AS_LO,AS_HI);
tasmkeyword = string[10]; tasmkeyword = string[10];
@ -76,14 +76,14 @@ unit raatt;
'.align','.balign','.p2align','.ascii', '.align','.balign','.p2align','.ascii',
'.asciz','.lcomm','.comm','.single','.double','.tfloat', '.asciz','.lcomm','.comm','.single','.double','.tfloat',
'.data','.text','END', '.data','.text','END',
'TYPE','%','<<','>>','!','&','|','^','~','@','lo','hi'); 'TYPE','SIZEOF','%','<<','>>','!','&','|','^','~','@','lo','hi');
type type
tattreader = class(tasmreader) tattreader = class(tasmreader)
actasmtoken : tasmtoken; actasmtoken : tasmtoken;
prevasmtoken : tasmtoken; prevasmtoken : tasmtoken;
procedure SetupTables; procedure SetupTables;
procedure BuildConstant(constsize: longint); procedure BuildConstant(constsize: byte);
procedure BuildConstantOperand(oper : toperand); procedure BuildConstantOperand(oper : toperand);
procedure BuildRealConstant(typ : tfloattype); procedure BuildRealConstant(typ : tfloattype);
procedure BuildStringConstant(asciiz: boolean); procedure BuildStringConstant(asciiz: boolean);
@ -354,6 +354,11 @@ unit raatt;
actasmtoken:=AS_TYPE; actasmtoken:=AS_TYPE;
exit; exit;
end; end;
if actasmpattern = 'SIZEOF' then
Begin
actasmtoken:=AS_SIZEOF;
exit;
end;
if is_register(actasmpattern) then if is_register(actasmpattern) then
begin begin
actasmtoken:=AS_REGISTER; actasmtoken:=AS_REGISTER;
@ -756,7 +761,7 @@ unit raatt;
end; end;
Procedure tattreader.BuildConstant(constsize: longint); Procedure tattreader.BuildConstant(constsize: byte);
var var
asmsymtyp : TAsmSymType; asmsymtyp : TAsmSymType;
asmsym, asmsym,
@ -784,6 +789,8 @@ unit raatt;
AS_PLUS, AS_PLUS,
AS_MINUS, AS_MINUS,
AS_LPAREN, AS_LPAREN,
AS_TYPE,
AS_SIZEOF,
AS_NOT, AS_NOT,
AS_ID : AS_ID :
Begin Begin
@ -1319,10 +1326,11 @@ unit raatt;
expr:=expr + tempstr; expr:=expr + tempstr;
Consume(AS_STRING); Consume(AS_STRING);
end; end;
AS_SIZEOF,
AS_TYPE: AS_TYPE:
begin begin
l:=0; l:=0;
Consume(AS_TYPE); Consume(actasmtoken);
if actasmtoken<>AS_ID then if actasmtoken<>AS_ID then
Message(asmr_e_type_without_identifier) Message(asmr_e_type_without_identifier)
else else
@ -1514,7 +1522,11 @@ end.
{ {
$Log$ $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 * os2 fixes for import
* asmsymtype support for intel reader * asmsymtype support for intel reader

View File

@ -427,7 +427,7 @@ begin
Case Expr[I] OF Case Expr[I] OF
'(' : OpPush('(',false); '(' : OpPush('(',false);
')' : begin ')' : begin
While OpStack[OpTop].ch <> '(' DO While (OpTop>0) and (OpStack[OpTop].ch <> '(') DO
Begin Begin
OpPop(opr); OpPop(opr);
RPNCalc(opr.ch,opr.is_prefix); RPNCalc(opr.ch,opr.is_prefix);
@ -1620,7 +1620,11 @@ end;
end. end.
{ {
$Log$ $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 * fixed operand size calculation for sse operands
+ all nasm assembler targets to help page output added + all nasm assembler targets to help page output added

View File

@ -48,12 +48,12 @@ Implementation
{ helpers } { helpers }
cutils, cutils,
{ global } { global }
globtype,globals,verbose, globtype,verbose,
systems, systems,
{ aasm } { aasm }
aasmbase,aasmtai,aasmcpu, aasmbase,aasmtai,aasmcpu,
{ symtable } { symtable }
symconst,symsym, symconst,
{ parser } { parser }
scanner, scanner,
procinfo, procinfo,
@ -775,7 +775,11 @@ Implementation
end. end.
{ {
$Log$ $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 * float routines all use internproc and compilerproc helpers
Revision 1.7 2004/11/08 22:09:59 peter Revision 1.7 2004/11/08 22:09:59 peter