Solved

strange ret?

Posted on 1998-11-09
2
360 Views
Last Modified: 2010-04-02
Dear guys,
     Another unrelated question...
     In an assembly program, What are the likely causes of a ret that jumps to a strange place after the return? The memory model is large which seems okay.

like this....
sub_123 proc far
    :
   :
     ret

sub_123 endp

the ret jumps to a strange place
mov ax, [bp+si]
mov ax, [bp+si]
:
:
:
Thanks
Jacky
0
Comment
Question by:whluk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 20 total points
ID: 1177299
Stack corruption.  To test it, set a breakpoint in the beginning of sub_123 and check the return address that is pushed on the stack.  Set another at the "ret" and check the stack again.  You'll have to single-step in the debugger to see what overwrites the stack.

Another possible cause is a confusion between a near call and a far return (or vice versa) but I think that it is not the case here.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1177300
You've gpt this question asked twice, sort of.  In the other place the return is a far return.

It would help to see the code of the function.  That is the likely culprit.  Also the code that calls the function.  (It does CALL it not JMP to it, right?)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question