Solved

strange ret?

Posted on 1998-11-09
2
349 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
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now