wok diff memtest/stuff/unlzsa1.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 | 7f7bd3c9775e |
line diff
1.1 --- a/memtest/stuff/unlzsa1.S Fri Nov 18 09:54:27 2022 +0000 1.2 +++ b/memtest/stuff/unlzsa1.S Sat Nov 19 17:37:48 2022 +0000 1.3 @@ -51,13 +51,13 @@ 1.4 jns lzsa1compressed 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 + movb $0, %cl 1.11 + movb $0, %dh 1.12 +copytail: 1.13 call lzsa1movStr 1.14 xchg %dx, %cx 1.15 incw %cx 1.16 - loop copy32k 1.17 + loop copytail 1.18 # else 1.19 movsb // copy block 1.20 copylp: 1.21 @@ -73,6 +73,7 @@ 1.22 # if !defined(FLAT32) && !defined(FLAT16) 1.23 xorw %cx, %cx 1.24 call normalize 1.25 +# define NeedNormalize 1.26 # endif 1.27 addw %si, %dx 1.28 #endif 1.29 @@ -82,7 +83,7 @@ 1.30 shrb $4, %al // shift literals length into place 1.31 movw $LITERALS_RUN_LEN*256+MIN_LITERALS_SIZE, %cx 1.32 call lzsa1len // %ch = LITERALS_RUN_LEN 1.33 -#if !defined(FLAT32) && !defined(FLAT16OUT) 1.34 +#if defined(NeedNormalize) && defined(PARANOIA) 1.35 call lzsa1movLit // copy %cx literals from %ds:%si to %es:%di 1.36 #else 1.37 rep movsb // copy %cx literals from %ds:%si to %es:%di 1.38 @@ -115,11 +116,29 @@ 1.39 movw %di, %si 1.40 addw %bx, %si 1.41 movw %es, %ax 1.42 - jc dxok 1.43 + jc axok 1.44 subb $0x10, %ah 1.45 -dxok: 1.46 +axok: 1.47 +.macro norm reg 1.48 + movw %si, \reg 1.49 + andw $0xF, %si 1.50 + shrw $4, \reg 1.51 + addw \reg, %ax 1.52 movw %ax, %ds 1.53 +lzsa1movLit: 1.54 + movw %di, \reg 1.55 + andw $0xF, %di 1.56 + shrw $4, \reg 1.57 + movw %es, %ax 1.58 + addw \reg, %ax 1.59 + movw %ax, %es 1.60 +.endm 1.61 +# if defined(NeedNormalize) || defined(PARANOIA) 1.62 call lzsa1movStr // copy string 1.63 +# else 1.64 + norm %bp 1.65 + rep movsb 1.66 +# endif 1.67 popw %si 1.68 popw %ds 1.69 #else 1.70 @@ -133,11 +152,12 @@ 1.71 lzsa1len: // get length in %ecx 1.72 andb %ch, %al 1.73 cbw // clear %ah 1.74 - cmpb %al, %ch 1.75 + cmpb %ch, %al 1.76 jne lzsa1minNumber // S=0-6, L=0-14 1.77 lodsb 1.78 - addb %cl, %ch 1.79 - addb %ch, %al 1.80 + addb %ch, %cl 1.81 +lzsa1minNumber: 1.82 + addb %cl, %al 1.83 jnc lzsa1gotNumber // 0-255 1.84 movb %al, %ah // S=256-1791, L=256-3839 or S=256-511, L=256-511 1.85 jne lzsa1midNumber 1.86 @@ -149,12 +169,8 @@ 1.87 xchgw %ax, %cx 1.88 lzsa1quit: 1.89 ret 1.90 -lzsa1minNumber: 1.91 - addb %cl, %al 1.92 - xchgw %ax, %cx 1.93 - ret 1.94 1.95 -#if !defined(FLAT32) && !defined(FLAT16OUT) 1.96 +#if defined(NeedNormalize) || defined(PARANOIA) 1.97 # if defined(PARANOIA) 1.98 lzsa1movlp: 1.99 decw %ch 1.100 @@ -162,20 +178,9 @@ 1.101 incw %ch 1.102 # endif 1.103 normalize: 1.104 + movw %ds, %bp 1.105 lzsa1movStr: 1.106 - movw %si, %ax 1.107 - andw $0xF, %si 1.108 - shrw $4, %ax 1.109 - movw %ds, %bp 1.110 - addw %ax, %bp 1.111 - movw %bp, %ds 1.112 -lzsa1movLit: 1.113 - movw %di, %ax 1.114 - andw $0xF, %di 1.115 - shrw $4, %ax 1.116 - movw %es, %bp 1.117 - addw %ax, %bp 1.118 - movw %bp, %es 1.119 + norm %bp 1.120 # if defined(PARANOIA) 1.121 cmpb $0xFF, %ch // catch FFFX case 1.122 je lzsa1movlp