473,396 Members | 1,826 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.

non-specific os C++ building

<I previously posted this in comp.os.misc, but no one answered and its been
3 days... actually no one has posted any messages at all(atleast they are
not showing up), so, while it might not be completely on-topic, and I know
how this news group is very bitchy about off topic messages, it is
none-the-less close enough(IMO)>

is there a C++ out there that I can use to build code for the intel
architecture that is non-os specific. By that, I mean where I can create
binaries that work without an os? I'm working on a small os and I'd like to
develop some utilities and I'd rather not write them in assembly at this
point(eventually I will have to in some for or another, but). Basicaly I
just need memory management and BIOS disk access. That is, I need some way
to allocate memory in an organized way and some way to "open" "files"(though
I can actually code the routines to use int 13h myself, it would be nice if
this has already been done(where I can specific the sectors that contain the
file).

Some things that would be nice: If it used flat memory model(not necessary
but would be nice to have access to more than a meg). If it could load files
on a sector basis istead of a filename basis. If the binary could be built
for windows and non-os with little modification(so I could test it on my VM
hard drive).

For the file stuff, to be clear, it would be nice for something like

#ifdef non_os
fstream somefile(drive, sector start, sector end, ios::write)
#else
fstream somefile(VM filename, start, end, ios::write)
#endif

then to write the buf to the disk

somefile.write(buf, size)

or something like that.
Just wondering if there is anything out there that can do something like
this. I suppose I could write the code myself, but then I might as well
just do it in assembly.

Thanks, Jon.
Jul 22 '05 #1
2 1370
On Sat, 8 Jan 2005 04:09:17 -0600, "Jon Slaughter"
<no****@nowhere.com> wrote:
<I previously posted this in comp.os.misc, but no one answered and its been
3 days... actually no one has posted any messages at all(atleast they are
not showing up), so, while it might not be completely on-topic, and I know
how this news group is very bitchy about off topic messages, it is
none-the-less close enough(IMO)>
Perhaps one of the embedded systems groups would be appropriate -- ??
is there a C++ out there that I can use to build code for the intel
architecture that is non-os specific. By that, I mean where I can create
binaries that work without an os? I'm working on a small os and I'd like to
develop some utilities and I'd rather not write them in assembly at this
point(eventually I will have to in some for or another, but). Basicaly I
just need memory management and BIOS disk access. That is, I need some way
to allocate memory in an organized way and some way to "open" "files"(though
I can actually code the routines to use int 13h myself, it would be nice if
this has already been done(where I can specific the sectors that contain the
file).
Well, you seem to assume that at least the BIOS is available... At the
very least, you will need to write some assembler code which
bootstraps your code from the disk. Take a look at the Linux LILO or
grub, for example.
Some things that would be nice: If it used flat memory model(not necessary
but would be nice to have access to more than a meg). If it could load files
on a sector basis istead of a filename basis. If the binary could be built
for windows and non-os with little modification(so I could test it on my VM
hard drive).
You want "Windows(R) AND non-OS"? That's a pretty tall order...
For the file stuff, to be clear, it would be nice for something like

#ifdef non_os
fstream somefile(drive, sector start, sector end, ios::write)
#else
fstream somefile(VM filename, start, end, ios::write)
#endif

then to write the buf to the disk

somefile.write(buf, size)

or something like that.
Just wondering if there is anything out there that can do something like
this. I suppose I could write the code myself, but then I might as well
just do it in assembly.


In theory, C++ is a platform-independent language. That means that you
can write the same correct C++ code and expect it to compile and build
on all standards-conforming platforms.

In practice, all the C++ implementations I have seen rely mostly on
the C runtime libraries. And all the C runtime library implementations
I have seen (actually only 4...Borland, Microsoft, GCC and
Dinkumware's cross-platform source libraries) rely heavily on the
operating system for opening files, allocating memory, etc.

So what one usually does is, for example, "Hey, I need to open a file
here for reading" and writes std::ifstream(...) without giving a
second thought as to *how* streams are implemented on the platform at
hand. Your OS-specific stuff should all be in a different layer, most
likely buried deep within the implementation of the particular C (not
C++) runtime library you are using.

Now there are many OS which have been developed with C (Windows and
Linux, for example, since you have already limited yourself to the
Intel platform(s) [presumably the 32-bit x86 architecture? There are
other Intel processors, you know...]). I don't know of any OS which
used C++ ... I remember reading that Linus Torvalds actually tried it
for Linux once, but found it just too painful and went back to C ...
besides, this was in the "dark ages" of C++ where there were no
templates, etc.) So it can be done. The question is more one of design
IMHO.

And at some point, you will have to interface with the hardware ...
after all, that is what an OS does, isn't it? So the question is, do
you want to sprinkle your code with hardware-specific stuff using
#ifdef's, or do you want to abstract the hardware layer? Obviously,
you need some kind of abstraction because unless you are 100% sure
that your code will never have to run on any other platform besides
the one you develop it for (e.g. custom-built hardware for the
military), you will need to abstract it to a large degree. And because
C++ *is* platform-independent, there are no C++ standard functions for
implementing hardware interrupt handlers, device I/O, etc.

There are C++ compilers (such as Intel, Comeau) which generate C code
to be parsed by a backend C compiler. This means that you can compile
the same source code on either Linux or Windows (since both compilers
mentioned support these OS) depending on which version you target, and
thus be platform-independent. In addition, both of these compilers are
very standards-conforming. You might be able to find some compiler for
embedded systems which could prove to be more useful.

The GCC compiler has been ported to several different platforms, for
example. And you have the advantage of it being open source. What you
need to do (IMHO) is to download the GCC source and examine as many
different implementations of it as might be of interest to you (as you
can find), then adapt it for your purposes. Be aware of the licensing
issues, though (GPL).

--
Bob Hairgrove
No**********@Home.com
Jul 22 '05 #2
Jon Slaughter wrote:
<I previously posted this in comp.os.misc, but no one answered and its been 3 days... actually no one has posted any messages at all(atleast they are not showing up), so, while it might not be completely on-topic, and I know how this news group is very bitchy about off topic messages, it is
none-the-less close enough(IMO)>

is there a C++ out there that I can use to build code for the intel
architecture that is non-os specific. By that, I mean where I can create binaries that work without an os? I'm working on a small os and I'd like to develop some utilities and I'd rather not write them in assembly at this point(eventually I will have to in some for or another, but). Basicaly I just need memory management and BIOS disk access. That is, I need some way to allocate memory in an organized way and some way to "open" "files"(though I can actually code the routines to use int 13h myself, it would be nice if this has already been done(where I can specific the sectors that contain the file).


STFW

googleing "intel c++ compiler embedded" gave 125,000 hits
<snip>
--
Nick Keighley

Jul 22 '05 #3

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

Similar topics

12
by: lothar | last post by:
re: 4.2.1 Regular Expression Syntax http://docs.python.org/lib/re-syntax.html *?, +?, ?? Adding "?" after the qualifier makes it perform the match in non-greedy or minimal fashion; as few...
5
by: klaus triendl | last post by:
hi, recently i discovered a memory leak in our code; after some investigation i could reduce it to the following problem: return objects of functions are handled as temporary objects, hence...
3
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in...
25
by: Yves Glodt | last post by:
Hello, if I do this: for row in sqlsth: ________pkcolumns.append(row.strip()) ________etc without a prior:
32
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
14
by: Patrick Kowalzick | last post by:
Dear all, I have an existing piece of code with a struct with some PODs. struct A { int x; int y; };
2
by: Ian825 | last post by:
I need help writing a function for a program that is based upon the various operations of a matrix and I keep getting a "non-aggregate type" error. My guess is that I need to dereference my...
0
by: amitvps | last post by:
Secure Socket Layer is very important and useful for any web application but it brings some problems too with itself. Handling navigation between secure and non-secure pages is one of the cumbersome...
399
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.