* regcall fixes

This commit is contained in:
Tomas Hajny 2004-03-21 20:18:39 +00:00
parent 7915d0e38c
commit b0c948a143

View File

@ -24,15 +24,14 @@
for all EMX applications until EMX.DLL is unloaded from memory (i.e.
all applications using this library finish).
*)
unit Ports;
{ This unit uses classes so ObjFpc mode is required. }
{$Mode ObjFpc}
{$calling StdCall}
interface
type
TPort = class
protected
@ -71,75 +70,137 @@ implementation
{Import syscall to call it nicely from assembler procedures.}
procedure syscall; external name '___SYSCALL';
{$WARNING Still using EMX - has to be updated once native linking available!}
{$AsmMode ATT}
procedure TPort.WritePort (P: word; Data: byte); assembler;
asm
xorl %ecx, %ecx
{$IFDEF REGCALL}
movw %ax, %cx
pushl %edx
pushl %ecx
{$ELSE REGCALL}
movw P, %cx
{$ENDIF REGCALL}
movl %ecx, %edx
movw $0x7F12, %ax
call syscall
{$IFDEF REGCALL}
popl %edx
popl %eax
{$ELSE REGCALL}
movw P, %dx
movb Data, %al
{$ENDIF REGCALL}
outb %al, %dx
end {['eax', 'ecx', 'edx']};
function TPort.ReadPort (P: word): byte; assembler;
asm
xorl %ecx, %ecx
{$IFDEF REGCALL}
movw %ax, %cx
{$ELSE REGCALL}
movw P, %cx
pushl %ecx
{$ENDIF REGCALL}
movl %ecx, %edx
movw $0x7F12, %ax
call syscall
{$IFDEF REGCALL}
popl %edx
{$ELSE REGCALL}
movw P, %dx
{$ENDIF REGCALL}
inb %dx, %al
end {['eax', 'ecx', 'edx']};
procedure TPortW.WritePort (P: word; Data : word); assembler;
asm
xorl %ecx, %ecx
{$IFDEF REGCALL}
movw %ax, %cx
pushl %edx
pushl %ecx
{$ELSE REGCALL}
movw P, %cx
{$ENDIF REGCALL}
movl %ecx, %edx
movw $0x7F12, %ax
call syscall
{$IFDEF REGCALL}
popl %edx
popl %eax
{$ELSE REGCALL}
movw P, %dx
movw Data, %ax
{$ENDIF REGCALL}
outw %ax, %dx
end {['eax', 'ecx', 'edx']};
function TPortW.ReadPort (P: word): word; assembler;
asm
xorl %ecx, %ecx
{$IFDEF REGCALL}
movw %ax, %cx
pushl %ecx
{$ELSE REGCALL}
movw P, %cx
{$ENDIF REGCALL}
movl %ecx, %edx
movw $0x7F12, %ax
call syscall
{$IFDEF REGCALL}
popl %edx
{$ELSE REGCALL}
movw P, %dx
{$ENDIF REGCALL}
inw %dx, %ax
end {['eax', 'ecx', 'edx']};
procedure TPortL.WritePort (P: word; Data: longint); assembler;
asm
xorl %ecx, %ecx
{$IFDEF REGCALL}
movw %ax, %cx
pushl %edx
pushl %ecx
{$ELSE REGCALL}
movw P, %cx
{$ENDIF REGCALL}
movl %ecx, %edx
movw $0x7F12, %ax
call syscall
{$IFDEF REGCALL}
popl %edx
popl %eax
{$ELSE REGCALL}
movw P, %dx
movl Data, %eax
{$ENDIF REGCALL}
outl %eax, %dx
end {['eax', 'ecx', 'edx']};
function TPortL.ReadPort (P: word): longint; assembler;
asm
xorl %ecx, %ecx
{$IFDEF REGCALL}
movw %ax, %cx
pushl %ecx
{$ELSE REGCALL}
movw P, %cx
{$ENDIF REGCALL}
movl %ecx, %edx
movw $0x7F12, %ax
call syscall
{$IFDEF REGCALL}
popl %edx
{$ELSE REGCALL}
movw P, %dx
{$ENDIF REGCALL}
inl %dx, %eax
end {['eax', 'ecx', 'edx']};
@ -147,7 +208,10 @@ end.
{
$Log$
Revision 1.5 2003-12-04 21:22:38 peter
Revision 1.6 2004-03-21 20:18:39 hajny
* regcall fixes
Revision 1.5 2003/12/04 21:22:38 peter
* regcall updates (untested)
Revision 1.4 2003/10/18 16:58:39 hajny