From 79c5b632f131d17c2c9626b3e0eeafe266d91b60 Mon Sep 17 00:00:00 2001 From: nickysn Date: Tue, 12 Jan 2016 18:06:21 +0000 Subject: [PATCH] + added portl class for 32-bit port access in the i8086-msdos ports unit, if the target cpu is 386 or later git-svn-id: trunk@32929 - --- rtl/msdos/ports.pp | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/rtl/msdos/ports.pp b/rtl/msdos/ports.pp index 55bfacbd29..e69e646ff9 100644 --- a/rtl/msdos/ports.pp +++ b/rtl/msdos/ports.pp @@ -20,6 +20,15 @@ unit ports; ObjFpc mode is required PM } {$Mode ObjFpc} +{$if defined(CPU80386) + or defined(CPUPENTIUM) + or defined(CPUPENTIUM2) + or defined(CPUPENTIUM3) + or defined(CPUPENTIUM4) + or defined(CPUPENTIUMM)} + {$define CPU_IS_386_OR_LATER} +{$endif} + interface type @@ -35,18 +44,22 @@ type property pp[w : word] : word read readport write writeport;default; end; -{ tportl = class +{$ifdef CPU_IS_386_OR_LATER} + tportl = class procedure writeport(p : word;data : longint); function readport(p : word) : longint; property pp[w : word] : longint read readport write writeport;default; - end;} + end; +{$endif CPU_IS_386_OR_LATER} var { we don't need to initialize port, because neither member variables nor virtual methods are accessed } port, portb : tport; portw : tportw; -// portl : tportl; +{$ifdef CPU_IS_386_OR_LATER} + portl : tportl; +{$endif CPU_IS_386_OR_LATER} implementation @@ -82,18 +95,22 @@ asm end; -{procedure tportl.writeport(p : word;data : longint);assembler; +{$ifdef CPU_IS_386_OR_LATER} +procedure tportl.writeport(p : word;data : longint);assembler; asm - movw p,%dx - movl data,%eax - outl %eax,%dx + mov dx, p + mov eax, data + out dx, eax end; function tportl.readport(p : word) : longint;assembler; asm - movw p,%dx - inl %dx,%eax -end;} + mov dx, p + in eax, dx + mov edx, eax + shr edx, 16 +end; +{$endif CPU_IS_386_OR_LATER} end.