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

syslinux/iso2exe: read isolinux.cfg
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Jan 12 07:47:12 2021 +0000 (2021-01-12)
parents a946c1651082
children bc4b94310a29
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@23996 20 loaderr db "Load failure",0
pascal@23983 21 msg_hang db "Himem broken",0
pascal@22668 22 vcpi_alloc_err db "VCPI"
pascal@22668 23 global overflow:byte
pascal@22668 24 overflow db "/"
pascal@23996 25 msg_malloc db "Out of memory"
pascal@23996 26 isorootofs dd 16*2048
pascal@19515 27
pascal@19515 28 ends _DATA
pascal@19515 29
pascal@19515 30 segment _BSS byte public use16 'BSS'
pascal@19515 31
pascal@23797 32 include "isostate.inc"
pascal@21747 33 public _isostate
pascal@21747 34 _isostate isostate <?>
pascal@21754 35 org $-7
pascal@20538 36 _xfer_buf db 4096 dup (?)
pascal@19515 37 filecnt db ? ; in fact 0 minus file count...
pascal@19515 38 nextfilename dw ?
pascal@19515 39
pascal@19515 40 ends _BSS
pascal@19515 41
pascal@19515 42 segment _TEXT byte public use16 'CODE'
pascal@19515 43
pascal@19515 44 ;***************************************************************
pascal@20630 45 ;_fastcall void strcatb(bx:const char* a, ax:const char* b);
pascal@19538 46 ;***************************************************************
pascal@20528 47 global @strcatb$qpxzct1:near
pascal@20528 48 proc @strcatb$qpxzct1 near
pascal@19538 49
pascal@19538 50 push si
pascal@20794 51 xchg ax,si ; b
pascal@20794 52 dec bx
pascal@19538 53 @@catlp:
pascal@20794 54 inc bx
pascal@20794 55 cmp [byte bx],0 ; a=bx
pascal@19538 56 jne @@catlp
pascal@20794 57 db 0b8h,20h ; mov ax,??20h
pascal@19538 58 @@cpylp:
pascal@20794 59 lodsb
pascal@20794 60 @@cpyhead:
pascal@20794 61 mov [bx],al
pascal@20142 62 inc bx
pascal@20527 63 or al,al
pascal@19538 64 jne @@cpylp
pascal@20142 65 strend:
pascal@19538 66 pop si
pascal@23797 67 @ret:
pascal@20142 68 ret
pascal@19538 69
pascal@20528 70 endp @strcatb$qpxzct1
pascal@19538 71
pascal@19538 72
pascal@20146 73 p8086
pascal@20146 74
pascal@23996 75 opendos:
pascal@23996 76 ifdef LONG_FILENAME
pascal@23996 77 xchg ax,cx ; attributes
pascal@23996 78 mov ax,716Ch
pascal@23996 79 push bx si
pascal@23996 80 mov si,bx
pascal@23996 81 xor bx,bx ; R/O
pascal@23996 82 cwd ; action = open
pascal@23996 83 stc
pascal@23996 84 int 21h
pascal@23996 85 pop si dx
pascal@23996 86 jnc openok
pascal@23996 87 mov ax,3d00h ; read-only+compatibility
pascal@23996 88 else
pascal@23996 89 mov ah,3dh ; read-only+compatibility
pascal@23996 90 mov dx,bx
pascal@23996 91 endif
pascal@23996 92 ;mov cl,0 ; attribute mask
pascal@23996 93 call dos
pascal@23996 94 jc openret
pascal@23996 95 openok:
pascal@23984 96 xchg ax,bx
pascal@23996 97 mov ax,4202h
pascal@23996 98 cwd
pascal@23996 99 xor cx,cx
pascal@23996 100 int 21h
pascal@23996 101 mov [word _isostate.filesize],ax
pascal@23996 102 mov [(word _isostate.filesize)+2],dx
pascal@23984 103 xchg ax,bx
pascal@23996 104 ;xor cx,cx
pascal@23996 105 cwd
pascal@23996 106 call seeksetpos0 ; filepos = 0
pascal@23996 107 xchg ax,bx ; fd
pascal@23996 108 openret:
pascal@23996 109 ret
pascal@20146 110
pascal@19538 111 ;***************************************************************
pascal@20630 112 ;_fastcall int open(bx:const char* name, int flags=O_RDONLY);
pascal@21757 113 ;_fastcall int openargs(bx:const char* name, int flags=O_RDONLY);
pascal@19515 114 ;***************************************************************
pascal@20538 115 global openargs:near ; openargs(bx)
pascal@20538 116 openargs:
pascal@20538 117 cmp [byte bx],'@'
pascal@20538 118 jne fail
pascal@20538 119 inc bx
pascal@20538 120
pascal@20528 121 global @open$qpxzc:near
pascal@23996 122 @open$qpxzc:
pascal@23996 123 mov ax,[_isostate.fd]
pascal@23996 124 or ax,ax
pascal@23996 125 je opendos
pascal@23996 126 openiso:
pascal@23996 127 ifdef ISOHOOK
pascal@23996 128 cmp [byte bx],'!'
pascal@23996 129 je @readmenu$qv
pascal@23996 130 endif
pascal@23996 131 extrn @_isoopen$qv:near
pascal@23996 132 mov [word _isostate.filename2open],bx
pascal@23996 133 jmp @_isoopen$qv ; filepos = 0
pascal@19515 134
pascal@19515 135
pascal@19515 136 ;***************************************************************
pascal@20632 137 ;_fastcall int fileexist(bx:const char* name);
pascal@20632 138 ;***************************************************************
pascal@20632 139 global @fileexist$qpxzc:near
pascal@20632 140 @fileexist$qpxzc:
pascal@20632 141 call @open$qpxzc
pascal@20632 142 jc fail
pascal@20632 143
pascal@20632 144 ;***************************************************************
pascal@20630 145 ;_fastcall int close(ax:int fd);
pascal@19515 146 ;***************************************************************
pascal@20528 147 global @close$qi:near
pascal@20528 148 proc @close$qi near
pascal@19515 149
pascal@20540 150 global close:near ; close(ax)
pascal@19515 151 close:
pascal@23985 152 mov bh,3Eh
pascal@23996 153 mov cx,[_isostate.fd]
pascal@23996 154 jcxz dosbx
pascal@23996 155 jmp fail
pascal@19515 156
pascal@20528 157 endp @close$qi
pascal@19515 158
pascal@19515 159
pascal@19515 160 ;***************************************************************
pascal@23996 161 ;_fastcall int readrm(si:struct himem *m, ax:int sz);
pascal@19515 162 ;***************************************************************
pascal@20751 163 global @readrm$qp11image_himemi:near
pascal@20751 164 @readrm$qp11image_himemi:
pascal@20751 165 xchg ax,dx ; sz
pascal@23996 166 mov ax,[si] ; fd
pascal@23996 167 mov bx,[si-2] ; data
pascal@20528 168 proc @read$qipvi near
pascal@19515 169
pascal@20632 170 @read$dxbxax:
pascal@20538 171 xchg ax,bx ; fd
pascal@23996 172 @read$dxaxbx:
pascal@20538 173 xchg ax,dx ; data
pascal@20538 174 xchg ax,cx ; sz
pascal@20528 175 global @read$cxdxbx:near
pascal@20528 176 @read$cxdxbx:
pascal@23996 177 push bx
pascal@23996 178 mov bx,offset _isostate.filepos
pascal@23996 179 push cx
pascal@23996 180 mov cx,[bx-4] ; filesize
pascal@23996 181 sub cx,[bx] ; filepos
pascal@23996 182 mov ax,[bx-2]
pascal@23996 183 sbb ax,[bx+2]
pascal@23996 184 pop ax
pascal@23996 185 ja @@axok
pascal@23996 186 ;je @@rem
pascal@23996 187 ;xor ax,ax
pascal@23996 188 @@rem:
pascal@23996 189 cmp cx,ax
pascal@23996 190 jb @@cxok
pascal@23996 191 @@axok:
pascal@23996 192 xchg ax,cx
pascal@23996 193 @@cxok:
pascal@23996 194 add [bx],cx
pascal@23996 195 adc [(word bx)+2],0
pascal@23996 196 pop bx
pascal@23996 197 readfd:
pascal@20146 198 mov ah,3Fh
pascal@23996 199 ;jcxz fail
pascal@21628 200 dos:
pascal@21628 201 int 21h
pascal@21628 202 jnc doret
pascal@21628 203 fail:
pascal@21628 204 stc
pascal@21628 205 failifc:
pascal@21628 206 sbb ax,ax ; ax=-1 CF
pascal@21628 207 doret:
pascal@21628 208 ret
pascal@19515 209
pascal@20528 210 endp @read$qipvi
pascal@19515 211
pascal@19515 212 ;***************************************************************
pascal@22632 213 ;_fastcall long rewind(ax:int fd);
pascal@19515 214 ;***************************************************************
pascal@19899 215
pascal@22632 216 global @rewind$qi:near ; fd=ax
pascal@22632 217 proc @rewind$qi near
pascal@20542 218
pascal@23996 219 rewind:
pascal@23996 220 mov bx,offset _isostate.fileofs
pascal@23996 221 jmp lseek
pascal@19515 222
pascal@22632 223 endp @rewind$qi
pascal@19825 224
pascal@23996 225
pascal@23996 226 ifdef ISOHOOK
pascal@23996 227 ;***************************************************************
pascal@23996 228 ;_fastcall void readmenu(void);
pascal@23996 229 ;***************************************************************
pascal@23996 230 proc @readmenu$qv near
pascal@23996 231
pascal@23996 232 mov dx,18
pascal@23996 233 xor cx,cx
pascal@23996 234 call seeksetpos0 ; filepos = 0
pascal@23996 235 mov dx,offset _isostate.filemod
pascal@23996 236 ; //magic = x->filemod;
pascal@23996 237 mov cl,10
pascal@23996 238 call readfd ; // read x->filemod + x->fileofs & x->filesize
pascal@23996 239 mov bx,offset _isostate.fileofs
pascal@23996 240 ; x->fileofs = 0x7FF0 - (x->filesize &= 0xFFFF);
pascal@23996 241 mov ax,7FF0h
pascal@23996 242 cwd
pascal@23996 243 mov [word bx+6],dx
pascal@23996 244 sub ax,[bx+4]
pascal@23996 245 mov [word bx+2],dx
pascal@23996 246 mov [bx],ax
pascal@23996 247 call isolseek ; filepos = 0
pascal@23996 248 xchg ax,bx ; fd
pascal@23996 249 ret
pascal@23996 250
pascal@23996 251 endp @readmenu$qv
pascal@23996 252 endif
pascal@23996 253
pascal@19825 254 ;***************************************************************
pascal@22749 255 ;_fastcall void isolseek(bx:const unsigned long *offset);
pascal@19825 256 ;***************************************************************
pascal@20528 257 global @isolseek$qpxul:near
pascal@20528 258 proc @isolseek$qpxul near
pascal@19825 259
pascal@20534 260 isolseek:
pascal@20632 261 mov ax,[_isostate.fd]
pascal@23996 262 lseek:
pascal@21984 263 les dx,[dword bx]
pascal@21984 264 mov cx,es
pascal@23996 265 seeksetpos0:
pascal@23996 266 xor bx,bx
pascal@23996 267 mov [word _isostate.filepos],bx
pascal@23996 268 mov [(word _isostate.filepos)+2],bx
pascal@23996 269 mov bh,42h ; bx=fd cx:dx=offset al=whence
pascal@23996 270 dosbx:
pascal@23996 271 xchg ax,bx
pascal@23996 272 jmp dos
pascal@20534 273
pascal@20538 274 endp @isolseek$qpxul
pascal@20534 275
pascal@20534 276 ;***************************************************************
pascal@20630 277 ;_fastcall int isoreadsector(bx:const unsigned long *offset);
pascal@23996 278 ;_fastcall int isoreadrootsector(void);
pascal@20534 279 ;***************************************************************
pascal@23996 280 global @isoreadrootsector$qv:near
pascal@23996 281 @isoreadrootsector$qv:
pascal@23996 282 mov bx,offset isorootofs
pascal@20534 283 global @isoreadsector$qpxul:near
pascal@20534 284 proc @isoreadsector$qpxul near
pascal@20534 285
pascal@23996 286 call isolseek ; filepos = 0
pascal@22749 287 jc fail
pascal@23996 288 mov dh,10
pascal@23996 289 mov ax,offset _isostate.buffer
pascal@23996 290 jmp @read$dxaxbx ; read(fd,buffer,2560+)
pascal@20534 291
pascal@20534 292 endp @isoreadsector$qpxul
pascal@20534 293
pascal@21628 294
pascal@23999 295 ifdef ISOHOOK
pascal@21628 296 ;***************************************************************
pascal@23996 297 ;_fastcall int strhead(bx:const char* a, ax:const char* b);
pascal@21628 298 ;***************************************************************
pascal@23996 299 global @strhead$qpxzct1:near
pascal@23996 300 proc @strhead$qpxzct1 near
pascal@21628 301
pascal@23996 302 @@loop:
pascal@23996 303 xchg ax,bx
pascal@23996 304 mov dl,[bx] ; dl = *b++
pascal@23996 305 inc bx
pascal@23996 306 xchg ax,bx
pascal@23996 307 or dl,dl ; clear C
pascal@23996 308 jz failifc ; return 0
pascal@23996 309 xor dl,[bx] ; dl -= *a++
pascal@23996 310 jne fail ; return -1
pascal@23996 311 inc bx
pascal@23996 312 jmp @@loop
pascal@21628 313
pascal@23996 314 endp @strhead$qpxzct1
pascal@21628 315
pascal@21628 316
pascal@21628 317 ;***************************************************************
pascal@23996 318 ;_fastcall int strcmp(bx:const char* a, ax:const char* b);
pascal@21628 319 ;***************************************************************
pascal@23996 320 global @strcmp$qpxzct1:near
pascal@23996 321 proc @strcmp$qpxzct1 near
pascal@21628 322
pascal@23996 323 call @strhead$qpxzct1
pascal@23996 324 jne fail ; return -1
pascal@23996 325 xor dl,[bx] ; clear C
pascal@23996 326 jne fail ; return -1
pascal@23996 327 jmp failifc ; return 0
pascal@21628 328
pascal@23996 329 endp @strcmp$qpxzct1
pascal@21628 330
pascal@23999 331 else
pascal@23999 332
pascal@23999 333 ;***************************************************************
pascal@23999 334 ;_fastcall int strcmp(bx:const char* a, ax:const char* b);
pascal@23999 335 ;***************************************************************
pascal@23999 336 global @strcmp$qpxzct1:near
pascal@23999 337 proc @strcmp$qpxzct1 near
pascal@23999 338
pascal@23999 339 @@loop:
pascal@23999 340 xchg ax,bx
pascal@23999 341 mov dl,[bx] ; dl = *b++
pascal@23999 342 inc bx
pascal@23999 343 xchg ax,bx
pascal@23999 344 xor dl,[bx] ; dl ^= *a++
pascal@23999 345 jne fail ; return -1
pascal@23999 346 inc bx
pascal@23999 347 or dl,dl ; clear C
pascal@23999 348 jz failifc ; return 0
pascal@23999 349 jmp @@loop
pascal@23999 350
pascal@23999 351 endp @strcmp$qpxzct1
pascal@23999 352 endif
pascal@19515 353
pascal@20751 354 ;***************************************************************
pascal@23996 355 ;_fastcall const char **argstr(bx:const char *s, ax:const char keywords[], dx:const char **var);
pascal@23993 356 ;_fastcall unsigned long *argnum(bx:char *s, ax:const char keywords[], dx:unsigned long *var);
pascal@20751 357 ;***************************************************************
pascal@20751 358 global @argstr$qpxzcxt1ppxzc:near
pascal@20751 359 proc @argstr$qpxzcxt1ppxzc near
pascal@20751 360
pascal@21569 361 mov cl,2
pascal@21569 362 db 0a9h ; test ax,#
pascal@20751 363 global @argnum$qpzcxpxzcpul:near
pascal@20751 364 @argnum$qpzcxpxzcpul:
pascal@21569 365 mov cl,4
pascal@23993 366 push bx
pascal@21569 367 xchg ax,bx ; keywords -> bx
pascal@21569 368 xchg ax,cx ; s -> cx
pascal@21569 369 cbw ; argstr:0002 argnum:0004
pascal@21569 370 xchg ax,dx ; vars -> ax
pascal@20751 371 push si di
pascal@21569 372 xchg ax,di ; vars => di
pascal@20751 373 dec bx
pascal@20751 374 @@testalt:
pascal@20751 375 sub di,dx
pascal@23797 376 @@loop:
pascal@20751 377 mov si,cx ; s
pascal@20751 378 add di,dx
pascal@20751 379 @@match:
pascal@21569 380 inc bx ; keywords++
pascal@21569 381 lodsb ; *s++
pascal@23999 382 or al,20h ; locase
pascal@20751 383 cmp al,[bx]
pascal@20751 384 je @@match
pascal@20751 385 cmp al,'/' ; 2f
pascal@20751 386 jne @@notopt
pascal@20751 387 cmp [byte bx],'-'
pascal@20751 388 je @@match
pascal@20751 389 @@notopt:
pascal@20751 390 cmp [byte bx],'|'
pascal@20751 391 je @@test
pascal@23984 392 cmp [byte bx],dh
pascal@23797 393 je @@test
pascal@23797 394 mov al,-1
pascal@20751 395 inc bx
pascal@23797 396 jmp @@notopt
pascal@23797 397 @@test:
pascal@23797 398 or al,al ; 1st loop ?
pascal@23797 399 jns @@testal
pascal@23984 400 cmp [byte bx],dh
pascal@23797 401 jne @@loop
pascal@23797 402 @@testal:
pascal@23999 403 cmp al,'*'
pascal@23999 404 je @@setnum
pascal@23797 405 cmp al,'='
pascal@23797 406 ;je @@found
pascal@23797 407 ;cmp al,0 ; eos, si=next argv
pascal@23996 408 xchg ax,cx ; return s if failure
pascal@23797 409 jne @@nokeyword
pascal@20751 410 @@found:
pascal@20751 411 dec dx
pascal@20751 412 dec dx
pascal@20751 413 je @@done
pascal@20751 414 call @strtol$qpxzc
pascal@23999 415 @@setnum:
pascal@23993 416 xchg ax,si
pascal@20751 417 mov [di+2],dx
pascal@20751 418 @@done:
pascal@23993 419 mov [di],si
pascal@23993 420 xchg ax,di
pascal@20751 421 @@nokeyword:
pascal@23993 422 pop di si bx
pascal@20751 423 ret
pascal@20751 424
pascal@20751 425 endp @argstr$qpxzcxt1ppxzc
pascal@20751 426
pascal@23996 427 ;***************************************************************
pascal@23996 428 ;_fastcall void puts(bx:const char* s):
pascal@23996 429 ;***************************************************************
pascal@23996 430 global @puts$qpxzc:near
pascal@20751 431
pascal@23996 432 ; global puts:near ; puts(bx)
pascal@23996 433 @putsz:
pascal@23996 434 call @putc
pascal@23996 435 @puts$qpxzc:
pascal@23996 436 puts:
pascal@23996 437 mov dl,[bx]
pascal@23996 438 inc bx
pascal@23996 439 or dl,dl
pascal@23996 440 jne @putsz
pascal@23996 441 mov dl,10
pascal@23996 442 @putc:
pascal@23996 443 cmp dl,10
pascal@23996 444 jne @putcz
pascal@23996 445 call @putcz2
pascal@23996 446 @putcz2:
pascal@23996 447 xor dl,7 ; 10^13 1010^1101
pascal@23996 448 @putcz:
pascal@23996 449 mov ah,2
pascal@23996 450 do_int21h:
pascal@23996 451 int 21h
pascal@23996 452 ret
pascal@19515 453
pascal@19515 454
pascal@22152 455 include "himem.inc"
pascal@22152 456
pascal@19515 457 ;***************************************************************
pascal@20630 458 ;_fastcall char* malloc_or_die(ax:unsigned size);
pascal@19515 459 ;***************************************************************
pascal@21757 460 xchg_heap_top:
pascal@22668 461 xchg ax,[bx]
pascal@21757 462 ret
pascal@21757 463
pascal@20528 464 proc @malloc_or_die$qui near
pascal@19515 465
pascal@23996 466 malloc_or_die: ; ax = malloc_or_die(ax)
pascal@22668 467 extrn _heap_top
pascal@22668 468 mov bx,offset _heap_top
pascal@22668 469 add ax,[bx]
pascal@22668 470 jnc xchg_heap_top
pascal@20456 471 mov bx,offset msg_malloc
pascal@19515 472
pascal@20528 473 endp @malloc_or_die$qui
pascal@19515 474
pascal@19515 475
pascal@19515 476 ;***************************************************************
pascal@20630 477 ;_fastcall int die(bx:const char* msg);
pascal@22152 478 ;int exit(ax:int status);
pascal@22152 479 ;int abort(void);
pascal@19515 480 ;***************************************************************
pascal@20528 481 global @die$qpxzc:near
pascal@20528 482 proc @die$qpxzc near
pascal@20528 483 @die$qpxzc:
pascal@19515 484 global die:near ; die(bx)
pascal@19515 485 die:
pascal@19515 486 call puts
pascal@21984 487 global @exit$qv:near
pascal@21984 488 @exit$qv:
pascal@19538 489 _exit:
pascal@22152 490 extrn _imgs:image_himem
pascal@22152 491 mov cx,[(word _imgs.buf)+2] ; no_exit ?
pascal@21757 492 mov ah,4Ch
pascal@22152 493 jcxz do_int21h
pascal@19515 494 mov bx, offset msg_hang
pascal@19515 495 call puts
pascal@20486 496 ; global _abort:near
pascal@19515 497 _abort:
pascal@19515 498 cli
pascal@19515 499 hlt
pascal@20778 500 jmp _abort
pascal@19515 501
pascal@20528 502 endp @die$qpxzc
pascal@19515 503
pascal@22152 504 ;***************************************************************
pascal@23996 505 ;_fastcall void open_image(si:struct image_himem *m, ax:const char *name);
pascal@22152 506 ;***************************************************************
pascal@22152 507
pascal@23996 508 global @open_image$qp11image_himempxzc:near
pascal@23996 509 proc @open_image$qp11image_himempxzc near
pascal@23996 510
pascal@23996 511 mov [(image_himem si).state],ax
pascal@23996 512 push ax
pascal@23996 513 @@next:
pascal@23996 514 call next_chunk
pascal@23996 515 ifndef NO386
pascal@23996 516 add eax,3
pascal@23996 517 and al,0FCh
pascal@23996 518 add [(image_himem si).size],eax ; m->size += m->chunk_size
pascal@23996 519 or eax,eax
pascal@23996 520 else
pascal@23996 521 add ax,3
pascal@23996 522 adc dx,0
pascal@23996 523 and al,0FCh
pascal@23996 524 add [word (image_himem si).size],ax ; m->size += m->chunk_size
pascal@23996 525 adc [word ((image_himem si).size)+2],dx
pascal@23996 526 or ax,dx
pascal@23996 527 endif
pascal@23996 528 jnz @@next
pascal@23996 529 pop [(image_himem si).state]
pascal@23996 530
pascal@23996 531 endp @open_image$qp11image_himempxzc
pascal@22152 532
pascal@19515 533
pascal@19636 534 ;***************************************************************
pascal@23996 535 ;static long next_chunk(struct image_himem *si);
pascal@19636 536 ;***************************************************************
pascal@19636 537 proc next_chunk near
pascal@19636 538
pascal@23996 539 ifndef NO_CLOSE
pascal@23996 540 mov ax,[(image_himem si).fd]
pascal@19636 541 call close
pascal@23996 542 endif
pascal@19636 543 ifndef NO386
pascal@19636 544 xor eax,eax
pascal@19636 545 else
pascal@19636 546 xor ax,ax
pascal@20485 547 cwd
pascal@19636 548 endif
pascal@23996 549 mov [(image_himem si).fd],ax
pascal@23996 550 mov bx,[(image_himem si).state]
pascal@19636 551 cmp al,[bx] ; ""
pascal@19636 552 jz @@end
pascal@23996 553 dec bx
pascal@23996 554 push di
pascal@19636 555 @@scan:
pascal@23996 556 inc bx
pascal@23996 557 mov al,[bx]
pascal@23996 558 mov di,bx
pascal@23996 559 or al,al
pascal@19636 560 jz @@eos
pascal@23996 561 sub al,','
pascal@19636 562 jnz @@scan
pascal@23996 563 inc bx
pascal@19636 564 @@eos:
pascal@23996 565 xchg [(image_himem si).state],bx ; set start of string
pascal@23996 566 mov [current_file],bx
pascal@23996 567 xchg [di],ax ; set temp eos (ax == 0)
pascal@23996 568 push ax
pascal@23996 569 call @open$qpxzc
pascal@23996 570 pop [word di] ; restore string
pascal@23996 571 pop di
pascal@23996 572 jnc @@opened
pascal@23996 573 loadfailure:
pascal@23996 574 ;***************************************************************
pascal@23996 575 ;_fastcall void loadfailure(void);
pascal@23996 576 ;***************************************************************
pascal@23996 577 global @loadfailure$qv:near
pascal@23996 578 @loadfailure$qv:
pascal@23996 579 mov bx,0
pascal@23996 580 org $-2
pascal@23996 581 current_file dw ?
pascal@23996 582 call puts
pascal@23996 583 mov bx,offset loaderr
pascal@23996 584 jmpdie:
pascal@23996 585 jmp die
pascal@23996 586 @@opened:
pascal@23996 587 mov [(image_himem si).fd],ax
pascal@23996 588 ifndef NO_CLOSE
pascal@23996 589 mov [(image_himem si).fd2close],ax
pascal@23996 590 endif
pascal@19636 591 ifndef NO386
pascal@23996 592 mov eax,[_isostate.filesize]
pascal@19636 593 @@end:
pascal@23996 594 mov [(image_himem si).chunk_size],eax
pascal@19636 595 else
pascal@23996 596 mov ax,[word _isostate.filesize]
pascal@23996 597 mov dx,[(word _isostate.filesize)+2]
pascal@19636 598 @@end:
pascal@23996 599 mov [word (image_himem si).chunk_size],ax
pascal@23996 600 mov [word ((image_himem si).chunk_size)+2],dx
pascal@19636 601 endif
pascal@19636 602 ret
pascal@19636 603
pascal@19636 604 endp next_chunk
pascal@19636 605
pascal@23996 606 ;***************************************************************
pascal@19636 607
pascal@19571 608 ifdef LARGE_IMAGES
pascal@19571 609 struc data_himem ;struct data_himem {
pascal@19571 610 first dd ? ; 0 u32 first;
pascal@19571 611 cacheidx dw ? ; 4 int cacheidx;
pascal@19571 612 pageidx dw ? ; 6 int pageidx;
pascal@19571 613 cache dd 1024 dup(?) ; 8 int cache;
pascal@19571 614 page dd 1024 dup(?) ;4104 int page;
pascal@22007 615 ends data_himem ;}; // size=8200
pascal@19571 616 endif
pascal@19571 617
pascal@19515 618 ;***************************************************************
pascal@23992 619 ;_fastcall u32* malloc_bufv_or_die(si:struct image_himem *m);
pascal@19538 620 ;***************************************************************
pascal@20528 621 global @malloc_bufv_or_die$qp11image_himem:near
pascal@20528 622 proc @malloc_bufv_or_die$qp11image_himem near
pascal@19538 623
pascal@19636 624 p386
pascal@19538 625 push si
pascal@23992 626 mov bx,si
pascal@19571 627 ifdef LARGE_IMAGES
pascal@21777 628 movzx eax,[word ((image_himem si).size) + 2]
pascal@21777 629 shr ax,4 ; pages index size = size >> 20
pascal@21777 630 add ax,8+4096+8
pascal@19571 631 call malloc_or_die
pascal@20527 632 mov cx,4096+4095 ; cnt = 1+(m->size+PAGE_MASK)/PAGE_SIZE;
pascal@19571 633 add ecx,[(image_himem si).size]
pascal@19571 634 shr ecx,12
pascal@19571 635 mov [curdata],ax
pascal@19571 636 else
pascal@21777 637 mov eax,[(image_himem si).size]
pascal@21777 638 dec eax
pascal@21777 639 shr eax,12
pascal@21777 640 inc ax ; cnt = (m->size+PAGE_MASK)/PAGE_SIZE;
pascal@21777 641 push ax
pascal@21777 642 inc ax ; cnt+1
pascal@21777 643 shl ax,2 ; bufv => vcpi => vm86
pascal@19538 644 ; our malloc zeroes allocated mem: bufv[cnt]=0;
pascal@19538 645 ; Allocate pages, storing addrs in addrbuf
pascal@19538 646 call malloc_or_die
pascal@19571 647 pop cx
pascal@19571 648 push ax
pascal@19571 649 endif
pascal@19546 650 mov [(image_himem si).bufv],ax
pascal@19571 651 xchg ax,si
pascal@19538 652 @@vcpi_alloc:
pascal@23996 653 mov ax,0DE04h ; allocate a 4K page => EDX
pascal@19538 654 int 67h
pascal@19538 655 or ah,ah
pascal@22176 656 stc
pascal@19538 657 mov bx,offset vcpi_alloc_err
pascal@23996 658 jnz jmpdie
pascal@19571 659 ; for (i = cnt-1; i >= 0; i--)
pascal@19571 660 ifdef LARGE_IMAGES
pascal@19571 661 mov eax,ecx
pascal@19571 662 dec eax
pascal@19571 663 else
pascal@19571 664 mov ax,cx
pascal@19571 665 dec ax
pascal@19571 666 cwde
pascal@19571 667 endif
pascal@19571 668 shl eax,12 ; i*_4k
pascal@19571 669 ; if (edx < pm.fallback+i*_4k && edx >= pm.fallback) again
pascal@22152 670 mov bx,offset _imgs.fallback
pascal@19571 671 push eax
pascal@19571 672 add eax,[bx-2+2]
pascal@19571 673 cmp eax,edx ; pm.fallback+i*_4k <= edx ?
pascal@19571 674 pop eax ; i*_4k
pascal@19571 675 jbe @@pmok
pascal@19571 676 cmp edx,[bx-2+2] ; edx >= pm.fallback ?
pascal@19571 677 jae @@vcpi_alloc
pascal@19571 678 @@pmok:
pascal@19571 679 ; if (edx >= initrd.fallback+i*_4k && edx < initrd.fallback+initrd.size) again
pascal@23996 680 add eax,[bx-2+2+32] ; +initrd.fallback
pascal@19571 681 cmp eax,edx ; initrd.fallback+i*_4k > edx ?
pascal@19571 682 ja @@initrdok
pascal@23996 683 mov eax,[bx-2+6+32] ; initrd.size
pascal@23996 684 add eax,[bx-2+2+32] ; +initrd.fallback
pascal@19571 685 cmp eax,edx ; initrd.fallback+initrd.size > edx ?
pascal@19571 686 @@jnc_vcpi_alloc:
pascal@19571 687 ja @@vcpi_alloc
pascal@19571 688 @@initrdok:
pascal@19571 689 ifdef LARGE_IMAGES
pascal@19571 690 cmp [(data_himem si).first],0
pascal@19571 691 jne @@notfirst
pascal@19571 692 mov [(data_himem si).first],edx
pascal@19571 693 @@notfirst:
pascal@19571 694 mov bx,[(data_himem si).cacheidx]
pascal@19571 695 cmp bh,4
pascal@19571 696 jae @@nextpage
pascal@19571 697 shl bx,2
pascal@19571 698 inc [(data_himem si).cacheidx]
pascal@19571 699 mov [(data_himem bx+si).cache],edx
pascal@19571 700 loopd @@vcpi_alloc
pascal@19571 701 mov [(data_himem bx+si).cache],ecx ; last is 0
pascal@19571 702 @@nextpage:
pascal@19571 703 and [(data_himem si).cacheidx],0
pascal@19571 704 mov bx,[(data_himem si).pageidx]
pascal@19571 705 mov [(data_himem bx+si).page],edx
pascal@19571 706 add [(data_himem si).pageidx],4
pascal@19571 707 push cx
pascal@19571 708 lea cx,[(data_himem si).cache]
pascal@19571 709 ifdef NO386
pascal@19571 710 push edx
pascal@23996 711 pop ax ; to dx:ax
pascal@19571 712 pop dx
pascal@19571 713 endif
pascal@19571 714 call storepage ; storepage(edx,cx)
pascal@19571 715 pop cx
pascal@19571 716 or ecx,ecx ; clear C
pascal@19571 717 jnz @@jnc_vcpi_alloc
pascal@19571 718 mov [dword (data_himem si).cacheidx],ecx
pascal@19571 719 xchg ax,si
pascal@19571 720 else
pascal@19571 721 mov [si],edx
pascal@19571 722 lodsd ; si=+4
pascal@19538 723 loop @@vcpi_alloc
pascal@19538 724 pop ax
pascal@19571 725 endif
pascal@19538 726 pop si
pascal@19538 727 ret
pascal@19636 728 ifdef NO386
pascal@19636 729 p8086
pascal@19636 730 endif
pascal@19538 731
pascal@20528 732 endp @malloc_bufv_or_die$qp11image_himem
pascal@19538 733
pascal@19538 734
pascal@19538 735 ;***************************************************************
pascal@20630 736 ;_fastcall void memcpy_image(bx:struct image_himem *m);
pascal@19515 737 ;***************************************************************
pascal@23992 738 global memcpy_image_initrd:near
pascal@23992 739 memcpy_image_initrd:
pascal@23992 740 lea bx,[si+32]
pascal@23992 741 db 0A9h ; test ax,imm
pascal@23992 742 global memcpy_image_kernel:near
pascal@23992 743 memcpy_image_kernel:
pascal@23992 744 mov bx,si
pascal@20528 745 proc @memcpy_image$qp11image_himem near
pascal@19515 746
pascal@19571 747 ifndef NO386
pascal@19571 748 mov edx,[(image_himem bx).fallback]
pascal@19571 749 mov eax,[(image_himem bx).buf]
pascal@19571 750 cmp eax,edx ; if (m->fallback != m->buf)
pascal@19571 751 jz @@skip ; memcpy32(m->fallback,0,m->buf,m->size)
pascal@19571 752 ifdef LARGE_IMAGES
pascal@19571 753 mov ecx,[(image_himem bx).size]
pascal@20146 754 memcpy_imagez: ; memcpy_imagez(edx,eax,ecx)
pascal@19571 755 push ecx
pascal@19571 756 else
pascal@19571 757 push [(image_himem bx).size]
pascal@19571 758 endif
pascal@19571 759 push eax
pascal@19571 760 push 0
pascal@19571 761 call_memcpy32:
pascal@19571 762 push edx
pascal@19571 763 else
pascal@21984 764 les ax,[dword ((image_himem bx).fallback)]
pascal@21984 765 mov dx,es
pascal@19571 766 mov cx,[word ((image_himem bx).buf)]
pascal@19571 767 cmp ax,cx ; if (m->fallback != m->buf)
pascal@19571 768 jnz @@do
pascal@19571 769 cmp dx,[word ((image_himem bx).buf)+2]
pascal@19571 770 jz @@skip ; memcpy32(m->fallback,0,m->buf,m->size)
pascal@19571 771 @@do:
pascal@19571 772 push [word ((image_himem bx).size)+2]
pascal@19571 773 push [word ((image_himem bx).size)]
pascal@19571 774 push [word ((image_himem bx).buf)+2]
pascal@19571 775 push cx
pascal@19571 776 xor cx,cx
pascal@19571 777 push cx
pascal@19571 778 call_memcpy32:
pascal@23996 779 push dx ; push dx:ax
pascal@19571 780 push ax
pascal@19571 781 ifdef LARGE_IMAGES
pascal@19571 782 jmp @@memcpy
pascal@20146 783 memcpy_imagez: ; memcpy_imagez(edx,eax,ecx)
pascal@19636 784 p386
pascal@19571 785 push ecx
pascal@19571 786 push eax
pascal@19571 787 push 0
pascal@19571 788 push edx
pascal@19636 789 ifdef NO386
pascal@19636 790 p8086
pascal@19636 791 endif
pascal@19571 792 endif
pascal@19571 793 endif
pascal@19571 794 @@memcpy:
pascal@20528 795 extrn memcpy32:near
pascal@20528 796 call near memcpy32
pascal@19571 797 @@skip:
pascal@19571 798 ret
pascal@19571 799
pascal@20528 800 endp @memcpy_image$qp11image_himem
pascal@19571 801
pascal@19571 802 ;***************************************************************
pascal@23992 803 ;_fastcall void storepage(di:u32 *dst);
pascal@19571 804 ;***************************************************************
pascal@20538 805 global @storepage$qpul:near
pascal@20538 806 proc @storepage$qpul near
pascal@19571 807
pascal@19571 808 ifndef NO386
pascal@23992 809 mov edx,[di]
pascal@19571 810 else
pascal@23992 811 les ax,[dword di]
pascal@23996 812 mov dx,es ; to dx:ax
pascal@19571 813 endif
pascal@20538 814 mov cx,offset _xfer_buf
pascal@20146 815 storepage: ; storepage(edx,cx)
pascal@19571 816 ifndef NO386
pascal@19571 817 push 0
pascal@19571 818 push 4096
pascal@19571 819 push 0
pascal@19571 820 else
pascal@19571 821 xor bx,bx
pascal@19571 822 push bx
pascal@19571 823 mov bh,4096/256
pascal@19571 824 push bx
pascal@19571 825 xor bx,bx
pascal@19571 826 push bx
pascal@19571 827 endif
pascal@19571 828 push cx
pascal@19571 829 push ds
pascal@19571 830 jmp call_memcpy32
pascal@19571 831
pascal@20538 832 endp @storepage$qpul
pascal@19571 833
pascal@19571 834
pascal@19571 835 ifdef LARGE_IMAGES
pascal@19636 836 p386
pascal@19571 837 ;***************************************************************
pascal@23992 838 ;_fastcall void reset_bufv(di:u32 *p);
pascal@19571 839 ;***************************************************************
pascal@20528 840 global @reset_bufv$qpul:near
pascal@20528 841 proc @reset_bufv$qpul near
pascal@19571 842
pascal@23992 843 mov [curdata],di
pascal@23992 844 and [dword (data_himem di).cacheidx],0
pascal@19571 845 ret
pascal@19571 846
pascal@20528 847 endp @reset_bufv$qpul
pascal@19571 848
pascal@19571 849 ;***************************************************************
pascal@23992 850 ;u32* di=prev_bufv();
pascal@23992 851 ;u32* di=prev_bufv();
pascal@19571 852 ;***************************************************************
pascal@19571 853 global _prev_bufv:near
pascal@19571 854 global _next_bufv:near
pascal@19571 855 proc _prev_bufv near
pascal@19571 856
pascal@19571 857 stc
pascal@19571 858 db 73h ; jnc
pascal@19571 859 _next_bufv:
pascal@19571 860 clc
pascal@23992 861 mov bx,0
pascal@22176 862 org $-2
pascal@22176 863 curdata dw ?
pascal@19571 864 sbb ax,ax
pascal@20527 865 cmc
pascal@23992 866 adc ax,[(data_himem bx).cacheidx] ; -1/+1
pascal@19571 867 xor ecx,ecx
pascal@19571 868 test ax,0fc00h
pascal@19571 869 jz @@gotpage
pascal@19571 870 push ax ; FFFF / 0400
pascal@19571 871 sar ax,8 ; FFFC / 0004
pascal@19571 872 and al,0fch
pascal@23992 873 add [(data_himem bx).pageidx],ax
pascal@23992 874 mov di,[(data_himem bx).pageidx]
pascal@23992 875 lea di,[(data_himem bx+di).page]
pascal@19571 876 mov edx,ds
pascal@19571 877 shl edx,4
pascal@23992 878 lea cx,[(data_himem bx).cache]
pascal@19571 879 add edx,ecx
pascal@23992 880 mov eax,[di]
pascal@19571 881 or eax,eax
pascal@19571 882 jnz @@pageok
pascal@19571 883 pop ax
pascal@19571 884 ret
pascal@19571 885 @@pageok:
pascal@19571 886 mov cx,4096
pascal@19571 887 call memcpy_imagez ; get page
pascal@19571 888 pop ax ; FFFF / 0400
pascal@19571 889 cbw
pascal@19571 890 shr ax,6 ; 03FF / 0000
pascal@19571 891 @@gotpage:
pascal@23992 892 mov [(data_himem bx).cacheidx],ax
pascal@19571 893 shl ax,2
pascal@23992 894 xchg ax,di
pascal@23992 895 lea ax,[(data_himem bx+di).cache]
pascal@23992 896 or di,[(data_himem bx).pageidx] ; !pageidx && !cacheidx
pascal@19571 897 jnz @@notfirst2
pascal@23992 898 xchg ax,bx ; &first
pascal@19571 899 @@notfirst2:
pascal@23992 900 xchg ax,di
pascal@19571 901 ret
pascal@19571 902
pascal@19571 903 endp _prev_bufv
pascal@19571 904 endif
pascal@19571 905
pascal@20146 906 ifdef NO386
pascal@20146 907 p8086
pascal@20146 908 endif
pascal@19571 909
pascal@19571 910 ;***************************************************************
pascal@23996 911 ;_fastcall int read_image(si:struct image_himem *m);
pascal@19515 912 ;***************************************************************
pascal@20538 913 global @read_image$qp11image_himem:near
pascal@20538 914 proc @read_image$qp11image_himem near
pascal@19515 915
pascal@23996 916 push di
pascal@23996 917 mov di,4096
pascal@23996 918 push di ; original size
pascal@19515 919 @@loop:
pascal@19538 920 ifndef NO386
pascal@23996 921 movzx ecx,di
pascal@23996 922 mov eax,[(image_himem si).chunk_size]
pascal@19538 923 cmp ecx,eax
pascal@19538 924 jb @@szok
pascal@19538 925 else
pascal@23996 926 mov cx,di
pascal@23996 927 mov ax,[word (image_himem si).chunk_size]
pascal@19538 928 cmp cx,ax
pascal@19515 929 jb @@szok
pascal@23996 930 cmp [word ((image_himem si).chunk_size)+2],0 ; hi m->chunk_size
pascal@19515 931 jne @@szok
pascal@20484 932 endif
pascal@19515 933 xchg ax,cx
pascal@19515 934 @@szok:
pascal@19538 935 jcxz image_done
pascal@20778 936 mov dx,offset _xfer_buf+4096
pascal@23996 937 sub dx,di
pascal@23996 938 mov bx,[si]
pascal@20528 939 call @read$cxdxbx
pascal@23806 940 jb image_done
pascal@19515 941 xor cx,cx
pascal@20539 942 cwd ; ax < 8000h
pascal@19538 943 ifndef NO386
pascal@19538 944 cwde ; ax < 8000h
pascal@23996 945 sub [(image_himem si).chunk_size],eax
pascal@20541 946 xchg eax,ebx
pascal@19538 947 else
pascal@23996 948 sub [word (image_himem si).chunk_size],ax
pascal@20539 949 xchg ax,bx
pascal@23996 950 sbb [word ((image_himem si).chunk_size)+2],dx
pascal@19538 951 jnz @@fill
pascal@23996 952 cmp [word (image_himem si).chunk_size],dx
pascal@19538 953 endif
pascal@19538 954 jnz @@fill
pascal@20539 955 dec cx
pascal@19515 956 @@fill:
pascal@20539 957 test bl,3
pascal@19515 958 je @@filled
pascal@20539 959 mov [bx+_xfer_buf],dh
pascal@20539 960 inc bx
pascal@19515 961 jmp @@fill
pascal@19515 962 @@filled:
pascal@19538 963 ifndef NO386
pascal@23996 964 sub [(image_himem si).remaining],ebx
pascal@19538 965 else
pascal@23996 966 sub [word (image_himem si).remaining],bx
pascal@23996 967 sbb [word ((image_himem si).remaining)+2],dx
pascal@19538 968 endif
pascal@23996 969 sub di,bx
pascal@19538 970 pushf
pascal@20778 971 jcxz @@same_chunk
pascal@20778 972 call next_chunk
pascal@19538 973 @@same_chunk:
pascal@19538 974 popf
pascal@19538 975 jnz @@loop
pascal@20484 976 image_done:
pascal@20528 977 pop ax ; original size
pascal@23996 978 sub ax,di
pascal@23996 979 pop di
pascal@20538 980 ret
pascal@19515 981
pascal@20538 982 endp @read_image$qp11image_himem
pascal@19515 983
pascal@19515 984
pascal@19515 985 ;***************************************************************
pascal@21569 986 ;_fastcall unsigned long strtol(const char *s);
pascal@19515 987 ;***************************************************************
pascal@20528 988 proc @strtol$qpxzc near
pascal@19515 989
pascal@20528 990 ifndef NO386
pascal@19515 991 xor ecx,ecx
pascal@19515 992 xor eax,eax
pascal@21569 993 xor ebx,ebx
pascal@19515 994 lodsb
pascal@19634 995 or al,20h
pascal@21984 996 cmp al,'a'
pascal@21984 997 jb @@notvga
pascal@23869 998 sub al,'o'
pascal@21984 999 @@vgaloop:
pascal@19538 1000 dec cx
pascal@21984 1001 add al,6
pascal@23869 1002 jnb @@vgaloop ; vga=normal,extended,ask
pascal@19538 1003 @@vga:
pascal@19538 1004 dec cx
pascal@19538 1005 xchg ax,cx
pascal@19538 1006 cwd
pascal@19634 1007 jmp @@popsiret
pascal@19538 1008 @@notvga:
pascal@22632 1009 mov cl,10 ; radix
pascal@19515 1010 cmp al,'-'
pascal@23868 1011 jne @@radixkeep
pascal@19515 1012 lodsb
pascal@19515 1013 @@radixkeep:
pascal@19515 1014 pushf
pascal@19515 1015 cmp al,'0'
pascal@19515 1016 jne @@radixok
pascal@19515 1017 mov cl,8
pascal@19515 1018 lodsb
pascal@19634 1019 or al,20h
pascal@19634 1020 cmp al,'x'
pascal@19515 1021 jne @@radixok
pascal@19515 1022 mov cl,16
pascal@19515 1023 @@strtollp:
pascal@19515 1024 lodsb
pascal@19515 1025 @@radixok:
pascal@19634 1026 or al,20h
pascal@19515 1027 sub al,'0'
pascal@19515 1028 jb @@endstrtol
pascal@19515 1029 cmp al,9
pascal@19515 1030 jbe @@digitok
pascal@19515 1031 cmp al,'a'-'0'
pascal@19515 1032 jb @@endstrtol
pascal@19515 1033 sub al,'a'-'0'-10
pascal@19515 1034 @@digitok:
pascal@19515 1035 cmp al,cl
pascal@19515 1036 jae @@endstrtol
pascal@23870 1037 cbw
pascal@23870 1038 cwde
pascal@19515 1039 xchg eax,ebx
pascal@19515 1040 mul ecx
pascal@23870 1041 add ebx,eax
pascal@19515 1042 jmp @@strtollp
pascal@19515 1043 @@endstrtol:
pascal@19515 1044 mov cl,10
pascal@19515 1045 cmp al,'k'-'a'+10
pascal@19515 1046 je @@shift
pascal@19515 1047 mov cl,20
pascal@19515 1048 cmp al,'m'-'a'+10
pascal@19515 1049 je @@shift
pascal@19515 1050 mov cl,30
pascal@19515 1051 cmp al,'g'-'a'+10
pascal@19515 1052 jne @@noshift
pascal@19515 1053 @@shift:
pascal@19515 1054 shl ebx,cl
pascal@19515 1055 @@noshift:
pascal@19515 1056 popf
pascal@19515 1057 jnc @@end
pascal@19515 1058 neg ebx
pascal@19515 1059 @@end:
pascal@19515 1060 push ebx
pascal@19515 1061 pop ax
pascal@19515 1062 pop dx
pascal@19634 1063 @@popsiret:
pascal@19515 1064 else
pascal@23868 1065 xor bx,bx
pascal@22632 1066 xor cx,cx
pascal@23870 1067 xor dx,dx
pascal@19538 1068 lodsb
pascal@19634 1069 or al,20h
pascal@21984 1070 cmp al,'a'
pascal@21984 1071 jb @@notvga
pascal@23869 1072 sub al,'o'
pascal@21984 1073 @@vgaloop:
pascal@19538 1074 dec cx
pascal@21984 1075 add al,6
pascal@23869 1076 jnb @@vgaloop ; vga=normal,extended,ask
pascal@19538 1077 @@vga:
pascal@19538 1078 xchg ax,cx
pascal@23869 1079 ;cwd
pascal@23983 1080 jmp @@end
pascal@19538 1081 @@notvga:
pascal@22632 1082 mov cl,10 ; radix
pascal@19515 1083 cmp al,'-'
pascal@23868 1084 jne @@radixkeep
pascal@19515 1085 lodsb
pascal@19515 1086 @@radixkeep:
pascal@19515 1087 pushf
pascal@19515 1088 cmp al,'0'
pascal@19515 1089 jne @@radixok
pascal@19515 1090 mov cl,8
pascal@19515 1091 lodsb
pascal@20146 1092 or al,20h
pascal@19634 1093 cmp al,'x'
pascal@19515 1094 jne @@radixok
pascal@19515 1095 mov cl,16
pascal@19515 1096 @@strtollp:
pascal@19515 1097 lodsb
pascal@19515 1098 @@radixok:
pascal@19634 1099 or al,20h
pascal@19515 1100 sub al,'0'
pascal@19515 1101 jb @@endstrtol
pascal@19515 1102 cmp al,9
pascal@19515 1103 jbe @@digitok
pascal@19515 1104 cmp al,'a'-'0'
pascal@19515 1105 jb @@endstrtol
pascal@19515 1106 sub al,'a'-'0'-10
pascal@19515 1107 @@digitok:
pascal@19515 1108 cmp al,cl
pascal@19515 1109 jae @@endstrtol
pascal@23870 1110 cbw
pascal@19515 1111
pascal@19515 1112 push ax
pascal@23870 1113 xchg ax,dx
pascal@23870 1114 mul cx
pascal@21984 1115 xchg ax,bx
pascal@21984 1116 mul cx
pascal@23870 1117 add dx,bx
pascal@23870 1118 pop bx
pascal@21984 1119 add bx,ax
pascal@19515 1120 adc dx,0
pascal@19515 1121
pascal@19515 1122 jmp @@strtollp
pascal@19515 1123 @@endstrtol:
pascal@19515 1124 mov cl,10
pascal@19515 1125 cmp al,'k'-'a'+10
pascal@19515 1126 je @@shift
pascal@19515 1127 mov cl,20
pascal@19515 1128 cmp al,'m'-'a'+10
pascal@19515 1129 je @@shift
pascal@19515 1130 mov cl,30
pascal@19515 1131 cmp al,'g'-'a'+10
pascal@23983 1132 @@shift:
pascal@23983 1133 xchg ax,bx
pascal@19515 1134 jne @@noshift
pascal@23983 1135 extrn N_LXLSH@:near
pascal@23983 1136 call N_LXLSH@
pascal@19515 1137 @@noshift:
pascal@19515 1138 popf
pascal@23868 1139 jne @@end
pascal@19515 1140 not dx
pascal@23983 1141 neg ax
pascal@19515 1142 jne @@end
pascal@19515 1143 inc dx
pascal@19515 1144 @@end:
pascal@19515 1145 endif
pascal@20528 1146 strtol_ret:
pascal@19515 1147 ret
pascal@19515 1148
pascal@20528 1149 endp @strtol$qpxzc
pascal@19515 1150
pascal@19515 1151
pascal@19515 1152 ends _TEXT
pascal@19515 1153
pascal@19515 1154 end
pascal@19515 1155
pascal@19515 1156 ;###### END OF FILE ############################################
pascal@19825 1157