I/O操作関数inb,outb,inw,outw
1353 ワード
; Copyright (C) 2011 Alen D. Archuleta ([email protected])
; I/O ,
; I/O , X86 PC I/O ,
; 、 ( )
; , I/O :
;in, out( DX,AX,AL )
; C , GNU inline asm,
; , 。
;inb I/O (BYTE, HALF-WORD)
;outb I/O (BYTE, HALF-WORD)
;inw I/O (WORD, )
;outw I/O (WORD, )
;byte inb(word port);
;word inw(word port);
;void outb(word port, byte value);
;void outw(word port, word value);
; :
;nasm -f elf -o io.o io.asm
;
global inb, outb, inw, outw
[section .text]
inb:
xor eax, eax ; C , EAX
push dx ; DX ,
; , 4 ,
; ,
mov dx, [esp + 4]
in al, dx
pop dx ; DX
ret
outb:
push dx
mov dx, [esp + 4]
mov al, [esp + 6]
out dx, al
pop dx
ret
inw:
xor eax, eax
push dx
mov dx, [esp + 4]
in ax, dx
pop dx
ret
outw:
push dx
mov dx, [esp + 4]
mov ax, [esp + 6]
out dx, ax
pop dx
ret
:http://www.live83.cn/?p=103