473,396 Members | 2,021 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can you switch to C in protected mode?

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
Nov 14 '05 #1
10 1959
Eric <no****@email.com> scribbled the following:
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 (pa*****@cc.helsinki.fi) ------------- 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
Nov 14 '05 #2
>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
Nov 14 '05 #3
Joona I Palaste wrote:
Eric <no****@email.com> scribbled the following:
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?).


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.
Nov 14 '05 #4
Eric <no****@email.com> scribbled the following:
Joona I Palaste wrote:
Eric <no****@email.com> scribbled the following:
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?).

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.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"It sure is cool having money and chicks."
- Beavis and Butt-head
Nov 14 '05 #5
Eric 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.


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
Nov 14 '05 #6
On Sun, 13 Jun 2004 18:35:50 GMT, in comp.lang.c , Eric <no****@email.com>
wrote:
Joona I Palaste wrote:
Eric <no****@email.com> scribbled the following:
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?).


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.


--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #7
Eric wrote:
Joona I Palaste wrote:

Eric <no****@email.com> scribbled the following:
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?).

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

Nov 14 '05 #8
Eric wrote:
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

Nov 14 '05 #9

"Eric" <no****@email.com> wrote in message
news:a81zc.84143$3x.77981@attbi_s54...
Joona I Palaste wrote:
Eric <no****@email.com> scribbled the following:
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?).


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?
Nov 14 '05 #10
Eric wrote:
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
Nov 14 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: webzila | last post by:
Hello, I have to write a program for an 8051 micro-controller using micro-C to monitor Switch 1 and if the switch in pushed the message "switch 1 pushed" should be displayed in the LCD. Also the...
7
by: Tim Cowan | last post by:
Hi I was wondering if someone could help me change these ifs to a switch statement. I tried but I can't make it work. Thanks Tim Code below: protected void...
3
by: steve | last post by:
Is there anyway my AP can detect system goto Sleep, Hibernation mode, switch user and logoff?
3
by: VK | last post by:
Given this simplified to the min constructor: function jsFileManager(mode) { this.mode = mode; } If there a way to make jsFileManager.mode property as final protected. Other words, it can be...
5
by: volvox | last post by:
hi, is it possible to access protected mode registers (EAX , EBX,ECX...) via assembly in C .
2
by: samuelberthelot | last post by:
Hi, How can I switch the browser back and forth to fullscreen mode, using javascript on the onclick event of a button ? Thanks
1
by: Mark Stafford | last post by:
I am attempting to use a DetailsView control to view some data where the fields returned by the database are determined at runtime. I create the TemplateFields on the fly using a class that...
11
by: Smithers | last post by:
Just wondering if the sequence of the case(s) in the switch block might impact performance. Suppose I switch on an int, and I have 4 expected cases. Lets say I expect case 3 to happen 95% of the...
15
by: Zhang Weiwu | last post by:
http://www.w3.org/MarkUp/2004/xhtml-faq provided a trick to serve xhtml webpage to IE as application/xml I used that trick and now every one of my xhtml webpage have following first 4 starting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.