- Timestamp:
- Apr 13, 2019, 1:32:32 PM (6 years ago)
- Location:
- branches/virtualcpu4
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/virtualcpu4/Forms/UFormMain.pas
r181 r182 159 159 LabelPrintLoop := IP; 160 160 DataPrefix8; LoadMem(R3, R1); 161 DataPrefix8; Output(0, R3);161 AddrPrefix8; DataPrefix8; Output(0, R3); 162 162 Increment(R1); 163 163 Decrement(R2); … … 199 199 200 200 // Read keyboard and print to console 201 Loadi(R1, 100);201 Loadi(R1, 0); 202 202 LabelConsole := IP; 203 203 Increment(R1); 204 Loadi(R2, $ 100);204 Loadi(R2, $ff); 205 205 DataPrefix8; StoreMem(R2, R1); 206 DataPrefix8; Input(R2, 0);207 DataPrefix8; Output(0, R2);206 AddrPrefix8; DataPrefix8; Input(R2, 0); 207 AddrPrefix8; DataPrefix8; Output(0, R2); 208 208 Jump(LabelConsole); 209 209 -
branches/virtualcpu4/UCpu.pas
r181 r182 41 41 TCpu = class 42 42 private 43 FAddrSizeBase: TBitWidth; 44 FDataSizeBase: TBitWidth; 43 45 FOnInput: TInputEvent; 44 46 FOnOutput: TOutputEvent; … … 46 48 FTicks: Integer; 47 49 Instructions: array[TOpcode] of TInstructionEvent; 48 DataSizeLast: TBitWidth; 49 DataSizePrefix: TBitWidth; 50 AddrSizeLast: TBitWidth; 51 AddrSizePrefix: TBitWidth; 50 Prefix: Boolean; 52 51 Z: Boolean; 53 52 Thread: TCpuThread; … … 101 100 procedure InstAddrSize; 102 101 procedure InitInstructions; 102 procedure SetAddrSizeBase(AValue: TBitWidth); 103 procedure SetDataSizeBase(AValue: TBitWidth); 103 104 public 104 105 Memory: Pointer; … … 107 108 IP: TAddress; 108 109 SP: TAddress; 110 DataSize: TBitWidth; 109 111 AddrSize: TBitWidth; 110 DataSize: TBitWidth;111 112 procedure Run; 112 113 procedure Step; inline; … … 121 122 constructor Create; 122 123 destructor Destroy; override; 124 property DataSizeBase: TBitWidth read FDataSizeBase write SetDataSizeBase; 125 property AddrSizeBase: TBitWidth read FAddrSizeBase write SetAddrSizeBase; 123 126 property Ticks: Integer read FTicks; 124 127 property Running: Boolean read FRunning; … … 140 143 Param2: TOpcodeParam; 141 144 Param3: TOpcodeParam; 145 Prefix: Boolean; 142 146 end; 143 147 … … 146 150 BitWidthText: array[TBitWidth] of string = ('None', '8-bit', '16-bit', '32-bit', '64-bit'); 147 151 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 )152 (Name: 'NOP'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: False), 153 (Name: 'HALT'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: False), 154 (Name: 'LD'; Param1: prReg; Param2: prReg; Param3: prNone; Prefix: False), 155 (Name: 'LDI'; Param1: prReg; Param2: prData; Param3: prNone; Prefix: False), 156 (Name: 'JP'; Param1: prAddr; Param2: prNone; Param3: prNone; Prefix: False), 157 (Name: 'JPZ'; Param1: prAddr; Param2: prNone; Param3: prNone; Prefix: False), 158 (Name: 'JPNZ'; Param1: prAddr; Param2: prNone; Param3: prNone; Prefix: False), 159 (Name: 'JR'; Param1: prAddrRel; Param2: prNone; Param3: prNone; Prefix: False), 160 (Name: 'JRZ'; Param1: prAddrRel; Param2: prNone; Param3: prNone; Prefix: False), 161 (Name: 'JRNZ'; Param1: prAddrRel; Param2: prNone; Param3: prNone; Prefix: False), 162 (Name: 'NEG'; Param1: prReg; Param2: prNone; Param3: prNone; Prefix: False), 163 (Name: 'CLR'; Param1: prReg; Param2: prNone; Param3: prNone; Prefix: False), 164 (Name: 'LDM'; Param1: prReg; Param2: prReg; Param3: prNone; Prefix: False), 165 (Name: 'STM'; Param1: prReg; Param2: prReg; Param3: prNone; Prefix: False), 166 (Name: 'EX'; Param1: prReg; Param2: prReg; Param3: prNone; Prefix: False), 167 (Name: 'PUSH'; Param1: prReg; Param2: prNone; Param3: prNone; Prefix: False), 168 (Name: 'POP'; Param1: prReg; Param2: prNone; Param3: prNone; Prefix: False), 169 (Name: 'CALL'; Param1: prAddr; Param2: prNone; Param3: prNone; Prefix: False), 170 (Name: 'RET'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: False), 171 (Name: 'ADD'; Param1: prReg; Param2: prReg; Param3: prNone; Prefix: False), 172 (Name: 'ADDI'; Param1: prReg; Param2: prData; Param3: prNone; Prefix: False), 173 (Name: 'SUB'; Param1: prReg; Param2: prReg; Param3: prNone; Prefix: False), 174 (Name: 'SUBI'; Param1: prReg; Param2: prData; Param3: prNone; Prefix: False), 175 (Name: 'INC'; Param1: prReg; Param2: prNone; Param3: prNone; Prefix: False), 176 (Name: 'DEC'; Param1: prReg; Param2: prNone; Param3: prNone; Prefix: False), 177 (Name: 'IN'; Param1: prReg; Param2: prAddr; Param3: prNone; Prefix: False), 178 (Name: 'OUT'; Param1: prAddr; Param2: prReg; Param3: prNone; Prefix: False), 179 (Name: 'SHL'; Param1: prReg; Param2: prReg; Param3: prNone; Prefix: False), 180 (Name: 'SHR'; Param1: prReg; Param2: prReg; Param3: prNone; Prefix: False), 181 (Name: 'DP8'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: True), 182 (Name: 'DP16'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: False), 183 (Name: 'DP32'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: True), 184 (Name: 'DP64'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: True), 185 (Name: 'DS'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: False), 186 (Name: 'AS'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: False), 187 (Name: 'TEST'; Param1: prReg; Param2: prNone; Param3: prNone; Prefix: False), 188 (Name: 'AND'; Param1: prReg; Param2: prReg; Param3: prNone; Prefix: False), 189 (Name: 'OR'; Param1: prReg; Param2: prReg; Param3: prNone; Prefix: False), 190 (Name: 'XOR'; Param1: prReg; Param2: prReg; Param3: prNone; Prefix: False), 191 (Name: 'LDDR'; Param1: prReg; Param2: prReg; Param3: prReg; Prefix: False), 192 (Name: 'LDDR'; Param1: prReg; Param2: prReg; Param3: prReg; Prefix: False), 193 (Name: 'MUL'; Param1: prReg; Param2: prReg; Param3: prNone; Prefix: False), 194 (Name: 'DIV'; Param1: prReg; Param2: prReg; Param3: prNone; Prefix: False), 195 (Name: 'MOD'; Param1: prReg; Param2: prReg; Param3: prNone; Prefix: False), 196 (Name: 'AP8'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: True), 197 (Name: 'AP16'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: True), 198 (Name: 'AP32'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: True), 199 (Name: 'AP64'; Param1: prNone; Param2: prNone; Param3: prNone; Prefix: True) 196 200 ); 197 201 … … 991 995 procedure TCpu.InstDataPrefix8; 992 996 begin 993 DataSizePrefix := bw8; 997 DataSize := bw8; 998 Prefix := True; 994 999 end; 995 1000 996 1001 procedure TCpu.InstDataPrefix16; 997 1002 begin 998 DataSizePrefix := bw16; 1003 DataSize := bw16; 1004 Prefix := True; 999 1005 end; 1000 1006 1001 1007 procedure TCpu.InstDataPrefix32; 1002 1008 begin 1003 DataSizePrefix := bw32; 1009 DataSize := bw32; 1010 Prefix := True; 1004 1011 end; 1005 1012 1006 1013 procedure TCpu.InstDataPrefix64; 1007 1014 begin 1008 DataSizePrefix := bw64; 1015 DataSize := bw64; 1016 Prefix := True; 1009 1017 end; 1010 1018 1011 1019 procedure TCpu.InstDataSize; 1012 1020 begin 1013 DataSize := TBitWidth(Read8); 1021 DataSizeBase := TBitWidth(Read8); 1022 DataSize := DataSizeBase; 1014 1023 end; 1015 1024 1016 1025 procedure TCpu.InstAddrPrefix8; 1017 1026 begin 1018 AddrSizePrefix := bw8; 1027 AddrSize := bw8; 1028 Prefix := True; 1019 1029 end; 1020 1030 1021 1031 procedure TCpu.InstAddrPrefix16; 1022 1032 begin 1023 AddrSizePrefix := bw16; 1033 AddrSize := bw16; 1034 Prefix := True; 1024 1035 end; 1025 1036 1026 1037 procedure TCpu.InstAddrPrefix32; 1027 1038 begin 1028 AddrSizePrefix := bw32; 1039 AddrSize := bw32; 1040 Prefix := True; 1029 1041 end; 1030 1042 1031 1043 procedure TCpu.InstAddrPrefix64; 1032 1044 begin 1033 AddrSizePrefix := bw64; 1045 AddrSize := bw64; 1046 Prefix := True; 1034 1047 end; 1035 1048 1036 1049 procedure TCpu.InstAddrSize; 1037 1050 begin 1038 AddrSize := TBitWidth(Read8); 1051 AddrSizeBase := TBitWidth(Read8); 1052 AddrSize := AddrSizeBase; 1039 1053 end; 1040 1054 … … 1091 1105 end; 1092 1106 1107 procedure TCpu.SetAddrSizeBase(AValue: TBitWidth); 1108 begin 1109 if FAddrSizeBase = AValue then Exit; 1110 FAddrSizeBase := AValue; 1111 AddrSize := AValue; 1112 end; 1113 1114 procedure TCpu.SetDataSizeBase(AValue: TBitWidth); 1115 begin 1116 if FDataSizeBase = AValue then Exit; 1117 FDataSizeBase := AValue; 1118 DataSize := AValue; 1119 end; 1120 1093 1121 procedure TCpu.Run; 1094 1122 begin 1123 DataSize := DataSizeBase; 1124 AddrSize := AddrSizeBase; 1095 1125 Terminated := False; 1096 1126 FTicks := 0; 1097 DataSizeLast := bwNone;1098 1127 IP := 0; 1099 1128 SP := MemSize(Memory); … … 1106 1135 Opcode: Byte; 1107 1136 begin 1108 if DataSizePrefix <> bwNone then begin 1109 DataSizeLast := DataSize; 1110 DataSize := DataSizePrefix; 1111 DataSizePrefix := bwNone; 1112 end; 1113 if AddrSizePrefix <> bwNone then begin 1114 AddrSizeLast := AddrSize; 1115 AddrSize := AddrSizePrefix; 1116 AddrSizePrefix := bwNone; 1117 end; 1137 Prefix := False; 1118 1138 Opcode := Read8; 1119 1139 if Opcode < Length(Instructions) then begin … … 1121 1141 else raise Exception.Create('Missing instruction handler for opcode '+ IntToStr(Opcode)); 1122 1142 end else raise Exception.Create('Unsupported opcode ' + IntToStr(Opcode) + ' at address ' + IntToHex(IP - 1, 8) + '.'); 1123 if DataSizeLast <> bwNone then begin 1124 DataSize := DataSizeLast; 1125 DataSizeLast := bwNone; 1126 end; 1127 if AddrSizeLast <> bwNone then begin 1128 AddrSize := AddrSizeLast; 1129 AddrSizeLast := bwNone; 1143 if not Prefix then begin 1144 DataSize := DataSizeBase; 1145 AddrSize := AddrSizeBase; 1130 1146 end; 1131 1147 IP := IP mod MemSize(Memory); … … 1201 1217 constructor TCpu.Create; 1202 1218 begin 1203 DataSize := bw16;1204 AddrSize := bw16;1219 DataSizeBase := bw16; 1220 AddrSizeBase := bw16; 1205 1221 SetLength(Registers, 32); 1206 1222 InitInstructions; -
branches/virtualcpu4/UDisassembler.pas
r181 r182 6 6 7 7 uses 8 Classes, SysUtils, UMemory, fgl, UCpu, UInstructionReader ;8 Classes, SysUtils, UMemory, fgl, UCpu, UInstructionReader, Math; 9 9 10 10 type … … 29 29 implementation 30 30 31 const 32 SignText: array[TValueSign] of string = ('-', '', '+'); 33 34 function SignedIntToHex(Value: Int64; Digits: Byte): string; 35 begin 36 Result := SignText[Sign(Value)] + IntToHex(Abs(Value), Digits); 37 end; 38 31 39 { TDisassembler } 32 40 … … 46 54 MemorySize := MemSize(Cpu.Memory); 47 55 while IP < MemorySize do begin 48 if DataSizePrefix <> bwNone then begin 49 DataSizeLast := DataSize; 50 DataSize := DataSizePrefix; 51 DataSizePrefix := bwNone; 52 end; 53 if AddrSizePrefix <> bwNone then begin 54 AddrSizeLast := AddrSize; 55 AddrSize := AddrSizePrefix; 56 AddrSizePrefix := bwNone; 57 end; 56 Prefix := False; 58 57 Opcode := Read8; 59 58 if Opcode < Integer(High(TOpcode)) then begin 59 Prefix := OpcodeDef[TOpcode(Opcode)].Prefix; 60 60 case TOpcode(Opcode) of 61 opDataPrefix8: DataSize Prefix:= bw8;62 opDataPrefix16: DataSize Prefix:= bw16;63 opDataPrefix32: DataSize Prefix:= bw32;64 opDataPrefix64: DataSize Prefix:= bw64;65 opAddrPrefix8: AddrSize Prefix:= bw8;66 opAddrPrefix16: AddrSize Prefix:= bw16;67 opAddrPrefix32: AddrSize Prefix:= bw32;68 opAddrPrefix64: AddrSize Prefix:= bw64;61 opDataPrefix8: DataSize := bw8; 62 opDataPrefix16: DataSize := bw16; 63 opDataPrefix32: DataSize := bw32; 64 opDataPrefix64: DataSize := bw64; 65 opAddrPrefix8: AddrSize := bw8; 66 opAddrPrefix16: AddrSize := bw16; 67 opAddrPrefix32: AddrSize := bw32; 68 opAddrPrefix64: AddrSize := bw64; 69 69 end; 70 70 Line := TDisassemblerLine.Create; … … 90 90 prAddrRel: begin 91 91 AddressRel := ReadAddressSigned; 92 Line.Opcode := Line.Opcode + ' ' + IntToHex( AddressRel, BitWidthBytes[AddrSize] * 2);93 Line.Instruction := Line.Instruction + ' $' + IntToHex(AddressRel, BitWidthBytes[AddrSize] * 2);92 Line.Opcode := Line.Opcode + ' ' + IntToHex(QWord(AddressRel), BitWidthBytes[AddrSize] * 2); 93 Line.Instruction := Line.Instruction + ' $' + SignedIntToHex(AddressRel, BitWidthBytes[AddrSize] * 2); 94 94 end; 95 95 end; … … 113 113 AddressRel := ReadAddressSigned; 114 114 Line.Opcode := Line.Opcode + ' ' + IntToHex(AddressRel, BitWidthBytes[AddrSize] * 2); 115 Line.Instruction := Line.Instruction + ', $' + IntToHex(AddressRel, BitWidthBytes[AddrSize] * 2);115 Line.Instruction := Line.Instruction + ', $' + SignedIntToHex(AddressRel, BitWidthBytes[AddrSize] * 2); 116 116 end; 117 117 end; … … 134 134 prAddrRel: begin 135 135 AddressRel := ReadAddressSigned; 136 Line.Opcode := Line.Opcode + ' ' + IntToHex( AddressRel, BitWidthBytes[AddrSize] * 2);137 Line.Instruction := Line.Instruction + ', $' + IntToHex(AddressRel, BitWidthBytes[AddrSize] * 2);136 Line.Opcode := Line.Opcode + ' ' + IntToHex(QWord(AddressRel), BitWidthBytes[AddrSize] * 2); 137 Line.Instruction := Line.Instruction + ', $' + SignedIntToHex(AddressRel, BitWidthBytes[AddrSize] * 2); 138 138 end; 139 139 end; … … 147 147 } 148 148 end; 149 if DataSizeLast <> bwNone then begin 150 DataSize := DataSizeLast; 151 DataSizeLast := bwNone; 152 end; 153 if AddrSizeLast <> bwNone then begin 154 AddrSize := AddrSizeLast; 155 AddrSizeLast := bwNone; 149 if not Prefix then begin 150 DataSize := DataSizeBase; 151 AddrSize := AddrSizeBase; 156 152 end; 157 153 end; -
branches/virtualcpu4/UInstructionReader.pas
r181 r182 14 14 TInstructionReader = class 15 15 protected 16 DataSizeLast: TBitWidth;17 DataSizePrefix: TBitWidth;18 AddrSizeLast: TBitWidth;19 AddrSizePrefix: TBitWidth;20 16 public 21 17 Cpu: TCpu; 22 18 IP: Integer; 19 Prefix: Boolean; 23 20 DataSize: TBitWidth; 21 DataSizeBase: TBitWidth; 24 22 AddrSize: TBitWidth; 23 AddrSizeBase: TBitWidth; 25 24 procedure Init; 26 25 function Read8: Byte; inline; … … 39 38 procedure TInstructionReader.Init; 40 39 begin 41 DataSize := Cpu.DataSize; 42 AddrSize := Cpu.AddrSize; 40 DataSizeBase := Cpu.DataSizeBase; 41 DataSize := DataSizeBase; 42 AddrSizeBase := Cpu.AddrSizeBase; 43 AddrSize := AddrSizeBase; 43 44 end; 44 45 -
branches/virtualcpu4/UInstructionWriter.pas
r181 r182 14 14 TInstructionWriter = class 15 15 private 16 DataSizeLast: TBitWidth;17 DataSizePrefix: TBitWidth;18 AddrSizeLast: TBitWidth;19 AddrSizePrefix: TBitWidth;20 16 procedure PrefixBegin; 21 17 procedure PrefixEnd; … … 24 20 IP: Integer; 25 21 DataSize: TBitWidth; 22 DataSizeBase: TBitWidth; 26 23 AddrSize: TBitWidth; 24 AddrSizeBase: TBitWidth; 25 Prefix: Boolean; 27 26 procedure Init; 28 27 procedure Write8(Value: Byte); … … 162 161 Write8(Byte(opJumpRelZero)); 163 162 WriteAddressSigned(Int64(Addr) - Int64(NextIP)); 164 if AddrSizeLast <> bwNone then AddrSize := AddrSizeLast;165 163 PrefixEnd; 166 164 end; … … 199 197 procedure TInstructionWriter.DataPrefix8; 200 198 begin 201 DataSizePrefix := bw8; 199 Prefix := True; 200 DataSize := bw8; 202 201 Write8(Byte(opDataPrefix8)); 203 202 end; … … 205 204 procedure TInstructionWriter.DataPrefix16; 206 205 begin 207 DataSizePrefix := bw16; 206 Prefix := True; 207 DataSize := bw16; 208 208 Write8(Byte(opDataPrefix16)); 209 209 end; … … 211 211 procedure TInstructionWriter.DataPrefix32; 212 212 begin 213 DataSizePrefix := bw32; 213 Prefix := True; 214 DataSize := bw32; 214 215 Write8(Byte(opDataPrefix32)); 215 216 end; … … 217 218 procedure TInstructionWriter.DataPrefix64; 218 219 begin 219 DataSizePrefix := bw64; 220 Prefix := True; 221 DataSize := bw64; 220 222 Write8(Byte(opDataPrefix64)); 221 223 end; … … 223 225 procedure TInstructionWriter.AddrPrefix8; 224 226 begin 225 AddrSizePrefix := bw8; 227 Prefix := True; 228 AddrSize := bw8; 226 229 Write8(Byte(opAddrPrefix8)); 227 230 end; … … 229 232 procedure TInstructionWriter.AddrPrefix16; 230 233 begin 231 AddrSizePrefix := bw16; 234 Prefix := True; 235 AddrSize := bw16; 232 236 Write8(Byte(opAddrPrefix16)); 233 237 end; … … 235 239 procedure TInstructionWriter.AddrPrefix32; 236 240 begin 237 AddrSizePrefix := bw32; 241 Prefix := True; 242 AddrSize := bw32; 238 243 Write8(Byte(opAddrPrefix32)); 239 244 end; … … 241 246 procedure TInstructionWriter.AddrPrefix64; 242 247 begin 243 AddrSizePrefix := bw64; 248 Prefix := True; 249 AddrSize := bw64; 244 250 Write8(Byte(opAddrPrefix64)); 245 251 end; … … 297 303 procedure TInstructionWriter.PrefixBegin; 298 304 begin 299 if DataSizePrefix <> bwNone then begin 300 DataSizeLast := DataSize; 301 DataSize := DataSizePrefix; 302 DataSizePrefix := bwNone; 303 end; 304 if AddrSizePrefix <> bwNone then begin 305 AddrSizeLast := AddrSize; 306 AddrSize := AddrSizePrefix; 307 AddrSizePrefix := bwNone; 308 end; 305 Prefix := False; 309 306 end; 310 307 311 308 procedure TInstructionWriter.PrefixEnd; 312 309 begin 313 if DataSizeLast <> bwNone then begin 314 DataSize := DataSizeLast; 315 DataSizeLast := bwNone; 316 end; 317 if AddrSizeLast <> bwNone then begin 318 AddrSize := AddrSizeLast; 319 AddrSizeLast := bwNone; 310 if not Prefix then begin 311 DataSize := DataSizeBase; 312 AddrSize := AddrSizeBase; 320 313 end; 321 314 end; … … 323 316 procedure TInstructionWriter.Init; 324 317 begin 325 DataSize := Cpu.DataSize; 326 AddrSize := Cpu.AddrSize; 318 DataSizeBase := Cpu.DataSizeBase; 319 DataSize := DataSizeBase; 320 AddrSizeBase := Cpu.AddrSizeBase; 321 AddrSize := AddrSizeBase; 327 322 end; 328 323 -
branches/virtualcpu4/UMachine.pas
r179 r182 50 50 Cpu.OnInput := CpuInput; 51 51 Cpu.OnOutput := CpuOutput; 52 Cpu.DataSize := bw32;53 Cpu.AddrSize := bw32;52 Cpu.DataSizeBase := bw32; 53 Cpu.AddrSizeBase := bw32; 54 54 Screen := TScreen.Create; 55 55 Screen.Size := Point(320, 240); -
branches/virtualcpu4/virtucpu4.lpi
r181 r182 103 103 <IsPartOfProject Value="True"/> 104 104 <ComponentName Value="FormDisassembler"/> 105 <HasResources Value="True"/> 105 106 <ResourceBaseClass Value="Form"/> 106 107 </Unit6> … … 109 110 <IsPartOfProject Value="True"/> 110 111 <ComponentName Value="FormMemory"/> 112 <HasResources Value="True"/> 111 113 <ResourceBaseClass Value="Form"/> 112 114 </Unit7> … … 115 117 <IsPartOfProject Value="True"/> 116 118 <ComponentName Value="FormCpuState"/> 119 <HasResources Value="True"/> 117 120 <ResourceBaseClass Value="Form"/> 118 121 </Unit8> … … 121 124 <IsPartOfProject Value="True"/> 122 125 <ComponentName Value="FormScreen"/> 126 <HasResources Value="True"/> 123 127 <ResourceBaseClass Value="Form"/> 124 128 </Unit9> … … 127 131 <IsPartOfProject Value="True"/> 128 132 <ComponentName Value="FormConsole"/> 133 <HasResources Value="True"/> 129 134 <ResourceBaseClass Value="Form"/> 130 135 </Unit10>
Note:
See TracChangeset
for help on using the changeset viewer.