-
Notifications
You must be signed in to change notification settings - Fork 0
/
io.s
20 lines (18 loc) · 856 Bytes
/
io.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
global outb ; make the label outb visible outside this file
global inb
; outb - send a byte to an I/O port
; stack: [esp + 8] the data byte
; [esp + 4] the I/O port
; [esp ] return address
outb:
mov al, [esp + 8] ; move the data to be sent into the al register
mov dx, [esp + 4] ; move the address of the I/O port into the dx register
out dx, al ; send the data to the I/O port
ret ; return to the calling function
; inb - returns a byte from the given I/O port
; stack: [esp + 4] The address of the I/O port
; [esp ] The return address
inb:
mov dx, [esp + 4] ; move the address of the I/O port to the dx register
in al, dx ; read a byte from the I/O port and store it in the al register
ret ; return the read byte