wok-6.x rev 22176

linld: spare up to 30k more for zImage
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Nov 08 20:55:40 2019 +0100 (2019-11-08)
parents 55af2ae5af8f
children 7dd1225d9461
files linld/stuff/src/!COMPILE.BAT linld/stuff/src/A20.ASM linld/stuff/src/CRTL.ASM linld/stuff/src/JUMP.ASM linld/stuff/src/LOAD.CPP linld/stuff/src/pipehole.awk
line diff
     1.1 --- a/linld/stuff/src/!COMPILE.BAT	Fri Nov 08 17:15:11 2019 +0100
     1.2 +++ b/linld/stuff/src/!COMPILE.BAT	Fri Nov 08 20:55:40 2019 +0100
     1.3 @@ -3,12 +3,12 @@
     1.4  tasm /h > helptasm.log
     1.5  bcc > helpbcc.log
     1.6  tlink > helptlink.log
     1.7 -bcc @bccopt.opt -S -mt -DUSE_ARGSTR -DLARGE_IMAGES *.cpp > cpp.log
     1.8 +bcc @bccopt.opt -S -mt -DMOVE_SETUP -DUSE_ARGSTR -DLARGE_IMAGES *.cpp > cpp.log
     1.9  ren LINLD.ASM LINLD.ASO
    1.10  ren LOAD.ASM LOAD.ASO
    1.11  ren HIMEM.ASM HIMEM.ASO
    1.12  mawk -f pipehole.awk LINLD.ASO > LINLD.ASM
    1.13  mawk -f pipehole.awk LOAD.ASO > LOAD.ASM
    1.14  mawk -f pipehole.awk HIMEM.ASO > HIMEM.ASM
    1.15 -tasm /la /m /dUSE_ARGSTR /dNO386 /dLARGE_IMAGES /dLONG_FILENAME *.asm > asm.log
    1.16 +tasm /la /m /dMOVE_SETUP /dUSE_ARGSTR /dNO386 /dLARGE_IMAGES /dLONG_FILENAME *.asm > asm.log
    1.17  tlink /m /s /t @link.cmd > lnk.log
     2.1 --- a/linld/stuff/src/A20.ASM	Fri Nov 08 17:15:11 2019 +0100
     2.2 +++ b/linld/stuff/src/A20.ASM	Fri Nov 08 20:55:40 2019 +0100
     2.3 @@ -99,23 +99,24 @@
     2.4  		push	si di
     2.5  		extrn	_heap_top:word
     2.6  		ifdef	NO386
     2.7 +		mov	ax,[_heap_top]
     2.8 +		mov	cl,4
     2.9 +		shr	ax,cl
    2.10 +		mov	dx,cs
    2.11 +		add	dx,ax
    2.12  		extrn	_topseg:near
    2.13  		call	near _topseg
    2.14 -		mov	cl,4
    2.15  		mov	[word sssp+2],ax
    2.16 -		xchg	ax,dx
    2.17 -		mov	ax,[_heap_top]
    2.18 -		shr	ax,cl
    2.19  		else
    2.20                  p386
    2.21  		mov	ax,[_heap_top]
    2.22  		shr	ax,4
    2.23 -		mov	dx,9000h
    2.24 +		mov	dx,cs
    2.25 +		add	dx,ax
    2.26 +		mov	ax,9000h
    2.27  		endif
    2.28 -		mov	es,dx
    2.29 -		mov	cx,cs
    2.30 -		add	ax,cx
    2.31 -		cmp	ax,dx
    2.32 +		mov	es,ax
    2.33 +		cmp	dx,ax
    2.34  		jb	@@nooverflow
    2.35  ; Oops! We can stomp on our toes... better stop now
    2.36  		mov	bx,offset overflow
    2.37 @@ -124,9 +125,18 @@
    2.38  		mov	cx,[bx-5]	; size
    2.39  		mov	si,[bx-2]	; data
    2.40  		xor	di,di
    2.41 +		ifdef	MOVE_SETUP
    2.42 +		extrn	_pm_high:byte
    2.43 +		cmp	[_pm_high],al
    2.44 +		jne	@@move_clear
    2.45 +		mov	di,8000h
    2.46 +		sub	di,cx
    2.47 +		extrn	_rm_offset:word
    2.48 +		mov	[_rm_offset],di
    2.49 +		endif
    2.50  @@move_clear:
    2.51  		movsb
    2.52 -		mov	[byte si-1],0
    2.53 +		mov	[byte si-1],al
    2.54  		loop	@@move_clear
    2.55  		;push	ds
    2.56  		;pop	es
     3.1 --- a/linld/stuff/src/CRTL.ASM	Fri Nov 08 17:15:11 2019 +0100
     3.2 +++ b/linld/stuff/src/CRTL.ASM	Fri Nov 08 20:55:40 2019 +0100
     3.3 @@ -59,9 +59,6 @@
     3.4  _xfer_buf	db	4096	dup (?)
     3.5  filecnt		db	?		; in fact 0 minus file count...
     3.6  nextfilename	dw	?
     3.7 -	ifdef	LARGE_IMAGES
     3.8 -curdata		dw	?
     3.9 -	endif
    3.10  	ifdef	EXTRA
    3.11  ultoabuf	db	12	dup (?)
    3.12  	endif
    3.13 @@ -586,12 +583,12 @@
    3.14  		mov	[byte si],ah		; set temp eos
    3.15  		call	open
    3.16  		pop	[word si]		; restore string
    3.17 -		jc	@@die
    3.18 +		jc	jcdie
    3.19  		mov	[(image_himem di).fd],ax
    3.20  		mov	[(image_himem di).fd2close],ax
    3.21  		mov	bl,02h			; SEEK_END
    3.22  		call	lseek0
    3.23 -@@die:
    3.24 +jcdie:
    3.25  		mov	bx,[(image_himem di).errmsg]
    3.26  		jc	die
    3.27  		ifndef	NO386
    3.28 @@ -663,12 +660,12 @@
    3.29  		mov	[(image_himem si).bufv],ax
    3.30  		xchg	ax,si
    3.31  @@vcpi_alloc:
    3.32 -                xor     edx,edx
    3.33                  mov     ax,0DE04h
    3.34                  int     67h
    3.35  		or	ah,ah
    3.36 +		stc
    3.37  		mov	bx,offset vcpi_alloc_err
    3.38 -		jnz	die
    3.39 +		jnz	jcdie
    3.40  ; for (i = cnt-1; i >= 0; i--)
    3.41  	ifdef	LARGE_IMAGES
    3.42  		mov	eax,ecx
    3.43 @@ -867,7 +864,9 @@
    3.44  _next_bufv:
    3.45  		clc
    3.46  		push	si
    3.47 -		mov	si,[curdata]
    3.48 +		mov	si,0
    3.49 +		org	$-2
    3.50 +curdata		dw	?
    3.51  		sbb	ax,ax
    3.52  		cmc
    3.53  		adc	ax,[(data_himem si).cacheidx]	; -1/+1
     4.1 --- a/linld/stuff/src/JUMP.ASM	Fri Nov 08 17:15:11 2019 +0100
     4.2 +++ b/linld/stuff/src/JUMP.ASM	Fri Nov 08 20:55:40 2019 +0100
     4.3 @@ -157,6 +157,12 @@
     4.4  		lodsw
     4.5  		xchg	ax,bx			; get pm->fallback low word
     4.6  		lodsw				; get pm->fallback high word
     4.7 +		ifdef	MOVE_SETUP
     4.8 +		mov	si,0
     4.9 +	global	_rm_offset:word
    4.10 +		org	$-2
    4.11 +_rm_offset	dw	?
    4.12 +		endif
    4.13  		push	es
    4.14  		call	near @@isbzimage	; pop cs ; ds=es=ss
    4.15  
    4.16 @@ -183,6 +189,14 @@
    4.17  		extrn   memcpy32:near
    4.18  		call	memcpy32
    4.19  
    4.20 +		ifdef	MOVE_SETUP
    4.21 +		;xor	di,di
    4.22 +		mov	cx,8000h
    4.23 +		;sub	cx,si
    4.24 +		rep
    4.25 +		  movsb
    4.26 +		endif
    4.27 +
    4.28  		ifndef  noelks
    4.29  		ifndef	NO386
    4.30  		cmp	[dword 1E6h],'SKLE'
     5.1 --- a/linld/stuff/src/LOAD.CPP	Fri Nov 08 17:15:11 2019 +0100
     5.2 +++ b/linld/stuff/src/LOAD.CPP	Fri Nov 08 20:55:40 2019 +0100
     5.3 @@ -119,7 +119,7 @@
     5.4  #define topseg() 0x9000
     5.5  #endif
     5.6  u16 rm_size;
     5.7 -static u8 pm_high;	// @ = @rm_size + 2, see JUMP.ASM
     5.8 +u8 pm_high;		// @ = @rm_size + 2, see JUMP.ASM
     5.9  static u8* rm_buf;	// @ = @rm_size + 3, see JUMP.ASM
    5.10  struct image_himem imgs[2];
    5.11  
    5.12 @@ -211,7 +211,13 @@
    5.13      // Try to load kernel high, maybe even blindly storing it
    5.14      // in unallocated memory as a last resort
    5.15  
    5.16 +#ifdef	MOVE_SETUP
    5.17 +    extern unsigned rm_offset;
    5.18 +    if((u16)(((m->fallback=(u32(u16(_CS)+(u16(heap_top)>>4)+1)<<4))
    5.19 +             +m->size-rm_offset)>>16) >=
    5.20 +#else
    5.21      if((u16)(((m->fallback=(u32(u16(_CS)+(u16(heap_top)>>4)+1)<<4))+m->size)>>16) >=
    5.22 +#endif
    5.23  		 (u16)(topseg()>>12) || _pm_high) {
    5.24          m->fallback = base_himem;
    5.25      }
     6.1 --- a/linld/stuff/src/pipehole.awk	Fri Nov 08 17:15:11 2019 +0100
     6.2 +++ b/linld/stuff/src/pipehole.awk	Fri Nov 08 20:55:40 2019 +0100
     6.3 @@ -183,7 +183,7 @@
     6.4  			print	"	extrn	N_LXLSH@4:near"
     6.5  			sub(/N_LXLSH@/,"N_LXLSH@4")
     6.6  		}
     6.7 -		sub(/,0/,",dh")
     6.8 +		sub(/-3\],0/,"-3],dh")
     6.9  		if (/_base_himem\+2/ || /pop/ || /push/) next
    6.10  		if (/_base_himem$/) {
    6.11  			sub(/mov	dx,/,"les	dx,d")