News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

call and ret/retn

Started by n00b!, September 23, 2008, 04:21:56 PM

Previous topic - Next topic

n00b!

Simple reconstruction of post: For what is the mnemonic "retn"?

And what exactly does a "call"?
Isn't it a simply jump (some values like the current EIP are pushed to the stack before the jmp)?

dsouza123

call is an x86 instruction, Procedure call,
it is one of the instructions that invoke statements are assembled to,
another x86 instruction involved is push.

A help file supplied with MASM32, Intel Opcodes and Mnemonics
has more details on instruction parameters.

hutch--

noob,

Both CALL and RET are what you call BRANCHING instructions, effectively they change the next instruction from the sequential order to one that is defined in code with either CALL or RET. The difference is that CALL also stores the address of the instruction to return to AFTER the next RET. With the two types of branches you develop things like loop code with any of the JMP or Jxx instructions and you develop procedures with CALL/RET so that the "flow" of instructions branches to the address of the procedure, executes the code then returns back to the next instruction AFTER the one that called it.

RET is actually a macro for the mnemonic RETN which is a NEAR return in win32. There are two forms in win32, one which simply returns to the next instruction and another that corrects the stack at the same time.

In a C calling convention procedure it terminates with a RET but with STDCALL it terminates with a RET number, the number being the byte count to correct the stack.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php