?
Solved

What happened in this cleanup procedure?

Posted on 1998-06-13
2
Medium Priority
?
161 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
[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
2 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 1165830
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
ID: 1165831
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

649 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