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