• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 163
  • Last Modified:

What happened in this cleanup procedure?

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
whluk
Asked:
whluk
  • 2
1 Solution
 
nietodCommented:
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
 
nietodCommented:
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now