First, you must understand that you must separate the computer architecture from the CPU. You can have the same computer architecture running with a different CPU. The computer architecture defines what and how works the devices in the system, how many ram, at what address they are, etc...
I going to try to explain it at a basic level so all can understand, and I'm sorry if my poorly English don't allow me to do that.What is a computer :
In a schematic representation, is this :
Clearly we can see 4 things here : The CPU, the memory, the I/O devices and the system bus.The CPU DON'T KNOW how many or what are the devices or how talk to they
. It only knows that can read & write data in addresses. Also, is reading instructions from the address pointed by the Program Counter register and executing it.So, how can use the devices ?
As you can see, the devices are attached to the system bus, like the Memory, so why not use addresses to read or write data to the devices ? Well, this is know as Memory Mapped I/O
. It's usual reserve a range of addresses were the devices will be placed, as we not like to have devices address in middle of the Memory blocks, as this make more complex programming and building the machine. We only have a problem, that is that you are losing potential memory addresses to talk with the devices. If you are using a 32 or 64 bit CPU you can spare this loss, as there a lot of address space, but this is a big problem for 8 and 16 bit CPUs were you have a very little address space (256 bytes in 8 bit cpus and 64KiB in 16 bit cpus), so you are being limited a lot your max possible memory and how many devices could do have. There is tricks like banking, but this becomes slow and complex.
Another solution is having a separate address bus for only devices. To read & write data to the devices you uses special instructions like IN and OUT instructions that uses these special address bus for devices. In this case, the address is called "Port", and we have what is called Port Mapped I/O
The Port Mapped I/O is useful if you are using a CPU that only can generate 8 or 16 bit address, as give you a separate address space for devices (and someone could say that is more clear), but with a 32 bit cpu not have sense.... you have address space of 4 GiB ! You can spare a few MiB in the top of the address space for Memory Mapped I/O and avoid adding special instructions for it, making the CPU more simple.Interrupts
An interrupt is what the name says. Interrupts what is doing the CPU to doing other thing.
The CPU interrupts comes from two possibles sources :
- Software (INT instruction)
- Hardware interrupt (toggling a interrupt signal)
When the interrupt happens, the CPU will jump to another place, and begin to execute different code. Were and/or what does will depend of the interrupt message (INT parameter or a value that the CPU will read from Data bus when the interrupt signal is toggle).
The Hardware interrupts are usually used to signal to the program (or the OS), that something has append and that need to check it. Software interrupts are usually used as a call method to the OS functions that expose to the programs.
Edit : More info here : http://en.wikipedia.org/wiki/Memory-mapped_I/O