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

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