wok view syslinux/stuff/iso2exe/libdos.c @ rev 24126
Add eudev-lib
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Oct 14 06:54:52 2021 +0000 (2021-10-14) |
parents | 00bb1e4137c6 |
children |
line source
1 #include "libdos.h"
2 #asm
3 use16 86
4 #endasm
6 char *progname(void)
7 {
8 #asm
9 .bss
10 ._name lcomm 80
11 .text
12 push es
13 seg cs
14 mov es, [0x2C]
15 mov cx, #-1
16 xor di, di
17 xor al, al
18 loop1:
19 repne
20 scasb
21 scasb
22 jne loop1
23 lea si, [di+2]
24 push ds
25 push ds
26 push es
27 pop ds
28 pop es
29 mov di, ._name
30 push di
31 loop2:
32 lodsb
33 stosb
34 or al, al
35 jnz loop2
36 pop ax
37 pop ds
38 pop es
39 #endasm
40 }
42 #ifdef __SLEEP
43 void sleep(int seconds)
44 {
45 unsigned long n;
47 n = (seconds * 182) / 10;
48 #asm
49 push es
50 push #0
51 pop es
52 mov di, #0x46C
53 sleeplp:
54 mov cx, #0x8000
55 or dx, dx
56 jne siok
57 mov cx, ax
58 jcxz done
59 siok:
60 sub ax, cx
61 sbb dx, #0
62 seg es
63 add cx, [di]
64 zzz:
65 seg es
66 cmp cx, [di]
67 jne zzz
68 jmp sleeplp
69 done:
70 pop es
71 #endasm
72 }
73 #endif
75 int chdirname(char *path)
76 {
77 #asm
78 pop ax
79 pop bx
80 push bx
81 push ax
82 cmp byte ptr [bx+1], #0x3A
83 jne nodisk
84 mov dl, [bx]
85 or dl, #0x20
86 sub dl, #0x61
87 mov ah, #0x0E
88 push bx
89 int 0x21
90 pop bx
91 inc bx
92 inc bx
93 nodisk:
94 mov dx, bx
95 xor cx, cx
96 next:
97 mov al, [bx]
98 cmp al, #0x5C
99 jne tsteos
100 mov cx, bx
101 tsteos:
102 inc bx
103 or al, al
104 jnz next
105 cbw
106 jcxz quit
107 mov bx, cx
108 push [bx]
109 mov [bx], al
110 push bx
111 call chdir
112 pop bx
113 pop [bx]
114 quit:
115 ret
117 // int chdir(char *path)
118 _chdir:
119 pop ax
120 pop dx
121 push dx
122 push ax
123 chdir:
124 stc
125 mov ax, #0x713B
126 int 0x21
127 jnc chdireturn
128 mov ah, #0x3B
129 int 0x21
130 chdireturn:
131 sbb ax, ax
132 #endasm
133 }
135 void dosshutdown(void)
136 {
137 #asm
138 push bp
139 push si
140 push di
141 push ds
142 seg cs
143 mov stack+2, ss
144 seg cs
145 mov stack,sp
146 xor bx, bx
147 mov ds, bx // ds = 0
148 mov [bx+4], #step
149 mov [bx+6], cs
150 pushf
151 pop ax
152 or ax, #0x100 // set TF
153 push ax
154 popf
155 jmp far [bx+4*0x19]
156 stack:
157 .long 0
158 stepagain:
159 iret
160 step:
161 push si
162 push ds
163 mov si, sp
164 seg ss
165 lds si, [si+4]
166 cmp word ptr [si], #0x19CD
167 pop ds
168 pop si
169 jne stepagain
170 seg cs
171 lds di, stack
172 push ds
173 pop ss
174 mov sp, di
175 pop ds
176 pop di
177 pop si
178 pop bp
179 #endasm
180 }
182 int versiondos;
183 int dosversion(void)
184 {
185 #asm
186 mov ah, #0x30
187 int 0x21
188 cbw
189 mov _versiondos, ax
190 #endasm
191 }
193 void copycmdline(char store[])
194 {
195 #asm
196 pop cx
197 pop ax
198 push ax
199 push cx
200 push si
201 push di
202 push ds
203 pop es
204 mov si, #0x81
205 xchg ax, di
206 space:
207 seg cs
208 lodsb
209 cmp al, #0x20
210 je space
211 dec si
212 mov cx, #0x80/2
213 rep
214 seg cs
215 movsw
216 pop di
217 pop si
218 #endasm
219 }