Changeset 180 for branches/virtualcpu4/UInstructionWriter.pas
- Timestamp:
- Apr 12, 2019, 10:48:02 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/virtualcpu4/UInstructionWriter.pas
r179 r180 1 1 unit UInstructionWriter; 2 2 3 {$mode objfpc}{$H+}3 {$mode delphi}{$H+} 4 4 5 5 interface 6 6 7 7 uses 8 Classes, SysUtils, UCpu ;8 Classes, SysUtils, UCpu, UMemory, fgl; 9 9 10 10 type … … 72 72 end; 73 73 74 TDisassemblerLine = class 75 Address: Integer; 76 Opcode: string; 77 Instruction: string; 78 end; 79 80 { TDisassembler } 81 74 82 TDisassembler = class 75 83 Memory: TMemoryPos; 84 Output: TFPGObjectList<TDisassemblerLine>; 85 procedure Process; 86 constructor Create; 87 destructor Destroy; override; 76 88 end; 77 89 … … 85 97 implementation 86 98 99 { TDisassembler } 100 101 procedure TDisassembler.Process; 102 var 103 Opcode: Byte; 104 Line: TDisassemblerLine; 105 begin 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; 119 end; 120 121 constructor TDisassembler.Create; 122 begin 123 Output := TFPGObjectList<TDisassemblerLine>.Create; 124 Memory := TMemoryPos.Create; 125 end; 126 127 destructor TDisassembler.Destroy; 128 begin 129 Memory.Free; 130 Output.Free; 131 inherited Destroy; 132 end; 133 87 134 { TAssembler } 88 135
Note:
See TracChangeset
for help on using the changeset viewer.