Changeset 180 for branches


Ignore:
Timestamp:
Apr 12, 2019, 10:48:02 PM (6 years ago)
Author:
chronos
Message:
  • Modified: Memory dump, CPU state, screen, console moved to separate forms.
  • Added: Dissasembler form.
Location:
branches/virtualcpu4
Files:
14 added
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • branches/virtualcpu4/UCpu.pas

    r178 r180  
    136136const
    137137  BitWidthBytes: array[TBitWidth] of Byte = (0, 1, 2, 4, 8);
     138  BitWidthText: array[TBitWidth] of string = ('None', '8-bit', '16-bit', '32-bit', '64-bit');
    138139
    139140implementation
  • branches/virtualcpu4/UInstructionWriter.pas

    r179 r180  
    11unit UInstructionWriter;
    22
    3 {$mode objfpc}{$H+}
     3{$mode delphi}{$H+}
    44
    55interface
    66
    77uses
    8   Classes, SysUtils, UCpu;
     8  Classes, SysUtils, UCpu, UMemory, fgl;
    99
    1010type
     
    7272  end;
    7373
     74  TDisassemblerLine = class
     75    Address: Integer;
     76    Opcode: string;
     77    Instruction: string;
     78  end;
     79
     80  { TDisassembler }
     81
    7482  TDisassembler = class
    75 
     83    Memory: TMemoryPos;
     84    Output: TFPGObjectList<TDisassemblerLine>;
     85    procedure Process;
     86    constructor Create;
     87    destructor Destroy; override;
    7688  end;
    7789
     
    8597implementation
    8698
     99{ TDisassembler }
     100
     101procedure TDisassembler.Process;
     102var
     103  Opcode: Byte;
     104  Line: TDisassemblerLine;
     105begin
     106  Output.Clear;
     107  Memory.Position := Memory.Data;
     108
     109  while Memory.Position < Memory.Data + Memory.Size do begin
     110    Opcode := Memory.ReadByte;
     111    if Opcode < Integer(High(TOpcode)) then begin
     112      Line := TDisassemblerLine.Create;
     113      Line.Address := Memory.Position - Memory.Data;
     114      Line.Opcode := IntToHex(Opcode, 2);
     115      Line.Instruction := OpcodeName[TOpcode(Opcode)];
     116      Output.Add(Line);
     117    end;
     118  end;
     119end;
     120
     121constructor TDisassembler.Create;
     122begin
     123  Output := TFPGObjectList<TDisassemblerLine>.Create;
     124  Memory := TMemoryPos.Create;
     125end;
     126
     127destructor TDisassembler.Destroy;
     128begin
     129  Memory.Free;
     130  Output.Free;
     131  inherited Destroy;
     132end;
     133
    87134{ TAssembler }
    88135
  • branches/virtualcpu4/virtucpu4.lpi

    r174 r180  
    2727          <SearchPaths>
    2828            <IncludeFiles Value="$(ProjOutDir)"/>
     29            <OtherUnitFiles Value="Forms"/>
    2930            <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    3031          </SearchPaths>
     
    7071      </Item1>
    7172    </RequiredPackages>
    72     <Units Count="5">
     73    <Units Count="11">
    7374      <Unit0>
    7475        <Filename Value="virtucpu4.lpr"/>
     
    7677      </Unit0>
    7778      <Unit1>
    78         <Filename Value="UFormMain.pas"/>
     79        <Filename Value="Forms\UFormMain.pas"/>
    7980        <IsPartOfProject Value="True"/>
    8081        <ComponentName Value="FormMain"/>
     
    9495        <IsPartOfProject Value="True"/>
    9596      </Unit4>
     97      <Unit5>
     98        <Filename Value="UMemory.pas"/>
     99        <IsPartOfProject Value="True"/>
     100      </Unit5>
     101      <Unit6>
     102        <Filename Value="Forms\UFormDisassembler.pas"/>
     103        <IsPartOfProject Value="True"/>
     104        <ComponentName Value="FormDisassembler"/>
     105        <ResourceBaseClass Value="Form"/>
     106      </Unit6>
     107      <Unit7>
     108        <Filename Value="Forms\UFormMemory.pas"/>
     109        <IsPartOfProject Value="True"/>
     110        <ComponentName Value="FormMemory"/>
     111        <ResourceBaseClass Value="Form"/>
     112      </Unit7>
     113      <Unit8>
     114        <Filename Value="Forms\UFormCpuState.pas"/>
     115        <IsPartOfProject Value="True"/>
     116        <ComponentName Value="FormCpuState"/>
     117        <ResourceBaseClass Value="Form"/>
     118      </Unit8>
     119      <Unit9>
     120        <Filename Value="Forms\UFormScreen.pas"/>
     121        <IsPartOfProject Value="True"/>
     122        <ComponentName Value="FormScreen"/>
     123        <ResourceBaseClass Value="Form"/>
     124      </Unit9>
     125      <Unit10>
     126        <Filename Value="Forms\UFormConsole.pas"/>
     127        <IsPartOfProject Value="True"/>
     128        <ComponentName Value="FormConsole"/>
     129        <ResourceBaseClass Value="Form"/>
     130      </Unit10>
    96131    </Units>
    97132  </ProjectOptions>
     
    104139    <SearchPaths>
    105140      <IncludeFiles Value="$(ProjOutDir)"/>
     141      <OtherUnitFiles Value="Forms"/>
    106142      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    107143    </SearchPaths>
  • branches/virtualcpu4/virtucpu4.lpr

    r176 r180  
    88  {$ENDIF}
    99  Interfaces, // this includes the LCL widgetset
    10   SysUtils, Forms, UFormMain, UCpu, UMachine
     10  SysUtils, Forms, UFormMain, UCpu, UMachine, UMemory, UFormDisassembler,
     11  UFormMemory, UFormCpuState, UFormScreen, UFormConsole
    1112  { you can add units after this };
    1213
Note: See TracChangeset for help on using the changeset viewer.