Changeset 182 for branches/virtualcpu4/UInstructionWriter.pas
- Timestamp:
- Apr 13, 2019, 1:32:32 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.