rev |
line source |
pascal@19515
|
1 ;***************************************************************
|
pascal@19515
|
2 ;****** This file is distributed under GPL
|
pascal@19515
|
3 ;***************************************************************
|
pascal@19515
|
4 ideal
|
pascal@19515
|
5 %crefref
|
pascal@19515
|
6 %noincl
|
pascal@19515
|
7 %nomacs
|
pascal@19636
|
8 ifdef NO386
|
pascal@19636
|
9 p8086
|
pascal@19636
|
10 else
|
pascal@19515
|
11 p386
|
pascal@19636
|
12 endif
|
pascal@19515
|
13
|
pascal@19515
|
14 group DGROUP _TEXT,_DATA,_BSS
|
pascal@19515
|
15 assume cs:DGROUP,ds:DGROUP
|
pascal@19515
|
16
|
pascal@19515
|
17 segment _DATA byte public use16 'DATA'
|
pascal@19515
|
18
|
pascal@19546
|
19 global _heap_top:word
|
pascal@19546
|
20 extrn _bss_end
|
pascal@19546
|
21 _heap_top dw _bss_end
|
pascal@19546
|
22 msg_hang db "High mem corrupted - not exiting to DOS"
|
pascal@19546
|
23 msg_crlf db 13,10,0
|
pascal@19538
|
24 vcpi_alloc_err db "vcpi "
|
pascal@19571
|
25 msg_malloc db "malloc failure",0
|
pascal@19825
|
26 ifdef EXTRA
|
pascal@19825
|
27 tazboot_cmd db "tazboot.cmd",0
|
pascal@19825
|
28 endif
|
pascal@19515
|
29
|
pascal@19515
|
30 ends _DATA
|
pascal@19515
|
31
|
pascal@19515
|
32 segment _BSS byte public use16 'BSS'
|
pascal@19515
|
33
|
pascal@19515
|
34 global _no_exit:byte
|
pascal@19515
|
35 _no_exit db ?
|
pascal@19515
|
36 filecnt db ? ; in fact 0 minus file count...
|
pascal@19515
|
37 nextfilename dw ?
|
pascal@19571
|
38 ifdef LARGE_IMAGES
|
pascal@19571
|
39 curdata dw ?
|
pascal@19571
|
40 endif
|
pascal@19825
|
41 ifdef EXTRA
|
pascal@19825
|
42 ultoabuf db 12 dup (?)
|
pascal@19825
|
43 endif
|
pascal@19515
|
44
|
pascal@19515
|
45 ends _BSS
|
pascal@19515
|
46
|
pascal@19515
|
47 segment _TEXT byte public use16 'CODE'
|
pascal@19515
|
48
|
pascal@19515
|
49 ;***************************************************************
|
pascal@19538
|
50 ;char* strcpy(const char* a, const char* b);
|
pascal@19580
|
51 ;char* strcat(const char* a, const char* b);
|
pascal@19634
|
52 ;char* strcatb(const char* a, const char* b);
|
pascal@19538
|
53 ;***************************************************************
|
pascal@19826
|
54 global _strcatb:near
|
pascal@19826
|
55 proc _strcatb near
|
pascal@19538
|
56
|
pascal@19826
|
57 ifdef EXTRA
|
pascal@19826
|
58 mov dl,3
|
pascal@19580
|
59 db 0bbh ; mov bx,imm opcode
|
pascal@19580
|
60 global _strcat:near
|
pascal@19580
|
61 _strcat:
|
pascal@19580
|
62 mov dl,1
|
pascal@19634
|
63 db 0bbh ; mov bx,imm opcode
|
pascal@19826
|
64 global _strcpy:near
|
pascal@19826
|
65 _strcpy:
|
pascal@19826
|
66 mov dl,0
|
pascal@19826
|
67 endif
|
pascal@19538
|
68 pop ax ;caller return address
|
pascal@19538
|
69 pop cx ; a
|
pascal@19538
|
70 pop bx ; b
|
pascal@19538
|
71 push bx
|
pascal@19538
|
72 push cx
|
pascal@19538
|
73 push ax
|
pascal@19538
|
74 push si
|
pascal@19538
|
75 mov si,cx
|
pascal@19826
|
76 ifdef EXTRA
|
pascal@19538
|
77 shr dl,1
|
pascal@19538
|
78 jnc @@nocat
|
pascal@19826
|
79 endif
|
pascal@19538
|
80 @@catlp:
|
pascal@19538
|
81 lodsb
|
pascal@19538
|
82 cmp al,0
|
pascal@19538
|
83 jne @@catlp
|
pascal@19538
|
84 dec si
|
pascal@19826
|
85 ifdef EXTRA
|
pascal@19538
|
86 shr dl,1
|
pascal@19538
|
87 jnc @@nocat
|
pascal@19826
|
88 endif
|
pascal@19538
|
89 cmp cx,si
|
pascal@19538
|
90 jz @@nocat
|
pascal@19538
|
91 mov [word si],20h
|
pascal@19538
|
92 inc si
|
pascal@19538
|
93 @@nocat:
|
pascal@19538
|
94 sub bx,si
|
pascal@19538
|
95 @@cpylp:
|
pascal@19538
|
96 mov al,[bx+si]
|
pascal@19538
|
97 mov [si],al
|
pascal@19538
|
98 inc si
|
pascal@19538
|
99 cmp al,0
|
pascal@19538
|
100 jne @@cpylp
|
pascal@19538
|
101 mov ax,cx
|
pascal@19538
|
102 pop si
|
pascal@19538
|
103 ret
|
pascal@19538
|
104
|
pascal@19826
|
105 endp _strcatb
|
pascal@19538
|
106
|
pascal@19538
|
107
|
pascal@19538
|
108 ;***************************************************************
|
pascal@19538
|
109 ;void* malloc(unsigned sz);
|
pascal@19538
|
110 ;***************************************************************
|
pascal@19538
|
111 global _malloc:near
|
pascal@19538
|
112 proc _malloc near
|
pascal@19538
|
113
|
pascal@19538
|
114 pop ax ;caller return address
|
pascal@19538
|
115 pop cx ; sz
|
pascal@19538
|
116 push cx
|
pascal@19538
|
117 push ax
|
pascal@19538
|
118 global malloc:near ; malloc(cx)
|
pascal@19571
|
119 malloc: ; keep CX, use AX,BX
|
pascal@19538
|
120 mov ax,[_heap_top]
|
pascal@19571
|
121 mov bx,-1400h ; MIN_STACK=_1k+PAGE_SIZE
|
pascal@19571
|
122 add bx,sp
|
pascal@19571
|
123 sub bx,ax ; can't overflow
|
pascal@19571
|
124 cmp bx,cx
|
pascal@19538
|
125 mov bx,offset msg_malloc
|
pascal@19538
|
126 jb puts
|
pascal@19538
|
127 add [_heap_top],cx ; _BEG has zero'd heap
|
pascal@19538
|
128 ;mov bx,ax
|
pascal@19538
|
129 @@zalloc:
|
pascal@19538
|
130 ;mov [byte bx],0
|
pascal@19538
|
131 ;inc bx ; ZF=0
|
pascal@19538
|
132 ;loop @@zalloc
|
pascal@19538
|
133 ret
|
pascal@19538
|
134
|
pascal@19538
|
135 endp _malloc
|
pascal@19538
|
136
|
pascal@19538
|
137
|
pascal@19538
|
138 ;***************************************************************
|
pascal@19515
|
139 ;void puts(const char* s):
|
pascal@19515
|
140 ;***************************************************************
|
pascal@19515
|
141 global _puts:near
|
pascal@19515
|
142 proc _puts near
|
pascal@19515
|
143
|
pascal@19515
|
144 pop ax ;caller return address
|
pascal@19515
|
145 pop bx ; s
|
pascal@19515
|
146 push bx
|
pascal@19515
|
147 push ax
|
pascal@19515
|
148 global puts:near ; puts(bx)
|
pascal@19515
|
149 puts:
|
pascal@19515
|
150 call putsz
|
pascal@19515
|
151 mov bx,offset msg_crlf
|
pascal@19515
|
152
|
pascal@19515
|
153 global putsz:near ; putsz(bx)
|
pascal@19515
|
154 putsz:
|
pascal@19515
|
155 push bx
|
pascal@19515
|
156 call strlen
|
pascal@19515
|
157 pop dx
|
pascal@19515
|
158 xchg ax,cx
|
pascal@19515
|
159 mov bx,1
|
pascal@19515
|
160 mov ah,40h
|
pascal@19538
|
161 int 21h
|
pascal@19538
|
162 xor ax,ax ; ZF=1 (for malloc failure)
|
pascal@19538
|
163 ret
|
pascal@19515
|
164
|
pascal@19515
|
165 endp _puts
|
pascal@19515
|
166
|
pascal@19515
|
167
|
pascal@19515
|
168 ;***************************************************************
|
pascal@19538
|
169 ;int fileattr(const char* name);
|
pascal@19538
|
170 ;***************************************************************
|
pascal@19538
|
171 global _fileattr:near
|
pascal@19538
|
172 proc _fileattr near
|
pascal@19538
|
173
|
pascal@19538
|
174 pop ax ;caller return address
|
pascal@19538
|
175 pop dx ; name
|
pascal@19538
|
176 push dx
|
pascal@19538
|
177 push ax
|
pascal@19538
|
178 mov ax,4300h
|
pascal@19538
|
179 int 21h
|
pascal@19538
|
180 xchg ax,cx
|
pascal@19538
|
181 jmp chkc
|
pascal@19538
|
182
|
pascal@19538
|
183 endp _fileattr
|
pascal@19538
|
184
|
pascal@19538
|
185
|
pascal@19538
|
186 ;***************************************************************
|
pascal@19546
|
187 ;int open(const char* name, int flags=O_RDONLY);
|
pascal@19515
|
188 ;***************************************************************
|
pascal@19515
|
189 global _open:near
|
pascal@19515
|
190 proc _open near
|
pascal@19515
|
191
|
pascal@19546
|
192 pop ax ;caller return address
|
pascal@19515
|
193 pop bx ; name
|
pascal@19546
|
194 push bx
|
pascal@19515
|
195 push ax
|
pascal@19546
|
196 global open:near ; open(bx)
|
pascal@19515
|
197 open:
|
pascal@19515
|
198 mov dx,bx
|
pascal@19546
|
199 mov ax,3d00h
|
pascal@19515
|
200 dos:
|
pascal@19515
|
201 int 21h
|
pascal@19538
|
202 chkc:
|
pascal@19515
|
203 jnc doret
|
pascal@19515
|
204 fail:
|
pascal@19515
|
205 sbb ax,ax ; ax=-1 CF
|
pascal@19515
|
206 cwd
|
pascal@19515
|
207 doret:
|
pascal@19515
|
208 ifndef NO386
|
pascal@19538
|
209 push dx ; see next_chunk:lseek
|
pascal@19538
|
210 push ax
|
pascal@19538
|
211 pop eax
|
pascal@19515
|
212 endif
|
pascal@19515
|
213 ret
|
pascal@19515
|
214
|
pascal@19515
|
215 endp _open
|
pascal@19515
|
216
|
pascal@19515
|
217
|
pascal@19515
|
218 ;***************************************************************
|
pascal@19515
|
219 ;int close(int fd);
|
pascal@19515
|
220 ;***************************************************************
|
pascal@19515
|
221 global _close:near
|
pascal@19515
|
222 proc _close near
|
pascal@19515
|
223
|
pascal@19515
|
224 pop ax ;caller return address
|
pascal@19515
|
225 pop bx ; fd
|
pascal@19515
|
226 push bx
|
pascal@19515
|
227 push ax
|
pascal@19515
|
228 global close:near ; close(bx)
|
pascal@19515
|
229 close:
|
pascal@19515
|
230 mov ah,3Eh
|
pascal@19515
|
231 or bx,bx
|
pascal@19515
|
232 jnz dos
|
pascal@19515
|
233 ret
|
pascal@19515
|
234
|
pascal@19515
|
235 endp _close
|
pascal@19515
|
236
|
pascal@19515
|
237
|
pascal@19515
|
238 ;***************************************************************
|
pascal@19515
|
239 ;int read(int fd, void* data, int sz);
|
pascal@19580
|
240 ;int write(int fd, const void* data, int sz);
|
pascal@19515
|
241 ;***************************************************************
|
pascal@19515
|
242 global _read:near
|
pascal@19515
|
243 proc _read near
|
pascal@19515
|
244
|
pascal@19580
|
245 stc
|
pascal@19634
|
246 db 0B0h ; mov al,im
|
pascal@19580
|
247 global _write:near
|
pascal@19580
|
248 clc
|
pascal@19580
|
249 pop ax ;caller return address
|
pascal@19580
|
250 pop bx ; fd
|
pascal@19580
|
251 pop dx ; data
|
pascal@19515
|
252 pop cx ; sz
|
pascal@19515
|
253 push cx
|
pascal@19515
|
254 push dx
|
pascal@19580
|
255 push bx
|
pascal@19580
|
256 push ax
|
pascal@19580
|
257 mov ah,40h
|
pascal@19580
|
258 sbb ah,0
|
pascal@19515
|
259 jcxz fail
|
pascal@19515
|
260 jmp dos
|
pascal@19515
|
261
|
pascal@19515
|
262 endp _read
|
pascal@19515
|
263
|
pascal@19825
|
264 ifdef EXTRA
|
pascal@19515
|
265 ;***************************************************************
|
pascal@19825
|
266 ;long lseekset(int fd, unsigned long sz);
|
pascal@19515
|
267 ;***************************************************************
|
pascal@19571
|
268 global _lseekset:near
|
pascal@19571
|
269 proc _lseekset near
|
pascal@19515
|
270
|
pascal@19515
|
271 pop ax ;caller return address
|
pascal@19515
|
272 pop bx ; fd
|
pascal@19571
|
273 pop dx ; sz lo
|
pascal@19571
|
274 pop cx ; sz hi
|
pascal@19571
|
275 push cx
|
pascal@19515
|
276 push dx
|
pascal@19825
|
277
|
pascal@19825
|
278 else
|
pascal@19825
|
279 ;***************************************************************
|
pascal@19825
|
280 ;long seekset(int fd, unsigned sz);
|
pascal@19825
|
281 ;***************************************************************
|
pascal@19825
|
282 global _seekset:near
|
pascal@19825
|
283 proc _seekset near
|
pascal@19825
|
284
|
pascal@19825
|
285 xor cx,cx
|
pascal@19825
|
286 pop ax ;caller return address
|
pascal@19825
|
287 pop bx ; fd
|
pascal@19825
|
288 pop dx ; sz
|
pascal@19825
|
289 push dx
|
pascal@19825
|
290 endif
|
pascal@19825
|
291
|
pascal@19515
|
292 push bx
|
pascal@19515
|
293 push ax
|
pascal@19571
|
294 global lseekset:near
|
pascal@19571
|
295 lseekset:
|
pascal@19571
|
296 clc
|
pascal@19634
|
297 db 0B0h ; mov al,im
|
pascal@19571
|
298 global rewind:near
|
pascal@19634
|
299 rewind: ; rewind(bx)
|
pascal@19634
|
300 stc
|
pascal@19571
|
301 mov ax,4200h
|
pascal@19571
|
302 jnc dos
|
pascal@19571
|
303 lseek0: ; lseek0(bx,ax=dir)
|
pascal@19571
|
304 cwd
|
pascal@19571
|
305 xor cx,cx
|
pascal@19515
|
306 jmp dos
|
pascal@19515
|
307
|
pascal@19825
|
308 ifdef EXTRA
|
pascal@19571
|
309 endp _lseekset
|
pascal@19825
|
310 else
|
pascal@19825
|
311 endp _seekset
|
pascal@19825
|
312 endif
|
pascal@19825
|
313
|
pascal@19825
|
314 ifdef EXTRA
|
pascal@19825
|
315 struc isostate ; struct isostate {
|
pascal@19825
|
316 fd dw ? ; 0 int fd;
|
pascal@19825
|
317 fileofs dd ? ; 2 unsigned long fileofs;
|
pascal@19825
|
318 filesize dd ? ; 6 unsigned long filesize;
|
pascal@19825
|
319 filemod dw ? ;10 unsigned short filemod;
|
pascal@19825
|
320 filename dw ? ;12 char *filename;
|
pascal@19825
|
321 dirofs dd ? ;14 unsigned long dirofs;
|
pascal@19825
|
322 dirsize dd ? ;16 unsigned long dirsize;
|
pascal@19825
|
323 curdirofs dd ? ;20 unsigned long curdirofs;
|
pascal@19825
|
324 curdirsize dd ? ;24 unsigned long curdirsize;
|
pascal@19825
|
325 curpos dd ? ;28 unsigned long curpos;
|
pascal@19825
|
326 ends ; } isostate;
|
pascal@19825
|
327 ;***************************************************************
|
pascal@19825
|
328 ;unsigned long isolseek(const unsigned long *offset);
|
pascal@19825
|
329 ;***************************************************************
|
pascal@19825
|
330 global _isolseek:near
|
pascal@19825
|
331 proc _isolseek near
|
pascal@19825
|
332
|
pascal@19825
|
333 pop ax
|
pascal@19825
|
334 pop bx
|
pascal@19825
|
335 push bx
|
pascal@19825
|
336 push ax
|
pascal@19825
|
337 mov dx,[bx]
|
pascal@19825
|
338 mov cx,[bx+2]
|
pascal@19825
|
339 extrn _isostate:isostate
|
pascal@19825
|
340 mov bx,[_isostate.fd]
|
pascal@19825
|
341 jmp lseekset ; (bx=fd, sz=cx:dx)
|
pascal@19825
|
342
|
pascal@19825
|
343 endp _isolseek
|
pascal@19825
|
344 endif
|
pascal@19515
|
345
|
pascal@19515
|
346
|
pascal@19515
|
347 ;***************************************************************
|
pascal@19515
|
348 ;int strlen(const char* s);
|
pascal@19515
|
349 ;***************************************************************
|
pascal@19515
|
350 global _strlen:near
|
pascal@19515
|
351 proc _strlen near
|
pascal@19515
|
352
|
pascal@19515
|
353 pop ax ;caller return address
|
pascal@19515
|
354 pop bx ; s
|
pascal@19515
|
355 push bx
|
pascal@19515
|
356 push ax
|
pascal@19515
|
357 global strlen:near ; strlen(bx)
|
pascal@19515
|
358 strlen:
|
pascal@19515
|
359 mov cx,bx
|
pascal@19515
|
360 jcxz @@end
|
pascal@19515
|
361 dec bx
|
pascal@19515
|
362 @@lenlp:
|
pascal@19515
|
363 inc bx
|
pascal@19515
|
364 cmp [byte bx],0
|
pascal@19515
|
365 jne @@lenlp
|
pascal@19515
|
366 sub bx,cx
|
pascal@19515
|
367 @@end:
|
pascal@19515
|
368 xchg ax,bx
|
pascal@19515
|
369 ret
|
pascal@19515
|
370
|
pascal@19515
|
371 endp _strlen
|
pascal@19515
|
372
|
pascal@19515
|
373
|
pascal@19515
|
374 ;***************************************************************
|
pascal@19515
|
375 ;int strhead(const char* a,const char* b);
|
pascal@19515
|
376 ;***************************************************************
|
pascal@19515
|
377 global _strhead:near
|
pascal@19515
|
378 proc _strhead near
|
pascal@19515
|
379
|
pascal@19515
|
380 pop cx ;caller return address
|
pascal@19634
|
381 pop bx ; a
|
pascal@19634
|
382 pop ax ; b
|
pascal@19634
|
383 push ax
|
pascal@19515
|
384 push bx
|
pascal@19515
|
385 push cx
|
pascal@19515
|
386 @@loop:
|
pascal@19634
|
387 xchg ax,bx
|
pascal@19515
|
388 mov cl,[bx] ; cl = *b++
|
pascal@19515
|
389 inc bx
|
pascal@19515
|
390 or cl,cl ; clear C
|
pascal@19515
|
391 jz fail ; return 0
|
pascal@19515
|
392 xchg ax,bx
|
pascal@19515
|
393 xor cl,[bx] ; cl -= *a++
|
pascal@19634
|
394 inc bx
|
pascal@19515
|
395 and cl,0dfh ; case insensitive
|
pascal@19634
|
396 jz @@loop
|
pascal@19634
|
397 ret ; return b (is not 0)
|
pascal@19515
|
398
|
pascal@19515
|
399 endp _strhead
|
pascal@19515
|
400
|
pascal@19515
|
401
|
pascal@19515
|
402 ;***************************************************************
|
pascal@19515
|
403 ;char* malloc_or_die(unsigned size);
|
pascal@19515
|
404 ;***************************************************************
|
pascal@19515
|
405 global _malloc_or_die:near
|
pascal@19515
|
406 proc _malloc_or_die near
|
pascal@19515
|
407
|
pascal@19515
|
408 pop ax ;caller return address
|
pascal@19515
|
409 pop cx ; size
|
pascal@19515
|
410 push cx
|
pascal@19515
|
411 push ax
|
pascal@19515
|
412 global malloc_or_die:near ; malloc_or_die(cx)
|
pascal@19515
|
413 malloc_or_die:
|
pascal@19515
|
414 call malloc
|
pascal@19538
|
415 jz _exit
|
pascal@19515
|
416 ret
|
pascal@19515
|
417
|
pascal@19515
|
418 endp _malloc_or_die
|
pascal@19515
|
419
|
pascal@19515
|
420
|
pascal@19515
|
421 ;***************************************************************
|
pascal@19515
|
422 ;int die(const char* msg);
|
pascal@19538
|
423 ;int exit();
|
pascal@19515
|
424 ;int abort();
|
pascal@19515
|
425 ;***************************************************************
|
pascal@19515
|
426 global _die:near
|
pascal@19515
|
427 proc _die near
|
pascal@19515
|
428
|
pascal@19515
|
429 pop ax ;caller return address
|
pascal@19515
|
430 pop bx ; s
|
pascal@19515
|
431 push bx
|
pascal@19515
|
432 push ax
|
pascal@19515
|
433 global die:near ; die(bx)
|
pascal@19515
|
434 die:
|
pascal@19515
|
435 call puts
|
pascal@19538
|
436 global _exit:near
|
pascal@19538
|
437 _exit:
|
pascal@19515
|
438 mov al,[_no_exit]
|
pascal@19515
|
439 cmp al,0
|
pascal@19515
|
440 jne @@hang
|
pascal@19515
|
441 extrn exit:near
|
pascal@19515
|
442 inc ax
|
pascal@19515
|
443 jmp near exit
|
pascal@19515
|
444 @@hang:
|
pascal@19515
|
445 mov bx, offset msg_hang
|
pascal@19515
|
446 call puts
|
pascal@19515
|
447 global _abort:near
|
pascal@19515
|
448 _abort:
|
pascal@19515
|
449 cli
|
pascal@19515
|
450 @@stop:
|
pascal@19515
|
451 hlt
|
pascal@19515
|
452 jmp @@stop
|
pascal@19515
|
453
|
pascal@19515
|
454 endp _die
|
pascal@19515
|
455
|
pascal@19546
|
456 struc image_himem ;struct image_himem {
|
pascal@19546
|
457 fd dw ? ; 0 int fd;
|
pascal@19546
|
458 fallback dd ? ; 2 u32 fallback;
|
pascal@19546
|
459 size dd ? ; 6 u32 size;
|
pascal@19546
|
460 remaining dd ? ;10 u32 remaining;
|
pascal@19546
|
461 buf dd ? ;14 u32 buf;
|
pascal@19546
|
462 bufv dw ? ;18 u32 *bufv;
|
pascal@19546
|
463 errmsg dw ? ;20 char *errmsg;
|
pascal@19546
|
464 chunk_size dd ? ;22 u32 chunk_size;
|
pascal@19546
|
465 next_chunk dw ? ;26 void (*next_chunk)(struct image_himem *);
|
pascal@19546
|
466 state dw ? ;28 u16 state;
|
pascal@19546
|
467 fd2close dw ? ;30 u16 fd2close;
|
pascal@19546
|
468 ends ;};
|
pascal@19515
|
469
|
pascal@19636
|
470 ;***************************************************************
|
pascal@19636
|
471 ;void next_chunk(struct image_himem *di);
|
pascal@19636
|
472 ;***************************************************************
|
pascal@19636
|
473 proc next_chunk near
|
pascal@19636
|
474
|
pascal@19636
|
475 push si
|
pascal@19636
|
476 mov bx,[(image_himem di).fd]
|
pascal@19636
|
477 call close
|
pascal@19636
|
478 ifndef NO386
|
pascal@19636
|
479 xor eax,eax
|
pascal@19636
|
480 else
|
pascal@19636
|
481 xor ax,ax
|
pascal@19636
|
482 endif
|
pascal@19636
|
483 cwd
|
pascal@19636
|
484 mov [(image_himem di).fd],ax
|
pascal@19636
|
485 mov bx,[(image_himem di).state]
|
pascal@19636
|
486 cmp al,[bx] ; ""
|
pascal@19636
|
487 jz @@end
|
pascal@19636
|
488 mov si,bx
|
pascal@19636
|
489 @@scan:
|
pascal@19636
|
490 lodsb
|
pascal@19636
|
491 mov cx,si
|
pascal@19636
|
492 cmp al,','
|
pascal@19636
|
493 jz @@eos
|
pascal@19636
|
494 cmp al,0
|
pascal@19636
|
495 jnz @@scan
|
pascal@19636
|
496 dec cx
|
pascal@19636
|
497 @@eos:
|
pascal@19636
|
498 mov [(image_himem di).state],cx
|
pascal@19636
|
499 dec si
|
pascal@19636
|
500 push [word si]
|
pascal@19636
|
501 mov [byte si],dl ; set temp eos
|
pascal@19636
|
502 call open
|
pascal@19636
|
503 pop [word si] ; restore string
|
pascal@19636
|
504 jc @@die
|
pascal@19636
|
505 mov [(image_himem di).fd],ax
|
pascal@19636
|
506 mov [(image_himem di).fd2close],ax
|
pascal@19636
|
507 xchg ax,bx
|
pascal@19636
|
508 mov ax,4202h ; SEEK_END
|
pascal@19636
|
509 call lseek0
|
pascal@19636
|
510 @@die:
|
pascal@19636
|
511 mov bx,[(image_himem di).errmsg]
|
pascal@19636
|
512 jc die
|
pascal@19636
|
513 mov bx,[(image_himem di).fd]
|
pascal@19636
|
514 ifndef NO386
|
pascal@19636
|
515 push eax
|
pascal@19636
|
516 call rewind
|
pascal@19636
|
517 pop eax
|
pascal@19636
|
518 @@end:
|
pascal@19636
|
519 mov [(image_himem di).chunk_size],eax
|
pascal@19636
|
520 else
|
pascal@19636
|
521 push ax
|
pascal@19636
|
522 push dx
|
pascal@19636
|
523 call rewind
|
pascal@19636
|
524 pop dx
|
pascal@19636
|
525 pop ax
|
pascal@19636
|
526 @@end:
|
pascal@19636
|
527 mov [word (image_himem di).chunk_size],ax
|
pascal@19636
|
528 mov [word ((image_himem di).chunk_size)+2],dx
|
pascal@19636
|
529 endif
|
pascal@19636
|
530 pop si
|
pascal@19636
|
531 ret
|
pascal@19636
|
532
|
pascal@19636
|
533 endp next_chunk
|
pascal@19636
|
534
|
pascal@19636
|
535
|
pascal@19571
|
536 ifdef LARGE_IMAGES
|
pascal@19571
|
537 struc data_himem ;struct data_himem {
|
pascal@19571
|
538 first dd ? ; 0 u32 first;
|
pascal@19571
|
539 cacheidx dw ? ; 4 int cacheidx;
|
pascal@19571
|
540 pageidx dw ? ; 6 int pageidx;
|
pascal@19571
|
541 cache dd 1024 dup(?) ; 8 int cache;
|
pascal@19571
|
542 page dd 1024 dup(?) ;4104 int page;
|
pascal@19571
|
543 ends ;}; // size=8200
|
pascal@19571
|
544 endif
|
pascal@19571
|
545
|
pascal@19515
|
546 ;***************************************************************
|
pascal@19538
|
547 ;u32* malloc_bufv_or_die(struct image_himem *m);
|
pascal@19538
|
548 ;***************************************************************
|
pascal@19538
|
549 global _malloc_bufv_or_die:near
|
pascal@19538
|
550 proc _malloc_bufv_or_die near
|
pascal@19538
|
551
|
pascal@19636
|
552 p386
|
pascal@19538
|
553 pop bx ;caller return address
|
pascal@19538
|
554 pop ax
|
pascal@19538
|
555 push ax
|
pascal@19538
|
556 push bx
|
pascal@19538
|
557 push si
|
pascal@19538
|
558 xchg ax,si
|
pascal@19571
|
559 ifdef LARGE_IMAGES
|
pascal@19571
|
560 mov cx,[word ((image_himem si).size) + 2]
|
pascal@19571
|
561 shr cx,4 ; pages index size = size >> 20
|
pascal@19571
|
562 add cx,8+4096+8
|
pascal@19571
|
563 call malloc_or_die
|
pascal@19571
|
564 mov ecx,4096+4095 ; cnt = 1+(m->size+PAGE_MASK)/PAGE_SIZE;
|
pascal@19571
|
565 add ecx,[(image_himem si).size]
|
pascal@19571
|
566 shr ecx,12
|
pascal@19571
|
567 mov [curdata],ax
|
pascal@19571
|
568 else
|
pascal@19546
|
569 mov ecx,[(image_himem si).size]
|
pascal@19538
|
570 dec ecx
|
pascal@19538
|
571 shr ecx,12
|
pascal@19538
|
572 inc cx ; cnt = (m->size+PAGE_MASK)/PAGE_SIZE;
|
pascal@19538
|
573 push cx
|
pascal@19538
|
574 inc cx ; cnt+1
|
pascal@19538
|
575 shl cx,2 ; bufv => vcpi => vm86
|
pascal@19538
|
576 ; our malloc zeroes allocated mem: bufv[cnt]=0;
|
pascal@19538
|
577 ; Allocate pages, storing addrs in addrbuf
|
pascal@19538
|
578 call malloc_or_die
|
pascal@19571
|
579 pop cx
|
pascal@19571
|
580 push ax
|
pascal@19571
|
581 endif
|
pascal@19546
|
582 mov [(image_himem si).bufv],ax
|
pascal@19571
|
583 xchg ax,si
|
pascal@19538
|
584 @@vcpi_alloc:
|
pascal@19538
|
585 xor edx,edx
|
pascal@19538
|
586 mov ax,0DE04h
|
pascal@19538
|
587 int 67h
|
pascal@19538
|
588 or ah,ah
|
pascal@19538
|
589 mov bx,offset vcpi_alloc_err
|
pascal@19571
|
590 jnz die
|
pascal@19571
|
591 ; for (i = cnt-1; i >= 0; i--)
|
pascal@19571
|
592 ifdef LARGE_IMAGES
|
pascal@19571
|
593 mov eax,ecx
|
pascal@19571
|
594 dec eax
|
pascal@19571
|
595 else
|
pascal@19571
|
596 mov ax,cx
|
pascal@19571
|
597 dec ax
|
pascal@19571
|
598 cwde
|
pascal@19571
|
599 endif
|
pascal@19571
|
600 shl eax,12 ; i*_4k
|
pascal@19571
|
601 ; if (edx < pm.fallback+i*_4k && edx >= pm.fallback) again
|
pascal@19571
|
602 extrn _pm
|
pascal@19571
|
603 mov bx,offset _pm+2
|
pascal@19571
|
604 push eax
|
pascal@19571
|
605 add eax,[bx-2+2]
|
pascal@19571
|
606 cmp eax,edx ; pm.fallback+i*_4k <= edx ?
|
pascal@19571
|
607 pop eax ; i*_4k
|
pascal@19571
|
608 jbe @@pmok
|
pascal@19571
|
609 cmp edx,[bx-2+2] ; edx >= pm.fallback ?
|
pascal@19571
|
610 jae @@vcpi_alloc
|
pascal@19571
|
611 @@pmok:
|
pascal@19571
|
612 ; if (edx >= initrd.fallback+i*_4k && edx < initrd.fallback+initrd.size) again
|
pascal@19571
|
613 extrn _initrd
|
pascal@19571
|
614 mov bx,offset _initrd+2
|
pascal@19571
|
615 add eax,[bx-2+2] ; +initrd.fallback
|
pascal@19571
|
616 cmp eax,edx ; initrd.fallback+i*_4k > edx ?
|
pascal@19571
|
617 ja @@initrdok
|
pascal@19571
|
618 mov eax,[bx-2+6] ; initrd.size
|
pascal@19571
|
619 add eax,[bx-2+2] ; +initrd.fallback
|
pascal@19571
|
620 cmp eax,edx ; initrd.fallback+initrd.size > edx ?
|
pascal@19571
|
621 @@jnc_vcpi_alloc:
|
pascal@19571
|
622 ja @@vcpi_alloc
|
pascal@19571
|
623 @@initrdok:
|
pascal@19571
|
624 ifdef LARGE_IMAGES
|
pascal@19571
|
625 cmp [(data_himem si).first],0
|
pascal@19571
|
626 jne @@notfirst
|
pascal@19571
|
627 mov [(data_himem si).first],edx
|
pascal@19571
|
628 @@notfirst:
|
pascal@19571
|
629 mov bx,[(data_himem si).cacheidx]
|
pascal@19571
|
630 cmp bh,4
|
pascal@19571
|
631 jae @@nextpage
|
pascal@19571
|
632 shl bx,2
|
pascal@19571
|
633 inc [(data_himem si).cacheidx]
|
pascal@19571
|
634 mov [(data_himem bx+si).cache],edx
|
pascal@19571
|
635 loopd @@vcpi_alloc
|
pascal@19571
|
636 mov [(data_himem bx+si).cache],ecx ; last is 0
|
pascal@19571
|
637 @@nextpage:
|
pascal@19571
|
638 and [(data_himem si).cacheidx],0
|
pascal@19571
|
639 mov bx,[(data_himem si).pageidx]
|
pascal@19571
|
640 mov [(data_himem bx+si).page],edx
|
pascal@19571
|
641 add [(data_himem si).pageidx],4
|
pascal@19571
|
642 push cx
|
pascal@19571
|
643 lea cx,[(data_himem si).cache]
|
pascal@19571
|
644 ifdef NO386
|
pascal@19571
|
645 push edx
|
pascal@19571
|
646 pop dx
|
pascal@19571
|
647 pop ax
|
pascal@19571
|
648 endif
|
pascal@19571
|
649 call storepage ; storepage(edx,cx)
|
pascal@19571
|
650 pop cx
|
pascal@19571
|
651 or ecx,ecx ; clear C
|
pascal@19571
|
652 jnz @@jnc_vcpi_alloc
|
pascal@19571
|
653 mov [dword (data_himem si).cacheidx],ecx
|
pascal@19571
|
654 xchg ax,si
|
pascal@19571
|
655 else
|
pascal@19571
|
656 mov [si],edx
|
pascal@19571
|
657 lodsd ; si=+4
|
pascal@19538
|
658 loop @@vcpi_alloc
|
pascal@19538
|
659 pop ax
|
pascal@19571
|
660 endif
|
pascal@19538
|
661 pop si
|
pascal@19538
|
662 ret
|
pascal@19636
|
663 ifdef NO386
|
pascal@19636
|
664 p8086
|
pascal@19636
|
665 endif
|
pascal@19538
|
666
|
pascal@19538
|
667 endp _malloc_bufv_or_die
|
pascal@19538
|
668
|
pascal@19538
|
669
|
pascal@19538
|
670 ;***************************************************************
|
pascal@19571
|
671 ; void memcpy_image(struct image_himem *m);
|
pascal@19515
|
672 ;***************************************************************
|
pascal@19571
|
673 global _memcpy_image:near
|
pascal@19571
|
674 proc _memcpy_image near
|
pascal@19515
|
675
|
pascal@19571
|
676 pop ax ;caller return address
|
pascal@19515
|
677 pop bx
|
pascal@19571
|
678 push bx
|
pascal@19571
|
679 push ax
|
pascal@19571
|
680 ifndef NO386
|
pascal@19571
|
681 mov edx,[(image_himem bx).fallback]
|
pascal@19571
|
682 mov eax,[(image_himem bx).buf]
|
pascal@19571
|
683 cmp eax,edx ; if (m->fallback != m->buf)
|
pascal@19571
|
684 jz @@skip ; memcpy32(m->fallback,0,m->buf,m->size)
|
pascal@19571
|
685 ifdef LARGE_IMAGES
|
pascal@19571
|
686 mov ecx,[(image_himem bx).size]
|
pascal@19571
|
687 memcpy_imagez:
|
pascal@19571
|
688 push ecx
|
pascal@19571
|
689 else
|
pascal@19571
|
690 push [(image_himem bx).size]
|
pascal@19571
|
691 endif
|
pascal@19571
|
692 push eax
|
pascal@19571
|
693 push 0
|
pascal@19571
|
694 call_memcpy32:
|
pascal@19571
|
695 push edx
|
pascal@19571
|
696 else
|
pascal@19571
|
697 mov ax,[word ((image_himem bx).fallback)]
|
pascal@19571
|
698 mov dx,[word ((image_himem bx).fallback)+2]
|
pascal@19571
|
699 mov cx,[word ((image_himem bx).buf)]
|
pascal@19571
|
700 cmp ax,cx ; if (m->fallback != m->buf)
|
pascal@19571
|
701 jnz @@do
|
pascal@19571
|
702 cmp dx,[word ((image_himem bx).buf)+2]
|
pascal@19571
|
703 jz @@skip ; memcpy32(m->fallback,0,m->buf,m->size)
|
pascal@19571
|
704 @@do:
|
pascal@19571
|
705 push [word ((image_himem bx).size)+2]
|
pascal@19571
|
706 push [word ((image_himem bx).size)]
|
pascal@19571
|
707 push [word ((image_himem bx).buf)+2]
|
pascal@19571
|
708 push cx
|
pascal@19571
|
709 xor cx,cx
|
pascal@19571
|
710 push cx
|
pascal@19571
|
711 call_memcpy32:
|
pascal@19571
|
712 push dx
|
pascal@19571
|
713 push ax
|
pascal@19571
|
714 ifdef LARGE_IMAGES
|
pascal@19571
|
715 jmp @@memcpy
|
pascal@19571
|
716 memcpy_imagez:
|
pascal@19636
|
717 p386
|
pascal@19571
|
718 push ecx
|
pascal@19571
|
719 push eax
|
pascal@19571
|
720 push 0
|
pascal@19571
|
721 push edx
|
pascal@19636
|
722 ifdef NO386
|
pascal@19636
|
723 p8086
|
pascal@19636
|
724 endif
|
pascal@19571
|
725 endif
|
pascal@19571
|
726 endif
|
pascal@19571
|
727 @@memcpy:
|
pascal@19571
|
728 extrn _memcpy32:near
|
pascal@19571
|
729 call near _memcpy32
|
pascal@19571
|
730 add sp,14
|
pascal@19571
|
731 @@skip:
|
pascal@19571
|
732 ret
|
pascal@19571
|
733
|
pascal@19571
|
734 endp _memcpy_image
|
pascal@19571
|
735
|
pascal@19571
|
736 ;***************************************************************
|
pascal@19571
|
737 ;void storepage(u32 *dst, u16 src);
|
pascal@19571
|
738 ;***************************************************************
|
pascal@19571
|
739 global _storepage:near
|
pascal@19571
|
740 proc _storepage near
|
pascal@19571
|
741
|
pascal@19571
|
742 pop ax ;caller return address
|
pascal@19571
|
743 pop bx
|
pascal@19571
|
744 pop cx
|
pascal@19571
|
745 push cx
|
pascal@19571
|
746 push bx
|
pascal@19571
|
747 push ax
|
pascal@19571
|
748 ifndef NO386
|
pascal@19571
|
749 mov edx,[bx]
|
pascal@19571
|
750 else
|
pascal@19571
|
751 mov ax,[bx]
|
pascal@19571
|
752 mov dx,[bx+2]
|
pascal@19571
|
753 endif
|
pascal@19571
|
754 storepage:
|
pascal@19571
|
755 ifndef NO386
|
pascal@19571
|
756 push 0
|
pascal@19571
|
757 push 4096
|
pascal@19571
|
758 push 0
|
pascal@19571
|
759 else
|
pascal@19571
|
760 xor bx,bx
|
pascal@19571
|
761 push bx
|
pascal@19571
|
762 mov bh,4096/256
|
pascal@19571
|
763 push bx
|
pascal@19571
|
764 xor bx,bx
|
pascal@19571
|
765 push bx
|
pascal@19571
|
766 endif
|
pascal@19571
|
767 push cx
|
pascal@19571
|
768 push ds
|
pascal@19571
|
769 jmp call_memcpy32
|
pascal@19571
|
770
|
pascal@19571
|
771 endp _storepage
|
pascal@19571
|
772
|
pascal@19571
|
773
|
pascal@19571
|
774 ifdef LARGE_IMAGES
|
pascal@19636
|
775 p386
|
pascal@19571
|
776 ;***************************************************************
|
pascal@19571
|
777 ;void reset_bufv(u32 *p);
|
pascal@19571
|
778 ;***************************************************************
|
pascal@19571
|
779 global _reset_bufv:near
|
pascal@19571
|
780 proc _reset_bufv near
|
pascal@19571
|
781
|
pascal@19634
|
782 pop ax ;caller return address
|
pascal@19634
|
783 pop bx
|
pascal@19634
|
784 push bx
|
pascal@19515
|
785 push ax
|
pascal@19634
|
786 mov [curdata],bx
|
pascal@19571
|
787 and [dword (data_himem bx).cacheidx],0
|
pascal@19571
|
788 ret
|
pascal@19571
|
789
|
pascal@19571
|
790 endp _reset_bufv
|
pascal@19571
|
791
|
pascal@19571
|
792 ;***************************************************************
|
pascal@19571
|
793 ;u32* prev_bufv();
|
pascal@19571
|
794 ;u32* prev_bufv();
|
pascal@19571
|
795 ;***************************************************************
|
pascal@19571
|
796 global _prev_bufv:near
|
pascal@19571
|
797 global _next_bufv:near
|
pascal@19571
|
798 proc _prev_bufv near
|
pascal@19571
|
799
|
pascal@19571
|
800 stc
|
pascal@19571
|
801 db 73h ; jnc
|
pascal@19571
|
802 _next_bufv:
|
pascal@19571
|
803 clc
|
pascal@19571
|
804 sbb ax,ax
|
pascal@19571
|
805 stc
|
pascal@19571
|
806 rcl ax,1 ; -1/+1
|
pascal@19571
|
807 xor ecx,ecx
|
pascal@19571
|
808 push si
|
pascal@19571
|
809 mov si,[curdata]
|
pascal@19571
|
810 add ax,[(data_himem si).cacheidx]
|
pascal@19571
|
811 test ax,0fc00h
|
pascal@19571
|
812 jz @@gotpage
|
pascal@19571
|
813 push ax ; FFFF / 0400
|
pascal@19571
|
814 sar ax,8 ; FFFC / 0004
|
pascal@19571
|
815 and al,0fch
|
pascal@19571
|
816 add [(data_himem si).pageidx],ax
|
pascal@19571
|
817 mov bx,[(data_himem si).pageidx]
|
pascal@19571
|
818 lea bx,[(data_himem bx+si).page]
|
pascal@19571
|
819 mov edx,ds
|
pascal@19571
|
820 shl edx,4
|
pascal@19571
|
821 lea cx,[(data_himem si).cache]
|
pascal@19571
|
822 add edx,ecx
|
pascal@19571
|
823 mov eax,[bx]
|
pascal@19571
|
824 or eax,eax
|
pascal@19571
|
825 jnz @@pageok
|
pascal@19571
|
826 pop ax
|
pascal@19571
|
827 xchg ax,bx
|
pascal@19571
|
828 pop si
|
pascal@19571
|
829 ret
|
pascal@19571
|
830 @@pageok:
|
pascal@19571
|
831 mov cx,4096
|
pascal@19571
|
832 call memcpy_imagez ; get page
|
pascal@19571
|
833 pop ax ; FFFF / 0400
|
pascal@19571
|
834 cbw
|
pascal@19571
|
835 shr ax,6 ; 03FF / 0000
|
pascal@19571
|
836 @@gotpage:
|
pascal@19571
|
837 mov [(data_himem si).cacheidx],ax
|
pascal@19571
|
838 shl ax,2
|
pascal@19571
|
839 xchg ax,bx
|
pascal@19571
|
840 lea ax,[(data_himem bx+si).cache]
|
pascal@19571
|
841 or bx,[(data_himem si).pageidx] ; !pageidx && !cacheidx
|
pascal@19571
|
842 jnz @@notfirst2
|
pascal@19571
|
843 xchg ax,si ; &first
|
pascal@19571
|
844 @@notfirst2:
|
pascal@19571
|
845 pop si
|
pascal@19571
|
846 ret
|
pascal@19636
|
847 ifdef NO386
|
pascal@19636
|
848 p8086
|
pascal@19636
|
849 endif
|
pascal@19571
|
850
|
pascal@19571
|
851 endp _prev_bufv
|
pascal@19571
|
852 endif
|
pascal@19571
|
853
|
pascal@19571
|
854
|
pascal@19571
|
855 ;***************************************************************
|
pascal@19515
|
856 ;void open_image(const char *name, struct image_himem *m);
|
pascal@19515
|
857 ;***************************************************************
|
pascal@19515
|
858 global _open_image:near
|
pascal@19515
|
859 proc _open_image near
|
pascal@19515
|
860
|
pascal@19515
|
861 arg fname :word, \
|
pascal@19515
|
862 m :word = PARAM_SIZE
|
pascal@19515
|
863
|
pascal@19515
|
864 push bp
|
pascal@19515
|
865 mov bp,sp
|
pascal@19515
|
866 push si di
|
pascal@19515
|
867 ifndef NO386
|
pascal@19515
|
868 xor eax,eax ; 1st loop flag + eos
|
pascal@19515
|
869 else
|
pascal@19515
|
870 xor ax,ax ; 1st loop flag + eos
|
pascal@19515
|
871 endif
|
pascal@19515
|
872 mov di,[m]
|
pascal@19546
|
873 cmp [(image_himem di).fd],ax
|
pascal@19515
|
874 jnz @@alreadydone
|
pascal@19515
|
875 ifndef NO386
|
pascal@19546
|
876 mov [(image_himem di).size],eax ; m->size = 0L
|
pascal@19515
|
877 else
|
pascal@19546
|
878 mov [word (image_himem di).size],ax ; m->size = 0L
|
pascal@19546
|
879 mov [word ((image_himem di).size)+2],ax
|
pascal@19515
|
880 endif
|
pascal@19571
|
881 mov [(image_himem di).next_chunk],offset next_chunk
|
pascal@19515
|
882 mov si,[fname]
|
pascal@19546
|
883 mov [(image_himem di).state],si
|
pascal@19515
|
884 @@next:
|
pascal@19515
|
885 push di
|
pascal@19546
|
886 call [(image_himem di).next_chunk] ; m->next_chunk()
|
pascal@19515
|
887 pop di
|
pascal@19515
|
888 ifndef NO386
|
pascal@19515
|
889 add eax,3
|
pascal@19515
|
890 and al,0FCh
|
pascal@19546
|
891 add [(image_himem di).size],eax ; m->size += m->chunk_size
|
pascal@19515
|
892 or eax,eax
|
pascal@19515
|
893 jnz @@next
|
pascal@19515
|
894 else
|
pascal@19515
|
895 mov cx,ax
|
pascal@19515
|
896 or cx,dx
|
pascal@19515
|
897 add ax,3
|
pascal@19515
|
898 adc dx,0
|
pascal@19515
|
899 and al,0FCh
|
pascal@19546
|
900 add [word (image_himem di).size],ax ; m->size += m->chunk_size
|
pascal@19546
|
901 adc [word ((image_himem di).size)+2],dx
|
pascal@19538
|
902 inc cx ; jcxnz
|
pascal@19515
|
903 loop @@next
|
pascal@19515
|
904 endif
|
pascal@19546
|
905 mov [(image_himem di).state],si
|
pascal@19515
|
906 push di
|
pascal@19546
|
907 call [(image_himem di).next_chunk] ; m->next_chunk()
|
pascal@19515
|
908 pop di
|
pascal@19515
|
909 @@alreadydone:
|
pascal@19515
|
910 push ax
|
pascal@19515
|
911 image_done:
|
pascal@19515
|
912 pop ax
|
pascal@19515
|
913 pop di si bp
|
pascal@19515
|
914 ret
|
pascal@19515
|
915
|
pascal@19515
|
916 endp _open_image
|
pascal@19515
|
917
|
pascal@19515
|
918
|
pascal@19515
|
919 ;***************************************************************
|
pascal@19515
|
920 ;int read_image(struct image_himem *m, void* data, int sz);
|
pascal@19515
|
921 ;***************************************************************
|
pascal@19515
|
922 global _read_image:near
|
pascal@19515
|
923 proc _read_image near
|
pascal@19515
|
924
|
pascal@19515
|
925 arg m :word, \
|
pascal@19515
|
926 data :word, \
|
pascal@19515
|
927 sz :word = PARAM_SIZE
|
pascal@19515
|
928
|
pascal@19515
|
929 push bp
|
pascal@19515
|
930 mov bp,sp
|
pascal@19515
|
931 push si di
|
pascal@19515
|
932 ifndef NO386
|
pascal@19515
|
933 push 0 ; return value
|
pascal@19515
|
934 else
|
pascal@19515
|
935 xor ax,ax
|
pascal@19515
|
936 push ax
|
pascal@19515
|
937 endif
|
pascal@19515
|
938 mov di,[m]
|
pascal@19515
|
939 @@loop:
|
pascal@19538
|
940 ifndef NO386
|
pascal@19538
|
941 xor ecx,ecx
|
pascal@19538
|
942 mov cx,[word sz]
|
pascal@19538
|
943 @@chksz:
|
pascal@19546
|
944 mov eax,[(image_himem di).chunk_size]
|
pascal@19538
|
945 cmp ecx,eax
|
pascal@19538
|
946 jb @@szok
|
pascal@19538
|
947 xchg eax,ecx
|
pascal@19538
|
948 else
|
pascal@19538
|
949 mov cx,[word sz]
|
pascal@19538
|
950 @@chksz:
|
pascal@19546
|
951 mov ax,[word (image_himem di).chunk_size]
|
pascal@19538
|
952 cmp cx,ax
|
pascal@19515
|
953 jb @@szok
|
pascal@19546
|
954 cmp [word ((image_himem di).chunk_size)+2],0 ; hi m->chunk_size
|
pascal@19515
|
955 jne @@szok
|
pascal@19515
|
956 xchg ax,cx
|
pascal@19538
|
957 endif
|
pascal@19515
|
958 @@szok:
|
pascal@19538
|
959 jcxz image_done
|
pascal@19538
|
960 push cx
|
pascal@19515
|
961 push [word data]
|
pascal@19515
|
962 push [word di]
|
pascal@19515
|
963 call _read
|
pascal@19538
|
964 pop dx
|
pascal@19515
|
965 pop bx
|
pascal@19538
|
966 pop dx
|
pascal@19538
|
967 jc image_done
|
pascal@19515
|
968 add bx,ax
|
pascal@19515
|
969 xor cx,cx
|
pascal@19538
|
970 ifndef NO386
|
pascal@19538
|
971 cwde ; ax < 8000h
|
pascal@19546
|
972 sub [(image_himem di).chunk_size],eax
|
pascal@19538
|
973 else
|
pascal@19538
|
974 cwd ; ax < 8000h
|
pascal@19546
|
975 sub [word (image_himem di).chunk_size],ax
|
pascal@19546
|
976 sbb [word ((image_himem di).chunk_size)+2],dx
|
pascal@19538
|
977 jnz @@fill
|
pascal@19546
|
978 cmp [word (image_himem di).chunk_size],dx
|
pascal@19538
|
979 endif
|
pascal@19538
|
980 jnz @@fill
|
pascal@19538
|
981 dec cx
|
pascal@19515
|
982 @@fill:
|
pascal@19515
|
983 test al,3
|
pascal@19515
|
984 je @@filled
|
pascal@19538
|
985 mov [bx],dl
|
pascal@19515
|
986 inc bx
|
pascal@19515
|
987 inc ax
|
pascal@19515
|
988 jmp @@fill
|
pascal@19515
|
989 @@filled:
|
pascal@19538
|
990 ifndef NO386
|
pascal@19546
|
991 sub [(image_himem di).remaining],eax
|
pascal@19538
|
992 else
|
pascal@19546
|
993 sub [word (image_himem di).remaining],ax
|
pascal@19546
|
994 sbb [word ((image_himem di).remaining)+2],dx
|
pascal@19538
|
995 endif
|
pascal@19515
|
996 add [bp-4-2],ax
|
pascal@19515
|
997 add [word data],ax
|
pascal@19515
|
998 sub [word sz],ax
|
pascal@19538
|
999 pushf
|
pascal@19546
|
1000 and cx,[(image_himem di).next_chunk]
|
pascal@19538
|
1001 jz @@same_chunk
|
pascal@19515
|
1002 push di
|
pascal@19515
|
1003 call cx ; m->next_chunk()
|
pascal@19515
|
1004 pop di
|
pascal@19538
|
1005 @@same_chunk:
|
pascal@19538
|
1006 popf
|
pascal@19538
|
1007 jnz @@loop
|
pascal@19538
|
1008 jmp image_done
|
pascal@19515
|
1009
|
pascal@19515
|
1010 endp _read_image
|
pascal@19515
|
1011
|
pascal@19515
|
1012
|
pascal@19515
|
1013 ;***************************************************************
|
pascal@19515
|
1014 ;unsigned long strtol(const char *s);
|
pascal@19515
|
1015 ;***************************************************************
|
pascal@19515
|
1016 global _strtol:near
|
pascal@19515
|
1017 proc _strtol near
|
pascal@19515
|
1018
|
pascal@19515
|
1019 ifndef NO386
|
pascal@19515
|
1020 pop ax ;caller return address
|
pascal@19515
|
1021 pop cx ; s
|
pascal@19515
|
1022 push cx
|
pascal@19515
|
1023 push ax
|
pascal@19515
|
1024 xor ebx,ebx
|
pascal@19515
|
1025 push si
|
pascal@19634
|
1026 jcxz @@end
|
pascal@19515
|
1027 mov si,cx
|
pascal@19515
|
1028 xor ecx,ecx
|
pascal@19515
|
1029 xor eax,eax
|
pascal@19515
|
1030 lodsb
|
pascal@19634
|
1031 mov dx,ax
|
pascal@19634
|
1032 or al,20h
|
pascal@19634
|
1033 cmp al,'n' ; vga=normal
|
pascal@19538
|
1034 je @@vga
|
pascal@19538
|
1035 dec cx
|
pascal@19634
|
1036 cmp al,'e' ; vga=extended
|
pascal@19538
|
1037 je @@vga
|
pascal@19538
|
1038 dec cx
|
pascal@19634
|
1039 cmp al,'a' ; vga=ask
|
pascal@19538
|
1040 jne @@notvga
|
pascal@19538
|
1041 @@vga:
|
pascal@19538
|
1042 dec cx
|
pascal@19538
|
1043 xchg ax,cx
|
pascal@19538
|
1044 cwd
|
pascal@19634
|
1045 jmp @@popsiret
|
pascal@19538
|
1046 @@notvga:
|
pascal@19538
|
1047 mov cx,10 ; radix
|
pascal@19634
|
1048 xchg ax,dx
|
pascal@19515
|
1049 cmp al,'+'
|
pascal@19515
|
1050 je @@radixskip
|
pascal@19515
|
1051 cmp al,'-'
|
pascal@19515
|
1052 clc
|
pascal@19515
|
1053 jne @@radixkeep
|
pascal@19515
|
1054 stc
|
pascal@19515
|
1055 @@radixskip:
|
pascal@19515
|
1056 lodsb
|
pascal@19515
|
1057 @@radixkeep:
|
pascal@19515
|
1058 pushf
|
pascal@19515
|
1059 cmp al,'0'
|
pascal@19515
|
1060 jne @@radixok
|
pascal@19515
|
1061 mov cl,8
|
pascal@19515
|
1062 lodsb
|
pascal@19634
|
1063 or al,20h
|
pascal@19634
|
1064 cmp al,'x'
|
pascal@19515
|
1065 jne @@radixok
|
pascal@19515
|
1066 mov cl,16
|
pascal@19515
|
1067 @@strtollp:
|
pascal@19515
|
1068 lodsb
|
pascal@19515
|
1069 @@radixok:
|
pascal@19634
|
1070 or al,20h
|
pascal@19515
|
1071 sub al,'0'
|
pascal@19515
|
1072 jb @@endstrtol
|
pascal@19515
|
1073 cmp al,9
|
pascal@19515
|
1074 jbe @@digitok
|
pascal@19515
|
1075 cmp al,'a'-'0'
|
pascal@19515
|
1076 jb @@endstrtol
|
pascal@19515
|
1077 sub al,'a'-'0'-10
|
pascal@19515
|
1078 @@digitok:
|
pascal@19515
|
1079 cmp al,cl
|
pascal@19515
|
1080 jae @@endstrtol
|
pascal@19515
|
1081 xchg eax,ebx
|
pascal@19515
|
1082 mul ecx
|
pascal@19515
|
1083 add eax,ebx
|
pascal@19515
|
1084 xchg eax,ebx
|
pascal@19515
|
1085 jmp @@strtollp
|
pascal@19515
|
1086 @@endstrtol:
|
pascal@19515
|
1087 mov cl,10
|
pascal@19515
|
1088 cmp al,'k'-'a'+10
|
pascal@19515
|
1089 je @@shift
|
pascal@19515
|
1090 mov cl,20
|
pascal@19515
|
1091 cmp al,'m'-'a'+10
|
pascal@19515
|
1092 je @@shift
|
pascal@19515
|
1093 mov cl,30
|
pascal@19515
|
1094 cmp al,'g'-'a'+10
|
pascal@19515
|
1095 jne @@noshift
|
pascal@19515
|
1096 @@shift:
|
pascal@19515
|
1097 shl ebx,cl
|
pascal@19515
|
1098 @@noshift:
|
pascal@19515
|
1099 popf
|
pascal@19515
|
1100 jnc @@end
|
pascal@19515
|
1101 neg ebx
|
pascal@19515
|
1102 @@end:
|
pascal@19515
|
1103 push ebx
|
pascal@19515
|
1104 pop ax
|
pascal@19515
|
1105 pop dx
|
pascal@19634
|
1106 @@popsiret:
|
pascal@19515
|
1107 pop si
|
pascal@19515
|
1108 else
|
pascal@19515
|
1109 pop ax ;caller return address
|
pascal@19515
|
1110 pop cx ; s
|
pascal@19515
|
1111 push cx
|
pascal@19515
|
1112 push ax
|
pascal@19515
|
1113 push si
|
pascal@19515
|
1114 push di
|
pascal@19515
|
1115 xor ax,ax
|
pascal@19515
|
1116 cwd
|
pascal@19634
|
1117 jcxz @@goend
|
pascal@19515
|
1118 xchg ax,di
|
pascal@19515
|
1119 mov si,cx
|
pascal@19538
|
1120 lodsb
|
pascal@19634
|
1121 mov bx,ax
|
pascal@19634
|
1122 or al,20h
|
pascal@19538
|
1123 mov cx,-1
|
pascal@19634
|
1124 cmp al,'n' ; vga=normal
|
pascal@19538
|
1125 je @@vga
|
pascal@19538
|
1126 dec cx
|
pascal@19634
|
1127 cmp al,'e' ; vga=extended
|
pascal@19538
|
1128 je @@vga
|
pascal@19538
|
1129 dec cx
|
pascal@19634
|
1130 cmp al,'a' ; vga=ask
|
pascal@19538
|
1131 jne @@notvga
|
pascal@19538
|
1132 @@vga:
|
pascal@19538
|
1133 xchg ax,cx
|
pascal@19538
|
1134 @@goend:
|
pascal@19634
|
1135 jmp @@popdisiret
|
pascal@19538
|
1136 @@notvga:
|
pascal@19515
|
1137 mov cx,10 ; radix
|
pascal@19634
|
1138 xchg ax,bx
|
pascal@19515
|
1139 cmp al,'+'
|
pascal@19515
|
1140 je @@radixskip
|
pascal@19515
|
1141 cmp al,'-'
|
pascal@19515
|
1142 clc
|
pascal@19515
|
1143 jne @@radixkeep
|
pascal@19515
|
1144 stc
|
pascal@19515
|
1145 @@radixskip:
|
pascal@19515
|
1146 lodsb
|
pascal@19515
|
1147 @@radixkeep:
|
pascal@19515
|
1148 pushf
|
pascal@19515
|
1149 cmp al,'0'
|
pascal@19515
|
1150 jne @@radixok
|
pascal@19515
|
1151 mov cl,8
|
pascal@19515
|
1152 lodsb
|
pascal@19634
|
1153 mov al,20h
|
pascal@19634
|
1154 cmp al,'x'
|
pascal@19515
|
1155 jne @@radixok
|
pascal@19515
|
1156 mov cl,16
|
pascal@19515
|
1157 @@strtollp:
|
pascal@19515
|
1158 lodsb
|
pascal@19515
|
1159 @@radixok:
|
pascal@19634
|
1160 or al,20h
|
pascal@19515
|
1161 sub al,'0'
|
pascal@19515
|
1162 jb @@endstrtol
|
pascal@19515
|
1163 cmp al,9
|
pascal@19515
|
1164 jbe @@digitok
|
pascal@19515
|
1165 cmp al,'a'-'0'
|
pascal@19515
|
1166 jb @@endstrtol
|
pascal@19515
|
1167 sub al,'a'-'0'-10
|
pascal@19515
|
1168 @@digitok:
|
pascal@19515
|
1169 cmp al,cl
|
pascal@19515
|
1170 jae @@endstrtol
|
pascal@19515
|
1171
|
pascal@19515
|
1172 push ax
|
pascal@19515
|
1173 push si
|
pascal@19515
|
1174 push dx
|
pascal@19515
|
1175 xchg ax,di
|
pascal@19515
|
1176 mul cx
|
pascal@19515
|
1177 xchg ax,di
|
pascal@19515
|
1178 xchg ax,dx
|
pascal@19515
|
1179 xchg ax,si
|
pascal@19515
|
1180 pop ax
|
pascal@19515
|
1181 mul cx
|
pascal@19515
|
1182 add ax,si
|
pascal@19515
|
1183 pop si
|
pascal@19515
|
1184 xchg ax,dx
|
pascal@19515
|
1185 pop ax
|
pascal@19515
|
1186 mov ah,0
|
pascal@19515
|
1187 add di,ax
|
pascal@19515
|
1188 adc dx,0
|
pascal@19515
|
1189
|
pascal@19515
|
1190 jmp @@strtollp
|
pascal@19515
|
1191 @@endstrtol:
|
pascal@19515
|
1192 mov cl,10
|
pascal@19515
|
1193 cmp al,'k'-'a'+10
|
pascal@19515
|
1194 je @@shift
|
pascal@19515
|
1195 mov cl,20
|
pascal@19515
|
1196 cmp al,'m'-'a'+10
|
pascal@19515
|
1197 je @@shift
|
pascal@19515
|
1198 mov cl,30
|
pascal@19515
|
1199 cmp al,'g'-'a'+10
|
pascal@19515
|
1200 jne @@noshift
|
pascal@19515
|
1201 @@shift:
|
pascal@19515
|
1202 rcl di,1
|
pascal@19515
|
1203 shl dx,1
|
pascal@19515
|
1204 loop @@shift
|
pascal@19515
|
1205 @@noshift:
|
pascal@19515
|
1206 popf
|
pascal@19515
|
1207 jnc @@end
|
pascal@19515
|
1208 not dx
|
pascal@19515
|
1209 neg di
|
pascal@19515
|
1210 jne @@end
|
pascal@19515
|
1211 inc dx
|
pascal@19515
|
1212 @@end:
|
pascal@19515
|
1213 xchg ax,di
|
pascal@19634
|
1214 @@popdisiret:
|
pascal@19515
|
1215 pop di
|
pascal@19515
|
1216 pop si
|
pascal@19515
|
1217 endif
|
pascal@19515
|
1218 ret
|
pascal@19515
|
1219
|
pascal@19515
|
1220 endp _strtol
|
pascal@19515
|
1221
|
pascal@19515
|
1222
|
pascal@19515
|
1223 ifdef NO386
|
pascal@19515
|
1224 ;***************************************************************
|
pascal@19515
|
1225 ;u16 topseg();
|
pascal@19515
|
1226 ;***************************************************************
|
pascal@19515
|
1227 global _topseg:near
|
pascal@19515
|
1228 proc _topseg near
|
pascal@19515
|
1229
|
pascal@19515
|
1230 int 12h
|
pascal@19515
|
1231 jnc @@max640k
|
pascal@19515
|
1232 mov ax,640 ; 9000
|
pascal@19515
|
1233 @@max640k:
|
pascal@19634
|
1234 dec ax
|
pascal@19515
|
1235 and al,0C0h
|
pascal@19515
|
1236 mov cl,6
|
pascal@19515
|
1237 shl ax,cl
|
pascal@19515
|
1238 ret
|
pascal@19515
|
1239
|
pascal@19515
|
1240 endp _topseg
|
pascal@19515
|
1241 endif
|
pascal@19515
|
1242
|
pascal@19825
|
1243 ifdef EXTRA
|
pascal@19825
|
1244 p8086
|
pascal@19825
|
1245
|
pascal@19825
|
1246 ;***************************************************************
|
pascal@19825
|
1247 ;int strcmp(const char* a,const char* b);
|
pascal@19825
|
1248 ;***************************************************************
|
pascal@19825
|
1249 global _strcmp:near
|
pascal@19825
|
1250 proc _strcmp near
|
pascal@19825
|
1251
|
pascal@19825
|
1252 pop cx ;caller return address
|
pascal@19825
|
1253 pop bx ; a
|
pascal@19825
|
1254 pop ax ; b
|
pascal@19825
|
1255 push ax
|
pascal@19825
|
1256 push bx
|
pascal@19825
|
1257 push cx
|
pascal@19825
|
1258 push si
|
pascal@19825
|
1259 xchg ax,si
|
pascal@19825
|
1260 sub bx,si
|
pascal@19825
|
1261 @@lp:
|
pascal@19825
|
1262 mov al,[si]
|
pascal@19825
|
1263 sub al,[bx+si]
|
pascal@19825
|
1264 jnz @@out
|
pascal@19825
|
1265 lodsb
|
pascal@19825
|
1266 cmp al,0
|
pascal@19825
|
1267 jne @@lp
|
pascal@19825
|
1268 @@out:
|
pascal@19825
|
1269 cbw
|
pascal@19825
|
1270 pop si
|
pascal@19825
|
1271 ret
|
pascal@19825
|
1272
|
pascal@19825
|
1273 endp _strcmp
|
pascal@19825
|
1274
|
pascal@19825
|
1275
|
pascal@19825
|
1276 ;***************************************************************
|
pascal@19825
|
1277 ;char strstr(const char* a,const char* b);
|
pascal@19825
|
1278 ;***************************************************************
|
pascal@19825
|
1279 global _strstr:near
|
pascal@19825
|
1280 proc _strstr near
|
pascal@19825
|
1281
|
pascal@19825
|
1282 pop ax ;caller return address
|
pascal@19825
|
1283 pop cx ; a
|
pascal@19825
|
1284 pop dx ; b
|
pascal@19825
|
1285 push dx
|
pascal@19825
|
1286 push cx
|
pascal@19825
|
1287 push ax
|
pascal@19825
|
1288 push si
|
pascal@19825
|
1289 @@loop:
|
pascal@19825
|
1290 xor ax,ax
|
pascal@19825
|
1291 mov si,cx
|
pascal@19825
|
1292 cmp [si],al ; *a
|
pascal@19825
|
1293 jz @@end ; return ax = NULL
|
pascal@19825
|
1294 mov bx,dx
|
pascal@19825
|
1295 sub bx,si
|
pascal@19825
|
1296 @@match:
|
pascal@19825
|
1297 or ah,[bx+si] ; *b
|
pascal@19825
|
1298 jz @@found
|
pascal@19825
|
1299 lodsb
|
pascal@19825
|
1300 sub ah,al
|
pascal@19825
|
1301 jz @@match
|
pascal@19825
|
1302 inc cx
|
pascal@19825
|
1303 jmp @@loop
|
pascal@19825
|
1304 @@found:
|
pascal@19825
|
1305 xchg ax,cx
|
pascal@19825
|
1306 @@end:
|
pascal@19825
|
1307 pop si
|
pascal@19825
|
1308 ret
|
pascal@19825
|
1309
|
pascal@19825
|
1310 endp _strstr
|
pascal@19825
|
1311
|
pascal@19825
|
1312
|
pascal@19825
|
1313 ;***************************************************************
|
pascal@19825
|
1314 ;char *progname(void)
|
pascal@19825
|
1315 ;***************************************************************
|
pascal@19825
|
1316 global _progname:near
|
pascal@19825
|
1317 proc _progname near
|
pascal@19825
|
1318
|
pascal@19825
|
1319 push si di es
|
pascal@19825
|
1320 mov ah,30h
|
pascal@19825
|
1321 int 21h
|
pascal@19875
|
1322 xor di,di
|
pascal@19825
|
1323 cmp al,3
|
pascal@19874
|
1324 mov ax,di
|
pascal@19825
|
1325 jb @@skip
|
pascal@19873
|
1326 ;mov es,[cs:2Ch]
|
pascal@19874
|
1327 mov es,[di+2Ch]
|
pascal@19825
|
1328 mov cx,-1
|
pascal@19870
|
1329 @@loop:
|
pascal@19825
|
1330 repne
|
pascal@19825
|
1331 scasb
|
pascal@19825
|
1332 scasb
|
pascal@19870
|
1333 jne @@loop
|
pascal@19870
|
1334 inc di
|
pascal@19870
|
1335 inc di
|
pascal@19870
|
1336 mov si,di ; progname @es:di
|
pascal@19870
|
1337 repne
|
pascal@19870
|
1338 scasb
|
pascal@19870
|
1339 mov cx,di
|
pascal@19874
|
1340 sub cx,si ; progname len
|
pascal@19870
|
1341 call malloc_or_die ; keep cx
|
pascal@19870
|
1342 mov di,ax
|
pascal@19825
|
1343 push ds
|
pascal@19825
|
1344 push es
|
pascal@19825
|
1345 pop ds
|
pascal@19825
|
1346 pop es
|
pascal@19870
|
1347 rep
|
pascal@19870
|
1348 movsb
|
pascal@19870
|
1349 push es
|
pascal@19825
|
1350 pop ds
|
pascal@19825
|
1351 @@skip:
|
pascal@19825
|
1352 pop es di si
|
pascal@19825
|
1353 ret
|
pascal@19825
|
1354
|
pascal@19825
|
1355 endp _progname
|
pascal@19825
|
1356
|
pascal@19825
|
1357
|
pascal@19825
|
1358 ;***************************************************************
|
pascal@19875
|
1359 ;void chdirname(char *path)
|
pascal@19825
|
1360 ;***************************************************************
|
pascal@19825
|
1361 global _chdirname:near
|
pascal@19825
|
1362 proc _chdirname near
|
pascal@19825
|
1363
|
pascal@19825
|
1364 pop ax
|
pascal@19825
|
1365 pop bx
|
pascal@19825
|
1366 push bx
|
pascal@19825
|
1367 push ax
|
pascal@19825
|
1368
|
pascal@19825
|
1369 cmp [byte bx+1],3Ah
|
pascal@19825
|
1370 jne @@nodisk
|
pascal@19875
|
1371 mov dl,20h
|
pascal@19875
|
1372 or dl,[bx]
|
pascal@19825
|
1373 sub dl,61h
|
pascal@19825
|
1374 mov ah,0Eh
|
pascal@19825
|
1375 int 21h
|
pascal@19825
|
1376 inc bx
|
pascal@19825
|
1377 inc bx
|
pascal@19825
|
1378 @@nodisk:
|
pascal@19825
|
1379 xor cx,cx
|
pascal@19825
|
1380 @@next:
|
pascal@19825
|
1381 mov al,[bx]
|
pascal@19825
|
1382 cmp al,5Ch
|
pascal@19825
|
1383 jne @@tsteos
|
pascal@19875
|
1384 mov dx,bx
|
pascal@19875
|
1385 inc cx
|
pascal@19825
|
1386 @@tsteos:
|
pascal@19825
|
1387 inc bx
|
pascal@19825
|
1388 or al,al
|
pascal@19825
|
1389 jnz @@next
|
pascal@19825
|
1390 jcxz @@end
|
pascal@19875
|
1391 mov bx,dx
|
pascal@19825
|
1392 push [word bx]
|
pascal@19825
|
1393 mov [bx],al
|
pascal@19875
|
1394 stc
|
pascal@19875
|
1395 mov ax,713Bh ; chdir long filename
|
pascal@19875
|
1396 int 21h
|
pascal@19875
|
1397 mov ah,3Bh ; chdir
|
pascal@19875
|
1398 jnc chdirdone
|
pascal@19875
|
1399 int 21h
|
pascal@19875
|
1400 chdirdone:
|
pascal@19825
|
1401 pop [word bx]
|
pascal@19825
|
1402 @@end:
|
pascal@19825
|
1403 ret
|
pascal@19825
|
1404
|
pascal@19825
|
1405 endp _chdirname
|
pascal@19825
|
1406
|
pascal@19825
|
1407
|
pascal@19825
|
1408 ;***************************************************************
|
pascal@19825
|
1409 ;char *ultoa(unsigned long n);
|
pascal@19825
|
1410 ;***************************************************************
|
pascal@19825
|
1411 global _ultoa:near
|
pascal@19825
|
1412 proc _ultoa near
|
pascal@19825
|
1413
|
pascal@19825
|
1414 pop ax
|
pascal@19825
|
1415 pop cx
|
pascal@19825
|
1416 pop dx
|
pascal@19825
|
1417 push dx
|
pascal@19825
|
1418 push cx
|
pascal@19825
|
1419 push ax ; DX:CX = n
|
pascal@19825
|
1420 push si
|
pascal@19825
|
1421 mov si,10
|
pascal@19825
|
1422 mov bx,offset ultoabuf+11
|
pascal@19825
|
1423 @@loop:
|
pascal@19825
|
1424 dec bx
|
pascal@19825
|
1425 xchg ax,dx
|
pascal@19825
|
1426 xor dx,dx
|
pascal@19825
|
1427 div si ; DX:AX = 0000:hi(n)
|
pascal@19825
|
1428 xchg ax,cx ; CX = hi(n)/10
|
pascal@19825
|
1429 div si ; DX:AX = hi(n)%10:lo(n)
|
pascal@19825
|
1430 xchg ax,cx ; CX = lo(n/10)
|
pascal@19825
|
1431 xchg ax,dx ; DX = hi(n)/10 = hi(n/10)
|
pascal@19825
|
1432 add al,'0'
|
pascal@19825
|
1433 mov [bx],al
|
pascal@19825
|
1434 mov ax,cx
|
pascal@19825
|
1435 or ax,dx
|
pascal@19825
|
1436 jnz @@loop
|
pascal@19825
|
1437 xchg ax,bx
|
pascal@19825
|
1438 pop si
|
pascal@19825
|
1439 ret
|
pascal@19825
|
1440
|
pascal@19825
|
1441 endp _ultoa
|
pascal@19825
|
1442
|
pascal@19825
|
1443
|
pascal@19825
|
1444 ;***************************************************************
|
pascal@19825
|
1445 ;unsigned long kver2ul(char *kernel_version);
|
pascal@19825
|
1446 ;***************************************************************
|
pascal@19825
|
1447 global _kver2ul:near
|
pascal@19825
|
1448 proc _kver2ul near
|
pascal@19825
|
1449
|
pascal@19825
|
1450 pop bx
|
pascal@19825
|
1451 pop ax
|
pascal@19825
|
1452 push ax
|
pascal@19825
|
1453 push bx
|
pascal@19825
|
1454 push bp si di
|
pascal@19825
|
1455 xchg ax,si
|
pascal@19825
|
1456 xor di,di
|
pascal@19825
|
1457 push di
|
pascal@19825
|
1458 push di
|
pascal@19825
|
1459 mov bp,sp
|
pascal@19825
|
1460 inc di
|
pascal@19825
|
1461 inc di
|
pascal@19825
|
1462 mov cl,4
|
pascal@19825
|
1463 @@number:
|
pascal@19825
|
1464 xor ax,ax
|
pascal@19825
|
1465 @@digit:
|
pascal@19825
|
1466 shl al,cl
|
pascal@19825
|
1467 shl ax,cl
|
pascal@19825
|
1468 lodsb
|
pascal@19825
|
1469 sub al,30h
|
pascal@19825
|
1470 cmp al,9
|
pascal@19825
|
1471 jbe @@digit
|
pascal@19825
|
1472 mov [bp+di],ah
|
pascal@19825
|
1473 dec di
|
pascal@19825
|
1474 jns @@number
|
pascal@19825
|
1475 pop ax
|
pascal@19825
|
1476 pop dx
|
pascal@19825
|
1477 pop di si bp
|
pascal@19825
|
1478 kver2ulret:
|
pascal@19825
|
1479 ret
|
pascal@19825
|
1480
|
pascal@19825
|
1481 endp _kver2ul
|
pascal@19825
|
1482
|
pascal@19825
|
1483
|
pascal@19825
|
1484 ;***************************************************************
|
pascal@19825
|
1485 ;void try_default_args();
|
pascal@19825
|
1486 ;***************************************************************
|
pascal@19825
|
1487 global _try_default_args:near
|
pascal@19825
|
1488 proc _try_default_args near
|
pascal@19825
|
1489
|
pascal@19825
|
1490 mov bx,offset tazboot_cmd
|
pascal@19825
|
1491 call open
|
pascal@19825
|
1492 jc kver2ulret
|
pascal@19825
|
1493 mov cx,4096
|
pascal@19825
|
1494 mov di,[_heap_top]
|
pascal@19825
|
1495 push cx
|
pascal@19825
|
1496 extrn read_cmdline:near
|
pascal@19825
|
1497 jmp near read_cmdline ; read_cmdline(ax,di,cx)
|
pascal@19825
|
1498
|
pascal@19825
|
1499 endp _try_default_args
|
pascal@19825
|
1500
|
pascal@19825
|
1501 endif
|
pascal@19825
|
1502
|
pascal@19515
|
1503 ends _TEXT
|
pascal@19515
|
1504
|
pascal@19515
|
1505 end
|
pascal@19515
|
1506
|
pascal@19515
|
1507 ;###### END OF FILE ############################################
|
pascal@19825
|
1508
|