• Assembly Language to Pseudo Translation? Or just help me, thanks.
    6 replies, posted
I am somewhat learning some Assembly opcodes through messing with Cheat Engine and Ollydbg. [code] fsubr dword ptr [ebx+4] [/code] From googling I know that fsubr is Subtract Real Reversed. ebx is the value of an address and +4 is its offset. dword is "double word", where word is 16 bits so dword is a 32bit type. ptr is a cast. So we are casting [ebx+4] as a dword before storing it back to [ebx+4]? In this case the value at address [ebx+4] is subtracted from something (Still no clue), and then the result goes back to [ebx+4] I guess my main question is, isn't there something missing? Subtraction takes 2 values, but from what I just learned (if I learned it correctly) there is only 1 variable showing, and that is [ebx+4] where the rest "dword ptr" is a cast, and fsubr is its opcode.
The result is always stored in ST(0) which is the top of the FPU register stack. I suggest downloading the Intel instruction set reference manual.
dword ptr specifies that the value located at ebx+4 is a dword. [] basically do the same thing as () in maths, it will be calculated before the execution of the fsubr operation. fsubr does: ST0 = (4 byes of the memory located here: ebx+4) - ST0
[QUOTE=ColdFusion;41280570]dword ptr specifies that the value located at ebx+4 is a dword. [] basically do the same thing as () in maths, it will be calculated before the execution of the fsubr operation. fsubr does: ST0 = (4 byes of the memory located here: ebx+4) - ST0[/QUOTE] Would I know what ST0 is based off probably the previous entry? Like is this ST0: [code] fstp dword ptr [ebx+4] [/code] From googling. st is store, fst is for float, p at the end means pop the variable... is it popping ebx+4?
[url]http://www.website.masmforum.com/tutorials/fptute/fpuchap4.htm#fstp[/url] It's popping from the FPU stack. Entries in the FPU stack are written as ST(n), where n is the index; ST(0) then refers to the top of the stack. And it's popping to the memory pointed to by ebx + 4 as dword, so as a [url=http://www.website.masmforum.com/tutorials/fptute/fpuchap2.htm#real4]REAL4[/url] (a 32-bit float). [editline]2nd July 2013[/editline] And yes, you would have to look for previous FPU instructions to know what lies at ST(0).
[QUOTE=ZeekyHBomb;41280927][url]http://www.website.masmforum.com/tutorials/fptute/fpuchap4.htm#fstp[/url] It's popping from the FPU stack. Entries in the FPU stack are written as ST(n), where n is the index; ST(0) then refers to the top of the stack. And it's popping to the memory pointed to by ebx + 4 as dword, so as a [url=http://www.website.masmforum.com/tutorials/fptute/fpuchap2.htm#real4]REAL4[/url] (a 32-bit float). [editline]2nd July 2013[/editline] And yes, you would have to look for previous FPU instructions to know what lies at ST(0).[/QUOTE] So putting these 2 together [code] fsubr dword ptr [ebx+4] fstp dword ptr [ebx+4] [/code] The first entry takes ST(n) and subtracts it with [ebx+4], and stores it in ST(n). The second entry pops ST(n) (theoretically to be used again later?) and then stores it in [ebx+4]. Am I right?
Yes, where n = 0 and [ebx+4] is interpreted as a 32-bit float. Since we're talking about a stack, I'm unsure what exactly you mean by ST(0) to be usable again.
Sorry, you need to Log In to post a reply to this thread.