wok diff memtest/stuff/unlz4.S @ rev 25487
Up exiftool (12.50), foomatic-db (4.0-20221111), lzsa (1.4.0), zlib (1.2.13)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Nov 15 16:20:54 2022 +0000 (18 months ago) |
parents | 18d1dc85701e |
children | 2ccf00d9c1cd |
line diff
1.1 --- a/memtest/stuff/unlz4.S Sun Aug 19 08:06:36 2012 +0200 1.2 +++ b/memtest/stuff/unlz4.S Tue Nov 15 16:20:54 2022 +0000 1.3 @@ -1,20 +1,36 @@ 1.4 -/* 1.5 - * Lz4Decode: 1.6 +// Lz4Decode: 1.7 #ifndef FLAT32 1.8 - * input ds:si=inStream, es:di=outStream 1.9 - * output outStream[], ds:si, es:di 1.10 +// input ds:si=inStream, es:di=outStream 1.11 +// output outStream[], ds:si, es:di 1.12 .code16 1.13 +#define AX %ax 1.14 +#define BX %bx 1.15 +#define CX %cx 1.16 +#define SI %si 1.17 +#define DI %di 1.18 #else 1.19 - * input esi=inStream, edi=outStream 1.20 - * output outStream[], esi, edi 1.21 +// input esi=inStream, edi=outStream 1.22 +// output outStream[], ds:esi, es:edi 1.23 .code32 1.24 +#define AX %eax 1.25 +#define BX %ebx 1.26 +#define CX %ecx 1.27 +#define SI %esi 1.28 +#define DI %edi 1.29 #endif 1.30 - */ 1.31 1.32 #define ARCHIVE_MAGICNUMBER 0x184C2102 1.33 1.34 +//#define PARANOIA // cover rare cases, optional 1.35 + 1.36 lz4main: 1.37 +#ifdef PARANOIA 1.38 cld 1.39 +# if !defined(FLAT32) && !defined(FLAT16OUT) 1.40 + xorl %cx, %cx 1.41 + call lz4mov 1.42 +# endif 1.43 +#endif 1.44 lodsl // get chunkSize 1.45 cmpl $ARCHIVE_MAGICNUMBER, %eax 1.46 je lz4main 1.47 @@ -23,48 +39,75 @@ 1.48 xchgl %eax, %edx 1.49 lz4chunk: // uncompress chunk 1.50 lodsb // get token 1.51 - decl %edx 1.52 - movzbl %al, %ebx 1.53 + movb %al, %bl 1.54 shrb $4, %al 1.55 call lz4len // get literal length, %eax < 255 1.56 - incl %ecx 1.57 - stc 1.58 - sbbl %ecx, %edx 1.59 - pushf 1.60 + subl %ecx, %edx // count literal 1.61 + subl $1+2, %edx // count token & string address 1.62 +#if !defined(FLAT32) && !defined(FLAT16OUT) 1.63 + pushf 1.64 call lz4mov // copy literals 1.65 popf 1.66 - js lz4main 1.67 +#else 1.68 + rep movsb 1.69 +#endif 1.70 + jle lz4main 1.71 lodsw // get string address 1.72 -#ifndef FLAT32 1.73 - pushw %bx 1.74 - movw %di, %bx 1.75 - subl %eax, %ebx 1.76 - popw %ax 1.77 + xchgw %ax, %bx 1.78 call lz4len // get string length 1.79 + add $4, CX 1.80 +#if !defined(FLAT32) && !defined(FLAT16OUT) 1.81 pushw %ds 1.82 pushw %si 1.83 - pushw %es 1.84 - popw %ds 1.85 - movw $0xF, %si 1.86 - andw %bx, %si 1.87 - shrl $4, %ebx 1.88 - addl $4+1, %ecx 1.89 - movw %bx, %bp 1.90 - call lz4mov2 // copy string 1.91 + movw %di, %si 1.92 + subw %bx, %si 1.93 + movw %es, %ax 1.94 + jnc axok 1.95 + subb $0x10, %ah 1.96 +axok: 1.97 + movw %ax, %ds 1.98 + call lz4mov // copy string 1.99 popw %si 1.100 popw %ds 1.101 #else 1.102 - negl %eax 1.103 - xchgl %eax, %ebx 1.104 - addl %edi, %ebx 1.105 - call lz4len // get string length 1.106 - pushl %esi 1.107 - xchgl %ebx, %esi 1.108 - call lz4mov // copy string 1.109 - popl %esi 1.110 + xchg AX, SI 1.111 + mov DI, SI 1.112 + sub BX, SI 1.113 + rep movsb %es(SI), %es(DI) 1.114 + xchg AX, SI 1.115 #endif 1.116 jmp lz4chunk 1.117 1.118 +#if !defined(FLAT32) && !defined(FLAT16OUT) 1.119 +# if defined(PARANOIA) 1.120 +lz4movlp: 1.121 + xchgw %ax, %cx 1.122 + movw $0x3C00, %cx 1.123 + rep movsl 1.124 + xchgw %ax, %cx 1.125 + sub $0xF0, %ch 1.126 +# endif 1.127 +lz4mov: 1.128 + movw %di, %ax 1.129 + andw $0xF, %di 1.130 + shrw $4, %ax 1.131 + movw %es, %bp 1.132 + addw %ax, %bp 1.133 + movw %bp, %es 1.134 + movw %si, %ax 1.135 + andw $0xF, %si 1.136 + shrw $4, %ax 1.137 + movw %ds, %bp 1.138 + addw %ax, %bp 1.139 + movw %bp, %ds 1.140 +# if defined(PARANOIA) 1.141 + cmp $0xFF, %ch // catch FFFX case 1.142 + jz lz4movlp 1.143 +# endif 1.144 + rep movsb 1.145 + ret 1.146 +#endif 1.147 + 1.148 lz4len: // get length in %ecx 1.149 andl $0xF, %eax 1.150 movl %eax, %ecx 1.151 @@ -73,33 +116,9 @@ 1.152 lz4len2: 1.153 lodsb 1.154 decl %edx // remaining chunk size 1.155 - addl %eax, %ecx 1.156 + addw %ax, %cx 1.157 cmpb $0xFF, %al 1.158 je lz4len2 1.159 lz4quit: 1.160 ret 1.161 1.162 -lz4movlp: 1.163 - movsb 1.164 -#ifndef FLAT32 1.165 - movw $0x800, %bp 1.166 - orw %di, %di 1.167 - jns lz4di 1.168 - subw $0x8000, %di 1.169 - movw %es, %ax 1.170 - addw %bp, %ax 1.171 - movw %ax, %es 1.172 -lz4di: 1.173 - orw %si, %si 1.174 - jns lz4si 1.175 - subw $0x8000, %si 1.176 -lz4mov2: 1.177 - movw %ds, %ax 1.178 - addw %bp, %ax 1.179 - movw %ax, %ds 1.180 -lz4si: 1.181 -#endif 1.182 -lz4mov: 1.183 - decl %ecx 1.184 - jnz lz4movlp 1.185 - ret