Ignore:
Timestamp:
Aug 1, 2024, 10:47:04 PM (3 months ago)
Author:
chronos
Message:
  • Added: Assembler to parse instructions from text string and produce binary code.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/bigint/FormMain.pas

    r3 r4  
    55uses
    66  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Machine, Int,
    7   Cpu;
     7  Cpu, Assembler;
    88
    99type
     
    4545procedure TFormMain.FormShow(Sender: TObject);
    4646var
    47   Label1: TInt;
     47  Assembler: TAssembler;
     48  Lines: TStringList;
    4849begin
    49   with Machine.Memory do begin
    50     WritePos(TInt(inLoadConst));
    51     WritePos(1000);
    52     WritePos(Ord('A'));
     50  Lines := TStringList.Create;
     51  Lines.LoadFromFile('Example.asm');
    5352
    54     WritePos(TInt(inLoadConst));
    55     WritePos(1001);
    56     WritePos(20);
     53  Assembler := TAssembler.Create;
     54  with Assembler do begin
     55    Compile(Lines.Text);
     56    Machine.Memory.CopyFrom(Memory, 0, 0, Memory.Size);
     57    Free;
     58  end;
    5759
    58     Label1 := Position;
     60  Lines.Free;
    5961
    60     WritePos(TInt(inOutput));
    61     WritePos(0);
    62     WritePos(1000);
    63 
    64     WritePos(TInt(inInc));
    65     WritePos(1000);
    66 
    67     WritePos(TInt(inDec));
    68     WritePos(1001);
    69 
    70     WritePos(TInt(inJumpNotZero));
    71     WritePos(1001);
    72     WritePos(Label1);
    73 
    74     WritePos(TInt(inHalt));
    75   end;
    7662  Machine.Run;
    7763end;
Note: See TracChangeset for help on using the changeset viewer.