-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathport.s
More file actions
81 lines (64 loc) · 1.31 KB
/
port.s
File metadata and controls
81 lines (64 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
.section .text
.global outb
.global inb
.global inw
.global insw
.global outsw
.type outb, @function
# void outb(uint16_t port, uint8_t value)
outb:
movzwl 4(%esp), %edx
movzbl 8(%esp), %eax
outb %al, %dx
ret
.size outb, . - outb
.type inb, @function
# uint8_t inb(uint16_t port)
inb:
xorl %eax, %eax
movzwl 4(%esp), %edx
inb %dx, %al
ret
.size inb, . - inb
.type inw, @function
# uint16_t inw(uint16_t port)
inw:
xorl %eax, %eax
movzwl 4(%esp), %edx
inw %dx, %ax
ret
.size inw, . - inw
.type insw, @function
# void insw(uint16_t port, void *addr, unsigned int count)
insw:
pushl %edi
movl 8(%esp), %edx # port
movl 12(%esp), %edi # addr
movl 16(%esp), %ecx # count
xorl %eax, %eax
.insw_startLoop:
cmpl %eax, %ecx
je .insw_end
insw
incl %eax
jmp .insw_startLoop
.insw_end:
popl %edi
ret
.type outsw, @function
# void outsw(uint16_t port, void *addr, unsigned int count)
outsw:
pushl %esi
movl 8(%esp), %edx # port
movl 12(%esp), %esi # addr
movl 16(%esp), %ecx # count
xorl %eax, %eax
.outsw_startLoop:
cmpl %eax, %ecx
je .outsw_end
outsw
incl %eax
jmp .outsw_startLoop
.outsw_end:
popl %esi
ret