Difference between revisions of "Assembler:Commands:RET"

From Cheat Engine
Jump to navigation Jump to search
(Created page with ''''command''' ret ''operand'' Returns from a CALL optionally removing, operand number of, bytes from the stack. This is used for POPing values passed, to the CALL, from the stac…')
 
Line 1: Line 1:
 
'''command''' ret ''operand''
 
'''command''' ret ''operand''
  
Returns from a CALL optionally removing, operand number of, bytes from the stack.
+
Returns from a [[Assembler:Commands:CALL|CALL]] optionally removing, operand number of, bytes from the stack.
This is used for POPing values passed, to the CALL, from the stack.
+
This is used for [[Assembler:Commands:POP|POP]]ing values passed, to the [[Assembler:Commands:CALL|CALL]], from the stack.
 +
 
 +
 
 +
<div style="padding:2px;border:1px dashed #2f6fab;background-color:#f4f4f4;">
 +
Transfers program control to a return address located on the top of the stack. The address is usually placed on the stack by a [[Assembler:Commands:CALL|CALL]] instruction, and the return is made to the instruction that follows the [[Assembler:Commands:CALL|CALL]] instruction.
 +
 
 +
The optional operand specifies the number of stack bytes to be released after the return address is popped; the default is none. This operand can be used to release parameters from the stack that were passed to the called procedure and are no longer needed. It must be used when the [[Assembler:Commands:CALL|CALL]] instruction used to switch to a new procedure uses a call gate with a non-zero word count to access the new procedure. Here, the source operand for the RET instruction must specify the same number of bytes as is specified in the word count field of the call gate.
 +
 
 +
The RET instruction can be used to execute three different types of returns:
 +
; Near return
 +
: A return to a calling procedure within the current code segment (the segment currently pointed to by the CS register), sometimes referred to as an intrasegment return.
 +
; Far return
 +
: A return to a calling procedure located in a different segment than the current code segment, sometimes referred to as an intersegment return.
 +
; Inter-privilege-level far return
 +
: A far return to a different privilege level than that of the currently executing program or procedure.
 +
 
 +
[http://x86.renejeschke.de/html/file_module_x86_id_280.html x86.renejeschke.de/html/file_module_x86_id_280.html]
 +
</div>
 +
 
  
 
=== Command Parameters ===
 
=== Command Parameters ===
Line 20: Line 38:
  
 
  ret 0x8
 
  ret 0x8
 
  
 
== See also ==
 
== See also ==
Line 29: Line 46:
 
== External links ==
 
== External links ==
 
* [https://wikipedia.org/wiki/X86_instruction_listings wikipedia.org/wiki/X86_instruction_listings]
 
* [https://wikipedia.org/wiki/X86_instruction_listings wikipedia.org/wiki/X86_instruction_listings]
 +
* [https://wikibooks.org/wiki/X86_Assembly/Other_Instructions wikibooks.org/wiki/X86_Assembly/Other_Instructions]
 
* [http://www.asmpedia.org/index.php?title=Main_Page asmpedia.org]
 
* [http://www.asmpedia.org/index.php?title=Main_Page asmpedia.org]

Revision as of 07:17, 14 March 2017

command ret operand

Returns from a CALL optionally removing, operand number of, bytes from the stack. This is used for POPing values passed, to the CALL, from the stack.


Transfers program control to a return address located on the top of the stack. The address is usually placed on the stack by a CALL instruction, and the return is made to the instruction that follows the CALL instruction.

The optional operand specifies the number of stack bytes to be released after the return address is popped; the default is none. This operand can be used to release parameters from the stack that were passed to the called procedure and are no longer needed. It must be used when the CALL instruction used to switch to a new procedure uses a call gate with a non-zero word count to access the new procedure. Here, the source operand for the RET instruction must specify the same number of bytes as is specified in the word count field of the call gate.

The RET instruction can be used to execute three different types of returns:

Near return
A return to a calling procedure within the current code segment (the segment currently pointed to by the CS register), sometimes referred to as an intrasegment return.
Far return
A return to a calling procedure located in a different segment than the current code segment, sometimes referred to as an intersegment return.
Inter-privilege-level far return
A far return to a different privilege level than that of the currently executing program or procedure.

x86.renejeschke.de/html/file_module_x86_id_280.html


Command Parameters

Parameter Description
operand The number of bytes to pop from the stack


Examples

ret
ret 4
ret 0x8

See also

External links