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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.