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
|
[bits 32]
global port_write8
global port_read8
; typedef enum port_type_t {
; PORT_TYPE_8BIT = 0,
; PORT_TYPE_8BIT_SLOW = 1,
; PORT_TYPE_16BIT = 2,
; PORT_TYPE_32BIT = 3
; } port_type_t;
PORT_TYPE_8BIT equ 0
PORT_TYPE_8BIT_SLOW equ 1
PORT_TYPE_16BIT equ 2
PORT_TYPE_32BIT equ 3
; void port_write8( port_t *port, uint8_t data );
port_write8:
push ebp
mov ebp, esp
mov ecx, [ebp+8]
mov edx, DWORD [ecx]
cmp edx, PORT_TYPE_8BIT
je .ok
int 10
.ok:
mov edx, DWORD [ecx+4]
movzx ax, BYTE [ebp+12]
out dx, al
leave
ret
; uint8_t port_read8( port_t *port )
port_read8:
push ebp
mov ebp, esp
mov ecx, DWORD [ebp+8]
mov edx, DWORD [ecx]
cmp edx, PORT_TYPE_8BIT
je .ok
int 11
.ok:
mov edx, [ecx+4]
in al, dx
leave
ret
|