Solved

What happened in this cleanup procedure?

Posted on 1998-06-13
2
154 Views
Last Modified: 2011-08-18
Dear All,
     I've got a C program which also contains assembly code.
The 'C' program first calls an assembly routine that does mode setting job. The program have to gain access to a data segment, so I did this mov ax, seg_b and mov ds, ax at the beginning.but when I add these statments into the assembly routine,then there comes some problems concerning the cleanup procedure. If I deleted them, the program works fine.
Why did this happen?

Jacky
0
Comment
Question by:whluk
  • 2
2 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
Comment Utility
The code expects that DS will still be pointing to the segment it originally was.  Just restore the original DS when you are done with the assembly and you will be fine.
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
I believe that many 16 bit compilers assume that DS will always point to a segment called _TEXT.  I'm not sure of the details about that, though.  Your best bet is to save and restore DS and ES around any procedure that messes with it.  You also might need to save and restore SI and DI, some compilers assume they will not change as well.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

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…
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 video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

763 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

8 Experts available now in Live!

Get 1:1 Help Now