Changeset 181 for branches/virtualcpu4
- Timestamp:
- Apr 13, 2019, 12:03:31 AM (6 years ago)
- Location:
- branches/virtualcpu4
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/virtualcpu4/Forms/UFormDisassembler.lfm
r180 r181 25 25 item 26 26 Caption = 'Opcode' 27 Width = 1 0027 Width = 150 28 28 end 29 29 item 30 30 Caption = 'Assembly' 31 Width = 4 9031 Width = 440 32 32 end> 33 33 OwnerData = True -
branches/virtualcpu4/Forms/UFormDisassembler.pas
r180 r181 7 7 uses 8 8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 U InstructionWriter;9 UDisassembler; 10 10 11 11 type -
branches/virtualcpu4/Forms/UFormMain.lfm
r180 r181 1 1 object FormMain: TFormMain 2 Left = 2883 Height = 9484 Top = 1965 Width = 17182 Left = 780 3 Height = 269 4 Top = 527 5 Width = 659 6 6 Caption = 'VirtCpu4' 7 ClientHeight = 9488 ClientWidth = 17187 ClientHeight = 269 8 ClientWidth = 659 9 9 DesignTimePPI = 144 10 10 OnCreate = FormCreate … … 13 13 LCLVersion = '2.0.0.4' 14 14 object ButtonStart: TButton 15 Left = 118115 Left = 229 16 16 Height = 37 17 Top = 1 017 Top = 17 18 18 Width = 113 19 19 Caption = 'Start' … … 23 23 end 24 24 object ButtonStop: TButton 25 Left = 118125 Left = 229 26 26 Height = 37 27 Top = 5827 Top = 65 28 28 Width = 113 29 29 Caption = 'Stop' … … 33 33 end 34 34 object ButtonDisassembler: TButton 35 Left = 132335 Left = 371 36 36 Height = 38 37 Top = 1 037 Top = 17 38 38 Width = 185 39 39 Caption = 'Disassembler' … … 42 42 end 43 43 object ButtonMemory: TButton 44 Left = 132344 Left = 371 45 45 Height = 38 46 Top = 5746 Top = 64 47 47 Width = 185 48 48 Caption = 'Memory' … … 51 51 end 52 52 object ButtonCpuState: TButton 53 Left = 132353 Left = 371 54 54 Height = 38 55 Top = 1 0455 Top = 111 56 56 Width = 185 57 57 Caption = 'CPU state' … … 60 60 end 61 61 object ButtonScreen: TButton 62 Left = 97662 Left = 24 63 63 Height = 38 64 Top = 964 Top = 16 65 65 Width = 185 66 66 Caption = 'Screen' … … 69 69 end 70 70 object ButtonConsole: TButton 71 Left = 97671 Left = 24 72 72 Height = 38 73 Top = 5773 Top = 64 74 74 Width = 185 75 75 Caption = 'Console' -
branches/virtualcpu4/Forms/UFormMain.pas
r180 r181 60 60 if not Assigned(FormDisassembler) then 61 61 FormDisassembler := TFormDisassembler.Create(Self); 62 FormDisassembler.Disassembler.Memory.Owner:= False; 63 FormDisassembler.Disassembler.Memory.Data := Machine.Memory; 62 FormDisassembler.Disassembler.Cpu := Machine.Cpu; 64 63 FormDisassembler.Disassembler.Process; 65 64 FormDisassembler.Show; … … 164 163 Decrement(R2); 165 164 Test(R2); 166 AddrPrefix8; Jump NotZero(LabelPrintLoop);165 AddrPrefix8; JumpRelNotZero(LabelPrintLoop); 167 166 Pop(R1); 168 167 Pop(R2); -
branches/virtualcpu4/UCpu.pas
r180 r181 134 134 end; 135 135 136 TOpcodeParam = (prNone, prReg, prData, prAddr, prAddrRel); 137 TOpcodeDef = record 138 Name: string; 139 Param1: TOpcodeParam; 140 Param2: TOpcodeParam; 141 Param3: TOpcodeParam; 142 end; 143 136 144 const 137 145 BitWidthBytes: array[TBitWidth] of Byte = (0, 1, 2, 4, 8); 138 146 BitWidthText: array[TBitWidth] of string = ('None', '8-bit', '16-bit', '32-bit', '64-bit'); 147 OpcodeDef: array[TOpcode] of TOpcodeDef = ( 148 (Name: 'NOP'; Param1: prNone; Param2: prNone; Param3: prNone), 149 (Name: 'HALT'; Param1: prNone; Param2: prNone; Param3: prNone), 150 (Name: 'LD'; Param1: prReg; Param2: prReg; Param3: prNone), 151 (Name: 'LDI'; Param1: prReg; Param2: prData; Param3: prNone), 152 (Name: 'JP'; Param1: prAddr; Param2: prNone; Param3: prNone), 153 (Name: 'JPZ'; Param1: prAddr; Param2: prNone; Param3: prNone), 154 (Name: 'JPNZ'; Param1: prAddr; Param2: prNone; Param3: prNone), 155 (Name: 'JR'; Param1: prAddrRel; Param2: prNone; Param3: prNone), 156 (Name: 'JRZ'; Param1: prAddrRel; Param2: prNone; Param3: prNone), 157 (Name: 'JRNZ'; Param1: prAddrRel; Param2: prNone; Param3: prNone), 158 (Name: 'NEG'; Param1: prReg; Param2: prNone; Param3: prNone), 159 (Name: 'CLR'; Param1: prReg; Param2: prNone; Param3: prNone), 160 (Name: 'LDM'; Param1: prReg; Param2: prReg; Param3: prNone), 161 (Name: 'STM'; Param1: prReg; Param2: prReg; Param3: prNone), 162 (Name: 'EX'; Param1: prReg; Param2: prReg; Param3: prNone), 163 (Name: 'PUSH'; Param1: prReg; Param2: prNone; Param3: prNone), 164 (Name: 'POP'; Param1: prReg; Param2: prNone; Param3: prNone), 165 (Name: 'CALL'; Param1: prAddr; Param2: prNone; Param3: prNone), 166 (Name: 'RET'; Param1: prNone; Param2: prNone; Param3: prNone), 167 (Name: 'ADD'; Param1: prReg; Param2: prReg; Param3: prNone), 168 (Name: 'ADDI'; Param1: prReg; Param2: prData; Param3: prNone), 169 (Name: 'SUB'; Param1: prReg; Param2: prReg; Param3: prNone), 170 (Name: 'SUBI'; Param1: prReg; Param2: prData; Param3: prNone), 171 (Name: 'INC'; Param1: prReg; Param2: prNone; Param3: prNone), 172 (Name: 'DEC'; Param1: prReg; Param2: prNone; Param3: prNone), 173 (Name: 'IN'; Param1: prReg; Param2: prAddr; Param3: prNone), 174 (Name: 'OUT'; Param1: prAddr; Param2: prReg; Param3: prNone), 175 (Name: 'SHL'; Param1: prReg; Param2: prReg; Param3: prNone), 176 (Name: 'SHR'; Param1: prReg; Param2: prReg; Param3: prNone), 177 (Name: 'DP8'; Param1: prNone; Param2: prNone; Param3: prNone), 178 (Name: 'DP16'; Param1: prNone; Param2: prNone; Param3: prNone), 179 (Name: 'DP32'; Param1: prNone; Param2: prNone; Param3: prNone), 180 (Name: 'DP64'; Param1: prNone; Param2: prNone; Param3: prNone), 181 (Name: 'DS'; Param1: prNone; Param2: prNone; Param3: prNone), 182 (Name: 'AS'; Param1: prNone; Param2: prNone; Param3: prNone), 183 (Name: 'TEST'; Param1: prReg; Param2: prNone; Param3: prNone), 184 (Name: 'AND'; Param1: prReg; Param2: prReg; Param3: prNone), 185 (Name: 'OR'; Param1: prReg; Param2: prReg; Param3: prNone), 186 (Name: 'XOR'; Param1: prReg; Param2: prReg; Param3: prNone), 187 (Name: 'LDDR'; Param1: prReg; Param2: prReg; Param3: prReg), 188 (Name: 'LDDR'; Param1: prReg; Param2: prReg; Param3: prReg), 189 (Name: 'MUL'; Param1: prReg; Param2: prReg; Param3: prNone), 190 (Name: 'DIV'; Param1: prReg; Param2: prReg; Param3: prNone), 191 (Name: 'MOD'; Param1: prReg; Param2: prReg; Param3: prNone), 192 (Name: 'AP8'; Param1: prNone; Param2: prNone; Param3: prNone), 193 (Name: 'AP16'; Param1: prNone; Param2: prNone; Param3: prNone), 194 (Name: 'AP32'; Param1: prNone; Param2: prNone; Param3: prNone), 195 (Name: 'AP64'; Param1: prNone; Param2: prNone; Param3: prNone) 196 ); 139 197 140 198 implementation -
branches/virtualcpu4/UInstructionWriter.pas
r180 r181 6 6 7 7 uses 8 Classes, SysUtils, UCpu , UMemory, fgl;8 Classes, SysUtils, UCpu; 9 9 10 10 type … … 31 31 procedure Write64(Value: QWord); 32 32 procedure WriteAddress(Value: TAddress); 33 procedure WriteAddressSigned(Value: TAddressSigned); 33 procedure WriteAddressSigned(Value: TAddressSigned); inline; 34 34 procedure WriteData(Value: QWord); 35 35 procedure WriteString(Text: string); … … 64 64 end; 65 65 66 { TAssembler }67 68 TAssembler = class69 Source: TStringList;70 Dest: array of Byte;71 procedure Compile;72 end;73 74 TDisassemblerLine = class75 Address: Integer;76 Opcode: string;77 Instruction: string;78 end;79 80 { TDisassembler }81 82 TDisassembler = class83 Memory: TMemoryPos;84 Output: TFPGObjectList<TDisassemblerLine>;85 procedure Process;86 constructor Create;87 destructor Destroy; override;88 end;89 90 const91 OpcodeName: array[TOpcode] of string = ('NOP', 'HALT', 'LD', 'LDI', 'JP', 'JPZ',92 'JPNZ', 'JR', 'JRZ', 'JRNZ', 'NEG', 'CLR', 'LDM', 'STM', 'EX', 'PUSH', 'POP',93 'CALL', 'RET', 'ADD', 'ADDI', 'SUB', 'SUBI', 'INC', 'DEC', 'IN', 'OUT',94 'SHL', 'SHR', 'DP8', 'DP16', 'DP32', 'DP64', 'DS', 'AS', 'TEST', 'AND', 'OR',95 'XOR', 'LDDR', 'LDIR', 'MUL', 'DIV', 'MOD', 'AP8', 'AP16', 'AP32', 'AP64');96 66 97 67 implementation 98 99 { TDisassembler }100 101 procedure TDisassembler.Process;102 var103 Opcode: Byte;104 Line: TDisassemblerLine;105 begin106 Output.Clear;107 Memory.Position := Memory.Data;108 109 while Memory.Position < Memory.Data + Memory.Size do begin110 Opcode := Memory.ReadByte;111 if Opcode < Integer(High(TOpcode)) then begin112 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 begin123 Output := TFPGObjectList<TDisassemblerLine>.Create;124 Memory := TMemoryPos.Create;125 end;126 127 destructor TDisassembler.Destroy;128 begin129 Memory.Free;130 Output.Free;131 inherited Destroy;132 end;133 134 { TAssembler }135 136 procedure TAssembler.Compile;137 begin138 139 end;140 68 141 69 { TInstructionWriter } -
branches/virtualcpu4/virtucpu4.lpi
r180 r181 71 71 </Item1> 72 72 </RequiredPackages> 73 <Units Count="1 1">73 <Units Count="14"> 74 74 <Unit0> 75 75 <Filename Value="virtucpu4.lpr"/> … … 129 129 <ResourceBaseClass Value="Form"/> 130 130 </Unit10> 131 <Unit11> 132 <Filename Value="UDisassembler.pas"/> 133 <IsPartOfProject Value="True"/> 134 </Unit11> 135 <Unit12> 136 <Filename Value="UAssembler.pas"/> 137 <IsPartOfProject Value="True"/> 138 </Unit12> 139 <Unit13> 140 <Filename Value="UInstructionReader.pas"/> 141 <IsPartOfProject Value="True"/> 142 </Unit13> 131 143 </Units> 132 144 </ProjectOptions> -
branches/virtualcpu4/virtucpu4.lpr
r180 r181 9 9 Interfaces, // this includes the LCL widgetset 10 10 SysUtils, Forms, UFormMain, UCpu, UMachine, UMemory, UFormDisassembler, 11 UFormMemory, UFormCpuState, UFormScreen, UFormConsole 11 UFormMemory, UFormCpuState, UFormScreen, UFormConsole, UDisassembler, 12 UAssembler, UInstructionReader 12 13 { you can add units after this }; 13 14
Note:
See TracChangeset
for help on using the changeset viewer.