473,242 Members | 1,473 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,242 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 1364
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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.