reading ports 
Author Message
 reading ports

Is reading a word from io port 100 the same as reading a byte from port 100
and 101?

What i mean is, does io read/write act as ram writes or are they handled in
a special way?

is
mov ax,0x1234
mov dx,0x100
out dx,ax

the same as

mov al,34
mov dx,0x100
out dx,al
mov al,12
inc dx
out dx,al

?



Fri, 01 Jul 2005 18:09:46 GMT  
 reading ports

Quote:

> Is reading a word from io port 100 the same as reading a byte from port 100
> and 101?
> What i mean is, does io read/write act as ram writes or are they handled in
> a special way?

> is
> mov ax,0x1234
> mov dx,0x100
> out dx,ax

> the same as

> mov al,34
> mov dx,0x100
> out dx,al
> mov al,12
> inc dx
> out dx,al

> ?

   Not always. Ports are not handled in some special way (the only
distinction is a special line on the bus that indicates memory or port
address space access). However, the addressed hardware may choose to
respond only to access of particular size (this is part of so-called
"not memory-like behavior"). E.g. in your example there may be a word
register mapped at ports 0x100. An adapter may require the entire
register to be written at the same time and is not willing to deal
with latching. So it will only allow writes or 16-bit words at once
and ignore byte writes. OTOH, byte registers in many cases allow word
or double-word access.

/BP



Sat, 02 Jul 2005 01:13:49 GMT  
 reading ports

Quote:
> Is reading a word from io port 100 the same as reading a byte from port 100
> and 101?

I found a difference in my serial port DOS utility. It worked well with
standard ISA COM ports but refused to communicate with PCI card MP9835
which emulates COM3/COM4. I had to rewrite all  IN AX,DX with sequence
 IN AL,DX
 XCHG AL,AH
 INC DX
 IN AL,DX
 XCHG AL,AH

Bye,
v
Sr.



Sat, 02 Jul 2005 01:28:05 GMT  
 reading ports

Quote:

>Is reading a word from io port 100 the same as reading a byte from port 100
>and 101?

Often, not always.

Quote:

>What i mean is, does io read/write act as ram writes or are they handled in
>a special way?

IO and memory both share the same address bus and data bus in
the x86 architecture, there is however some special lines on
the CPU control bus that indicate to the device whether it
is an IO or a memory transfer.

Anything within the address range of the actual device can,
in theory, be interpretted in any way it pleases. In a multiple
bus system (like most machines nowadays, PCI, ISA,...) it
is even possible that an interfacing bridge chip  can swallow
up the IO access if it is addressed as a word (word 0x100)
but forward the byte accesses (byte 0x100,0x101) to that range
to the bus, so another device could service those... that
is probably a little perverse thing to do but it just shows
that the *possibility* for this behaviour exists in the hardware.

The morale of the story is that if you want to program a hardware
device you should always get hold of the manufacturers data-sheets
first. These will give you the full low-down on how everything should
behave, and the correct way to program it.

Quote:

>is
>mov ax,0x1234
>mov dx,0x100
>out dx,ax

>the same as

>mov al,34
>mov dx,0x100
>out dx,al
>mov al,12
>inc dx
>out dx,al

Actually I never heard of 'pass-through' access before PCI (I haven't
programmed that much ISA IO hardware though...) like for example
on the PIIX3 Southbridge component (PCI-ISA bus bridge);

CF8 (dword) & CFC (dword):
  Access the configuration register space
CF9 (byte):
  Reset

In this case OUT CF8,EAX does one thing and OUT CF9,AL something
else entirely....

bestwishes
laura

Quote:

>?



Sun, 03 Jul 2005 10:21:29 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. UDP Question - Reading port

2. Reading ports 60 and 61- my own keyboard handler?

3. Read from port until STR [Was: Reading multi-char delimiters]

4. Reading data on a serial port

5. Read from serial port

6. Reading COM-port from Clarion app.

7. Read/Write data from/to I/O-Ports

8. Reading comm port?

9. Reading chars from serial port

10. reading from parallel port

11. Read Serial Port?

12. Reading a COM port

 

 
Powered by phpBB® Forum Software