Device Access
This post is regarding a presentation that I did in SPO600 where I talked about device access in low level languages.
Access using I/O Ports
I/O ports: These look just a memory cell to a computer but they connect any data written or read from it to a device that is connected to the computer.MOV DX, 0487 ; Port number. MOV AL, 1 ; Number to write to the port. OUT DX, AL ; Write to the port. IN DX, AL ; Read from the port.
Danger:
Accessing devices in this way is dangerous. Every port cannot be accessed in the same way, Some ports are read only, and some are write only and some are both. If you don’t know exactly what port you are using you risk damaging any device that is accessing that port.
Access using Interrupts
An alternative method is using software interrupts to gain access to a device, This is often used in more complex devices such as the mouse in order to simplify accessing it.MOV AX, 0 ; Access subfunction 0 of int 33h INT 33 ; Make the interrupt call
Platform / architecture Issues
I/O and device instructions are very processor dependent, due to the details of how a processor moves data in and out, most of the source code is coded specifically for a platform. For example in the linux kernel they have many different files including io.h that are stored in folders specific to the architecture.Arm: io.h
x86: io.h
Conclusions
I was unable to find to much information about this topic and Chris Tyler, my professor for SPO600, pointed out to me that this is because all the device access SHOULD be handled by the operating system unless you are writing for device drivers or doing embedded programming.Resources
Thanks for reading
No comments:
Post a Comment