wok diff linld/stuff/src/MEMCPY32.ASM @ rev 25697

dool: reduced size of package
author Hans-G?nter Theisgen
date Sun May 12 07:10:04 2024 +0100 (2 weeks ago)
parents 217c02cbbe8d
children
line diff
     1.1 --- a/linld/stuff/src/MEMCPY32.ASM	Sun Mar 14 19:55:20 2021 +0000
     1.2 +++ b/linld/stuff/src/MEMCPY32.ASM	Sun May 12 07:10:04 2024 +0100
     1.3 @@ -2,7 +2,7 @@
     1.4  ;****** This file is distributed under GPL
     1.5  ;***************************************************************
     1.6                  ideal
     1.7 -		%PAGESIZE 1000
     1.8 +		%PAGESIZE 255
     1.9                  %crefref
    1.10                  %noincl
    1.11                  %nomacs
    1.12 @@ -24,6 +24,12 @@
    1.13  				;3+ NOPs also work fine (chkd on 386)
    1.14  endm
    1.15  
    1.16 +macro   addzx_e rm,i
    1.17 +        db      66h
    1.18 +        add     rm,i
    1.19 +        dw      0
    1.20 +endm
    1.21 +
    1.22          segment _TEXT byte public use16 'CODE'
    1.23  
    1.24  ;***************************************************************
    1.25 @@ -41,18 +47,19 @@
    1.26  
    1.27  ;****** Init ***************************************************
    1.28  
    1.29 +		push	bp
    1.30 +		mov	bp,sp
    1.31 +		;cld
    1.32 +                pushf
    1.33 +                push    ds
    1.34 +
    1.35  			ifndef	NO386
    1.36  
    1.37 -		enter	0,0
    1.38 -		;cld
    1.39 -                pushf
    1.40 -                push    ds es
    1.41  		pushad				; struct declared in VCPI.ASM
    1.42  		mov	cl,4
    1.43                  movzx   esi,[srcseg]
    1.44                  shl     esi,cl
    1.45                  add     esi,[srcofs]
    1.46 -                mov     [srcofs],esi		; for memcpy_vcpi
    1.47                  mov     edi,[dstofs]
    1.48  
    1.49  	ifndef	pm_only
    1.50 @@ -60,9 +67,8 @@
    1.51  		shr	eax,cl
    1.52  		mov	edx,edi
    1.53  		shr	edx,cl
    1.54 -		mov	ecx,esi
    1.55 -		or	ecx,edi
    1.56 -		shr	ecx,20			; >1mb ?
    1.57 +		lea	ecx,[eax+edx]
    1.58 +		shr	ecx,16			; >1mb ?
    1.59                  jnz     @@pmcopy
    1.60  @@movlp:
    1.61  		mov	ds,ax
    1.62 @@ -84,13 +90,8 @@
    1.63  @@pmcopy:
    1.64  			else
    1.65  
    1.66 -		push	bp
    1.67 -		mov	bp,sp
    1.68 -		;cld
    1.69 -                pushf
    1.70 -                push    ds es
    1.71  		push	si
    1.72 -		xor	bx,bx
    1.73 +		push	di
    1.74  		xor	si,si
    1.75  		mov	ax,[srcseg]
    1.76  		extrn	N_LXLSH@4:near
    1.77 @@ -98,32 +99,31 @@
    1.78  		add	[word srcofs],ax
    1.79  		adc	[word srcofs+2],dx
    1.80  @@2flat:
    1.81 -		les	ax,[dword si+srcofs]	; srcofs, dstofs
    1.82 -		mov	dx,es
    1.83 +		les	dx,[dword si+srcofs]	; srcofs, dstofs
    1.84 +		mov	di,dx			; dstofs
    1.85 +		mov	ax,es
    1.86  		mov	cl,4
    1.87  @@loop:
    1.88 -		shr	dx,1
    1.89 -		rcr	ax,1
    1.90 +		shr	ax,1			; high
    1.91 +		rcr	dx,1			; low
    1.92  		loop	@@loop
    1.93 -		or	bx,dx			; >=1mb flag
    1.94 -		push	ax			; srcseg, dstseg
    1.95 +		push	dx			; srcseg, dstseg
    1.96 +		xchg	ax,bx			; save/restore high srcreg
    1.97  		xor	si,-6
    1.98  		jnz	@@2flat
    1.99 +		or	bx,ax			; srcseg & dstseg < 1mb ? clear C
   1.100  		pop	dx			; dstseg
   1.101  		pop	ax			; srcseg
   1.102 -		cmp	bx,si			; <1mb ?
   1.103 -                jne     @@pmcopy
   1.104 -		push	di
   1.105 -@@movlp:
   1.106 +                jnz	@@pmcopy
   1.107 +@@movlp:					; bx=cx=0
   1.108  		mov	ds,ax
   1.109  		mov	es,dx
   1.110  		inc	ax
   1.111  		inc	dx
   1.112  		mov	cl,0Fh
   1.113  		mov	si,cx
   1.114 -		mov	di,cx
   1.115 +		and	di,cx
   1.116  		and	si,[word srcofs]
   1.117 -		and	di,[word dstofs]
   1.118  		inc	cx
   1.119                  sub     [word sz],cx
   1.120  		;jae	@@movpara
   1.121 @@ -134,9 +134,10 @@
   1.122  @@movpara:
   1.123              rep movsb
   1.124  		jae	@@movlp
   1.125 +@@pmcopy:
   1.126  		pop	di
   1.127 -		jmp	@@done16
   1.128 -@@pmcopy:
   1.129 +		pop	si
   1.130 +		jc	@@done16
   1.131                  p386
   1.132  		pushad				; struct declared in VCPI.ASM
   1.133                  mov     esi,[srcofs]
   1.134 @@ -146,6 +147,7 @@
   1.135  
   1.136                  mov     ecx,[sz]
   1.137                  jecxz   @@done
   1.138 +                cli
   1.139  
   1.140  		ifdef	VCPI
   1.141  		smsw	ax
   1.142 @@ -158,11 +160,22 @@
   1.143  		jmp	@@done
   1.144  		endif
   1.145  @@real_mode:
   1.146 -                cli
   1.147  oldGDTR		=	(pword srcseg)	; don't need src seg/ofs anymore
   1.148                  sgdt    [oldGDTR]
   1.149  
   1.150  ;****** Load gdtr **********************************************
   1.151 +		ifdef	LARGE_ZIMAGE
   1.152 +		local	rflags: word, rds: word, \
   1.153 +			reax: dword, recx: dword, redx: dword, rebx: dword, \
   1.154 +			resp: dword, rebp: dword, resi: dword, redi: dword, \
   1.155 +			GDTR: pword = LOCAL_SIZE
   1.156 +		mov	eax,cs
   1.157 +		shl	eax,4
   1.158 +		addzx_e	ax,<offset gdt_memcpy>
   1.159 +		push	eax		; gdt_base_memcpy
   1.160 +		push	-1		; gdt_limit
   1.161 +		endif
   1.162 +
   1.163                  lgdt    [GDTR]
   1.164  
   1.165  ;****** Go into pm *********************************************
   1.166 @@ -192,21 +205,16 @@
   1.167  		lcr0	eax
   1.168  ;****** Return *************************************************
   1.169                  lgdt    [oldGDTR]
   1.170 +		ifdef	LARGE_ZIMAGE
   1.171 +		add	sp,6
   1.172 +		endif
   1.173  @@done:
   1.174                  popad
   1.175                  p8086
   1.176  @@done16:
   1.177 -			ifdef	NO386
   1.178 -		pop	si
   1.179 -			endif
   1.180 -                pop     es ds
   1.181 +                pop     ds
   1.182  		popf			; restore I & D
   1.183 -			ifndef	NO386
   1.184 -                p386
   1.185 -		leave
   1.186 -			else
   1.187  		pop	bp
   1.188 -			endif
   1.189                  ret	14
   1.190  
   1.191  ;****** Const data *********************************************
   1.192 @@ -224,16 +232,15 @@
   1.193  		;	base_med  P  S D A  G ??l_hi  base_hi
   1.194  		;	           Pl E W    D
   1.195  		endif
   1.196 +		ifndef	LARGE_ZIMAGE
   1.197  label	GDTR	pword
   1.198  gdt_limit	dw	0ffffh
   1.199  		global	gdt_base_memcpy:word
   1.200  gdt_base_memcpy dw	offset gdt_memcpy,0
   1.201 +		endif
   1.202  
   1.203          endp    memcpy32
   1.204  
   1.205 -		global	movedend:near
   1.206 -movedend:
   1.207 -
   1.208          ends    _TEXT
   1.209  
   1.210          end