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