Help porting newlib to a new CPU architecture (sorta)
Brian Inglis
Brian.Inglis@SystematicSw.ab.ca
Tue Jul 6 18:08:38 GMT 2021
On 2021-07-06 08:35, Orlando Arias wrote:
> Keep in mind that C assumes you are working on a von Neumann
> architecture. This means that the language expects both program and data
> to be in the same address space. If your CPU [which I can not really
> check since I do not work on Logisim, I use Verilog/SystemVerilog/VHDL
> myself] uses a Harvard or modified Harvard architecture, you need to
> figure out a way for your C runtime to emulate a von Neumann machine.
C has no assumptions or requirements for outdated von Neumann
architectures, but it also may not assume it is not running on such
architectures.
Early C and Unix took advantage of the Harvard architecture of larger
PDP-11s which supported split I/D space with mapping registers to
support double the program size (64KB each 16b I and D) as well as
splitting kernel/supervisor/runtime/user spaces [and similar features on
other systems], and shared text (the original meaning of the 't' "sticky
text" perm on executables), which is why there is wording in the
standards about unmodifiable constant values.
One of the big issues with systems around the time C was developed was
the unreliability resulting from systems, runtimes, and programs using
self-modifying code "tricks", and programs ability to change constant
data values used in programs (PI did not always stay π).
That was one of the benefits touted for higher level system
implementation languages such as Bliss, C, PL/S.
In the face of failures frequently caused by arbitrary code and data
modifications, branches and jumps, worries about trivial issues such as
delimited strings, unsized APIs, dynamic memory management were decades
in the future!
Various implementations, ABIs, and systems require modifiable code and
constant data, but it is *NOT* a C language assumption or requirement;
in fact I would consider it to be a C anti-pattern, that has long
limited the abilities of compilers and optimizers to do better jobs.
Copying sections tends to be due to limitations of CPUs, systems,
runtimes, or compilers to DTRT to make programs more reliable. ;^>
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]
More information about the Newlib
mailing list