PDA

View Full Version : Help with assembly code


callan300
June 22nd, 2007, 23:37
Hello,

Could someone tell what this function does? line by line would be great. I am learning and need help.

Thanks.

SomeFunction:
fld dword [esp+0x18]
fcomp dword [0x100080e4]
fnstsw ax
test ah,0x40
jz 0x1000113c
mov eax,[esp+0x4]
mov ecx,[esp+0xc]
cmp eax,ecx
jl 0x10001136
test eax,eax
jng 0x10001136
mov eax,[esp+0x8]
mov ecx,[esp+0x14]
sub eax,ecx
mov ecx,[esp+0x10]
lea eax,[eax+ecx-0x1]
ret 0x18

LLXX
June 23rd, 2007, 02:05
Go read the Intel manuals and figure it out yourself.

No way for any of us to make sense of it with the jump targets missing.

callan300
June 23rd, 2007, 05:28
what are jump targets?
I will put them in the post if you can tell me what it is

Swimmer
June 23rd, 2007, 06:01
Quote:
[Originally Posted by callan300;66627]Hello,

Could someone tell what this function does? line by line would be great. I am learning and need help.

Thanks.

SomeFunction:
fld dword [esp+0x18]
fcomp dword [0x100080e4]
fnstsw ax
test ah,0x40
jz 0x1000113c
ret 0x18


I would recommend you first study floating point code.
That's what the first line is.

Use the altavista advanced search and put in something like
fpu instructions in the "only words" box.

Show what work you have done too.

callan300
June 27th, 2007, 17:05
This is a very vasic question, but I really need to know before I go into a lot of trouble.
Is is all all possible to figure out what the Assembly code is doing so the the function can be re-written?

LLXX
June 27th, 2007, 17:43
INTEL MANUALS, go READ them.

And to answer your question, yes it's possible with the use of a brain and some knowledge you are currently lacking.

FrankRizzo
June 27th, 2007, 18:08
callan300: YES! I ripped the "verification code" out of an that was used for verifying you license key, and through a couple of steps, rewrote the whole thing in C. But as LLXX says, you WILL need to understand asm to be able to do this. Because YOU have to become the processor, in that you look at the instruction, and execute it in your head. (Or single step it in a debugger), and then watch what effect it has on the registers. Once you understand what the instructions do individually, you can start to get an idea of what's going on. Just remember, there are C instructions that generate quite a few ASM instructions.

Some of the multiply, or divide operations especially, they can result in: Loading a value into a register, shifting it left or right, then adding or subtracting the original value, etc. It seems complicated, but they you realize "Hey, that's just taking that 1st number, and multiplying it by 9!".