wok view linld/stuff/src/CRTLX.ASM @ rev 19546

linld/tazboot: default conf in tazboot.cmd
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Dec 06 18:49:44 2016 +0100 (2016-12-06)
parents 7f92b23984dc
children e428345df29a
line source
1 ;***************************************************************
2 ;****** This file is distributed under GPL
3 ;***************************************************************
4 ideal
5 %crefref
6 %noincl
7 %nomacs
8 p386
10 group DGROUP _TEXT,_DATA,_BSS
11 assume cs:DGROUP,ds:DGROUP
13 segment _DATA byte public use16 'DATA'
15 tazboot_cmd db "tazboot.cmd",0
17 ends _DATA
19 segment _BSS byte public use16 'BSS'
21 ultoabuf db 12 dup (?)
23 ends _BSS
25 segment _TEXT byte public use16 'CODE'
27 ;***************************************************************
28 ;int strcmp(const char* a,const char* b);
29 ;***************************************************************
30 global _strcmp:near
31 proc _strcmp near
33 pop ax ;caller return address
34 pop cx ; a
35 pop bx ; b
36 push bx
37 push cx
38 push ax
39 push si
40 mov si,cx
41 sub bx,si
42 @@lp:
43 mov al,[bx+si]
44 sub al,[si]
45 jnz @@out
46 lodsb
47 cmp al,0
48 jne @@lp
49 @@out:
50 cbw
51 pop si
52 ret
54 endp _strcmp
57 ;***************************************************************
58 ;char strstr(const char* a,const char* b);
59 ;***************************************************************
60 global _strstr:near
61 proc _strstr near
63 pop ax ;caller return address
64 pop cx ; a
65 pop dx ; b
66 push dx
67 push cx
68 push ax
69 push si
70 @@loop:
71 xor ax,ax
72 mov si,cx
73 cmp [si],al ; *a
74 jz @@end ; return ax = NULL
75 mov bx,dx
76 sub bx,si
77 @@match:
78 or ah,[bx+si] ; *b
79 jz @@found
80 lodsb
81 sub ah,al
82 jz @@match
83 inc cx
84 jmp @@loop
85 @@found:
86 xchg ax,cx
87 @@end:
88 pop si
89 ret
91 endp _strstr
94 ;***************************************************************
95 ;int cpuhaslm(void)
96 ;***************************************************************
97 global _cpuhaslm:near
98 proc _cpuhaslm near
100 pushf
101 ; Check for oldies
102 mov bh, 0F0h
103 push bx ; < 286 : flags[12..15] are forced 1
104 popf ; = 286 : flags[12..15] are forced 0
105 pushf ; > 286 : only flags[15] is forced 0
106 pop dx
107 popf
108 add dh,bh ; NS=386+, NC=286
109 clc
110 js @@bad ;it is a 86/186/286, not a 386+
111 pushfd
112 pushfd
113 pop ebx
114 mov ecx,ebx
115 xor ebx,00100000h ; toggle CPUID feature bit 21
116 push ebx
117 popfd
118 pushfd
119 pop ebx
120 popfd
121 xor ebx,ecx
122 shr ebx,1+21 ; CPUID feature bit ?
123 jnc @@bad
124 mov eax,80000001h ; Extended Processor Info and Feature Bits
125 db 0Fh,0A2h ; cpuid
126 shr edx,1+29 ; LM feature bit ?
127 @@bad:
128 sbb ax,ax
129 ret
131 endp _cpuhaslm
134 ;***************************************************************
135 ;char *progname(void)
136 ;***************************************************************
137 global _progname:near
138 proc _progname near
140 push si di es
141 mov ah,30h
142 int 21h
143 cmp al,3
144 mov ax,0
145 jb @@skip
146 mov es,[cs:2Ch]
147 mov cx,-1
148 xor di,di
149 xor al,al
150 @@loop1:
151 repne
152 scasb
153 scasb
154 jne @@loop1
155 lea si,[di+2]
156 mov bx, si
157 extrn strlen:near
158 call near strlen
159 xchg ax,cx
160 inc cx
161 extrn malloc_or_die:near
162 call near malloc_or_die
163 xchg ax,di
164 push ds
165 push ds
166 push es
167 pop ds
168 pop es
169 push di
170 @@loop2:
171 lodsb
172 stosb
173 or al,al
174 jnz @@loop2
175 pop ax
176 pop ds
177 @@skip:
178 pop es di si
179 ret
181 endp _progname
184 ;***************************************************************
185 ;int chdir(char *path);
186 ;***************************************************************
187 global _chdir:near
188 proc _chdir near
190 pop ax
191 pop dx
192 push dx
193 push ax
194 chdir:
195 stc
196 mov ax,713Bh
197 int 21h
198 jnc @@end
199 mov ah,3Bh
200 int 21h
201 @@end:
202 sbb ax,ax
203 ret
205 endp _chdir
208 ;***************************************************************
209 ;int chdirname(char *path)
210 ;***************************************************************
211 global _chdirname:near
212 proc _chdirname near
214 pop ax
215 pop bx
216 push bx
217 push ax
219 cmp [byte bx+1],3Ah
220 jne @@nodisk
221 mov dl,[bx]
222 or dl,20h
223 sub dl,61h
224 mov ah,0Eh
225 push bx
226 int 21h
227 pop bx
228 inc bx
229 inc bx
230 @@nodisk:
231 mov dx,bx
232 xor cx,cx
233 @@next:
234 mov al,[bx]
235 cmp al,5Ch
236 jne @@tsteos
237 mov cx,bx
238 @@tsteos:
239 inc bx
240 or al,al
241 jnz @@next
242 cbw
243 jcxz @@end
244 mov bx,cx
245 push [word bx]
246 mov [bx],al
247 push bx
248 call chdir
249 pop bx
250 pop [word bx]
251 @@end:
252 ret
254 endp _chdirname
257 ;***************************************************************
258 ;char *ultoa(unsigned long n);
259 ;***************************************************************
260 global _ultoa:near
261 proc _ultoa near
263 pop ax
264 pop cx
265 pop dx
266 push dx
267 push cx
268 push ax ; DX:CX = n
269 push si
270 mov si,10
271 mov bx,offset ultoabuf+11
272 @@loop:
273 dec bx
274 xchg ax,dx
275 xor dx,dx
276 div si ; DX:AX = 0000:hi(n)
277 xchg ax,cx ; CX = hi(n)/10
278 div si ; DX:AX = hi(n)%10:lo(n)
279 xchg ax,cx ; CX = lo(n/10)
280 xchg ax,dx ; DX = hi(n)/10 = hi(n/10)
281 add al,'0'
282 mov [bx],al
283 mov ax,cx
284 or ax,dx
285 jnz @@loop
286 xchg ax,bx
287 pop si
288 ret
290 endp _ultoa
293 ;***************************************************************
294 ;unsigned long kver2ul(char *kernel_version);
295 ;***************************************************************
296 global _kver2ul:near
297 proc _kver2ul near
299 pop ax
300 pop dx
301 push dx
302 push ax
303 push bp si di
304 xor di,di
305 push di
306 push di
307 mov bp,sp
308 mov si,dx
309 inc di
310 inc di
311 mov cl,4
312 @@number:
313 xor ax,ax
314 @@digit:
315 shl al,cl
316 shl ax,cl
317 lodsb
318 sub al,30h
319 cmp al,9
320 jbe @@digit
321 mov [bp+di],ah
322 dec di
323 jns @@number
324 pop ax
325 pop dx
326 pop di si bp
327 kver2ulret:
328 ret
330 endp _kver2ul
333 ;***************************************************************
334 ;void try_default_args();
335 ;***************************************************************
336 global _try_default_args:near
337 proc _try_default_args near
339 mov bx,offset tazboot_cmd
340 extrn open:near
341 call near open
342 jc kver2ulret
343 mov cx,4096
344 extrn _heap_top:word
345 mov di,[_heap_top]
346 push cx
347 extrn read_cmdline:near
348 jmp near read_cmdline ; read_cmdline(ax,di,cx)
350 endp _try_default_args
352 ends _TEXT
354 end
356 ;###### END OF FILE ############################################