wok diff memtest64/stuff/unlzsa1.S @ rev 25594

Update some web_site/wget_url
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Jul 11 10:40:23 2023 +0000 (14 months ago)
parents a7a39e042b62
children be3de88419e0
line diff
     1.1 --- a/memtest64/stuff/unlzsa1.S	Thu Feb 16 14:18:05 2023 +0000
     1.2 +++ b/memtest64/stuff/unlzsa1.S	Tue Jul 11 10:40:23 2023 +0000
     1.3 @@ -25,173 +25,175 @@
     1.4  #define PACKED_ONLY			// assume no copy block, optional
     1.5  //#define PARANOIA			// cover rare cases, optional
     1.6   
     1.7 +.macro	shrclw cnt,obj
     1.8 +#ifdef ONLY8086
     1.9 +	movb	\cnt, %cl
    1.10 +	shrw	%cl, \obj
    1.11 +#else
    1.12 +	shrw	\cnt, \obj
    1.13 +#endif
    1.14 +.endm
    1.15 +
    1.16 +#ifdef FLAT16OUT
    1.17 +#define RAW_FORMAT
    1.18 +#endif
    1.19  lzsa1main:
    1.20  #ifdef PARANOIA
    1.21  	cld
    1.22  #endif
    1.23 -#ifdef FLAT16OUT
    1.24 -#define RAW_FORMAT
    1.25 -#endif
    1.26  #ifndef RAW_FORMAT
    1.27 -# if defined(PARANOIA) && !defined(FLAT32) && !defined(FLAT16)
    1.28 -	xorw	%cx, %cx
    1.29 -	call	normalize
    1.30 -# endif
    1.31  # ifndef NO_LZSA1_HEADER
    1.32  	lodsw
    1.33  	cmpw	$0x9E7B, %ax	// magic
    1.34  	jne	lzsa1main
    1.35  	lodsb
    1.36 -	cmpb	$0, %al		// lzsa1
    1.37 -	jne	lzsa1main
    1.38 +//	cmpb	$0, %al		// lzsa1
    1.39 +//	jne	lzsa1main
    1.40 +# endif
    1.41 +	xorw	%ax, %ax
    1.42 +	xchgw	%ax, %di
    1.43 +	shrclw	$4, %ax
    1.44 +	jmp	lzsa1blockz	// %di *MUST* be paragraph aligned
    1.45 +# ifndef PACKED_ONLY
    1.46 +lzsa1copy:
    1.47 +	movsb			// handle 64K case
    1.48 +	decw	%cx
    1.49 +	rep	movsb		// copy block
    1.50  # endif
    1.51  lzsa1block:			// uncompress chunk
    1.52 +	movw	$0x1000, %ax
    1.53 +lzsa1blockz:	
    1.54 +	movw	%es, %bx
    1.55 +	addw	%ax, %bx
    1.56 +	movw	%bx, %es
    1.57 +# ifndef FLAT16
    1.58 +	movw	%si, %ax
    1.59 +	andw	$0xf, %si
    1.60 +	shrclw	$4, %ax
    1.61 +	movw	%ds, %bx
    1.62 +	addw	%ax, %bx
    1.63 +	movw	%bx, %ds
    1.64 +# endif
    1.65  	lodsw			// block size
    1.66  	xchgw	%ax, %cx
    1.67 +	movw	%cx, %dx
    1.68  	lodsb
    1.69  # ifndef PACKED_ONLY
    1.70  	orb	%al, %al
    1.71 -	jns	lzsa1compressed
    1.72 -#  if !defined(FLAT32) && !defined(FLAT16OUT)
    1.73 -	movw	%cx, %dx
    1.74 -	movb	$0, %cl
    1.75 -	movb	$0, %dh
    1.76 -copytail:
    1.77 -	call	lzsa1movStr
    1.78 -	xchg	%dx, %cx
    1.79 -	incw	%cx
    1.80 -	loop	copytail
    1.81 -#  else
    1.82 -	movsb			// copy block
    1.83 -copylp:
    1.84 -	movsb			// copy block
    1.85 -	loop	copylp		// handle 64K case
    1.86 -#  endif
    1.87 -	jmp	lzsa1block	// end of block
    1.88 -lzsa1compressed:
    1.89 -	jne	lzsa1chunk	// 64Kb block
    1.90 +	js	lzsa1copy
    1.91 +	jne	lzsa1full	// 64Kb block
    1.92  # endif
    1.93  	jcxz	lzsa1quit	// bail if we hit EOD
    1.94 -	pushw	%cx
    1.95 -# if !defined(FLAT32) && !defined(FLAT16)
    1.96 -	xorw	%cx, %cx
    1.97 -	call	normalize
    1.98 -# define NeedNormalize
    1.99 -# endif
   1.100 -	popw	%dx
   1.101 +lzsa1full:
   1.102  	addw	%si, %dx
   1.103  #endif
   1.104  lzsa1chunk:			// uncompress chunk
   1.105  	lodsb			// get token O|LLL|MMMM
   1.106  	movb	%al, %bl	// keep token in bl
   1.107 -	shrb	$4, %al		// shift literals length into place
   1.108 -	movw	$LITERALS_RUN_LEN*256+MIN_LITERALS_SIZE, %cx
   1.109 +	shrclw	$4, %ax		// shift literals length into place
   1.110 +	movw	$LITERALS_RUN_LEN+256*MIN_LITERALS_SIZE, %cx
   1.111  	call	lzsa1len	// %ch = LITERALS_RUN_LEN
   1.112 -#if defined(NeedNormalize)
   1.113 -	call	lzsa1movLit	// copy %cx literals from %ds:%si to %es:%di
   1.114 -#else
   1.115  	rep	movsb		// copy %cx literals from %ds:%si to %es:%di
   1.116 -#endif
   1.117  #ifndef RAW_FORMAT
   1.118  	cmpw	%dx, %si
   1.119 -	jae	lzsa1block	// bail if we hit EOD
   1.120 +	je	lzsa1block	// bail if we hit EOD
   1.121  #endif
   1.122  #ifdef FLAT32
   1.123  	orl	$-1, %eax
   1.124 -#else
   1.125 -	movb	$-1, %ah
   1.126  #endif
   1.127  	testb	%bl, %bl	// check match offset size in token (O bit)
   1.128 -	jns	lzsa1ShortOfs
   1.129 +	js	lzsa1LongOfs
   1.130 +#ifndef FLAT32
   1.131 +	movb	$-1, %ah	// set offset bits 15-8 to 1
   1.132 +#endif
   1.133 +	lodsb
   1.134 +	.byte	0x3C		// mask lodsw with cmpb $0xAD, %al
   1.135 +lzsa1LongOfs:
   1.136  	lodsw
   1.137 -	.byte	0x3C		// mask lodsb with cmpb $0xAC, %al
   1.138 -lzsa1ShortOfs:
   1.139 -	lodsb
   1.140  	xchg	AX, BX		// %bx: match offset  %ax: original token
   1.141 -	movw	$MATCH_RUN_LEN*256+MIN_MATCH_SIZE, %cx
   1.142 +	movw	$MATCH_RUN_LEN+256*MIN_MATCH_SIZE, %cx
   1.143  	call	lzsa1len
   1.144  #ifdef RAW_FORMAT
   1.145  	jcxz	lzsa1quit	// bail if we hit EOD
   1.146  #endif
   1.147 -#if !defined(FLAT32) && !defined(FLAT16OUT)
   1.148 +
   1.149 +#if !defined(FLAT16OUT) && !defined(FLAT32)
   1.150 +	xchg	AX, SI		// save %si	
   1.151 +	lea	(BX,DI), SI
   1.152  	pushw	%ds
   1.153 +	movw	%es, %bp
   1.154 +	cmpw	%si, %di
   1.155 +	jnc	lzsa1sameSeg
   1.156  	pushw	%si
   1.157 -	movw	%di, %si
   1.158 -	addw	%bx, %si
   1.159 -	movw	%es, %ax
   1.160 -	jc	axok
   1.161 -	subb	$0x10, %ah
   1.162 -axok:
   1.163 -.macro norm	reg
   1.164 -	movw	%si, \reg
   1.165 -	subw	%si, %dx
   1.166 +	shrclw	$4, %si
   1.167 +	lea	-4096(%bp,%si), %bp
   1.168 +	popw	%si
   1.169  	andw	$0xF, %si
   1.170 -	addw	%si, %dx
   1.171 -	shrw	$4, \reg
   1.172 -	addw	\reg, %ax
   1.173 -	movw	%ax, %ds
   1.174 -	movw	%di, \reg
   1.175 -	andw	$0xF, %di
   1.176 -	shrw	$4, \reg
   1.177 -	movw	%es, %ax
   1.178 -	addw	\reg, %ax
   1.179 -	movw	%ax, %es
   1.180 -.endm 
   1.181 -	pushw	%dx
   1.182 -# if defined(NeedNormalize) || defined(PARANOIA)
   1.183 -	call	lzsa1movStr	// copy string
   1.184 -# else
   1.185 -	norm	%bp
   1.186 +lzsa1sameSeg:
   1.187 +	movw	%bp, %ds
   1.188 +# ifdef FASTFILL
   1.189 +	cmp	$-FASTFILL,BX
   1.190 +	jae	lzsa1fast
   1.191 +# endif
   1.192  	rep movsb
   1.193 -# endif
   1.194 -	popw	%dx
   1.195 -	popw	%si
   1.196 +lzsa1chunkz:
   1.197  	popw	%ds
   1.198  #else
   1.199 +# ifdef FASTFILL
   1.200 +	cmp	$-FASTFILL,BX
   1.201 +	jae	lzsa1fast
   1.202 +# endif
   1.203  	xchg	AX, SI		// save %si	
   1.204  	lea	(BX,DI), SI
   1.205  	rep movsb	%es:(SI), %es:(DI)
   1.206 +#define lzsa1chunkz lzsa1chunk
   1.207 +#endif
   1.208  	xchg	AX, SI		// restore %si	
   1.209 +	jmp	lzsa1chunk
   1.210 +#ifdef FASTFILL
   1.211 +lzsa1fast:
   1.212 +# if FASTFILL == 1
   1.213 +#  if !defined(FLAT16OUT) && !defined(FLAT32)
   1.214 +	lodsb
   1.215 +#  else
   1.216 +	movb	%es:(BX,DI), %al
   1.217 +#  endif
   1.218 +	rep stosb
   1.219 +# endif
   1.220 +# if FASTFILL == 2
   1.221 +#  if !defined(FLAT16OUT) && !defined(FLAT32)
   1.222 +	lodsw
   1.223 +#  else
   1.224 +	movw	%es:(BX,DI), %ax
   1.225 +#  endif
   1.226 +	je	lzsa1fastword
   1.227 +	movb	%ah, %al
   1.228 +lzsa1fastword:
   1.229 +	shr	$1, CX
   1.230 +	rep stosw
   1.231 +	jnc	lzsa1chunkz
   1.232 +	stosb
   1.233 +# endif
   1.234 +	jmp	lzsa1chunkz
   1.235  #endif
   1.236 -	jmp	lzsa1chunk
   1.237  
   1.238  lzsa1len:			// get length in %ecx
   1.239 -	andb	%ch, %al
   1.240 +	andb	%cl, %al
   1.241  	cbw			// clear %ah
   1.242 -	cmpb	%ch, %al
   1.243 -	jne	lzsa1minNumber	// S=0-6, L=0-14
   1.244 +	cmpb	%al, %cl
   1.245 +	jne	lzsa1minNumber	// S=0-6, L=0-14		%cx = %ch + %al   if (%al & %cl != %cl)
   1.246 +	addb	%al, %ch
   1.247  	lodsb
   1.248 -	addb	%ch, %cl
   1.249  lzsa1minNumber:
   1.250 -	addb	%cl, %al
   1.251 -	jnc	lzsa1gotNumber  // 0-255
   1.252 -	movb	%al, %ah	// S=256-1791, L=256-3839 or S=256-511, L=256-511
   1.253 +	addb	%ch, %al
   1.254 +	jnc	lzsa1gotNumber  // 0-255			%cx = %ch + %cl + byte   if (%al & %cl == %cl && %ch + %cl + byte < 0x100)
   1.255 +	movb	%al, %ah	// S=256-1791, L=256-4607 or S=256-511, L=256-511
   1.256  	jne	lzsa1midNumber
   1.257 -	lodsw			// 0-65535
   1.258 +	lodsw			// 0-65535			%cx = word   if (%al & %cl == %cl && %ch + %cl + byte == 0x100)
   1.259  	.byte	0x3C		// mask lodsb with cmpb $0xAC, %al
   1.260  lzsa1midNumber:
   1.261 -	lodsb
   1.262 +	lodsb			//				%cx = (%ch + %cl + byte)*256 + byte2   if (%al & %cl == %cl && %ch + %cl + byte > 0x100)
   1.263  lzsa1gotNumber:
   1.264  	xchgw	%ax, %cx
   1.265  lzsa1quit:
   1.266  	ret
   1.267 -
   1.268 -#if defined(NeedNormalize) || defined(PARANOIA)
   1.269 -# if defined(PARANOIA)
   1.270 -lzsa1movlp:
   1.271 -	decw	%ch
   1.272 -	rep movsb
   1.273 -	incw	%ch
   1.274 -# endif
   1.275 -normalize:
   1.276 -lzsa1movLit:
   1.277 -	movw	%ds, %ax
   1.278 -lzsa1movStr:
   1.279 -	norm	%bp
   1.280 -# if defined(PARANOIA)
   1.281 -	cmpb	$0xFF, %ch	// catch FFFX case
   1.282 -	je	lzsa1movlp
   1.283 -# endif
   1.284 -	rep movsb
   1.285 -	ret
   1.286 -#endif