wok rev 23985

linld: up to 60k for header.com
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Nov 28 09:45:01 2020 +0000 (17 months ago)
parents 431c14b76522
children f3eb71ce1913
files linld/stuff/src/CRTL.ASM linld/stuff/src/HEADER.ASM linld/stuff/src/ISOCRTL.ASM linld/stuff/src/_BEG.ASM
line diff
     1.1 --- a/linld/stuff/src/CRTL.ASM	Wed Nov 25 20:41:41 2020 +0000
     1.2 +++ b/linld/stuff/src/CRTL.ASM	Sat Nov 28 09:45:01 2020 +0000
     1.3 @@ -135,6 +135,7 @@
     1.4          global  @strcmp$qpxzct1:near
     1.5          proc    @strcmp$qpxzct1 near
     1.6  
     1.7 +		ifdef	USE_ARGSTR
     1.8  @@loop:
     1.9  		xchg	ax,bx
    1.10                  mov	cl,[bx]			; cl = *b++
    1.11 @@ -147,6 +148,15 @@
    1.12  		jz	failifc			; return 0
    1.13                  jmp	@@loop
    1.14  
    1.15 +		else
    1.16 +
    1.17 +		call	@strhead$qpxzct1
    1.18 +		jne	closeret		; return -1
    1.19 +		cmp	cl,[bx]
    1.20 +		jmp	failifc			; return 0 or -1
    1.21 +
    1.22 +		endif
    1.23 +
    1.24          endp    @strcmp$qpxzct1
    1.25  	endif
    1.26  
    1.27 @@ -166,9 +176,10 @@
    1.28  
    1.29  open:						; open(bx)
    1.30  	ifdef	ISOHOOK
    1.31 -;_fastcall int open(bx:const char* name);
    1.32  		extrn	iso_open_hack:word
    1.33 -		call	[iso_open_hack]		; or ret
    1.34 +		jmp	[iso_open_hack]
    1.35 +        global  __open:near
    1.36 +__open:
    1.37  	endif
    1.38  	ifdef	LONG_FILENAME
    1.39  		mov	ax,716Ch
    1.40 @@ -206,15 +217,17 @@
    1.41  
    1.42          global  close:near			; close(ax)
    1.43  close:
    1.44 +		mov	bh,3Eh
    1.45  	ifdef	ISOHOOK
    1.46  		extrn	iso_close_hack:word
    1.47 -		call	[iso_close_hack]	; or ret
    1.48 +		jmp	[iso_close_hack]
    1.49  	endif
    1.50 -		mov	bh,3Eh
    1.51 +	global	dosbx:near
    1.52  dosbx:
    1.53  		xchg	ax,bx
    1.54  		or	bx,bx
    1.55  		jnz	dos
    1.56 +closeret:
    1.57  		ret
    1.58  
    1.59          endp    @close$qi
    1.60 @@ -252,12 +265,13 @@
    1.61  @read$cxdxbx:
    1.62                  mov	ah,3Fh
    1.63  		endif
    1.64 +                jcxz	fail
    1.65  	ifdef	ISOHOOK
    1.66 -;_fastcall int read(bx:int fd, dx:void* data, cx:int sz);
    1.67 +;_fastcall int read(bx:int fd, dx:void* data, cx:int sz, ah=3Fh);
    1.68  		extrn	iso_read_hack:word
    1.69 -		call	[iso_read_hack]		; or ret
    1.70 +		jmp	[iso_read_hack]		; or ret
    1.71  	endif
    1.72 -                jcxz	fail
    1.73 +	global	dos:near
    1.74  dos:
    1.75                  int	21h
    1.76                  jnc	doret
    1.77 @@ -296,13 +310,14 @@
    1.78  lseekword:
    1.79  		sbb	cx,cx
    1.80  lseekset:
    1.81 +		mov	bh,42h			; bx=fd cx:dx=offset al=whence
    1.82  	ifdef	ISOHOOK
    1.83 -;_fastcall long lseek(ax:int fd, cxdx:unsigned long offset, bl:whence);
    1.84 +;_fastcall long lseek(ax:int fd, cxdx:unsigned long offset, bl:whence, bh=42h);
    1.85  		extrn	iso_lseek_hack:word
    1.86 -		call	[iso_lseek_hack]	; or ret
    1.87 +		jmp	[iso_lseek_hack]
    1.88 +	else
    1.89 +		jmp	dosbx
    1.90  	endif
    1.91 -		mov	bh,42h			; bx=fd cx:dx=offset al=whence
    1.92 -		jmp	dosbx
    1.93  
    1.94          endp    @rewind$qi
    1.95  
    1.96 @@ -463,9 +478,9 @@
    1.97  		xchg	ax,bx
    1.98                  mov	cl,[bx]			; cl = *b++
    1.99                  inc	bx
   1.100 +		xchg	ax,bx
   1.101  		or	cl,cl			; clear C
   1.102  		jz	failifc			; return 0
   1.103 -		xchg	ax,bx
   1.104                  xor	cl,[bx]			; cl -= *a++
   1.105                  inc	bx
   1.106  		and	cl,0dfh			; case insensitive
     2.1 --- a/linld/stuff/src/HEADER.ASM	Wed Nov 25 20:41:41 2020 +0000
     2.2 +++ b/linld/stuff/src/HEADER.ASM	Sat Nov 28 09:45:01 2020 +0000
     2.3 @@ -13,52 +13,45 @@
     2.4  
     2.5          segment _TEXT byte public use16 'CODE'
     2.6  
     2.7 -                org     100h
     2.8 +COMSTART	=	100h
     2.9 +MAXCODESZ	=	0F000h			; < 64K - COMSTART - STKSZ 
    2.10 +
    2.11 +                org     COMSTART
    2.12          global  _text_start:byte
    2.13          label   _text_start byte
    2.14  
    2.15 +		cld
    2.16 +		mov	dx,offset tazboot_cmd
    2.17  		mov	di,80h
    2.18 -		cmp	[byte di],1
    2.19 +		cmp	[byte di],dh
    2.20  		ja	notfound
    2.21 -	ifdef	WITH_LONG_FILENAME
    2.22 -		mov	si,offset tazboot_cmd
    2.23 -		mov	ax,716Ch
    2.24 -		xor	bx,bx			; R/O
    2.25 -		xor	cx,cx			; attributes
    2.26 -		cwd				; action = open
    2.27 -		stc
    2.28 -                int	21h
    2.29 -                jnc	found
    2.30 -		mov	dx,si
    2.31 -	else
    2.32 -		mov	dx,offset tazboot_cmd
    2.33 -	endif
    2.34                  mov	ax,3d00h		; read-only+compatibility
    2.35  		;mov	cl,0			; attribute mask
    2.36  		int	21h
    2.37  		jc	notfound
    2.38  found:
    2.39  		xchg	ax,bx
    2.40 -		mov	ah,3Eh
    2.41 +		mov	ah,3Eh			; close
    2.42  		int	21h
    2.43 -		mov	cx,endcmd-begcmd+1
    2.44 -		mov	si,offset default_arg
    2.45 +		mov	si,offset default_arg	; di = 0080h
    2.46 +		mov	cx,di
    2.47  		rep
    2.48  		  movsb
    2.49  notfound:
    2.50 -		mov	di,9000h
    2.51 -		mov	si,offset tomove
    2.52 -		mov	ch,1
    2.53 -		jmp	move
    2.54 -tomove:
    2.55 -		cld
    2.56 -		mov	di,100h
    2.57 -		mov	si,offset endcmd
    2.58 -		mov	ch,40h
    2.59 +		mov	di,MAXCODESZ+offset endcmd
    2.60 +		mov	si,offset move
    2.61 +		mov	cx,COMSTART
    2.62 +		mov	ax,offset endcmd
    2.63  move:
    2.64  		push	di
    2.65 +		push	cx
    2.66  		rep
    2.67 -		  movsw
    2.68 +		  movsb
    2.69 +		pop	di
    2.70 +		pop	cx
    2.71 +		;sub	cx,ax
    2.72 +		xchg	ax,si
    2.73 +		push	cx
    2.74  		ret
    2.75  
    2.76  default_arg	db	endcmd-begcmd
     3.1 --- a/linld/stuff/src/ISOCRTL.ASM	Wed Nov 25 20:41:41 2020 +0000
     3.2 +++ b/linld/stuff/src/ISOCRTL.ASM	Sat Nov 28 09:45:01 2020 +0000
     3.3 @@ -51,13 +51,13 @@
     3.4  		push	ds
     3.5  		pop	es
     3.6  		mov	di,128h		; TABLE
     3.7 -		mov	ax,offset iso_open_hack
     3.8 +		mov	ax,offset iso_close_hack
     3.9  		stosw
    3.10 -		mov	al,offset iso_read_hack-0F000h
    3.11 +		inc	ax	; iso_open_hack
    3.12  		stosw
    3.13 -		mov	al,offset iso_lseek_hack-0F000h
    3.14 +		add	al,offset iso_read_hack-offset iso_open_hack
    3.15  		stosw
    3.16 -		mov	al,offset iso_close_hack-0F000h
    3.17 +		add	al,offset iso_lseek_hack-offset iso_read_hack
    3.18  		stosw
    3.19  	ifdef	NO386
    3.20          global  N_LXLSH@ES:near
    3.21 @@ -71,6 +71,7 @@
    3.22  		rcl	dx,1
    3.23  		loop	@@lp
    3.24  	endif
    3.25 +iso_close_hack:
    3.26  		ret
    3.27  
    3.28  ;***************************************************************
    3.29 @@ -81,135 +82,24 @@
    3.30  		cmp	[byte bx],'!'
    3.31  		je	@readmenu$qv
    3.32  		xchg	ax,bx
    3.33 -		global	iso_open:near
    3.34  iso_open:
    3.35  		mov	[_isostate.filename2open],ax
    3.36  		call	@_isoopen$qv
    3.37  		cmp	al,1
    3.38  		cmc
    3.39 -iso_close_hack:
    3.40 -		pop	bx
    3.41  		ret
    3.42  
    3.43  
    3.44  ;***************************************************************
    3.45 -;_fastcall void readmenu(void);
    3.46 -;***************************************************************
    3.47 -	global	@readmenu$qv:near
    3.48 -	proc	@readmenu$qv near
    3.49 -
    3.50 -		pop	ax
    3.51 -		mov	dx,18
    3.52 -		xor	cx,cx
    3.53 -		call	lseekset
    3.54 -		mov	dx,offset _isostate.filemod
    3.55 -		mov	cx,10
    3.56 -		call	readfd ; // read x->filemod + x->fileofs & x->filesize
    3.57 -		mov	bx,offset _isostate.fileofs
    3.58 -		; x->fileofs = 0x7FF0 - (x->filesize &= 0xFFFF);
    3.59 -		mov	ax,7FF0h
    3.60 -		cwd
    3.61 -		mov	[word bx+6],dx
    3.62 -		sub	ax,[bx+4]
    3.63 -		mov	[word bx+2],dx
    3.64 -		mov	[bx],ax
    3.65 -		; //magic = x->filemod;
    3.66 -
    3.67 -	endp	@readmenu$qv
    3.68 -
    3.69 -;***************************************************************
    3.70 -;_fastcall void isolseek(bx:const unsigned long *offset);
    3.71 -;***************************************************************
    3.72 -        global  @isolseek$qpxul:near
    3.73 -        proc    @isolseek$qpxul near
    3.74 -
    3.75 -isolseek:
    3.76 -		mov	dx,[bx]
    3.77 -		mov	cx,[bx+2]
    3.78 -lseekset:
    3.79 -		mov	ax,4200h			; bx=fd cx:dx=offset al=whence
    3.80 -dosfd:
    3.81 -		mov	bx,[_isostate.fd]
    3.82 -dos:
    3.83 -		int	21h
    3.84 -failifc:
    3.85 -		jnc	dosok
    3.86 -fail:
    3.87 -		sbb	ax,ax
    3.88 -		cwd
    3.89 -dosok:
    3.90 -		ret
    3.91 -
    3.92 -	endp	@isolseek$qpxul
    3.93 -
    3.94 -;***************************************************************
    3.95 -;_fastcall int isoreadsector(bx:const unsigned long *offset);
    3.96 -;***************************************************************
    3.97 -        global  @isoreadsector$qpxul:near
    3.98 -        proc    @isoreadsector$qpxul near
    3.99 -
   3.100 -		call	isolseek
   3.101 -		jc	fail
   3.102 -		mov	cx,2560
   3.103 -		mov	dx,offset _isostate.buffer
   3.104 -		global	readfd:near
   3.105 -readfd:
   3.106 -                mov	ah,3Fh
   3.107 -		jmp	dosfd
   3.108 -
   3.109 -        endp    @isoreadsector$qpxul
   3.110 -
   3.111 -;***************************************************************
   3.112 -;_fastcall int strhead(bx:const char* a, ax:const char* b);
   3.113 -;***************************************************************
   3.114 -        global  @strhead$qpxzct1:near
   3.115 -        proc    @strhead$qpxzct1 near
   3.116 -
   3.117 -@@loop:
   3.118 -		xchg	ax,bx
   3.119 -                mov	cl,[bx]			; cl = *b++
   3.120 -                inc	bx
   3.121 -		or	cl,cl			; clear C
   3.122 -		jz	fail			; return 0
   3.123 -		xchg	ax,bx
   3.124 -                xor	cl,[bx]			; cl -= *a++
   3.125 -                inc	bx
   3.126 -		or	cl,cl
   3.127 -		stc
   3.128 -		jne	fail			; return -1
   3.129 -                jmp	@@loop
   3.130 -
   3.131 -	endp	@strhead$qpxzct1
   3.132 -
   3.133 -;***************************************************************
   3.134 -;_fastcall int strcmp(bx:const char* a, ax:const char* b);
   3.135 -;***************************************************************
   3.136 -        global  @strcmp$qpxzct1:near
   3.137 -        proc    @strcmp$qpxzct1 near
   3.138 -
   3.139 -		call	@strhead$qpxzct1
   3.140 -		jne	dosok			; return -1
   3.141 -		xchg	ax,bx
   3.142 -		cmp	cl,[bx]
   3.143 -		jmp	fail			; return 0 or -1
   3.144 -
   3.145 -        endp    @strcmp$qpxzct1
   3.146 -
   3.147 -;***************************************************************
   3.148 -;_fastcall int read(bx:int fd=isostate.fd, dx:void* data, cx:int sz);
   3.149 +;_fastcall int read(bx:int fd=isostate.fd, dx:void* data, cx:int sz, ah=3Fh);
   3.150  ;***************************************************************
   3.151  iso_read_hack:
   3.152  		push	dx
   3.153  		push	cx
   3.154  		xor	cx,cx
   3.155 -		mov	ax,4201h
   3.156 -		cwd
   3.157 -	ifdef	SEEK_CUR
   3.158 -		call	curpos		; bx = _isostate.fileofs
   3.159 -	else
   3.160 -		call	dosfd		; lseek(,0L,SEEK_CUR)
   3.161 -		call	sub_fileofs	; bx = _isostate.fileofs
   3.162 -	endif
   3.163 +		xor	dx,dx
   3.164 +		mov	al,01h
   3.165 +		call	doseek		; bx = _isostate.fileofs
   3.166  	ifdef	NO386
   3.167  		mov	cx,[bx+4]	; _isostate.filesize
   3.168  		sub	cx,ax
   3.169 @@ -240,38 +130,138 @@
   3.170  		xchg	ax,cx
   3.171  @@cxok:
   3.172  		pop	dx		; buffer
   3.173 -		pop	bx		; skip last caller
   3.174  		jmp	readfd
   3.175  
   3.176 +
   3.177  ;***************************************************************
   3.178 -;_fastcall long lseek(ax:int fd=isostate.fd, cxdx:unsigned long offset, bl:whence);
   3.179 +;_fastcall long lseek(ax:int fd=isostate.fd, cxdx:unsigned long offset, bl:whence, bh=42h);
   3.180  ;***************************************************************
   3.181  iso_lseek_hack:
   3.182  		xchg	ax,bx
   3.183 -		pop	bx		; skip last caller
   3.184  	ifdef	SEEK_CUR
   3.185  		cmp	al,1	; current
   3.186 -		jne	@@nocurrent
   3.187 -curpos:
   3.188 -		call	dosfd		; lseek(,0L,SEEK_CUR)
   3.189 -		jmp	sub_fileofs
   3.190 -@@nocurrent:
   3.191 +		je	doseek
   3.192  	endif
   3.193  		mov	bx,offset _isostate.fileofs
   3.194  		add	dx,[bx]
   3.195  		adc	cx,[bx+2]
   3.196  		cmp	al,0	; start
   3.197 -		je	@@doseek
   3.198 +		je	doseek
   3.199  		add	dx,[bx+4]	; _isostate.filesize
   3.200  		adc	cx,[bx+6]
   3.201 -@@doseek:
   3.202 -		call	lseekset	; lseek(,0L,SEEK_SET)
   3.203 +doseek:
   3.204 +		call	lseek		; lseek(,,al)
   3.205  sub_fileofs:
   3.206  		mov	bx,offset _isostate.fileofs
   3.207  		sub	ax,[bx]
   3.208  		sbb	dx,[bx+2]
   3.209  		ret
   3.210  
   3.211 +
   3.212 +;***************************************************************
   3.213 +;_fastcall void readmenu(void);
   3.214 +;***************************************************************
   3.215 +	proc	@readmenu$qv near
   3.216 +
   3.217 +		mov	dx,18
   3.218 +		xor	cx,cx
   3.219 +		call	lseekset
   3.220 +		mov	dx,offset _isostate.filemod
   3.221 +		mov	cl,10
   3.222 +		call	readfd ; // read x->filemod + x->fileofs & x->filesize
   3.223 +		mov	bx,offset _isostate.fileofs
   3.224 +		; x->fileofs = 0x7FF0 - (x->filesize &= 0xFFFF);
   3.225 +		mov	ax,7FF0h
   3.226 +		cwd
   3.227 +		mov	[word bx+6],dx
   3.228 +		sub	ax,[bx+4]
   3.229 +		mov	[word bx+2],dx
   3.230 +		mov	[bx],ax
   3.231 +		; //magic = x->filemod;
   3.232 +
   3.233 +	endp	@readmenu$qv
   3.234 +
   3.235 +;***************************************************************
   3.236 +;_fastcall void isolseek(bx:const unsigned long *offset);
   3.237 +;***************************************************************
   3.238 +        global  @isolseek$qpxul:near
   3.239 +        proc    @isolseek$qpxul near
   3.240 +
   3.241 +isolseek:
   3.242 +		mov	dx,[bx]
   3.243 +		mov	cx,[bx+2]
   3.244 +lseekset:
   3.245 +		mov	al,00h			; bx=fd cx:dx=offset al=whence
   3.246 +lseek:
   3.247 +		mov	ah,42h
   3.248 +dosfd:
   3.249 +		mov	bx,[_isostate.fd]
   3.250 +dos:
   3.251 +		int	21h
   3.252 +failifc:
   3.253 +		jnc	dosok
   3.254 +fail:
   3.255 +		sbb	ax,ax
   3.256 +		cwd
   3.257 +dosok:
   3.258 +		ret
   3.259 +
   3.260 +	endp	@isolseek$qpxul
   3.261 +
   3.262 +
   3.263 +;***************************************************************
   3.264 +;_fastcall int isoreadsector(bx:const unsigned long *offset);
   3.265 +;***************************************************************
   3.266 +        global  @isoreadsector$qpxul:near
   3.267 +        proc    @isoreadsector$qpxul near
   3.268 +
   3.269 +		call	isolseek
   3.270 +		jc	fail
   3.271 +		mov	ch,9			; < 2560
   3.272 +		mov	dx,offset _isostate.buffer
   3.273 +readfd:
   3.274 +                mov	ah,3Fh
   3.275 +		jmp	dosfd
   3.276 +
   3.277 +        endp    @isoreadsector$qpxul
   3.278 +
   3.279 +
   3.280 +;***************************************************************
   3.281 +;_fastcall int strhead(bx:const char* a, ax:const char* b);
   3.282 +;***************************************************************
   3.283 +        global  @strhead$qpxzct1:near
   3.284 +        proc    @strhead$qpxzct1 near
   3.285 +
   3.286 +@@loop:
   3.287 +		xchg	ax,bx
   3.288 +                mov	cl,[bx]			; cl = *b++
   3.289 +                inc	bx
   3.290 +		xchg	ax,bx
   3.291 +		or	cl,cl			; clear C
   3.292 +		jz	fail			; return 0
   3.293 +                xor	cl,[bx]			; cl -= *a++
   3.294 +                inc	bx
   3.295 +		or	cl,cl
   3.296 +		stc
   3.297 +		jne	fail			; return -1
   3.298 +                jmp	@@loop
   3.299 +
   3.300 +	endp	@strhead$qpxzct1
   3.301 +
   3.302 +
   3.303 +;***************************************************************
   3.304 +;_fastcall int strcmp(bx:const char* a, ax:const char* b);
   3.305 +;***************************************************************
   3.306 +        global  @strcmp$qpxzct1:near
   3.307 +        proc    @strcmp$qpxzct1 near
   3.308 +
   3.309 +		call	@strhead$qpxzct1
   3.310 +		jne	dosok			; return -1
   3.311 +		cmp	cl,[bx]
   3.312 +		jmp	fail			; return 0 or -1
   3.313 +
   3.314 +        endp    @strcmp$qpxzct1
   3.315 +
   3.316          ends    _TEXT
   3.317  
   3.318  	end
     4.1 --- a/linld/stuff/src/_BEG.ASM	Wed Nov 25 20:41:41 2020 +0000
     4.2 +++ b/linld/stuff/src/_BEG.ASM	Sat Nov 28 09:45:01 2020 +0000
     4.3 @@ -106,15 +106,17 @@
     4.4  		endif
     4.5  
     4.6  	ifdef	ISOHOOK
     4.7 -		extrn	@ret:near
     4.8 -		global	iso_open_hack
     4.9 -iso_open_hack	dw	@ret
    4.10 +		global	iso_close_hack
    4.11 +iso_close_hack	dw	dosbx
    4.12 +		global  iso_open_hack
    4.13 +	        extrn   __open:near
    4.14 +iso_open_hack	dw      __open
    4.15  		global	iso_read_hack
    4.16 -iso_read_hack	dw	@ret
    4.17 +		extrn	dos:near
    4.18 +iso_read_hack	dw	dos
    4.19  		global	iso_lseek_hack
    4.20 -iso_lseek_hack	dw	@ret
    4.21 -		global	iso_close_hack
    4.22 -iso_close_hack	dw	@ret
    4.23 +		extrn	dosbx:near
    4.24 +iso_lseek_hack	dw	dosbx
    4.25  	        global  _cpu_features:dword
    4.26  _cpu_features	dd	?		; default _cpu_features+3=1Fh/8Eh (bit5=0, not 64bits)
    4.27  		org	$-4