wok annotate linld/stuff/src/CRTL.ASM @ rev 22668

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