Here are my "vanilla" assembly routines:
read_port:
mov edx, [esp + 4]
in al, dx
ret
write_port:
mov edx, [esp + 4]
mov eax, [esp + 4 + 4]
out dx, al
ret
read_port_word: ;Btw is there a better way to do this??? I use gcc. Something like inb/outb?
mov edx, [esp + 4]
in ax, dx
ret
write_port_word:
mov edx, [esp + 4]
mov eax, [esp + 4 + 4]
out dx, ax
ret
I make these global and call them in my C routines. I'm using gcc, and I suspect there are already macros for this!
Also, if I write_port_word to a port of 1 byte size, what happens? Error? Or the lower byte is transferred? Do I even need these many routines?
What is the suggested way to solve this issue?