>  2005/03/21 (月) 01:32:33        [qwerty]
> なんとなくわかってきた(;´Д`)クシコ
> ついでにもうイッコ教えて(;´人`)
> 例えば俺がCでAT互換機用の新OS開発しようと思ったら
> どうやってデバイスドライバ作ればいいの?
> どうやってIOポートアドレス指定すればいいのかわからない
> んですけど
> BIOSルーチンコールするとか?

u_char
inb(u_int port)
{
        u_char  data;
        /*
         * We use %%dx and not %1 here because i/o is done at %dx and not at
         * %edx, while gcc generates inferior code (movw instead of movl)
         * if we tell it to load (u_short) port.
         */
        __asm __volatile("inb %%dx,%0" : "=a" (data) : "d" (port));
        return (data);
}
void
outb(u_int port, u_char data)
{
        u_char  al;
        /*
         * Use an unnecessary assignment to help gcc's register allocator.
         * This make a large difference for gcc-1.40 and a tiny difference
         * for gcc-2.6.0.  For gcc-1.40, al had to be ``asm("ax")'' for
         * best results.  gcc-2.6.0 can't handle this.
         */
        al = data;
        __asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port));
}

参考:2005/03/21(月)01時29分18秒