?
Solved

What happened in this cleanup procedure?

Posted on 1998-06-13
2
Medium Priority
?
160 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 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 clear a vector as well as how to detect empty vectors in C++.
Suggested Courses
Course of the Month12 days, 5 hours left to enroll

752 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