Opie Pecheux wrote:
I think that there is a mistake un the ports.pas unit on the gpc-19990430-i386-pc-djgppv202.zip :
function InPortW (PortNumber : ShortWord) : ShortWord; var Result : volatile ShortWord; (*@@*) begin asm ('inb %%dx, %%al' : '=a' (Result) : 'd' (PortNumber) : 'ax', 'dx'); InPortW := Result end;
Wasn't ax instead of al?
it should read asm ('inw %%dx,%%ax' : '=a' (Result) : 'd' (PortNumber));
Reasons: - inw to indicate 16 bit operand size - ax to properly specify destination register - no registers set to undefined values by the instruction. Note that this probably needs to be changed in all other InPort* implementations.
It may also be possible (didn`t check!) to write %1,%0 instead of %%dx,%%ax. I'm not sure, however, if the registers are propagated to 32 bit values. If this is the case, then wrong register sizes would be used for the operands. So it is probably best to leave it like it is written above.
If someone has questions about the stuff I wrote above or gcc asm() writing in general, just ask.
Klaus