# HG changeset patch # User Pascal Bellard # Date 1606556701 0 # Node ID 555bcdab610b7922cc0f979578f8fa6d998c5e38 # Parent 431c14b76522c8e233724d8b544abbf8225f6245 linld: up to 60k for header.com diff -r 431c14b76522 -r 555bcdab610b linld/stuff/src/CRTL.ASM --- a/linld/stuff/src/CRTL.ASM Wed Nov 25 20:41:41 2020 +0000 +++ b/linld/stuff/src/CRTL.ASM Sat Nov 28 09:45:01 2020 +0000 @@ -135,6 +135,7 @@ global @strcmp$qpxzct1:near proc @strcmp$qpxzct1 near + ifdef USE_ARGSTR @@loop: xchg ax,bx mov cl,[bx] ; cl = *b++ @@ -147,6 +148,15 @@ jz failifc ; return 0 jmp @@loop + else + + call @strhead$qpxzct1 + jne closeret ; return -1 + cmp cl,[bx] + jmp failifc ; return 0 or -1 + + endif + endp @strcmp$qpxzct1 endif @@ -166,9 +176,10 @@ open: ; open(bx) ifdef ISOHOOK -;_fastcall int open(bx:const char* name); extrn iso_open_hack:word - call [iso_open_hack] ; or ret + jmp [iso_open_hack] + global __open:near +__open: endif ifdef LONG_FILENAME mov ax,716Ch @@ -206,15 +217,17 @@ global close:near ; close(ax) close: + mov bh,3Eh ifdef ISOHOOK extrn iso_close_hack:word - call [iso_close_hack] ; or ret + jmp [iso_close_hack] endif - mov bh,3Eh + global dosbx:near dosbx: xchg ax,bx or bx,bx jnz dos +closeret: ret endp @close$qi @@ -252,12 +265,13 @@ @read$cxdxbx: mov ah,3Fh endif + jcxz fail ifdef ISOHOOK -;_fastcall int read(bx:int fd, dx:void* data, cx:int sz); +;_fastcall int read(bx:int fd, dx:void* data, cx:int sz, ah=3Fh); extrn iso_read_hack:word - call [iso_read_hack] ; or ret + jmp [iso_read_hack] ; or ret endif - jcxz fail + global dos:near dos: int 21h jnc doret @@ -296,13 +310,14 @@ lseekword: sbb cx,cx lseekset: + mov bh,42h ; bx=fd cx:dx=offset al=whence ifdef ISOHOOK -;_fastcall long lseek(ax:int fd, cxdx:unsigned long offset, bl:whence); +;_fastcall long lseek(ax:int fd, cxdx:unsigned long offset, bl:whence, bh=42h); extrn iso_lseek_hack:word - call [iso_lseek_hack] ; or ret + jmp [iso_lseek_hack] + else + jmp dosbx endif - mov bh,42h ; bx=fd cx:dx=offset al=whence - jmp dosbx endp @rewind$qi @@ -463,9 +478,9 @@ xchg ax,bx mov cl,[bx] ; cl = *b++ inc bx + xchg ax,bx or cl,cl ; clear C jz failifc ; return 0 - xchg ax,bx xor cl,[bx] ; cl -= *a++ inc bx and cl,0dfh ; case insensitive diff -r 431c14b76522 -r 555bcdab610b linld/stuff/src/HEADER.ASM --- a/linld/stuff/src/HEADER.ASM Wed Nov 25 20:41:41 2020 +0000 +++ b/linld/stuff/src/HEADER.ASM Sat Nov 28 09:45:01 2020 +0000 @@ -13,52 +13,45 @@ segment _TEXT byte public use16 'CODE' - org 100h +COMSTART = 100h +MAXCODESZ = 0F000h ; < 64K - COMSTART - STKSZ + + org COMSTART global _text_start:byte label _text_start byte + cld + mov dx,offset tazboot_cmd mov di,80h - cmp [byte di],1 + cmp [byte di],dh ja notfound - ifdef WITH_LONG_FILENAME - mov si,offset tazboot_cmd - mov ax,716Ch - xor bx,bx ; R/O - xor cx,cx ; attributes - cwd ; action = open - stc - int 21h - jnc found - mov dx,si - else - mov dx,offset tazboot_cmd - endif mov ax,3d00h ; read-only+compatibility ;mov cl,0 ; attribute mask int 21h jc notfound found: xchg ax,bx - mov ah,3Eh + mov ah,3Eh ; close int 21h - mov cx,endcmd-begcmd+1 - mov si,offset default_arg + mov si,offset default_arg ; di = 0080h + mov cx,di rep movsb notfound: - mov di,9000h - mov si,offset tomove - mov ch,1 - jmp move -tomove: - cld - mov di,100h - mov si,offset endcmd - mov ch,40h + mov di,MAXCODESZ+offset endcmd + mov si,offset move + mov cx,COMSTART + mov ax,offset endcmd move: push di + push cx rep - movsw + movsb + pop di + pop cx + ;sub cx,ax + xchg ax,si + push cx ret default_arg db endcmd-begcmd diff -r 431c14b76522 -r 555bcdab610b linld/stuff/src/ISOCRTL.ASM --- a/linld/stuff/src/ISOCRTL.ASM Wed Nov 25 20:41:41 2020 +0000 +++ b/linld/stuff/src/ISOCRTL.ASM Sat Nov 28 09:45:01 2020 +0000 @@ -51,13 +51,13 @@ push ds pop es mov di,128h ; TABLE - mov ax,offset iso_open_hack + mov ax,offset iso_close_hack stosw - mov al,offset iso_read_hack-0F000h + inc ax ; iso_open_hack stosw - mov al,offset iso_lseek_hack-0F000h + add al,offset iso_read_hack-offset iso_open_hack stosw - mov al,offset iso_close_hack-0F000h + add al,offset iso_lseek_hack-offset iso_read_hack stosw ifdef NO386 global N_LXLSH@ES:near @@ -71,6 +71,7 @@ rcl dx,1 loop @@lp endif +iso_close_hack: ret ;*************************************************************** @@ -81,135 +82,24 @@ cmp [byte bx],'!' je @readmenu$qv xchg ax,bx - global iso_open:near iso_open: mov [_isostate.filename2open],ax call @_isoopen$qv cmp al,1 cmc -iso_close_hack: - pop bx ret ;*************************************************************** -;_fastcall void readmenu(void); -;*************************************************************** - global @readmenu$qv:near - proc @readmenu$qv near - - pop ax - mov dx,18 - xor cx,cx - call lseekset - mov dx,offset _isostate.filemod - mov cx,10 - call readfd ; // read x->filemod + x->fileofs & x->filesize - mov bx,offset _isostate.fileofs - ; x->fileofs = 0x7FF0 - (x->filesize &= 0xFFFF); - mov ax,7FF0h - cwd - mov [word bx+6],dx - sub ax,[bx+4] - mov [word bx+2],dx - mov [bx],ax - ; //magic = x->filemod; - - endp @readmenu$qv - -;*************************************************************** -;_fastcall void isolseek(bx:const unsigned long *offset); -;*************************************************************** - global @isolseek$qpxul:near - proc @isolseek$qpxul near - -isolseek: - mov dx,[bx] - mov cx,[bx+2] -lseekset: - mov ax,4200h ; bx=fd cx:dx=offset al=whence -dosfd: - mov bx,[_isostate.fd] -dos: - int 21h -failifc: - jnc dosok -fail: - sbb ax,ax - cwd -dosok: - ret - - endp @isolseek$qpxul - -;*************************************************************** -;_fastcall int isoreadsector(bx:const unsigned long *offset); -;*************************************************************** - global @isoreadsector$qpxul:near - proc @isoreadsector$qpxul near - - call isolseek - jc fail - mov cx,2560 - mov dx,offset _isostate.buffer - global readfd:near -readfd: - mov ah,3Fh - jmp dosfd - - endp @isoreadsector$qpxul - -;*************************************************************** -;_fastcall int strhead(bx:const char* a, ax:const char* b); -;*************************************************************** - global @strhead$qpxzct1:near - proc @strhead$qpxzct1 near - -@@loop: - xchg ax,bx - mov cl,[bx] ; cl = *b++ - inc bx - or cl,cl ; clear C - jz fail ; return 0 - xchg ax,bx - xor cl,[bx] ; cl -= *a++ - inc bx - or cl,cl - stc - jne fail ; return -1 - jmp @@loop - - endp @strhead$qpxzct1 - -;*************************************************************** -;_fastcall int strcmp(bx:const char* a, ax:const char* b); -;*************************************************************** - global @strcmp$qpxzct1:near - proc @strcmp$qpxzct1 near - - call @strhead$qpxzct1 - jne dosok ; return -1 - xchg ax,bx - cmp cl,[bx] - jmp fail ; return 0 or -1 - - endp @strcmp$qpxzct1 - -;*************************************************************** -;_fastcall int read(bx:int fd=isostate.fd, dx:void* data, cx:int sz); +;_fastcall int read(bx:int fd=isostate.fd, dx:void* data, cx:int sz, ah=3Fh); ;*************************************************************** iso_read_hack: push dx push cx xor cx,cx - mov ax,4201h - cwd - ifdef SEEK_CUR - call curpos ; bx = _isostate.fileofs - else - call dosfd ; lseek(,0L,SEEK_CUR) - call sub_fileofs ; bx = _isostate.fileofs - endif + xor dx,dx + mov al,01h + call doseek ; bx = _isostate.fileofs ifdef NO386 mov cx,[bx+4] ; _isostate.filesize sub cx,ax @@ -240,38 +130,138 @@ xchg ax,cx @@cxok: pop dx ; buffer - pop bx ; skip last caller jmp readfd + ;*************************************************************** -;_fastcall long lseek(ax:int fd=isostate.fd, cxdx:unsigned long offset, bl:whence); +;_fastcall long lseek(ax:int fd=isostate.fd, cxdx:unsigned long offset, bl:whence, bh=42h); ;*************************************************************** iso_lseek_hack: xchg ax,bx - pop bx ; skip last caller ifdef SEEK_CUR cmp al,1 ; current - jne @@nocurrent -curpos: - call dosfd ; lseek(,0L,SEEK_CUR) - jmp sub_fileofs -@@nocurrent: + je doseek endif mov bx,offset _isostate.fileofs add dx,[bx] adc cx,[bx+2] cmp al,0 ; start - je @@doseek + je doseek add dx,[bx+4] ; _isostate.filesize adc cx,[bx+6] -@@doseek: - call lseekset ; lseek(,0L,SEEK_SET) +doseek: + call lseek ; lseek(,,al) sub_fileofs: mov bx,offset _isostate.fileofs sub ax,[bx] sbb dx,[bx+2] ret + +;*************************************************************** +;_fastcall void readmenu(void); +;*************************************************************** + proc @readmenu$qv near + + mov dx,18 + xor cx,cx + call lseekset + mov dx,offset _isostate.filemod + mov cl,10 + call readfd ; // read x->filemod + x->fileofs & x->filesize + mov bx,offset _isostate.fileofs + ; x->fileofs = 0x7FF0 - (x->filesize &= 0xFFFF); + mov ax,7FF0h + cwd + mov [word bx+6],dx + sub ax,[bx+4] + mov [word bx+2],dx + mov [bx],ax + ; //magic = x->filemod; + + endp @readmenu$qv + +;*************************************************************** +;_fastcall void isolseek(bx:const unsigned long *offset); +;*************************************************************** + global @isolseek$qpxul:near + proc @isolseek$qpxul near + +isolseek: + mov dx,[bx] + mov cx,[bx+2] +lseekset: + mov al,00h ; bx=fd cx:dx=offset al=whence +lseek: + mov ah,42h +dosfd: + mov bx,[_isostate.fd] +dos: + int 21h +failifc: + jnc dosok +fail: + sbb ax,ax + cwd +dosok: + ret + + endp @isolseek$qpxul + + +;*************************************************************** +;_fastcall int isoreadsector(bx:const unsigned long *offset); +;*************************************************************** + global @isoreadsector$qpxul:near + proc @isoreadsector$qpxul near + + call isolseek + jc fail + mov ch,9 ; < 2560 + mov dx,offset _isostate.buffer +readfd: + mov ah,3Fh + jmp dosfd + + endp @isoreadsector$qpxul + + +;*************************************************************** +;_fastcall int strhead(bx:const char* a, ax:const char* b); +;*************************************************************** + global @strhead$qpxzct1:near + proc @strhead$qpxzct1 near + +@@loop: + xchg ax,bx + mov cl,[bx] ; cl = *b++ + inc bx + xchg ax,bx + or cl,cl ; clear C + jz fail ; return 0 + xor cl,[bx] ; cl -= *a++ + inc bx + or cl,cl + stc + jne fail ; return -1 + jmp @@loop + + endp @strhead$qpxzct1 + + +;*************************************************************** +;_fastcall int strcmp(bx:const char* a, ax:const char* b); +;*************************************************************** + global @strcmp$qpxzct1:near + proc @strcmp$qpxzct1 near + + call @strhead$qpxzct1 + jne dosok ; return -1 + cmp cl,[bx] + jmp fail ; return 0 or -1 + + endp @strcmp$qpxzct1 + ends _TEXT end diff -r 431c14b76522 -r 555bcdab610b linld/stuff/src/_BEG.ASM --- a/linld/stuff/src/_BEG.ASM Wed Nov 25 20:41:41 2020 +0000 +++ b/linld/stuff/src/_BEG.ASM Sat Nov 28 09:45:01 2020 +0000 @@ -106,15 +106,17 @@ endif ifdef ISOHOOK - extrn @ret:near - global iso_open_hack -iso_open_hack dw @ret + global iso_close_hack +iso_close_hack dw dosbx + global iso_open_hack + extrn __open:near +iso_open_hack dw __open global iso_read_hack -iso_read_hack dw @ret + extrn dos:near +iso_read_hack dw dos global iso_lseek_hack -iso_lseek_hack dw @ret - global iso_close_hack -iso_close_hack dw @ret + extrn dosbx:near +iso_lseek_hack dw dosbx global _cpu_features:dword _cpu_features dd ? ; default _cpu_features+3=1Fh/8Eh (bit5=0, not 64bits) org $-4