source: branches/virtcpu varint/UInstructionReader.pas

Last change on this file was 197, checked in by chronos, 5 years ago
  • Modified: All parts of virtual machine have own form in Forms subdirectory.
  • Modified: Main form moved to Forms subdirectory.
  • Modified: TCpu class moved to UCpu unit.
  • Added: Assembler and dissasembler forms.
File size: 644 bytes
Line 
1unit UInstructionReader;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, UCpu;
9
10type
11
12 { TInstructionReader }
13
14 TInstructionReader = class
15 protected
16 public
17 Cpu: TCpu;
18 IP: Integer;
19 procedure Init;
20 function Read: T; inline;
21 function ReadSigned: T; inline;
22 end;
23
24implementation
25
26{ TInstructionReader }
27
28procedure TInstructionReader.Init;
29begin
30 IP := 0;
31end;
32
33function TInstructionReader.Read: T;
34begin
35 IP := IP + Result.ReadFromAddr(Pointer(NativeInt(Cpu.Memory) + IP));
36end;
37
38function TInstructionReader.ReadSigned: T;
39begin
40 IP := IP + Result.ReadFromAddr(Pointer(NativeInt(Cpu.Memory) + IP));
41end;
42
43end.
44
Note: See TracBrowser for help on using the repository browser.