#define SERIAL_BASE 0x3f8 #define UART_LSR 0x5 #define UART_TX 0x0 #define UART_LSR_TXRDY 0x20 static int putc(char); static int inb(int port) { char in; __asm __volatile("in %%dx,%0" : "=a" (in) : "d" (port)); return (in); } static void outb(int port, char o) { __asm __volatile("out %0,%%dx" :: "a" (o), "d" (port)); } static void serial_out(char c) { while ((inb(SERIAL_BASE + UART_LSR) & UART_LSR_TXRDY) == 0); outb(SERIAL_BASE + UART_TX, c); } static int putc(char c) { serial_out(c); return (0); } int main(void) { putc('a'); putc('\n'); return (0); }