Help porting newlib to a new CPU architecture (sorta)

ElijaxApps elijaxapps@gmail.com
Tue Jul 6 00:49:05 GMT 2021


Hi all,

I designed a Logisim schematic of a full system, able to run programs in
the simulation, as shown in this video:

https://www.youtube.com/watch?v=UP6tO8x5I5A

Is based on a SAP-1 (Simplest as Possible) basis, containing 4 GP registers
(8 bit), stack for function operations (up to 256 depth levels of
recursivity), 24bit plain RAM component, and a simple ALU able to echo
strings and perform not floating point math.

AFAIK, newlib is suitable for embedded devices, and I want to create the
full toolchain for C/C++ language at least.

At first I tried porting it by my own using this guide:

https://www.embecosm.com/appnotes/ean9/ean9-howto-newlib-1.0.html#sec_crt0

And I am stuck here:

   1.

   Implement the Board Support Package(s) for the target (Chapter 5
   <https://www.embecosm.com/appnotes/ean9/ean9-howto-newlib-1.0.html#chap_libgloss>
   ).
   -

      Implement the C Runtime start up, crt0.o for each BSP (Section 5.2
      <https://www.embecosm.com/appnotes/ean9/ean9-howto-newlib-1.0.html#sec_crt0>
      ).
      -

      Implement the environment global variable and 18 system call
      functions for each BSP following the convention namespace and
      reentrancy conventions specified in newlib/configure.host (Section 5.3
      <https://www.embecosm.com/appnotes/ean9/ean9-howto-newlib-1.0.html#sec_syscalls>
       and Section 5.4
      <https://www.embecosm.com/appnotes/ean9/ean9-howto-newlib-1.0.html#sec_reentrant_syscalls>
      ).
      -

      Create libgloss/*target*/Makefile.in and libgloss/*target*/
      configure.ac, based on the versions in the libgloss/libnosys directory
      and run aclocal and autoconf in libgloss/*target* (Section 5.5
      <https://www.embecosm.com/appnotes/ean9/ean9-howto-newlib-1.0.html#sec_bsp_config_make>
      ).

I have some questions regarding those points:

1) ATM my system is programmable, using a kind of own pseudo-assembler code
I created for that purpose, alongside with a Java compiler which translates
it to text hex file, then I copy its contents to the simulation's RAM. But
it's not "normal", "standard" ASSY, just an approximation made by not an
assy guy... (never coded any in actual ASSY).

So:
 - How do I write CRT code? In standard ASSY? In my own assy, and somewhere
I tell which binary format represents each mnemonic? In case of the first,
how will  the toolchain know the opcodes and binary format of the
instructions and data? In case of the second, could you please clarify the
paths of those files in the docs? :)

The full source to Libre 8 CPU is here. Some recent changes are not yet
pushed but the commited and de documentation provided in github should be
enough to make you an idea of what I tell by pseudo-assy.

https://github.com/ElijaxApps/Libre-8

I want to push it further, and perhaps port some existing software to it as
FreeDOS ... , as far as I can get. All ideas are welcome.

If you have to make questions about the architecture don't hesitate and do
it. If I have to modify os made changes to fit any requirement it won't be
a problem, even now I've reached this far.

I hope this is possible. Thank you,
Elijax Apps.


More information about the Newlib mailing list