Repository navigation
Expand file tree
/
Copy pathio.nas
More file actions
96 lines (78 loc) · 1.79 KB
/
Copy pathio.nas
File metadata and controls
96 lines (78 loc) · 1.79 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;
; io.nas
; 2016-01-30 by zlq
;
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[FORMAT "WCOFF"] ; 制作目标文件的模式
[INSTRSET "i486p"] ; 486の命令まで使いたいという記述
[BITS 32] ; 制作32位模式用的机械语言
[FILE "io.nas"] ; 源文件名信息
global _io_hlt,_io_cli,_io_sti
global _io_in8,_io_in16,_io_in32
global _io_out8,_io_out16,_io_out32
global _io_load_eflags,_io_store_eflags
global _load_gdtr,_load_idtr
; 以下是实际的函数
[SECTION .text] ; 目标文件中写了这些之后再写程序
_io_hlt: ; void io_hlt(void);
hlt
ret
_io_cli: ; void io_cli(void);
cli
ret
_io_sti: ; void io_sti(void);
sti
ret
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_io_in8: ; int io_in8(int port);
mov edx,[esp+4]
mov eax,0
in al,dx
ret
_io_in16:
mov edx,[esp+4]
mov eax,0
in ax,dx
ret
_io_in32:
mov edx,[esp+4]
in eax,dx
ret
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_io_out8:
mov edx,[esp+4]
mov al,[esp+8]
out dx,al
ret
_io_out16:
mov edx,[esp+4]
mov eax,[esp+8]
out dx,ax
ret
_io_out32:
mov edx,[esp+4]
mov eax,[esp+8]
out dx,eax
ret
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_io_load_eflags: ; int io_load_eflags(void);
pushfd ; 指push eflags
pop eax
ret
_io_store_eflags: ; void io_store_eflags(int flags);
mov eax,[esp+4]
push eax
popfd
ret
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_load_gdtr: ; void load_gdtr(int limit,int addr);
mov ax,[esp+4]
mov [esp+6],ax
lgdt [esp+6]
ret
_load_idtr: ; void load_idtr(int limit,int addr);
mov ax,[esp+4]
mov [esp+6],ax
lidt [esp+6]
ret