wok rev 20485

linld: fix memcpy32 (16 low mem case)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Oct 23 08:25:49 2018 +0200 (2018-10-23)
parents 81a3d87e0965
children 049ced0bd387
files linld/stuff/src/CRTL.ASM linld/stuff/src/JUMP.ASM linld/stuff/src/LOAD.CPP linld/stuff/src/MEMCPY32.ASM linld/stuff/src/pipehole.awk
line diff
     1.1 --- a/linld/stuff/src/CRTL.ASM	Sun Oct 21 17:30:30 2018 +0200
     1.2 +++ b/linld/stuff/src/CRTL.ASM	Tue Oct 23 08:25:49 2018 +0200
     1.3 @@ -482,8 +482,8 @@
     1.4  		xor	eax,eax
     1.5  		else
     1.6  		xor	ax,ax
     1.7 +		cwd
     1.8  		endif
     1.9 -		cwd
    1.10  		mov	[(image_himem di).fd],ax
    1.11  		mov	bx,[(image_himem di).state]
    1.12  		cmp	al,[bx]			; ""
    1.13 @@ -501,7 +501,7 @@
    1.14  		mov	[(image_himem di).state],cx
    1.15  		dec	si
    1.16  		push	[word si]
    1.17 -		mov	[byte si],dl		; set temp eos
    1.18 +		mov	[byte si],ah		; set temp eos
    1.19  		call	open
    1.20  		pop	[word si]		; restore string
    1.21  		jc	@@die
    1.22 @@ -861,26 +861,19 @@
    1.23          global  _open_image:near
    1.24          proc    _open_image near
    1.25  
    1.26 -		pop	ax			;caller return address
    1.27 +		pop	cx			;caller return address
    1.28  		pop	bx			; name
    1.29 -		pop	cx			; m
    1.30 +		pop	ax			; m
    1.31 +		push	ax
    1.32 +		push	bx
    1.33  		push	cx
    1.34 -		push	bx
    1.35 -		push	ax
    1.36                  push	di
    1.37 -		mov	di,cx
    1.38 -		ifndef	NO386
    1.39 -                xor	eax,eax			; 1st loop flag + eos
    1.40 -		else
    1.41 -                xor	ax,ax			; 1st loop flag + eos
    1.42 -		endif
    1.43 +		xchg	ax,di
    1.44  		mov	[(image_himem di).next_chunk],offset next_chunk
    1.45                  mov	[(image_himem di).state],bx
    1.46  		push	bx
    1.47  @@next:
    1.48 -		push	di
    1.49                  call	[(image_himem di).next_chunk]	; m->next_chunk()
    1.50 -		pop	di
    1.51  		ifndef	NO386
    1.52  		add	eax,3
    1.53  		and	al,0FCh
    1.54 @@ -984,9 +977,7 @@
    1.55  		sub	[word sz],ax
    1.56  		pushf
    1.57  		jcxz	@@same_chunk
    1.58 -		push	di
    1.59                  call	[(image_himem di).next_chunk]
    1.60 -		pop	di
    1.61  @@same_chunk:
    1.62  		popf
    1.63  		jnz	@@loop
     2.1 --- a/linld/stuff/src/JUMP.ASM	Sun Oct 21 17:30:30 2018 +0200
     2.2 +++ b/linld/stuff/src/JUMP.ASM	Tue Oct 23 08:25:49 2018 +0200
     2.3 @@ -143,31 +143,30 @@
     2.4  		mov	ch,10h			; 4k
     2.5  		rep
     2.6  		  movsb
     2.7 -		cmp	al,cl			; load high ?
     2.8 -		pushf
     2.9  		ifdef	NO386
    2.10  		add	bh,9
    2.11  		push	bx			; topseg()+0x0900
    2.12  		else
    2.13  		push	9800h+(4096/16)		; 4096 bytes for cmdline
    2.14  		endif
    2.15 +		cmp	al,cl			; load high ?
    2.16 +		pushf
    2.17  		; finish loading
    2.18  		extrn   @last_ditch$qv:near
    2.19  		call	@last_ditch$qv
    2.20 +		dos_shutdown			; clear di; ds=0
    2.21 +		push	cs
    2.22 +		pop	ds
    2.23 +		popf
    2.24  		; self move
    2.25  		;cld
    2.26  		pop	es			; min 2048 bytes for stack
    2.27 +		jne	@@isbzimage
    2.28  		mov	cx,offset movedend
    2.29  		xor	si,si			;  A000 -9000 -0800(>movedend)
    2.30 -		xor	di,di			; set ZF
    2.31  		rep
    2.32  		  movsb
    2.33 -		push	es
    2.34 -		dos_shutdown			; clear di; ds=0
    2.35 -		pop	es
    2.36 -		popf
    2.37 -		jne	@@isbzimage
    2.38 -		mov	ax,[word cs:_imgs+2+2]	; get pm->fallback high word
    2.39 +		mov	ax,[word _imgs+2+2]	; get pm->fallback high word
    2.40  		push	es
    2.41  		call	near @@isbzimage	; pop cs ; ds=es=ss
    2.42  
    2.43 @@ -186,6 +185,7 @@
    2.44  		;or	al,80h			; disable NMI
    2.45  		;out	70h,al
    2.46  
    2.47 +		xor	di,di
    2.48  		push	di			; src ofs lo
    2.49  		push	di			; src seg=0
    2.50  		ifdef	NO386
     3.1 --- a/linld/stuff/src/LOAD.CPP	Sun Oct 21 17:30:30 2018 +0200
     3.2 +++ b/linld/stuff/src/LOAD.CPP	Tue Oct 23 08:25:49 2018 +0200
     3.3 @@ -178,7 +178,7 @@
     3.4  
     3.5      if(vid_mode) kernelparams->vid_mode = vid_mode;
     3.6      if(root_dev) kernelparams->root_dev = root_dev;
     3.7 -    version_string = 0;
     3.8 +    version_string = "";
     3.9  
    3.10  #if 1
    3.11      if(kernelparams->header == HdrS) { // starting linux 1.3.73
     4.1 --- a/linld/stuff/src/MEMCPY32.ASM	Sun Oct 21 17:30:30 2018 +0200
     4.2 +++ b/linld/stuff/src/MEMCPY32.ASM	Tue Oct 23 08:25:49 2018 +0200
     4.3 @@ -123,7 +123,7 @@
     4.4  		inc	cx
     4.5                  sub     [word sz],cx
     4.6              rep movsb
     4.7 -		ja	@@movlp
     4.8 +		jae	@@movlp
     4.9  		dec	[word sz+2]
    4.10  		jns	@@movlp			; mov 1-16 more bytes...
    4.11  		pop	di
     5.1 --- a/linld/stuff/src/pipehole.awk	Sun Oct 21 17:30:30 2018 +0200
     5.2 +++ b/linld/stuff/src/pipehole.awk	Tue Oct 23 08:25:49 2018 +0200
     5.3 @@ -65,7 +65,9 @@
     5.4  	}
     5.5  	s=$0
     5.6  	# These optimisation may break ZF or CF
     5.7 -	if (/^	add	sp,4/) { print "	pop	cx"; print "	pop	cx"; next }
     5.8 +	if (/^	sub	sp,2$/) { print "	push	ax"; next }
     5.9 +	if (/^	sub	sp,4$/) { print "	push	ax"; print "	push	ax"; next }
    5.10 +	if (/^	add	sp,4$/) { print "	pop	cx"; print "	pop	cx"; next }
    5.11  	if (/^	mov	d*word ptr .*,0$/ || /^	mov	dword ptr .*,large 0$/) {
    5.12  		sub(/mov/,"and",s); print s; next	# slower
    5.13  	}