Ignore:
Timestamp:
Sep 8, 2009, 2:01:55 PM (15 years ago)
Author:
george
Message:
  • Přidáno: Analýza páru dalších programových konstrukcí.
  • Přidáno: Pár jednoduchých testovacích příkladů pro překladač.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DelphiToC/UAssemblerSource.pas

    r14 r20  
    2828    procedure AddInstruction(LabelName, Instruction, Operand1,
    2929      Operand2: string);
    30     procedure GenerateCommonBlock(CommonBlock: TCommonBlock; LabelPrefix: string);
     30//    procedure GenerateCommonBlock(CommonBlock: TCommonBlock; LabelPrefix: string);
    3131    procedure GenerateExpression(Expression: TExpression; LabelPrefix: string);
    3232    procedure GenerateProgram(ProgramBlock: TProgram);
     
    114114end;
    115115
    116 procedure TAssemblerProducer.GenerateCommonBlock(CommonBlock: TCommonBlock; LabelPrefix: string);
    117 var
    118   I: Integer;
    119   LabelName: string;
    120 begin
    121   with CommonBlock do
    122   for I := 0 to Operations.Count - 1 do
    123   with TOperation(Operations[I]) do begin
    124     if Referenced then LabelName := Name + '_L' + IntToStr(I)
    125       else LabelName := '';
    126     case Instruction of
    127       inJump: begin
    128         AddInstruction(LabelName, 'JMP', Name + '_L' + IntToStr(GotoAddress), '');
     116(*
     117  procedure TAssemblerProducer.GenerateCommonBlock(CommonBlock: TCommonBlock; LabelPrefix: string);
     118  var
     119    I: Integer;
     120    LabelName: string;
     121  begin
     122    with CommonBlock do
     123    for I := 0 to Operations.Count - 1 do
     124    with TOperation(Operations[I]) do begin
     125      if Referenced then LabelName := Name + '_L' + IntToStr(I)
     126        else LabelName := '';
     127      case Instruction of
     128        inJump: begin
     129          AddInstruction(LabelName, 'JMP', Name + '_L' + IntToStr(GotoAddress), '');
     130        end;
     131        inConditionalJump: begin
     132          GenerateExpression(ExpressionTree, LabelPrefix + '_L' + IntToStr(GotoAddress));
     133          AddInstruction(LabelName, 'BRCS', Name + '_L' + IntToStr(GotoAddress), '');
     134        end;
     135        inExpressionEvaluation: begin
     136          if LabelName <> '' then AddInstruction(LabelName, '', '', '');
     137          GenerateExpression(ExpressionTree, Name + '_L' + IntToStr(GotoAddress));
     138        end;
     139        inReturn:
     140          AddInstruction(LabelName, 'RET', '', '');
    129141      end;
    130       inConditionalJump: begin
    131         GenerateExpression(ExpressionTree, LabelPrefix + '_L' + IntToStr(GotoAddress));
    132         AddInstruction(LabelName, 'BRCS', Name + '_L' + IntToStr(GotoAddress), '');
    133       end;
    134       inExpressionEvaluation: begin
    135         if LabelName <> '' then AddInstruction(LabelName, '', '', '');
    136         GenerateExpression(ExpressionTree, Name + '_L' + IntToStr(GotoAddress));
    137       end;
    138       inReturn:
    139         AddInstruction(LabelName, 'RET', '', '');
    140142    end;
    141143  end;
    142 end;
     144*)
    143145
    144146procedure TAssemblerProducer.GenerateExpression(Expression: TExpression; LabelPrefix: string);
     
    180182  I: Integer;
    181183begin
    182   with ProgramBlock do
    183   for I := 0 to Modules.Count - 1 do
    184     GenerateCommonBlock(TModule(Modules[I]), '');
     184//  with ProgramBlock do
     185//  for I := 0 to Modules.Count - 1 do
     186//    GenerateCommonBlock(TModule(Modules[I]), '');
    185187end;
    186188
Note: See TracChangeset for help on using the changeset viewer.