Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!mit-eddie!interlan!backman From: backman@interlan.UUCP (Larry Backman) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Re: Microsoft C: Getting The DS & SS For A Module Message-ID: <114@interlan.UUCP> Date: Wed, 7-Jan-87 08:30:44 EST Article-I.D.: interlan.114 Posted: Wed Jan 7 08:30:44 1987 Date-Received: Wed, 7-Jan-87 21:51:39 EST References: <1273@kontron.UUCP> Reply-To: backman@interlan.UUCP (1014-Larry Backman) Organization: MICOM-Interlan, Boxborough, MA Lines: 60 Keywords: Microsoft C DS and SS Xref: mnetor comp.sys.ibm.pc:829 comp.lang.c:614 In article <1273@kontron.UUCP> cramer@kontron.UUCP (Clayton Cramer) writes: >I'm writing a program using Microsoft C and MASM which installs a new >interrupt 17 ISR. The new ISR calls a C function. How do I get the >DS and SS values for the C function to set before calling the C function? > I've solved this problem before by calling an assembly function from the C module sometime during program initialization. The assembly function copies both the DS and SS into variables located in its code segment. Then when the ISR is invoked, it replaces the existing DS and SS values with the values aaved in code segment. For example: CODE SEGMENT save_ds dw ? save_ss dw ? post_init proc far push ax mov ax,ds mov cs:save_ds,ax mov ax,ss mov cs:save_ss,ax pop ax retf post_init endp something_isr proc far ... save registers ... mov ax,cs:save_ds mov ds,ax mov ax,cs:save_ss mov ss,ax ....call C with correct segments .... iret something_isr proc far A word of warning - Make sure that interrupts are off when you start playing with DS and SS! Larry Backman\ Micom - Interlan Inc 155 Swanson Rd. Boxborough Ma, 01719 617-263-9929 x291 ulowell mit-eddie !interlan!backman