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