You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New interfaces are added instaed of modifying the old ones in order to keep compatibility. The most important change is the addition of the InstructionExecutorExtendedPorts property to the Z80Processor class.
Copy file name to clipboardExpand all lines: Docs/Configuration.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,3 +21,42 @@ _NOTE:_ Remember that plugging [custom dependencies](Dependencies.md) is an alte
21
21
***`SetPortWaitStates`** and **`GetPortWaitStates`** methods allow to configure the amount of extra T states that will be counted for timing purposes when a port is read or written during the execution of an instruction (not including the extra T state that is always added by the Z80 itself). The default value is zero for the entire ports space.
22
22
23
23
***`UserState`**: This is a convenience property that can be used by the client code to store just anything. The code of the processor class will never access this property for anything. The default value is _null_.
24
+
25
+
***`UseExtendedPortsSpace`**: Enables or disables the extended ports space (it's disabled by default), see below for details.
26
+
27
+
28
+
### The extended ports space
29
+
30
+
In a real Z80 processor the port access instructions (`IN`, `INI`, `INIR`, `IND`, `INDR`, `OUT`, `OUTI`, `OTIR`, `OUTD`, `OTDR`) work with 16 bit port numbers. These port numbers are composed as follows:
31
+
32
+
* The lower half, whose value is set to pins A7-A0 of the address bus, is included in the instruction itself, either explicitly (as part of the instruction opcode) or implicitly (in register C).
33
+
* The higher half, whose value is set to pins A15-A8 of the address bus, is taken from register A or B (when the instruction begins its execution) as follows:
34
+
* For the `IN A,(n)` and `OUT (n),A` instructions: register A.
35
+
* For the other instructions: register B.
36
+
37
+
Z80.NET 1.0 didn't support 16 bit port numbers: register A/B was ignored and the actual port accessed was always a number in the range 0-255, as specified by the instruction opcode or as taken from register C.
38
+
39
+
Z80.NET 1.1 implements a new boolean property, `UseExtendedPortsSpace`, that works as follows:
40
+
41
+
* When it's `false` (default) the behavior is as in Z80.NET 1.0: port numbers are always 8 bit values.
42
+
* When it's `true`, 16 bit port numbers are supported as specified above.
43
+
44
+
For example, take the following snippet:
45
+
46
+
```
47
+
ld a,12h
48
+
in a,(34h)
49
+
```
50
+
51
+
* When `UseExtendedPortsSpace` is `false` this will load A with the value of `PortsSpace[0x34]`.
52
+
* When `UseExtendedPortsSpace` is `true` this will load A with the value of `PortsSpace[0x1234]`.
53
+
54
+
Note that before setting `UseExtendedPortsSpace` to `true` you need to set `PortsSpace` to an instance of `IMemory` that reports a size of at least 65536, otherwise you'll get an exception; example:
55
+
56
+
```C#
57
+
varZ80=newZ80Processor();
58
+
Z80.PortsSpace=newPlainMemory(65536);
59
+
Z80.UseExtendedPortsSpace=true;
60
+
```
61
+
62
+
You may want to take a look at [the relevant unit tests](../Main.Tests/Z80ProcessorTests_PortsAccess.cs) for more details on how port access works depending on the value of `UseExtendedPortsSpace`.
0 commit comments