gaf
User
 Platinum Osdever
| Posts: 153 |  | Karma: 10
|
Re:hardware interfacing - 2006/10/30 14:25
Hello, On the x86 architecture there are two address spaces that can be used to communicate with devices:
a) Some memory regions are mapped to certain devices that can then be accessed using regular mov instructions
The video console for example start at linear address 0xB8000 in memory. To write a large 'A' to the upper left corner, all you have to do is to move the ANSI character to this address:
| Code: | mov al, 'A'
mov [0xB8000}, al
|
b) Port space is 16bit wide and can be accessed using the in/out instructions
An example for a device that uses ports is the console cursor (the small blinking thing on your boot screen). Setting its position is a bit tedious, but the idea is really simple:
| Code: | mov al, 0x0f ; Command: "Write lower 8bit"
mov dx, 0x03d4 ; Command port
out al, dx ; Send the command to the device
mov al, 0x00 ; The lower 8bit (character #__XX)
mov dx, 0x03d5 ; Data port
out al, dx ; Send the data
mov al, 0x0e ; Command: "Write upper 8bit"
mov dx, 0x03d4 ; Command port
out al, dx ; Send the command to the device
mov al, 0x00 ; The upper 8bit (character #XX__)
mov dx, 0x03d5 ; Data port
out al, dx ; Send the data
|
Apart from that you should probably know that devices can use interrupt to inform the processor on an event. There are several tutorials about this topic on bonafide.
Searching google and amazon I can't find anything that isn't specific to certain hardware/ports.
Every device has its own command set and provides different functions. There really is no official standard that covers more than a group of devices (all floppy disks, all IDE devices, etc).
You can find a list of ports and memory ranges used by the most important hardware on Ralf Brown's site. If you told me which device(s) you're interested in I could probably provide you with some additional papers and information.
regards,
gaf
|