Assembly – How I/O Port Addresses and Data are Sent

asmassembly

First of all, I'd like to say this is a hardware-level question, which is very closely related to the "in" and "out" command in x86 assembly.

I have searched for quite some time, but I still haven't found how they send the addresses and the data. Does the 8086 first send the address, then the data? If so, how does the receiver know if the 8086 is sending a 16-bit address or an 8-bit address?

Aside from that, I'd also like to learn how the 8255 works, and how it accepts specific ports such as "port 60H".

Thanks for reading! 😀

Best Answer

As you mentioned 8086 processor i'm explaining with reference to 8086:

8086 is 16-bit processor(16-bit Data Bus means: no.of Physical lines to carry-out or carry-in are 16 lines some time ALU size also) and 20-bit Address Bus(20-bit Address Bus means : no.of Physical lines to carry-out the address are 20) these lines are nothing but 8086-pins.

To save No.of 8086 pins 16-data bus lines and 16- Address lines are multiplexed(during first part of Machine cycle 16-lines acts as Address bus later they acts as DATA Bus line) so pin count will be reduced.

Now your main Question Answer: Case:1(8086 wants to access a Byte in a Memory) 8086 can address 2^20(Address Bus size) Locations, each location holds a Byte(8-bits of data) that implies (2^10 x 2^10 =1024(1K) x1024(1K)=>1M) finally it ought to be 1MByte

Memory: Like USB Drive(2GB, 4GB,etc.) Each memory location has an Address and Location holds a byte(8-bits) suppose 1MB memory Chip will have 1024K Memory locations and each location has 8-bits data unit capacity

If 8086 Processor wants access a byte at an address first it'll send Address to to 1MB memory chip let say(0x20002) Location, this 1MB memory chip is connected to the 8086 Address bus and data bus. it's like below

  1. 8086 address on address bus to 1MB Memory Chip
  2. 1MB memory Chip will receive address on its address Bus(0x20002)
  3. 8086 waits for awhile to sync with memory waiting time(memory may slower than Processor )
  4. 1MB Memory Chip will send out requested byte on the data bus lines to 8086
  5. 8086 reads in the receiving byte

There is another case if the memory is stack of memory chips like two 512KB chips of total 1MB(512KB + 512KB) In this case each memory chip has 19 address lines(512K = 512 x 1024 =>2^9 x 2^10) and one Important line called CHIP SELECT which enables the memory Chip Both Memory chip address line are connected to 8086 address bus But 8086 has 20 address lines so one line is used to connect Chip Select line of 512K Memory Chip which Enables the 512KB chip Here 1 address line has two states:0 or 1

  1. 0:is used to select one memory Chip-A-521KB + 19 Address line
  2. 1:is used to select second memory Chip-B-521KB + 19 Address line

Another case if memory size of 256 Bytes capacity(2^8), It has 8-ADDRESS LINES and a Chip Select Line

In the above case just 8 address line of 8086 are connected to the 256 Bytes Memory Chip but reaming are connected to the Chip select line of memory chip it maybe NOR gate whose output is one if all the inputs are zero

here let say 20 address lines(A19-A0) of 8086

  1. Address Lines A7-A0 are connected to the 256 bytes Memory Chip
  2. Reaming Address lines i.e A19 to A8 are connected to the Chip Select Line of memory Chip Through 14-Input NOR gate Whose out put is One if All the inputs are Zero i.e.(A19-A8=0x0 00)
  3. Above Procedure is called Address Decoding 4. The Address Range for 256 Bytes memory Chip is(A7-A0=>0x00 to 0xFF) But 8086 has 20-Address Lines So Reaming lines are connected to Chip select of 256 Bytes memory Chip through NOR gate So final Address range is 0x000 00 to 0x000 FF in this way 256 Bytes Memory Chip is addressed

In this way Processor access data from Memory Chip with the help of address and Data Bus

Case:2(some device may wants send data to 8086) It's very complex to explain here but soon i'll add to this question

finally about 8255 please refer this intel 8255 Wiki Page