wok-6.x view memtest/stuff/unlz4.S @ rev 16452
Add: SkypeFreak
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Sat Apr 19 12:42:09 2014 +0300 (2014-04-19) |
parents | |
children | ed5f25d05ff6 |
line source
1 /*
2 * Lz4Decode:
3 #ifndef FLAT32
4 * input ds:si=inStream, es:di=outStream
5 * output outStream[], ds:si, es:di
6 .code16
7 #else
8 * input esi=inStream, edi=outStream
9 * output outStream[], esi, edi
10 .code32
11 #endif
12 */
14 #define ARCHIVE_MAGICNUMBER 0x184C2102
16 lz4main:
17 cld
18 lodsl // get chunkSize
19 cmpl $ARCHIVE_MAGICNUMBER, %eax
20 je lz4main
21 orl %eax, %eax // end of file ?
22 je lz4quit
23 xchgl %eax, %edx
24 lz4chunk: // uncompress chunk
25 lodsb // get token
26 decl %edx
27 movzbl %al, %ebx
28 shrb $4, %al
29 call lz4len // get literal length, %eax < 255
30 incl %ecx
31 stc
32 sbbl %ecx, %edx
33 pushf
34 call lz4mov // copy literals
35 popf
36 js lz4main
37 lodsw // get string address
38 #ifndef FLAT32
39 pushw %bx
40 movw %di, %bx
41 subl %eax, %ebx
42 popw %ax
43 call lz4len // get string length
44 pushw %ds
45 pushw %si
46 pushw %es
47 popw %ds
48 movw $0xF, %si
49 andw %bx, %si
50 shrl $4, %ebx
51 addl $4+1, %ecx
52 movw %bx, %bp
53 call lz4mov2 // copy string
54 popw %si
55 popw %ds
56 #else
57 negl %eax
58 xchgl %eax, %ebx
59 addl %edi, %ebx
60 call lz4len // get string length
61 pushl %esi
62 xchgl %ebx, %esi
63 call lz4mov // copy string
64 popl %esi
65 #endif
66 jmp lz4chunk
68 lz4len: // get length in %ecx
69 andl $0xF, %eax
70 movl %eax, %ecx
71 cmpb $0xF, %al
72 jne lz4quit
73 lz4len2:
74 lodsb
75 decl %edx // remaining chunk size
76 addl %eax, %ecx
77 cmpb $0xFF, %al
78 je lz4len2
79 lz4quit:
80 ret
82 lz4movlp:
83 movsb
84 #ifndef FLAT32
85 movw $0x800, %bp
86 orw %di, %di
87 jns lz4di
88 subw $0x8000, %di
89 movw %es, %ax
90 addw %bp, %ax
91 movw %ax, %es
92 lz4di:
93 orw %si, %si
94 jns lz4si
95 subw $0x8000, %si
96 lz4mov2:
97 movw %ds, %ax
98 addw %bp, %ax
99 movw %ax, %ds
100 lz4si:
101 #endif
102 lz4mov:
103 decl %ecx
104 jnz lz4movlp
105 ret