|
Last change
on this file was 197, checked in by chronos, 6 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 | |
|---|
| 1 | unit UInstructionReader;
|
|---|
| 2 |
|
|---|
| 3 | {$mode delphi}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Classes, SysUtils, UCpu;
|
|---|
| 9 |
|
|---|
| 10 | type
|
|---|
| 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 |
|
|---|
| 24 | implementation
|
|---|
| 25 |
|
|---|
| 26 | { TInstructionReader }
|
|---|
| 27 |
|
|---|
| 28 | procedure TInstructionReader.Init;
|
|---|
| 29 | begin
|
|---|
| 30 | IP := 0;
|
|---|
| 31 | end;
|
|---|
| 32 |
|
|---|
| 33 | function TInstructionReader.Read: T;
|
|---|
| 34 | begin
|
|---|
| 35 | IP := IP + Result.ReadFromAddr(Pointer(NativeInt(Cpu.Memory) + IP));
|
|---|
| 36 | end;
|
|---|
| 37 |
|
|---|
| 38 | function TInstructionReader.ReadSigned: T;
|
|---|
| 39 | begin
|
|---|
| 40 | IP := IP + Result.ReadFromAddr(Pointer(NativeInt(Cpu.Memory) + IP));
|
|---|
| 41 | end;
|
|---|
| 42 |
|
|---|
| 43 | end.
|
|---|
| 44 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.