Can you switch to C in protected mode?

E

Eric

I have a pet project I'm working on. I start in DOS in assembly, switch to
protected mode and play around with things in that environment. I'm
wondering if i started at main in a C program then called the assembly
stuff to switch to pmode if i could then use some of C's functions in
pmode?
Thanks
Eric
 
J

Joona I Palaste

Eric said:
I have a pet project I'm working on. I start in DOS in assembly, switch to
protected mode and play around with things in that environment. I'm
wondering if i started at main in a C program then called the assembly
stuff to switch to pmode if i could then use some of C's functions in
pmode?

The terms "DOS", "assembly", "protected mode" and "pmode" are not
defined in C. They're specific to a certain operating system, not to
programming languages.
Your question is completely off-topic here. Please ask in a newsgroup
dedicated to your own operating system (MS-DOS?).

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"'It can be easily shown that' means 'I saw a proof of this once (which I didn't
understand) which I can no longer remember'."
- A maths teacher
 
G

Gordon Burditt

I have a pet project I'm working on. I start in DOS in assembly, switch to
protected mode and play around with things in that environment. I'm
wondering if i started at main in a C program then called the assembly
stuff to switch to pmode if i could then use some of C's functions in
pmode?

Most reasonable operating systems start in "protected mode", if the
CPU in question has one, and you never get to execute code outside
of it.

Try answering your own question: does the (binary) code written
for non-protected-mode in assembly language generally work unchanged
in both protected mode and non-protected mode? I doubt it. And
if it DOES work unchanged, why would you care which mode you are
in?

Gordon L. Burditt
 
E

Eric

Joona said:
The terms "DOS", "assembly", "protected mode" and "pmode" are not
defined in C. They're specific to a certain operating system, not to
programming languages.
Your question is completely off-topic here. Please ask in a newsgroup
dedicated to your own operating system (MS-DOS?).

I disagree, i think it is relevant. I'm asking about the internals of C
Just because i didn't specifically mention printf or fopen doesn't mean its
not about C.
 
J

Joona I Palaste

I disagree, i think it is relevant. I'm asking about the internals of C
Just because i didn't specifically mention printf or fopen doesn't mean its
not about C.

I disagree. The "internals of C" are a property of a specific
implementation, not of the C programming language itself. Believe it or
not, MS-DOS is not the only operating system with a C implementation. C
exists for lots of systems that don't even have the concept of "modes"
at all.
 
I

Igmar Palsenberg

Eric said:
I disagree, i think it is relevant. I'm asking about the internals of C
Just because i didn't specifically mention printf or fopen doesn't mean its
not about C.

The internals are compiler dependant. Protected mode is processor
dependant, and is Intel specific AFAIK. The C standard doesn't dictate
implementation dependant stuff, so it is OT here.

Calling functions in x86 protected mode isn't a problem, calling OS
specific stuff can, depending on the OS.



Igmar
 
M

Mark McIntyre

I disagree, i think it is relevant. I'm asking about the internals of C
Just because i didn't specifically mention printf or fopen doesn't mean its
not about C.

You can disagree all you like, You're in a minority of one. Use of assembly
is offtopic. How to call realmode C functions from protected mode is
offtopic. Whether any of this even makes any sense is offtopic.

You really need to ask all this in a DOS programming group, where they'll
know the answers. We really can't help you.
 
T

Thomas Matthews

Eric said:
Joona I Palaste wrote:




I disagree, i think it is relevant. I'm asking about the internals of C
Just because i didn't specifically mention printf or fopen doesn't mean its
not about C.

No. The ARM processor only changes into user mode or system mode using
assembly language instructions, which are not available in the pure
C language.

No, the 8032 processor series has no protected mode.

In general, if a processor requires a specific instruction to change
into protected mode, then it cannot be performed using C. However,
if the mode switching is memory-mapped, then it can be.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
 
T

Thomas Matthews

Eric said:
I have a pet project I'm working on. I start in DOS in assembly, switch to
protected mode and play around with things in that environment. I'm
wondering if i started at main in a C program then called the assembly
stuff to switch to pmode if i could then use some of C's functions in
pmode?
Thanks
Eric

The only way to switch processor modes using the C language is
for the mode switch to be memory mapped. One can write to any
memory location using pointers (and if your operating system
allows it and the location exists).

If your processor requires special assembly language instructions
or a special "port", then you can't use the C language to do this.
You _can_ write an assembly language function and call this
function from the C language. Whether an operating system allows
you to change modes or not, is out of scope for this newsgroup.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
 
J

J. J. Farrell

Eric said:
I disagree, i think it is relevant.

You are wrong.
I'm asking about the internals of C

No you're not. You're asking about the internals of an implementation
of an operating environment and its relationship to an implementation
of C. Ask yourself whether or not your question is equally applicable
on an IBM mainframe, a SPARC server, and an ARM-based MP3 player. If
not, then in almost all cases it's off-topic in comp.lang.c.
Just because i didn't specifically mention printf or fopen doesn't mean its
not about C.

Indeed. It's the fact that you mentioned DOS, assembly, and Protected
Mode (and that they are relevant to the answer) that means that your
question is not about C as such.

There are newsgroups dedicated to discussing the sorts of questions
that you are asking, with people who know the answer and want to
discuss it. Why insist on discussing it in a newsgroup where it is
off-topic, and where a much smaller percentage of the readership are
competent to answer?
 
R

Ronald Landheer-Cieslak

Eric said:
I have a pet project I'm working on. I start in DOS in assembly, switch to
protected mode and play around with things in that environment. I'm
wondering if i started at main in a C program then called the assembly
stuff to switch to pmode if i could then use some of C's functions in
pmode?
Thanks
Eric
Have a loog at DJGPP (www.delorie.com) a port of the GNU C compiler to
DOS, which works in protected mode. Using that will start your program
off in protected mode - it won't let you switch, though..

Still, this is off-topic here..

rlc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top