[comp.lang.c] DS != SS in Turbo C 2.0

rhl@computing-maths.cardiff.ac.uk (Robert Hartill) (02/07/91)

I want to use Turbo C's small memory model to write Interrupt Service Routines
for an operating system..

Since the ISRs are to use tasks stack space, their DS and SS are going to be
 different, but TC assumes their the same. I want the ISRs to access kernel
 data via DS (which never changes), so changing DS to SS inside the ISR isn't
 good enough.

I tried compiling the ISRs using the medium memory model, that had the desired
affect, but gave the ISRs a different CS to the rest of the OS. This is 
unacceptable since it means changing lots of code to account for it.

What I need is a compier option *SS!=DS*, which is found on other compilers...

Is there any other way ?

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::     Robert Hartill, Dept Of Computing Mathematics, UWCC, Cardiff, UK.     ::
::          e-mail : rhl@cm.cf.ac.uk         Fax : 0222 371921               ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
He who can, does. He who cannot teaches.
-George Bernard Shaw.
-------------------------------------------------------------------------------

johnm@cory.Berkeley.EDU (John D. Mitchell) (02/07/91)

In article <1991Feb7.105811.17817@computing-maths.cardiff.ac.uk> rhl@computing-maths.cardiff.ac.uk (Robert Hartill) writes:
>I want to use Turbo C's small memory model to write Interrupt Service Routines
>for an operating system..

>Since the ISRs are to use tasks stack space, their DS and SS are going to be
> different, but TC assumes their the same. I want the ISRs to access kernel
> data via DS (which never changes), so changing DS to SS inside the ISR isn't
> good enough.
[...deleted...]
>What I need is a compier option *SS!=DS*, which is found on other compilers...

Upgrade to TC++ v1.0x (current version, akz TC v3.0x).  The compiler now
supports some switches so you can expressly request SS == or != DS.  Since
you can do this on a module by module basis none of you other code need be
screwed (oops sorry about that technical terminology :-).

Good luck,
	John
	johnm@cory.Berkeley.EDU

scott@bbxsda.UUCP (Scott Amspoker) (02/08/91)

In article <1991Feb7.105811.17817@computing-maths.cardiff.ac.uk> rhl@computing-maths.cardiff.ac.uk (Robert Hartill) writes:
>I want to use Turbo C's small memory model to write Interrupt Service Routines
>for an operating system..
>
>Since the ISRs are to use tasks stack space, their DS and SS are going to be
> different, but TC assumes their the same. I want the ISRs to access kernel
> data via DS (which never changes), so changing DS to SS inside the ISR isn't
> good enough.

Upon enterance to an interrupt handler, TC loads DS to point the main
data segment of the application containing the interrupt handler.  As
you have pointed out, this could be different from the SS.  This will not
cause any trouble unless you take the address of something on the stack.
(do not set a pointer to anything but global data).

-- 
Scott Amspoker                       | 
Basis International, Albuquerque, NM |     This space available
(505) 345-5232                       | 
unmvax.cs.unm.edu!bbx!bbxsda!scott   |