Browse Source

+ add support for port object on Z80 using the new IN/OUT intrinsics

git-svn-id: trunk@45608 -
svenbarth 5 years ago
parent
commit
ac5093274d
4 changed files with 61 additions and 2 deletions
  1. 2 0
      .gitattributes
  2. 2 2
      rtl/msxdos/system.pp
  3. 28 0
      rtl/z80/ports.inc
  4. 29 0
      rtl/z80/portsh.inc

+ 2 - 0
.gitattributes

@@ -12214,6 +12214,8 @@ rtl/z80/cpuinnr.inc svneol=native#text/plain
 rtl/z80/int64p.inc svneol=native#text/plain
 rtl/z80/makefile.cpu svneol=native#text/plain
 rtl/z80/math.inc svneol=native#text/plain
+rtl/z80/ports.inc svneol=native#text/plain
+rtl/z80/portsh.inc svneol=native#text/plain
 rtl/z80/set.inc svneol=native#text/plain
 rtl/z80/setjump.inc svneol=native#text/plain
 rtl/z80/setjumph.inc svneol=native#text/plain

+ 2 - 2
rtl/msxdos/system.pp

@@ -33,7 +33,7 @@ interface
 
 {$I systemh.inc}
 {$I tnyheaph.inc}
-{.$I portsh.inc}
+{$I portsh.inc}
 
 {$ifndef FPUNONE}
 {$ifdef FPC_HAS_FEATURE_SOFTFPU}
@@ -233,7 +233,7 @@ function CheckNullArea: Boolean; external name 'FPC_CHECK_NULLAREA';
 
 {$I tinyheap.inc}
 
-{.$I ports.inc}
+{$I ports.inc}
 
 {$ifndef FPUNONE}
 {$ifdef FPC_HAS_FEATURE_SOFTFPU}

+ 28 - 0
rtl/z80/ports.inc

@@ -0,0 +1,28 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2020 by the Free Pascal development team.
+
+    These files adds support for TP styled port accesses
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{ to give easy port access like tp with port[] }
+
+procedure tport.writeport(p : byte;data : byte);inline;
+begin
+  fpc_z80_outport(p,data);
+end;
+
+
+function tport.readport(p : byte) : byte;inline;
+begin
+  readport:=fpc_z80_inport(p);
+end;
+

+ 29 - 0
rtl/z80/portsh.inc

@@ -0,0 +1,29 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2020 by the Free Pascal development team.
+
+    These files adds support for TP styled port accesses
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+type
+   tport = object
+   private
+      procedure writeport(p : byte;data : byte);inline;
+      function  readport(p : byte) : byte;inline;
+   public
+      property pp[p : byte] : byte read readport write writeport;default;
+   end;
+
+var
+{ we don't need to initialize port, because neither member
+  variables nor virtual methods are accessed }
+   port : tport;
+   portb : tport absolute port;