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