wok diff memtest/stuff/unlzsa2.S @ rev 25493

Add libgnt
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Nov 19 17:37:48 2022 +0000 (18 months ago)
parents 2ccf00d9c1cd
children 48dff2952881
line diff
     1.1 --- a/memtest/stuff/unlzsa2.S	Fri Nov 18 09:54:27 2022 +0000
     1.2 +++ b/memtest/stuff/unlzsa2.S	Sat Nov 19 17:37:48 2022 +0000
     1.3 @@ -57,13 +57,13 @@
     1.4  	jns	lzsa2compressed
     1.5  #  if !defined(FLAT32) && !defined(FLAT16OUT)
     1.6  	movw	%cx, %dx
     1.7 -	andb	$0x7F, %ch
     1.8 -	andw	$0x8000, %dx
     1.9 -copy32k:
    1.10 -	call	lzsa2movStr
    1.11 +	movb	$0, %cl
    1.12 +	movb	$0, %dh
    1.13 +copytail:
    1.14 +	call	lzsa1movStr
    1.15  	xchg	%dx, %cx
    1.16  	incw	%cx
    1.17 -	loop	copy32k
    1.18 +	loop	copytail
    1.19  #  else
    1.20  	movsb			// copy block
    1.21  copylp:
    1.22 @@ -79,39 +79,36 @@
    1.23  	movw	%cx, %dx
    1.24  	xorw	%cx, %cx
    1.25  	call	normalize
    1.26 +# define NeedNormalize
    1.27  	addw	%si, %dx
    1.28  # else
    1.29  	movw	%si, %dx
    1.30  	addw	%cx, %dx
    1.31  # endif
    1.32 -	shll	$16, %edx
    1.33  #else
    1.34  # if !defined(FLAT16)
    1.35  	xorw	%cx, %cx
    1.36  	call	normalize
    1.37 +# define NeedNormalize
    1.38  # endif
    1.39  #endif
    1.40 -	movb	$1, %dh		// no nibble stored
    1.41 +	movb	$0, %bh		// no nibble stored
    1.42  lzsa2chunk:			// uncompress chunk
    1.43  	lodsb			// get token XYZ|LL|MMM
    1.44 -#if !defined(FLAT32) && !defined(FLAT16OUT)
    1.45 -	pushw	%ax
    1.46 -#else
    1.47  	movb	%al, %bl	// keep token in bl
    1.48 -#endif
    1.49 -	shrb	$3, %al		// shift literals length into place
    1.50 -	movw	$LITERALS_RUN_LEN*256+MIN_LITERALS_SIZE, %cx
    1.51 -	call	lzsa2len	// %ch = LITERALS_RUN_LEN
    1.52 -#if !defined(FLAT32) && !defined(FLAT16OUT)
    1.53 +	movw	$LITERALS_RUN_LEN+256*MIN_LITERALS_SIZE, %cx
    1.54 +	shrb	%cl, %al	// shift literals length into place
    1.55 +	call	lzsa2len	// %cl = LITERALS_RUN_LEN
    1.56 +#if defined(NeedNormalize) && defined(PARANOIA)
    1.57 +	pushw	%bp
    1.58  	call	lzsa2movLit	// copy %cx literals from %ds:%si to %es:%di
    1.59 -	popw	%bx
    1.60 +	popw	%bp
    1.61  #else
    1.62  	rep	movsb		// copy %cx literals from %ds:%si to %es:%di
    1.63  #endif
    1.64  #ifndef RAW_FORMAT
    1.65  maxsi:
    1.66 -	shld	$16, %edx, %eax
    1.67 -	cmpw	%ax, %si
    1.68 +	cmpw	%dx, %si
    1.69  	jae	lzsa2block	// bail if we hit EOD
    1.70  #endif
    1.71  #ifdef FLAT32
    1.72 @@ -126,7 +123,7 @@
    1.73  	jne	offset_9_bit
    1.74  // 00Z 5-bit offset: read a nibble for offset bits 1-4 and use the inverted bit Z of the token as bit 0 of the offset.
    1.75  //                   set bits 5-15 of the offset to 1.
    1.76 -	call	getByteFromNibble
    1.77 +	call	getByteFromNibbleAndC
    1.78  	jmp	get_match_length
    1.79  offset_9_bit:
    1.80  // 01Z 9-bit offset: read a byte for offset bits 0-7 and use the inverted bit Z for bit 8 of the offset.
    1.81 @@ -135,14 +132,14 @@
    1.82  	jmp	get_match_length_0
    1.83  
    1.84  getNibble:
    1.85 -	negb	%dh
    1.86 +	xorb	$0xF0, %bh	// toggle nibble stored flags
    1.87 +	movb	%bh, %al
    1.88  	jns	gotnibble
    1.89  	lodsb
    1.90 -	movb	%al, %dl
    1.91 +	movb	$0xF0, %bh
    1.92 +	orb	%al, %bh
    1.93 +	shrb	$4, %al
    1.94  gotnibble:
    1.95 -	rolb	$4, %dl
    1.96 -	movb	%dl, %al
    1.97 -	andb	$0xF, %al
    1.98  lzsa2quit:
    1.99  	ret
   1.100  
   1.101 @@ -151,7 +148,7 @@
   1.102  //10Z 13-bit offset: read a nibble for offset bits 9-12 and use the inverted bit Z for bit 8 of the offset,
   1.103  //                   then read a byte for offset bits 0-7. set bits 13-15 of the offset to 1.
   1.104  //                   substract 512 from the offset to get the final value.
   1.105 -	call	getByteFromNibble
   1.106 +	call	getByteFromNibbleAndC
   1.107  	subb	$2, %al		// substract 512
   1.108  	jmp	get_match_length_1
   1.109  rep_match_or_16_bit:
   1.110 @@ -167,8 +164,8 @@
   1.111  repeat_match:
   1.112  //111 repeat offset: reuse the offset value of the previous match command.
   1.113  
   1.114 -	xchg	AX, BX		// %ax: original token
   1.115 -	movw	$MATCH_RUN_LEN*256+MIN_MATCH_SIZE, %cx
   1.116 +	movb	%bl, %al	// %al: original token
   1.117 +	movw	$MATCH_RUN_LEN+256*MIN_MATCH_SIZE, %cx
   1.118  	call	lzsa2len
   1.119  #ifdef RAW_FORMAT
   1.120  	jz	lzsa2quit	// bail if we hit EOD
   1.121 @@ -179,11 +176,31 @@
   1.122  	movw	%di, %si
   1.123  	addw	%bp, %si
   1.124  	movw	%es, %ax
   1.125 -	jc	dxok
   1.126 +	jc	axok
   1.127  	subb	$0x10, %ah
   1.128 -dxok:
   1.129 +axok:
   1.130 +.macro norm	reg
   1.131 +	movw	%si, \reg
   1.132 +	andw	$0xF, %si
   1.133 +	shrw	$4, \reg
   1.134 +	addw	\reg, %ax
   1.135  	movw	%ax, %ds
   1.136 +lzsa2movLit:
   1.137 +	movw	%di, \reg
   1.138 +	andw	$0xF, %di
   1.139 +	shrw	$4, \reg
   1.140 +	movw	%es, %ax
   1.141 +	addw	\reg, %ax
   1.142 +	movw	%ax, %es
   1.143 +.endm 
   1.144 +	pushw	%bp
   1.145 +# if defined(NeedNormalize) || defined(PARANOIA)
   1.146  	call	lzsa2movStr	// copy string
   1.147 +# else
   1.148 +	norm	%bp
   1.149 +	rep movsb
   1.150 +# endif
   1.151 +	popw	%bp
   1.152  	popw	%si
   1.153  	popw	%ds
   1.154  #else
   1.155 @@ -194,7 +211,7 @@
   1.156  #endif
   1.157  	jmp	lzsa2chunk
   1.158  
   1.159 -getByteFromNibble:
   1.160 +getByteFromNibbleAndC:
   1.161  	pushfw
   1.162  	call	getNibble	// get nibble for offset bits 0-3
   1.163  	popfw
   1.164 @@ -202,20 +219,20 @@
   1.165  	xorb	$0xE1, %al	// set offset bits 7-5 to 1
   1.166  	ret
   1.167  
   1.168 -lzsa2len:			// get length in %ecx
   1.169 -	andb	%ch, %al
   1.170 +lzsa2len:			// get length in %cx
   1.171 +	andb	%cl, %al
   1.172  	cbw			// clear %ah
   1.173 -	cmpb	%al, %ch
   1.174 +	cmpb	%al, %cl
   1.175  	jne	lzsa2minNumber	// S=0-2, L=0-6
   1.176  	call	getNibble
   1.177  	cmp	$0xF, %al
   1.178  	jne	lzsa2noExtraByte
   1.179 +	addb	%al, %ch
   1.180  	lodsb
   1.181 -	addb	$0xF, %cl
   1.182  lzsa2noExtraByte:
   1.183 -	addb	%ch, %cl
   1.184 +	addb	%cl, %ch
   1.185  lzsa2minNumber:
   1.186 -	addb	%cl, %al
   1.187 +	addb	%ch, %al
   1.188  	jnc	lzsa2gotNumber  // 0-255
   1.189  #if 0
   1.190  	je	lzsa2BigNumber
   1.191 @@ -229,7 +246,7 @@
   1.192  	xchgw	%ax, %cx
   1.193  	ret
   1.194  
   1.195 -#if !defined(FLAT32) && !defined(FLAT16OUT)
   1.196 +#if defined(NeedNormalize) || defined(PARANOIA)
   1.197  # if defined(PARANOIA)
   1.198  lzsa2movlp:
   1.199  	decw	%ch
   1.200 @@ -237,20 +254,9 @@
   1.201  	incw	%ch
   1.202  # endif
   1.203  normalize:
   1.204 +	movw	%ds, %bp
   1.205  lzsa2movStr:
   1.206 -	movw	%si, %ax
   1.207 -	andw	$0xF, %si
   1.208 -	shrw	$4, %ax
   1.209 -	movw	%ds, %bx
   1.210 -	addw	%ax, %bx
   1.211 -	movw	%bx, %ds
   1.212 -lzsa2movLit:
   1.213 -	movw	%di, %ax
   1.214 -	andw	$0xF, %di
   1.215 -	shrw	$4, %ax
   1.216 -	movw	%es, %bx
   1.217 -	addw	%ax, %bx
   1.218 -	movw	%bx, %es
   1.219 +	norm	%bp
   1.220  # if defined(PARANOIA)
   1.221  	cmpb	$0xFF, %ch	// catch FFFX case
   1.222  	je	lzsa2movlp