diff options
author | Simponic <loganthebean222@gmail.com> | 2021-03-01 15:17:24 -0700 |
---|---|---|
committer | Simponic <loganthebean222@gmail.com> | 2021-03-01 15:17:24 -0700 |
commit | c0c846cc15bbc4a14f705eeb923ed1024f4ee1a0 (patch) | |
tree | 9556cbe258bc72d263c33dc4d9876d4fb72402dc /src/port.c | |
parent | 09d1dcf3b115658283cb09a08986271398e8d8f8 (diff) | |
download | simponicos-c0c846cc15bbc4a14f705eeb923ed1024f4ee1a0.tar.gz simponicos-c0c846cc15bbc4a14f705eeb923ed1024f4ee1a0.zip |
Move to GitHub for flexing
Diffstat (limited to 'src/port.c')
-rw-r--r-- | src/port.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/port.c b/src/port.c new file mode 100644 index 0000000..2a19315 --- /dev/null +++ b/src/port.c @@ -0,0 +1,21 @@ +#include "port.h" + +uint8_t port_byte_in (uint8_t port) { + uint8_t result; + __asm__("in %%dx, %%al" : "=a" (result) : "d" (port)); + return result; +} + +void port_byte_out(uint8_t port, uint8_t data) { + __asm__("out %%al, %%dx" : :"a" (data), "d" (port)); +} + +uint16_t port_word_in (uint16_t port) { + uint16_t result; + __asm__("in %%dx, %%ax" : "=a" (result) : "d" (port)); + return result; +} + +void port_word_out (uint16_t port, uint16_t data) { + __asm__("out %%ax, %%dx" : :"a" (data), "d" (port)); +} |