+ rec.field(%esi) support

+ [esi+rec.field] support
This commit is contained in:
peter 1998-12-23 22:55:55 +00:00
parent f986459350
commit ce3e2aec84
3 changed files with 762 additions and 769 deletions

View File

@ -228,6 +228,8 @@ Type
Procedure OpPop(var _Operator:TExprOperator); Procedure OpPop(var _Operator:TExprOperator);
end; end;
{ Evaluate an expression string to a longint }
Function CalculateExpression(const expression: string): longint;
{---------------------------------------------------------------------} {---------------------------------------------------------------------}
{ String routines } { String routines }
@ -546,6 +548,15 @@ Begin
end; end;
Function CalculateExpression(const expression: string): longint;
var
expr: TExprParse;
Begin
expr.Init;
CalculateExpression := expr.Evaluate(expression);
expr.Done;
end;
{*************************************************************************} {*************************************************************************}
{ String conversions/utils } { String conversions/utils }
{*************************************************************************} {*************************************************************************}
@ -657,6 +668,7 @@ end;
'7': vs:=vs shl 3+7; '7': vs:=vs shl 3+7;
else else
begin begin
Message(assem_f_error_converting_octal);
OctalToDec := ''; OctalToDec := '';
exit; exit;
end; end;
@ -683,6 +695,7 @@ end;
vs:=vs shl 1+1 vs:=vs shl 1+1
else else
begin begin
Message(assem_f_error_converting_bin);
BinaryToDec := ''; BinaryToDec := '';
exit; exit;
end; end;
@ -719,6 +732,7 @@ end;
'F': vs:=vs shl 4+15; 'F': vs:=vs shl 4+15;
else else
begin begin
Message(assem_f_error_converting_hex);
HexToDec := ''; HexToDec := '';
exit; exit;
end; end;
@ -1788,7 +1802,11 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.16 1998-12-11 00:02:44 peter Revision 1.17 1998-12-23 22:55:55 peter
+ rec.field(%esi) support
+ [esi+rec.field] support
Revision 1.16 1998/12/11 00:02:44 peter
+ globtype,tokens,version unit splitted from globals + globtype,tokens,version unit splitted from globals
Revision 1.15 1998/11/17 00:26:11 peter Revision 1.15 1998/11/17 00:26:11 peter

View File

