?
Solved

strange ret?

Posted on 1998-11-09
2
Medium Priority
?
361 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 40 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

771 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