[英]assembly conversion to basm
I'm trying to convert the CrapWOW Hash from http://www.team5150.com/~andrew/noncryptohashzoo/CrapWow.html to delphi or rather to basm. 我正在尝试将CrapWOW哈希从http://www.team5150.com/~andrew/noncryptohashzoo/CrapWow.html转换为delphi或改为basm。 My asm skills are very limited, but i thought it wouldn't be too hard...
我的asm技能非常有限,但我认为这并不难...
Anyway, with help of some webpages about asm conversion, I came to this, but it don't work... Especially, for the last part I have no Idea how to convert. 无论如何,在一些有关asm转换的网页的帮助下,我想到了这一点,但是它不起作用...特别是,对于最后一部分,我不知道如何进行转换。 Is this an assignment of the registers to the parameters and the return parameter?
这是将寄存器分配给参数和返回参数吗?
function CrapWow(key: PAnsiChar; len, seed: Cardinal): Cardinal;
//finline u32 fastcall CrapWow( const u8 *key, u32 len, u32 seed ) {
// #if !defined(__LP64__) && !defined(_MSC_VER) && ( defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) )
// // esi = k, ebx = h
// u32 hash;
// asm(
asm
lea esi, 5052acdbh[ecx+esi] //leal 0x5052acdb(%ecx,%esi), %esi
mov ebx, ecx //movl %ecx, %ebx
cmp ecx, 8 //cmpl $8, %ecx
jb @DW
@QW: //QW%=:
mov eax, 5052acdbh //movl $0x5052acdb, %eax
mul [edi] //mull (%edi) << CRASH HERE
add ecx, -8 //addl $-8, %ecx
xor ebx, eax //xorl %eax, %ebx
xor esi, edx //xorl %edx, %esi
mov eax, 57559429h //movl $0x57559429, %eax
mul 4[edi] //mull 4(%edi)
xor esi, eax //xorl %eax, %esi
xor ebx, edx //xorl %edx, %ebx
add edi, 8 //addl $8, %edi
cmp ecx, 8 //cmpl $8, %ecx
jae @QW //jae QW%=
@DW: //DW%=:
cmp ecx, 4 //cmpl $4, %ecx
jb @B //jb B%=
mov eax, 5052acdbh //movl $0x5052acdb, %eax
mul [edi] //mull (%edi)
add edi, 4 //addl $4, %edi
xor ebx, eax //xorl %eax, %ebx
add ecx, -4 //addl $-4, %ecx
xor esi, edx //xorl %edx, %esi
@B: //B%=:
test ecx, ecx //testl %ecx, %ecx
jz @F //jz F%=
shl ecx, 3 //shll $3, %ecx
mov edx, 1 //movl $1, %edx
mov eax, 57559429h //movl $0x57559429, %eax
shl edx, cl //shll %cl, %edx
add edx, -1 //addl $-1, %edx
and edx, [edi] //andl (%edi), %edx
mul edx //mull %edx
xor esi, eax //xorl %eax, %esi
xor ebx, edx //xorl %edx, %ebx
@F: //F%=:
lea edx, 5052acdbh[esi] //leal 0x5052acdb(%esi), %edx
xor edx, ebx //xorl %ebx, %edx
mov eax, 5052acdbh //movl $0x5052acdb, %eax
mul edx //mull %edx
xor eax, ebx //xorl %ebx, %eax
xor esi, edx //xorl %edx, %esi
xor eax, esi //xorl %esi, %eax
//No idea how to convert this...
// : =a(hash), =c(len), =S(len), =D(key)
// : c(len), S(seed), D(key)
// : %ebx, %edx, cc
// );
// return hash;}
end;
I would be very glad to have some help on this. 我很高兴在此方面有所帮助。
knight_killer knight_killer
It looks EDI is used before being initialized. 看起来EDI已在初始化之前使用。 It seems to happen later with other registers as well.
似乎以后也会与其他寄存器一起发生。 You should check how those registers are set by the original code compiler on entering the procedure code, and check you've copied it correctly.
输入程序代码时,应检查原始代码编译器如何设置这些寄存器,并检查是否已正确复制了它们。 Looks also at comments to your question.
还会查看对您的问题的评论。
是的..它看起来像EDI在初始化之前就被使用了,您应该通过使用指针..来传递len参数,因为您正在使用“ mul [edi]”指令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.