@ -2426,17 +2426,6 @@ const
Function CalculateExpression(expression: string): longint;
var
expr: TExprParse;
Begin
expr.Init;
CalculateExpression := expr.Evaluate(expression);
expr.Done;
end;
Procedure GetRecordOffsetSize(const expr: string;var offset:longint;var size:longint); Procedure GetRecordOffsetSize(const expr: string;var offset:longint;var size:longint);
{*********************************************************************} {*********************************************************************}
{ PROCEDURE GetRecordOffsetSize } { PROCEDURE GetRecordOffsetSize }
@ -2445,7 +2434,7 @@ const
{ On entry actasmtoken should be equal to AS_DOT } { On entry actasmtoken should be equal to AS_DOT }
{*********************************************************************} {*********************************************************************}
{ EXIT CONDITION: On exit the routine should point to either the } { EXIT CONDITION: On exit the routine should point to either the }
{ AS_COMMA or AS_SEPARATOR token. } { ERROR RECOVER: read until AS_COMMA or AS_SEPARATOR token. }
{ Warning: This is called recursively. } { Warning: This is called recursively. }
{*********************************************************************} {*********************************************************************}
var var
@ -2466,24 +2455,12 @@ const
inc(offset,toffset); inc(offset,toffset);
size:=tsize; size:=tsize;
Consume(AS_ID); Consume(AS_ID);
case actasmtoken of if actasmtoken=AS_DOT then
AS_SEPARATOR, begin
AS_COMMA : exit;
AS_DOT : begin
GetRecordOffsetSize(expr,toffset,tsize); GetRecordOffsetSize(expr,toffset,tsize);
inc(offset,toffset); inc(offset,toffset);
size:=tsize; size:=tsize;
end; end;
else
Begin
Message(assem_e_syntax_error);
repeat
consume(actasmtoken)
until (actasmtoken = AS_SEPARATOR) or (actasmtoken = AS_COMMA);
exit;
end;
end;
end end
else else
Begin Begin
@ -2797,7 +2774,7 @@ const
Consume(AS_RPAREN) Consume(AS_RPAREN)
else else
Message(assem_e_invalid_scaling_value); Message(assem_e_invalid_scaling_value);
{ // .Field.Field ... or separator/comma // } { .Field.Field ... or separator/comma }
if actasmtoken in [AS_COMMA,AS_SEPARATOR] then if actasmtoken in [AS_COMMA,AS_SEPARATOR] then
Begin Begin
end end
@ -3031,7 +3008,7 @@ const
End; End;
exit; exit;
End; End;
{ // (reg ... // } { (reg ... }
AS_REGISTER: Begin AS_REGISTER: Begin
{ Check if there is already a base (mostly ebp,esp) than this is { Check if there is already a base (mostly ebp,esp) than this is
not allowed,becuase it will give crashing code } not allowed,becuase it will give crashing code }
@ -3040,7 +3017,7 @@ const
instr.operands[operandnum].ref.base := findregister(actasmpattern); instr.operands[operandnum].ref.base := findregister(actasmpattern);
Consume(AS_REGISTER); Consume(AS_REGISTER);
{ can either be a register or a right parenthesis } { can either be a register or a right parenthesis }
{ // (reg) // } { (reg) }
if actasmtoken=AS_RPAREN then Begin if actasmtoken=AS_RPAREN then Begin
Consume(AS_RPAREN); Consume(AS_RPAREN);
if not (actasmtoken in [AS_COMMA, if not (actasmtoken in [AS_COMMA,
@ -3053,7 +3030,7 @@ const
end; end;
exit; exit;
end; end;
{ // (reg,reg .. // } { (reg,reg .. }
{ we need a comman here !! } { we need a comman here !! }
{ oops.. } { oops.. }
Consume(AS_COMMA); Consume(AS_COMMA);
@ -3098,7 +3075,7 @@ const
end; end;
end; {end case } end; {end case }
end; end;
{ // (, ... // } { (, ... }
AS_COMMA: { can either be scaling, or index } AS_COMMA: { can either be scaling, or index }
Begin Begin
Consume(AS_COMMA); Consume(AS_COMMA);
@ -3213,20 +3190,20 @@ const
expr: string; expr: string;
lab: Pasmlabel; lab: Pasmlabel;
hl: plabel; hl: plabel;
tsize, tsize,l,
toffset : longint; toffset : longint;
Begin Begin
tempstr := ''; tempstr := '';
expr := ''; expr := '';
case actasmtoken of case actasmtoken of
{ // Memory reference // } AS_LPAREN: { Memory reference }
AS_LPAREN:
Begin Begin
initAsmRef(instr); initAsmRef(instr);
BuildReference(instr); BuildReference(instr);
end; end;
{ // Constant expression // }
AS_DOLLAR: Begin AS_DOLLAR: { Constant expression }
Begin
Consume(AS_DOLLAR); Consume(AS_DOLLAR);
if not (instr.operands[operandnum].operandtype in [OPR_NONE,OPR_CONSTANT]) then if not (instr.operands[operandnum].operandtype in [OPR_NONE,OPR_CONSTANT]) then
Message(assem_e_invalid_operand_type); Message(assem_e_invalid_operand_type);
@ -3234,30 +3211,28 @@ const
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 memory offset . // }
{ // This must absolutely be followed by ( // }
AS_HEXNUM,AS_INTNUM,AS_MINUS, AS_HEXNUM,AS_INTNUM,AS_MINUS,
AS_BINNUM,AS_OCTALNUM,AS_PLUS: AS_BINNUM,AS_OCTALNUM,AS_PLUS:
Begin Begin
{ Constant memory offset }
{ This must absolutely be followed by ( }
InitAsmRef(instr); InitAsmRef(instr);
instr.operands[operandnum].ref.offset:=BuildRefExpression(False); instr.operands[operandnum].ref.offset:=BuildRefExpression(False);
BuildReference(instr); BuildReference(instr);
end; end;
{ // Call from memory address // } AS_STAR: { Call from memory address }
AS_STAR: Begin Begin
Consume(AS_STAR); Consume(AS_STAR);
InitAsmRef(instr); InitAsmRef(instr);
if not CreateVarInstr(instr,actasmpattern,operandnum) then if not CreateVarInstr(instr,actasmpattern,operandnum) then
Message(assem_e_syn_opcode_operand); Message(assem_e_syn_opcode_operand);
end; end;
{ // A constant expression, or a Variable ref. // } AS_ID: { A constant expression, or a Variable ref. }
AS_ID: Begin Begin
{ // Local label. // } { Local label ? }
if (actasmpattern[1] ='.') and (actasmpattern[2] = 'L') then if (actasmpattern[1] ='.') and (actasmpattern[2] = 'L') then
Begin Begin
Begin delete(actasmpattern,1,2);
delete(actasmpattern,1,1);
delete(actasmpattern,1,1);
if actasmpattern = '' then if actasmpattern = '' then
Message(assem_e_null_label_ref_not_allowed); Message(assem_e_null_label_ref_not_allowed);
lab := labellist.search(actasmpattern); lab := labellist.search(actasmpattern);
@ -3274,26 +3249,25 @@ const
end; end;
end end
else else
Begin
{ the label does not exist, create it } { the label does not exist, create it }
{ emit the opcode, but set that the } { emit the opcode, but set that the }
{ label has not been emitted } { label has not been emitted }
Begin
getlabel(hl); getlabel(hl);
labellist.insert(actasmpattern,hl,FALSE); labellist.insert(actasmpattern,hl,FALSE);
instr.operands[operandnum].operandtype := OPR_LABINSTR; instr.operands[operandnum].operandtype := OPR_LABINSTR;
instr.operands[operandnum].hl := hl; instr.operands[operandnum].hl := hl;
instr.labeled := TRUE; instr.labeled := TRUE;
end; end;
end;
Consume(AS_ID); Consume(AS_ID);
if not (actasmtoken in [AS_SEPARATOR,AS_COMMA]) then if not (actasmtoken in [AS_SEPARATOR,AS_COMMA]) then
Begin Begin
Message(assem_e_syntax_error); Message(assem_e_syntax_error);
end; end;
end end
else
{ probably a variable or normal expression } { probably a variable or normal expression }
{ or a procedure (such as in CALL ID) } { or a procedure (such as in CALL ID) }
else
Begin Begin
{ 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. }
@ -3323,10 +3297,8 @@ const
if assigned(procinfo._class) then if assigned(procinfo._class) then
Begin Begin
instr.operands[operandnum].operandtype := OPR_REFERENCE; instr.operands[operandnum].operandtype := OPR_REFERENCE;
instr.operands[operandnum].ref.offset := instr.operands[operandnum].ref.offset := procinfo.ESI_offset;
procinfo.ESI_offset; instr.operands[operandnum].ref.base := procinfo.framepointer;
instr.operands[operandnum].ref.base :=
procinfo.framepointer;
end end
else else
Message(assem_e_cannot_use___SELF_outside_methode); Message(assem_e_cannot_use___SELF_outside_methode);
@ -3337,14 +3309,12 @@ const
if lexlevel>normal_function_level then if lexlevel>normal_function_level then
Begin Begin
instr.operands[operandnum].operandtype := OPR_REFERENCE; instr.operands[operandnum].operandtype := OPR_REFERENCE;
instr.operands[operandnum].ref.offset := instr.operands[operandnum].ref.offset := procinfo.framepointer_offset;
procinfo.framepointer_offset; instr.operands[operandnum].ref.base := procinfo.framepointer;
instr.operands[operandnum].ref.base :=
procinfo.framepointer;
end end
else else
Message(assem_e_cannot_use___OLDEBP_outside_nested_procedure); Message(assem_e_cannot_use___OLDEBP_outside_nested_procedure);
end { endif actasmpattern = '__OLDEBP' } end
else else
{ check for direct symbolic names } { check for direct symbolic names }
{ only if compiling the system unit } { only if compiling the system unit }
@ -3362,23 +3332,32 @@ const
end; end;
{ constant expression? } { constant expression? }
if (instr.operands[operandnum].operandtype=OPR_CONSTANT) then if (instr.operands[operandnum].operandtype=OPR_CONSTANT) then
instr.operands[operandnum].val := BuildExpression begin
instr.operands[operandnum].val := BuildRefExpression(false);
previous_was_id:=FALSE;
{ indexing? }
if actasmtoken=AS_LPAREN then
begin
l:=instr.operands[operandnum].val;
instr.operands[operandnum].operandtype:=OPR_REFERENCE;
reset_reference(Instr.Operands[OperandNum].Ref);
Instr.Operands[OperandNum].Ref.Offset:=l;
BuildReference(instr);
end;
end
else else
begin begin
expr := actasmpattern; expr := actasmpattern;
Consume(AS_ID); Consume(AS_ID);
case actasmtoken of case actasmtoken of
AS_LPAREN: Begin AS_DOT:
{ indexing } Begin
previous_was_id:=FALSE;
BuildReference(instr);
end;
AS_DOT : Begin
GetRecordOffsetSize(expr,toffset,tsize); GetRecordOffsetSize(expr,toffset,tsize);
inc(instr.operands[operandnum].ref.offset,toffset); inc(instr.operands[operandnum].ref.offset,toffset);
SetOperandSize(instr,operandnum,tsize); SetOperandSize(instr,operandnum,tsize);
end; end;
AS_SEPARATOR,AS_COMMA: ; AS_SEPARATOR,
AS_COMMA: ;
else else
Message(assem_e_syntax_error); Message(assem_e_syntax_error);
end; { end case } end; { end case }
@ -3387,9 +3366,9 @@ const
previous_was_id := FALSE; previous_was_id := FALSE;
end; { end if } end; { end if }
end; { end if } end; { end if }
end; { end this case } end;
{ // Register, a variable reference or a constant reference // } AS_REGISTER: { Register, a variable reference or a constant reference }
AS_REGISTER: Begin Begin
{ save the type of register used. } { save the type of register used. }
tempstr := actasmpattern; tempstr := actasmpattern;
Consume(AS_REGISTER); Consume(AS_REGISTER);
@ -3401,12 +3380,12 @@ const
{ here we can have either an identifier } { here we can have either an identifier }
{ or a constant, where either can be } { or a constant, where either can be }
{ followed by a parenthesis... } { followed by a parenthesis... }
{ // Constant memory offset . // } { Constant memory offset . }
{ // This must absolutely be followed by ( // } { This must absolutely be followed by ( }
case actasmtoken of case actasmtoken of
AS_HEXNUM,AS_INTNUM,AS_MINUS, AS_HEXNUM,AS_INTNUM,AS_MINUS,
AS_BINNUM,AS_OCTALNUM,AS_PLUS AS_BINNUM,AS_OCTALNUM,AS_PLUS:
: Begin Begin
instr.operands[operandnum]. instr.operands[operandnum].
ref.offset:=BuildRefExpression(False); ref.offset:=BuildRefExpression(False);
BuildReference(instr); BuildReference(instr);
@ -3446,7 +3425,7 @@ const
end; end;
end; { end case } end; { end case }
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
@ -3457,7 +3436,8 @@ const
else else
Message1(assem_e_syn_register,tempstr); Message1(assem_e_syn_register,tempstr);
end; end;
AS_SEPARATOR, AS_COMMA: ; AS_SEPARATOR,
AS_COMMA: ;
else else
Begin Begin
Message(assem_e_syn_opcode_operand); Message(assem_e_syn_opcode_operand);
@ -3599,8 +3579,8 @@ const
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 }
@ -3608,7 +3588,7 @@ const
instr.addprefix(asmtok); instr.addprefix(asmtok);
Consume(AS_OPCODE); Consume(AS_OPCODE);
end; end;
{ // opcode // } { opcode }
{ allow for newline as in gas styled syntax } { allow for newline as in gas styled syntax }
{ under DOS you get two AS_SEPARATOR !! } { under DOS you get two AS_SEPARATOR !! }
while actasmtoken=AS_SEPARATOR do while actasmtoken=AS_SEPARATOR do
@ -3625,11 +3605,11 @@ const
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);
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
exit exit
else else
@ -3638,7 +3618,7 @@ const
repeat repeat
case actasmtoken of case actasmtoken of
{ // Operand delimiter // } { Operand delimiter }
AS_COMMA: Begin AS_COMMA: Begin
if operandnum > MaxOperands then if operandnum > MaxOperands then
Message(assem_e_too_many_operands) Message(assem_e_too_many_operands)
@ -3646,7 +3626,7 @@ const
Inc(operandnum); Inc(operandnum);
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; AS_END : break;
else else
@ -3969,7 +3949,11 @@ end.
{ {
$Log$ $Log$
Revision 1.26 1998-12-11 00:03:42 peter Revision 1.27 1998-12-23 22:55:56 peter
+ rec.field(%esi) support
+ [esi+rec.field] support
Revision 1.26 1998/12/11 00:03:42 peter
+ globtype,tokens,version unit splitted from globals + globtype,tokens,version unit splitted from globals
Revision 1.25 1998/12/09 13:23:40 jonas Revision 1.25 1998/12/09 13:23:40 jonas

View File

@ -2006,18 +2006,6 @@ var
Function CalculateExpression(expression: string): longint;
var
expr: TExprParse;
Begin
expr.Init;
CalculateExpression := expr.Evaluate(expression);
expr.Done;
end;
Procedure GetRecordOffsetSize(const expr: string;var offset:longint;var size:longint); Procedure GetRecordOffsetSize(const expr: string;var offset:longint;var size:longint);
{*********************************************************************} {*********************************************************************}
{ PROCEDURE GetRecordOffsetSize } { PROCEDURE GetRecordOffsetSize }
@ -2026,7 +2014,7 @@ var
{ On entry actasmtoken should be equal to AS_DOT } { On entry actasmtoken should be equal to AS_DOT }
{*********************************************************************} {*********************************************************************}
{ EXIT CONDITION: On exit the routine should point to either the } { EXIT CONDITION: On exit the routine should point to either the }
{ AS_COMMA or AS_SEPARATOR token. } { ERROR RECOVER: read until AS_COMMA or AS_SEPARATOR token. }
{ Warning: This is called recursively. } { Warning: This is called recursively. }
{*********************************************************************} {*********************************************************************}
var var
@ -2047,24 +2035,12 @@ var
inc(offset,toffset); inc(offset,toffset);
size:=tsize; size:=tsize;
Consume(AS_ID); Consume(AS_ID);
case actasmtoken of if actasmtoken=AS_DOT then
AS_SEPARATOR, begin
AS_COMMA : exit;
AS_DOT : begin
GetRecordOffsetSize(expr,toffset,tsize); GetRecordOffsetSize(expr,toffset,tsize);
inc(offset,toffset); inc(offset,toffset);
size:=tsize; size:=tsize;
end; end;
else
Begin
Message(assem_e_syntax_error);
repeat
consume(actasmtoken)
until (actasmtoken = AS_SEPARATOR) or (actasmtoken = AS_COMMA);
exit;
end;
end;
end end
else else
Begin Begin
@ -2091,8 +2067,8 @@ var
{ ERROR RECOVERY: Tries to find COMMA or SEPARATOR token by consuming } { ERROR RECOVERY: Tries to find COMMA or SEPARATOR token by consuming }
{ invalid tokens. } { invalid tokens. }
{*********************************************************************} {*********************************************************************}
var tempstr: string; var
expr: string; tempstr,expr : string;
l,k : longint; l,k : longint;
errorflag : boolean; errorflag : boolean;
Begin Begin
@ -2104,68 +2080,90 @@ var
inexpression := TRUE; inexpression := TRUE;
Repeat Repeat
Case actasmtoken of Case actasmtoken of
AS_LPAREN: Begin AS_LPAREN:
Begin
Consume(AS_LPAREN); Consume(AS_LPAREN);
expr := expr + '('; expr := expr + '(';
end; end;
AS_RPAREN: Begin AS_RPAREN:
Begin
Consume(AS_RPAREN); Consume(AS_RPAREN);
expr := expr + ')'; expr := expr + ')';
end; end;
AS_SHL: Begin AS_SHL:
Begin
Consume(AS_SHL); Consume(AS_SHL);
expr := expr + '<'; expr := expr + '<';
end; end;
AS_SHR: Begin AS_SHR:
Begin
Consume(AS_SHR); Consume(AS_SHR);
expr := expr + '>'; expr := expr + '>';
end; end;
AS_SLASH: Begin AS_SLASH:
Begin
Consume(AS_SLASH); Consume(AS_SLASH);
expr := expr + '/'; expr := expr + '/';
end; end;
AS_MOD: Begin AS_MOD:
Begin
Consume(AS_MOD); Consume(AS_MOD);
expr := expr + '%'; expr := expr + '%';
end; end;
AS_STAR: Begin AS_STAR:
Begin
Consume(AS_STAR); Consume(AS_STAR);
expr := expr + '*'; expr := expr + '*';
end; end;
AS_PLUS: Begin AS_PLUS:
Begin
Consume(AS_PLUS); Consume(AS_PLUS);
expr := expr + '+'; expr := expr + '+';
end; end;
AS_MINUS: Begin AS_MINUS:
Begin
Consume(AS_MINUS); Consume(AS_MINUS);
expr := expr + '-'; expr := expr + '-';
end; end;
AS_AND: Begin AS_AND:
Begin
Consume(AS_AND); Consume(AS_AND);
expr := expr + '&'; expr := expr + '&';
end; end;
AS_NOT: Begin AS_NOT:
Begin
Consume(AS_NOT); Consume(AS_NOT);
expr := expr + '~'; expr := expr + '~';
end; end;
AS_XOR: Begin AS_XOR:
Begin
Consume(AS_XOR); Consume(AS_XOR);
expr := expr + '^'; expr := expr + '^';
end; end;
AS_OR: Begin AS_OR:
Begin
Consume(AS_OR); Consume(AS_OR);
expr := expr + '|'; expr := expr + '|';
end; end;
{ End of reference } AS_INTNUM:
AS_RBRACKET: Begin Begin
if not ErrorFlag then expr := expr + actasmpattern;
BuildRefExpression := CalculateExpression(expr) Consume(AS_INTNUM);
else end;
BuildRefExpression := 0; AS_BINNUM:
Consume(AS_RBRACKET); Begin
{ no longer in an expression } expr:=expr+BinaryToDec(actasmpattern);
inexpression := FALSE; Consume(AS_BINNUM);
exit; end;
AS_HEXNUM:
Begin
expr:=expr+HexToDec(actasmpattern);
Consume(AS_HEXNUM);
end;
AS_OCTALNUM:
Begin
expr:=expr+OctalToDec(actasmpattern);
Consume(AS_OCTALNUM);
end; end;
AS_ID: AS_ID:
Begin Begin
@ -2188,31 +2186,16 @@ var
Message1(assem_e_invalid_const_symbol,tempstr); Message1(assem_e_invalid_const_symbol,tempstr);
end; end;
end; end;
AS_INTNUM: Begin AS_RBRACKET: { End of reference }
expr := expr + actasmpattern; Begin
Consume(AS_INTNUM); if not ErrorFlag then
end; BuildRefExpression := CalculateExpression(expr)
AS_BINNUM: Begin else
tempstr := BinaryToDec(actasmpattern); BuildRefExpression := 0;
if tempstr = '' then Consume(AS_RBRACKET);
Message(assem_f_error_converting_bin); { no longer in an expression }
expr:=expr+tempstr; inexpression := FALSE;
Consume(AS_BINNUM); exit;
end;
AS_HEXNUM: Begin
tempstr := HexToDec(actasmpattern);
if tempstr = '' then
Message(assem_f_error_converting_hex);
expr:=expr+tempstr;
Consume(AS_HEXNUM);
end;
AS_OCTALNUM: Begin
tempstr := OctalToDec(actasmpattern);
if tempstr = '' then
Message(assem_f_error_converting_octal);
expr:=expr+tempstr;
Consume(AS_OCTALNUM);
end; end;
else else
Begin Begin
@ -2220,7 +2203,8 @@ var
if not errorflag then if not errorflag then
Message(assem_e_invalid_constant_expression); Message(assem_e_invalid_constant_expression);
BuildRefExpression := 0; BuildRefExpression := 0;
if actasmtoken in [AS_COMMA,AS_SEPARATOR] then exit; if actasmtoken in [AS_COMMA,AS_SEPARATOR] then
exit;
{ consume tokens until we find COMMA or SEPARATOR } { consume tokens until we find COMMA or SEPARATOR }
Consume(actasmtoken); Consume(actasmtoken);
errorflag := TRUE; errorflag := TRUE;
@ -2603,8 +2587,8 @@ var
Begin Begin
{ save the reg } { save the reg }
reg := actasmpattern; reg := actasmpattern;
{ is the syntax of the form: [REG:REG...] }
consume(AS_REGISTER); consume(AS_REGISTER);
{ is the syntax of the form: [REG:REG...] }
if actasmtoken = AS_COLON then if actasmtoken = AS_COLON then
begin begin
segreg := TRUE; segreg := TRUE;
@ -2614,24 +2598,20 @@ var
instr.operands[operandnum].ref.segment := findsegment(reg); instr.operands[operandnum].ref.segment := findsegment(reg);
{ Here we should process the syntax of the form } { Here we should process the syntax of the form }
{ [reg:reg...] } { [reg:reg...] }
{!!!!!!!!!!!!!!!!!!!!!!!! }
end end
{ This is probably of the following syntax: } else { SREG:[REG...] where SReg: is optional. }
{ SREG:[REG...] where SReg: is optional. }
{ Therefore we immediately say that reg }
{ is the base. }
else
Begin Begin
if instr.operands[operandnum].ref.base <> R_NO then if instr.operands[operandnum].ref.base <> R_NO then
Message(assem_e_defining_base_more_than_once); Message(assem_e_defining_base_more_than_once);
instr.operands[operandnum].ref.base := findregister(reg); instr.operands[operandnum].ref.base := findregister(reg);
end; end;
{ we process this type of syntax immediately... } { we process this type of syntax immediately... }
case actasmtoken of case actasmtoken of
{ SREG:[REG].Field.Field ... }
{ REG:[REG].Field.Field ... } { SREG:[REG].Field[REG].Field... }
{ REG:[REG].Field[REG].Field... } AS_RBRACKET:
AS_RBRACKET: Begin Begin
Consume(AS_RBRACKET); Consume(AS_RBRACKET);
{ check for record fields } { check for record fields }
if actasmtoken = AS_DOT then if actasmtoken = AS_DOT then
@ -2641,8 +2621,11 @@ var
else else
Message(assem_e_syn_reference); Message(assem_e_syn_reference);
end; end;
{ REG:[REG +/- ...].Field.Field ... }
AS_PLUS,AS_MINUS: Begin { SREG:[REG +/- ...].Field.Field ... }
AS_PLUS,
AS_MINUS:
Begin
if actasmtoken = AS_MINUS then if actasmtoken = AS_MINUS then
Begin Begin
expr := '-'; expr := '-';
@ -2664,40 +2647,42 @@ 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: { SREG:[REG+REG].Field.Field... }
Begin Begin
Consume(AS_RBRACKET); Consume(AS_RBRACKET);
Case actasmtoken of Case actasmtoken of
AS_DOT: BuildRecordOffset(instr,''); AS_DOT: BuildRecordOffset(instr,'');
AS_COMMA,AS_SEPARATOR: exit; AS_COMMA,
AS_SEPARATOR: exit;
else else
Message(assem_e_syntax_error); Message(assem_e_syntax_error);
end
end; end;
AS_PLUS,AS_MINUS: { REG:[REG+REG+/-expr... } end;
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);
instr.operands[operandnum].ref.offset := instr.operands[operandnum].ref.offset:=BuildRefExpression;
BuildRefExpression;
case actasmtoken of case actasmtoken of
AS_DOT: BuildRecordOffset(instr,''); AS_DOT: BuildRecordOffset(instr,'');
AS_COMMA,AS_SEPARATOR: ; AS_COMMA,
AS_SEPARATOR: ;
else else
Message(assem_e_syntax_error); Message(assem_e_syntax_error);
end; { end case }
end; end;
AS_STAR: Begin { REG:[REG+REG*SCALING...].Field.Field... } end;
AS_STAR: { REG:[REG+REG*SCALING...].Field.Field... }
begin
BuildScaling(instr); BuildScaling(instr);
end; end;
else else
Begin
Message(assem_e_syntax_error); Message(assem_e_syntax_error);
end;
end; { end case } end; { end case }
end end
else if actasmtoken = AS_STAR then else
{ REG:[REG*SCALING ... ] } { REG:[REG*(+/-)SCALING ... ] }
if actasmtoken = AS_STAR then
Begin Begin
BuildScaling(instr); BuildScaling(instr);
end end
@ -2709,14 +2694,16 @@ var
instr.operands[operandnum].ref.offset := BuildRefExpression; instr.operands[operandnum].ref.offset := BuildRefExpression;
case actasmtoken of case actasmtoken of
AS_DOT: BuildRecordOffset(instr,''); AS_DOT: BuildRecordOffset(instr,'');
AS_COMMA,AS_SEPARATOR: ; AS_COMMA,
AS_SEPARATOR: ;
else else
Message(assem_e_syntax_error); Message(assem_e_syntax_error);
end; { end case } end;
end; { end if } end; { end if }
end; { end this case } end; { end this case }
{ REG:[REG*scaling] ... }
AS_STAR: Begin AS_STAR: { REG:[REG*scaling] ... }
Begin
BuildScaling(instr); BuildScaling(instr);
end; end;
end; end;
@ -3517,7 +3504,11 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.18 1998-12-11 00:03:43 peter Revision 1.19 1998-12-23 22:55:57 peter
+ rec.field(%esi) support
+ [esi+rec.field] support
Revision 1.18 1998/12/11 00:03:43 peter
+ globtype,tokens,version unit splitted from globals + globtype,tokens,version unit splitted from globals
Revision 1.17 1998/12/08 23:03:46 jonas Revision 1.17 1998/12/08 23:03:46 jonas