[Help] Using Asm

11/19/2009 19:56 lostmage333#1
Heya,

I'm trying to do some .dll editing. However, being a 1st year ME student, all this stuff is a lil complicated for me. I have no idea where to turn to ask some of these questions, so I'll start by asking here.

I know that "TEST" performs a bitwise and between 2 values. However, here's part of pleione.dll
Code:
 TEST EDX,EDX
JE SHORT <Address>
I see that TEST is used in a few instances like this. Do there exist any situation where that conditional jump would not be taken? I would imagine there would be... how would that be triggered?

Also, what exactly does "LEAVE" do? The definition on Wikipedia seemed to say that it behaves similarly to POP on stack memory?

And, if at some point in the code, a subroutine is called, does it run from the address called until the next RETN? In ASM, what exactly would a line like RETN 4 do? Where does the 4 get stored?

Alright... that's about all I have for now. Maybe more questions to come later. Any help would be appreciated.
11/20/2009 09:19 Augur#2
Starting with the 80186 processor, the ENTER and LEAVE instructions simplify the stack setup and restore instructions at the beginning and end of procedures. However, ENTER uses a lot of time. It is necessary only with nested, statically-scoped procedures. Thus, a Pascal compiler may sometimes generate ENTER. The LEAVE instruction, on the other hand, is an efficient way to do the stack cleanup. LEAVE reverses the effect of the last ENTER instruction by restoring BP and SP to their values before the procedure call.

---

The syntax for RETN and RETF is:

label: | label LABEL NEAR
statements
RETN [[constant]]

label LABEL FAR
statements
RETF [[constant]]

The RET instruction (and its RETF and RETN variations) allows an optional constant operand that specifies a number of bytes to be added to the value of the SP register after the return. This operand adjusts for arguments passed to the procedure before the call.
11/20/2009 14:59 lostmage333#3
Thank you! So if I'm understanding correctly, it makes no sense to change the LEAVE. Also, changing the constant does not seem like it would do much?