wok-next diff linld/stuff/src/MEMCPY32.ASM @ rev 19667

linld: resync with wok
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Mar 17 15:18:10 2017 +0100 (2017-03-17)
parents 31c5cbbd9380
children 937f2ed1d5c8
line diff
     1.1 --- a/linld/stuff/src/MEMCPY32.ASM	Tue Dec 06 18:49:44 2016 +0100
     1.2 +++ b/linld/stuff/src/MEMCPY32.ASM	Fri Mar 17 15:18:10 2017 +0100
     1.3 @@ -5,7 +5,11 @@
     1.4                  %crefref
     1.5                  %noincl
     1.6                  %nomacs
     1.7 +		ifdef	NO386
     1.8 +                p8086
     1.9 +		else
    1.10                  p386
    1.11 +		endif
    1.12  
    1.13          group   DGROUP  _TEXT,_DATA
    1.14          assume  cs:DGROUP,ds:DGROUP
    1.15 @@ -50,7 +54,7 @@
    1.16  		inc	ah			; set TF
    1.17  		push	ax
    1.18  		popf
    1.19 -		jmp	small [dword bx+4*19h]
    1.20 +		jmp	[dword bx+4*19h]
    1.21  doiret:
    1.22  		iret
    1.23  sssp:
    1.24 @@ -113,37 +117,35 @@
    1.25                          oldGDTR :pword  = TEMP_SIZE
    1.26  
    1.27  ;****** Init ***************************************************
    1.28 -		push	bp
    1.29 -		mov	bp,sp
    1.30 -		sub	sp,TEMP_SIZE
    1.31 -                pushf
    1.32 -		cld
    1.33 -                push    ds es
    1.34  
    1.35  			ifndef	NO386
    1.36  
    1.37 +		enter	TEMP_SIZE,0
    1.38 +		;cld
    1.39 +                pushf
    1.40 +                push    ds es
    1.41                  pushad
    1.42 +		mov	cl,4
    1.43                  movzx   esi,[srcseg]
    1.44 -                shl     esi,4
    1.45 -                add     [srcofs],esi
    1.46 -                mov     esi,[srcofs]
    1.47 +                shl     esi,cl
    1.48 +                add     esi,[srcofs]
    1.49 +                mov     [srcofs],esi		; for memcpy_vcpi
    1.50                  mov     edi,[dstofs]
    1.51  
    1.52  	ifndef	pm_only
    1.53  		mov	eax,esi
    1.54 -		or	eax,edi
    1.55 -		shr	eax,20			; >1mb ?
    1.56 -                jnz     pmcopy
    1.57 -		mov	eax,esi
    1.58 -		shr	eax,4
    1.59 +		shr	eax,cl
    1.60  		mov	edx,edi
    1.61 -		shr	edx,4
    1.62 +		shr	edx,cl
    1.63 +		mov	ecx,esi
    1.64 +		or	ecx,edi
    1.65 +		shr	ecx,20			; >1mb ?
    1.66 +                jnz     @@pmcopy
    1.67  @@movlp:
    1.68  		mov	ds,ax
    1.69  		mov	es,dx
    1.70  		inc	ax
    1.71  		inc	dx
    1.72 -		xor	ecx,ecx
    1.73  		mov	cl,0Fh
    1.74  		and	si,cx
    1.75  		and	di,cx
    1.76 @@ -151,19 +153,25 @@
    1.77                  sub     [sz],ecx
    1.78              rep movsb
    1.79                  ja	@@movlp
    1.80 -		jmp	done
    1.81 +		jmp	@@done
    1.82  	endif
    1.83 -pmcopy:
    1.84 +@@pmcopy:
    1.85  			else
    1.86  
    1.87 +		push	bp
    1.88 +		mov	bp,sp
    1.89 +		sub	sp,TEMP_SIZE
    1.90 +		;cld
    1.91 +                pushf
    1.92 +                push    ds es
    1.93  		push	si
    1.94  		xor	bx,bx
    1.95  		xor	dx,dx
    1.96  		xor	si,si
    1.97 -		mov	ax,[bp+si+8]		; srcseg
    1.98 +		mov	ax,[bp+8]		; srcseg
    1.99  		call	near N_LXLSH@4
   1.100 -		add	[bp+si+10],ax		; srcofs lo
   1.101 -		adc	[bp+si+10+2],dx		; srcofs hi
   1.102 +		add	[bp+10],ax		; srcofs lo
   1.103 +		adc	[bp+10+2],dx		; srcofs hi
   1.104  @@2flat:
   1.105  		mov	ax,[bp+si+10]		; srcofs, dstofs lo
   1.106  		mov	dx,[bp+si+10+2]		; srcofs, dstofs hi
   1.107 @@ -174,8 +182,8 @@
   1.108  		jnz	@@2flat
   1.109  		pop	dx			; dstseg
   1.110  		pop	ax			; srcseg
   1.111 -		or	bx,bx			; <1mb ?
   1.112 -                jnz     pmcopy
   1.113 +		test	bx,bx			; <1mb ? (clear C)
   1.114 +                jnz     @@pmcopy
   1.115  		push	di
   1.116  @@movlp:
   1.117  		mov	ds,ax
   1.118 @@ -190,13 +198,14 @@
   1.119  		inc	cx
   1.120                  sub     [word sz],cx
   1.121              rep movsb
   1.122 -		jae	@@movlp
   1.123 +		ja	@@movlp
   1.124  		dec	[word sz+2]
   1.125 -                jns	@@movlp			; mov 1-16 more bytes...
   1.126 -		pop	di si
   1.127 -		jmp	done16
   1.128 -pmcopy:
   1.129 +		jns	@@movlp			; mov 1-16 more bytes...
   1.130 +		pop	di
   1.131 +@@pmcopy:
   1.132  		pop	si
   1.133 +		js	@@done16
   1.134 +                p386
   1.135                  pushad
   1.136                  mov     esi,[srcofs]
   1.137                  mov     edi,[dstofs]
   1.138 @@ -204,7 +213,7 @@
   1.139  			endif
   1.140  
   1.141                  mov     ecx,[sz]
   1.142 -                jecxz   done
   1.143 +                jecxz   @@done
   1.144  
   1.145  		smsw	ax
   1.146  		test	al,1
   1.147 @@ -216,11 +225,8 @@
   1.148  		extrn	call_pm_routine:near
   1.149                  call    near call_pm_routine ; Call pm copy routine via vcpi pm
   1.150                  pop     ax
   1.151 -		jmp	done
   1.152 +		jmp	@@done
   1.153  @@real_mode:
   1.154 -		mov	dx,-1
   1.155 -
   1.156 -with_movsw:
   1.157                  cmp     esi,edi
   1.158                  jae     @@do_copy
   1.159                  add     esi,ecx         ;src<dst: we must do
   1.160 @@ -236,13 +242,13 @@
   1.161                  mov     eax,cs
   1.162                  shl     eax,4
   1.163                  addzx_e ax,<offset GDT>
   1.164 -                mov     [word GDTR],dx          ;GDT limit = 0FFFFh
   1.165 +                or      [word GDTR],-1          ;GDT limit = 0FFFFh
   1.166                  mov     [dword GDTR+2],eax      ;GDT base
   1.167                  lgdt    [GDTR]
   1.168  
   1.169  ;****** Go into pm *********************************************
   1.170                  mov     eax,cr0
   1.171 -                or      al,01h          ;CR0_PE on
   1.172 +                inc     ax		;CR0_PE on
   1.173                  mov     cr0,eax
   1.174                  jmp     short $+2       ;*Required*!
   1.175                                          ;3+ NOPs also work fine (chkd on 386)
   1.176 @@ -251,9 +257,10 @@
   1.177                  pop     ds              ;base=0, lim = 4gb
   1.178                  push    ds              ;
   1.179                  pop     es              ;
   1.180 -                db      66h     ;operand width override for ecx
   1.181 +                ;db      66h     ;operand width override for ecx
   1.182                  db      67h     ;address width override for esi/edi
   1.183              rep movsb
   1.184 +		cld
   1.185  
   1.186  ;****** Return to rm *******************************************
   1.187                  dec     ax              ;CR0_PE off
   1.188 @@ -263,13 +270,19 @@
   1.189  
   1.190  ;****** Return *************************************************
   1.191                  lgdt    [oldGDTR]
   1.192 -done:
   1.193 +@@done:
   1.194                  popad
   1.195 -done16:
   1.196 +                p8086
   1.197 +@@done16:
   1.198                  pop     es ds
   1.199                  popf
   1.200 +			ifndef	NO386
   1.201 +                p386
   1.202 +		leave
   1.203 +			else
   1.204  		mov	sp,bp
   1.205  		pop	bp
   1.206 +			endif
   1.207                  ret
   1.208  
   1.209  ;****** Const data *********************************************