Permalink
Browse files

Found kkrunchy_k7 023.a4/asm07 (most recent version) source code

  • Loading branch information...
rygorous committed Apr 18, 2012
1 parent fd16b03 commit 5ddf84f8c5c511b59b284911fda17aa6509b7bf4
Showing with 130 additions and 181 deletions.
  1. +1 −1 kkrunchy_k7/_config.hpp
  2. +10 −30 kkrunchy_k7/depack2.asm
  3. +38 −61 kkrunchy_k7/depacker.asm
  4. +30 −27 kkrunchy_k7/dis.cpp
  5. +1 −1 kkrunchy_k7/dis.hpp
  6. +11 −0 kkrunchy_k7/exepacker.cpp
  7. +39 −61 kkrunchy_k7/model_asm.asm
View
@@ -14,4 +14,4 @@
#define sINTRO 0 // compile for small size
#define sDEBUG 1 // include debug code even in release build
#define sAPPNAME "kkrunchy" // application name for window title
-#define sVERSION "0.23 alpha 3" // version number string
+#define sVERSION "0.23a4/asm07" // version number string
View
@@ -4,7 +4,7 @@
bits 32
-%define NBUFFERS 22
+%define NBUFFERS 20
%define BUFFER dataArea.buffer
struc dataArea
@@ -243,9 +243,9 @@ DisUnfilter:
cmp al, 0x04
jne .nosib
- xchg esi, [ebp+BUFFER+21*4]
+ xchg esi, [ebp+BUFFER+19*4]
movsb
- xchg esi, [ebp+BUFFER+21*4]
+ xchg esi, [ebp+BUFFER+19*4]
.nosib mov dl, ch
and dl, 0xc0
@@ -276,13 +276,8 @@ DisUnfilter:
inc ebx
.nomr5 xchg esi, [ebp+BUFFER+13*4+ebx*4]
lodsd
- dec esi
xchg esi, [ebp+BUFFER+13*4+ebx*4]
- xchg esi, [ebp+BUFFER+18*4]
- shl eax, 8
- lodsb
- xchg esi, [ebp+BUFFER+18*4]
- ror eax, 8
+ bswap eax
stosd
cmp word [ebp+dataArea.codebuf], 0x24ff
@@ -301,15 +296,8 @@ DisUnfilter:
jnz .noad
xchg esi, [ebp+BUFFER+15*4]
- lodsd
- dec esi
+ movsd
xchg esi, [ebp+BUFFER+15*4]
- xchg esi, [ebp+BUFFER+19*4]
- shl eax, 8
- lodsb
- xchg esi, [ebp+BUFFER+19*4]
- ror eax, 8
- stosd
jmp .main
.noad dec cl
@@ -324,12 +312,8 @@ DisUnfilter:
cmp byte [edi-1], 0xe8
je .dwcal
- xchg esi, [ebp+BUFFER+20*4]
- lodsw
- xchg esi, [ebp+BUFFER+20*4]
xchg esi, [ebp+BUFFER+17*4]
- shl eax, 16
- lodsw
+ lodsd
xchg esi, [ebp+BUFFER+17*4]
shr eax, 1
@@ -350,14 +334,10 @@ DisUnfilter:
mov eax, [ebp+dataArea.funcTable+eax*4]
jmp short .storad
-.dcesc xchg esi, [ebp+BUFFER+20*4]
- lodsw
- xchg esi, [ebp+BUFFER+20*4]
- xchg esi, [ebp+BUFFER+16*4]
- shl eax, 16
- lodsw
- xchg esi, [ebp+BUFFER+16*4]
-
+.dcesc xchg esi, [ebp+BUFFER+18*4]
+ lodsd
+ xchg esi, [ebp+BUFFER+18*4]
+
mov ebx, [ebp+dataArea.funcTable]
mov [ebp+dataArea.funcTable+ebx*4], eax
.dcinc inc byte [ebp+dataArea.funcTable]
View
@@ -8,21 +8,20 @@ bits 32
section .bss
-%define MEMSHIFT 18
+%define MEMSHIFT 23
%define MEM (1<<MEMSHIFT)
-%define NMODEL 9
-%define NINPUT 40
-%define NWEIGHT (256+256+16)
+%define NMODEL 11
+%define NINPUT 48
+%define NWEIGHT (256+256+16+128)
%define MAXLEN 2047
%define USEAPM 1
-%define APMSIZE 1024
+%define APMSIZE 8192
struc ContextModel
.cpr resd 1
.cps resd 1
.ctx resd 1
.st resd 1
- .t resb MEM*2
.size:
endstruc
@@ -53,7 +52,8 @@ struc Work
.APMi resd 1
%endif
.cm resb ContextModel.size * NMODEL
- .match resd MEM
+ .match resd MEM/16
+ .modelMem resb MEM
.tx resw NINPUT
.wx resw NINPUT*NWEIGHT
.tx2 resw 4
@@ -127,9 +127,9 @@ squash:
contextHash:
mov edx, eax
- shr edx, MEMSHIFT-1
- and eax, ((MEM / 2) - 1) & ~1
- lea eax, [esi+ContextModel.t+eax*4]
+ shr edx, 24
+ and eax, ((MEM / 4) - 1) & ~1
+ lea eax, [ebp+Work.modelMem+eax*4]
cmp dl, [eax]
jne .notequal1
@@ -159,7 +159,7 @@ contextHash:
; in: eax=err
; esi=t
; edi=w
-; ecx=n/8
+; ecx=n/4
; out: esi,edi advanced.
train:
movd mm0, eax
@@ -168,8 +168,6 @@ train:
pcmpeqb mm1, mm1
psrlw mm1, 15
-%if 1
- add ecx, ecx
.lp:
movq mm3, [esi]
movq mm2, [edi]
@@ -182,28 +180,6 @@ train:
add esi, byte 8
add edi, byte 8
loop .lp
-%else
-.lp:
- movq mm3, [esi]
- movq mm5, [esi+8]
- movq mm2, [edi]
- movq mm4, [edi+8]
- paddsw mm3, mm3
- paddsw mm5, mm5
- pmulhw mm3, mm0
- pmulhw mm5, mm0
- paddsw mm3, mm1
- paddsw mm5, mm1
- psraw mm3, 1
- psraw mm5, 1
- paddsw mm2, mm3
- paddsw mm4, mm5
- movq [edi], mm2
- movq [edi+8], mm4
- add esi, byte 16
- add edi, byte 16
- loop .lp
-%endif
ret
@@ -406,7 +382,7 @@ STAGE0ENTRY:
xor eax, eax
call contextHash
mov [esi+ContextModel.cps], eax
- add esi, ContextModel.size
+ add esi, byte ContextModel.size
loop .ctxModelLoop
%if USEAPM
@@ -448,7 +424,7 @@ STAGE0ENTRY:
mov eax, [ebp+Work.zeroprob]
neg edx
inc eax
- and edx, 4095
+ shr edx, 32-12 ; eqv. to and edx, 4095 here
add eax, edx
shr eax, 1
mov [ebp+Work.zeroprob], eax
@@ -570,7 +546,7 @@ STAGE0ENTRY:
imul edi, byte (NINPUT*2)
lea edi, [ebp+Work.wx+edi]
mov esi, WorkData+Work.tx
- push byte (NINPUT/8)
+ push byte (NINPUT/4)
pop ecx
call train
@@ -625,14 +601,20 @@ STAGE0ENTRY:
; fnv hash function
; assumes edi=_bufPtr
mov eax, 0x811c9dc5
+ inc ecx
+ imul eax, ecx
+ dec ecx
mov bl, [masks+ecx-1]
+ mov dh, [bitm+ecx-1]
.hashnext:
dec edi
shr bl, 1
jnc .hashnotset
- xor al, [edi]
+ mov dl, [edi]
+ and dl, dh
+ xor al, dl
imul eax, 0x01000193
jmp short .hashnext
@@ -643,7 +625,7 @@ STAGE0ENTRY:
; match processing
; assumes esi points to "match"
- and eax, MEM-1
+ and eax, (MEM/16)-1
mov edi, [ebp+Work.dst]
xchg edi, [esi+eax*4] ; now edi=Match[h]
mov esi, [ebp+Work.dst]
@@ -735,7 +717,7 @@ STAGE0ENTRY:
cmp eax, 400
jbe .contextmodels
- mov dword [ebp+Work.ctx], 526
+ mov dword [ebp+Work.ctx], 512+14
jmp .mix
; context models
@@ -821,7 +803,7 @@ STAGE0ENTRY:
cmp ebx, byte 1
sbb dword [ebp+Work.ctx+8], byte -1
- add esi, ContextModel.size
+ add esi, byte ContextModel.size
dec ecx
jnz near .contextloop
@@ -833,6 +815,17 @@ STAGE0ENTRY:
inc ah
mov [ebp+Work.ctx+4], eax
+ xor ebx, ebx
+ mov eax, [ebp+Work.matchl]
+ dec eax
+ cmovs eax, ebx
+ not bl
+ cmp eax, ebx
+ cmova eax, ebx
+ mov eax, [ebp+Work.runTable+eax*4]
+ shr eax, 3
+ add [ebp+Work.ctx+8], eax
+
.mix:
; perform mixing
push byte 2
@@ -845,7 +838,6 @@ STAGE0ENTRY:
mov esi, WorkData+Work.tx
pxor mm0, mm0
-%if 1
push byte (NINPUT/4)
pop ecx
@@ -857,23 +849,6 @@ STAGE0ENTRY:
add esi, byte 8
add edi, byte 8
loop .mixdploop
-%else
- push byte (NINPUT/8)
- pop ecx
-
-.mixdploop:
- movq mm1, [esi]
- movq mm2, [esi+8]
- pmaddwd mm1, [edi]
- pmaddwd mm2, [edi+8]
- psrad mm1, 8
- psrad mm2, 8
- paddd mm0, mm1
- paddd mm0, mm2
- add esi, byte 16
- add edi, byte 16
- loop .mixdploop
-%endif
movq mm1, mm0
psrlq mm1, 32
@@ -971,4 +946,6 @@ section .data
squashTab dw 1, 2, 4, 6, 10, 17, 27, 45, 74, 120, 194
dw 311, 488, 747,1102,1546,2048,2550,2994,3349,3608,3785
dw 3902,3976,4022,4051,4069,4079,4086,4090,4092,4094,4095
-masks db 0x1f, 0x07, 0x0a, 0x09, 0x05, 0x03, 0x04, 0x02, 0x01
+masks db 0x1f, 0x27, 0x88, 0x07, 0x0a, 0x09, 0x05, 0x03, 0x04, 0x02, 0x01
+bitm db 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+
Oops, something went wrong.

0 comments on commit 5ddf84f

Please sign in to comment.