public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Joel Sherrill <joel@rtems.org>
To: ElijaxApps <elijaxapps@gmail.com>
Cc: Newlib <newlib@sourceware.org>
Subject: Re: Help porting newlib to a new CPU architecture (sorta)
Date: Tue, 6 Jul 2021 17:00:20 -0500	[thread overview]
Message-ID: <CAF9ehCXPuRAr7yj9fZsLbZ2uHOZFUuVLvCYQVfftrZB+h7WiMQ@mail.gmail.com> (raw)
In-Reply-To: <CAK=1DaubbSKkWd2tKKc0uYacr5_nHNOt_bJZFg=ksQLqZYJWdg@mail.gmail.com>

On Tue, Jul 6, 2021, 4:10 PM ElijaxApps <elijaxapps@gmail.com> wrote:

> Hi, thank you a lot four your great responses, them really got me on some
> direction.
>
> >even DOS (iiuc) requires at least a 16-bit CPU.  not sure FreeDOS supports
> >16-bit though, or if it too requires 32-bit.
> >-mike
>
> Well, Libre 8 has:
> 4 GP 8 Bit registers for math operations. 16 Bit integers are not a big
> problem,  if:
>   - I could use 2 cycles for batching the operation,
>   - I could use registers 2 on 2 (and update ALU width).
> Or even I could rewrite the microcode of my CPU to make it work
> independently, as in
>   - Sum lower 8 bits, push to stack,
>   - Sum higher 8 bits, push to stack,
>   - On return (int) pop twice.
>
> In memory terms it has 24 bit address RAM, all of them addressable and
> directionable in 3 cycle jumps. No segmentation, no paragraphs, just plain
> 16MB of RAM in a single component. That's why I am confident about using a
> DOS-like OS.
>

I think you might get some ideas from the old m6809 port of gcc

http://vectrexc.malban.de/documentation/gcc-6809-documentation

That was an 8 bit CPU with only 64k memory space if I remember everything
correctly.

I think given an add with carry, gcc can be taught to use 8 bit operations
in sequence on larger types. I recall seeing this on the h8 or avr.


> >Consider the AVR toolchain, used in Arduino.  Isn't that an 8-bit
> machine?  It certainly is small.
> >paul
>
> Thanks for the tip! I have checked, I think this is the source code:
>
> https://github.com/esp8266/Arduino/tree/master/cores/esp8266
>
> Could you point out what files I need to rewrite? Thanks in advance.
> Correct me if that is not the code, and in case I finally decide this
> approach I'll move to its mailing list.
>

The gcc source would be in a directory like gcc/config/avr


> >The full toolchain includes libc, libbfd, binutils, gcc, which would
> >have to be bootstrapped by cross-compiling from a host system.
>
> >There is an AVR target which may support 8b and avr-libc which should
> >support the toolchain.
>
> >There is also an Arduino toolchain based off the AVR toolchain which
> >supports developing and loading sketches which run on pretty bare 8b MCUs.
>
> >You may be better off targeting the latter approach for simplicity.
> >A lot may depend on how close a match you can find between your target
> >architecture and some existing architecture.
>
> Yeah, I've been checking GCC repository and there is already an AVR target,
> that I could use as a base to make Libre 8 target. Another candidate is z80
> you mentioned, with the only caveat of having to implement 16b integer
> operations on my CPU firmware (not hard at all).
>
> I know I will have to cross-compile at least once libc for using it, then
> crosscompiling gcc itself, and it should be done then the compilation of
> the full toolchain in the Libre 8 CPU itself. But the latter part is for
> the moment out of scope, as I have very limited resources on the CPU and no
> disk nor filesystem, just plain RAM (I was thinking on defining programs
> and files as memory offsets, and made them reside in memory, in a future,
> or . . . designing a component in logisim suitable as a hard disk with its
> filesystem and such...)
>
> Or, compiling every monolithic program I want to run as STATIC, so it will
> include dependant libraries binary code on the executable.
>
> For this, I need the libc library to be embedded, and that is why I reached
> newlib.
>
> @Orlando: You're pointing the very right direction there, I'll be quiet on
> the quotes.
>
> - I got already an assembler, written in Java. Is more like a parser, it
> just transcribes a bunch of implemented opcodes into its binary format for
> Libre 8. But I want to use any preexisting toolchain, as gcc ones. In other
> case I would end rewriting the full toolchain. However, your indication
> about porting GAS is actually a thing I really considered before.
>
> So as far as I understand now, it is not only porting newlib, *I have to
> port also to port GAS (GNU Assembler) and GCC (GNU compiler)? Take in mind
> I just want to CROSS-COMPILE binaries.*
>
> - How its an ABI formally defined on code? How is defined AVR - ABI? Could
> you point some sources? I googled without finding much about ABI
> definitions - "as is".
>
> - Architecture is Von-Neumann (Instructions and Data ar mixed in a single
> memory compartiment). Decoder will find instructions and data in the same
> input.
>
> - I found this project (
> https://docs.platformio.org/en/latest/platforms/creating_platform.html )
> which allows you to define toolchain components and right, I would need
> only to change gas to libre 8 compiler. BUT, I would need some kind of
> workaround to make C compiler to output mine pseudo assy, which I no doubt
> it is possible but would be crappy. - OR, I just have to port GAS to Libre
> 8, and use "Standard ASSY".
>
> - Thanks a lot for suggesting other 8 bit DOS OS's.
>
>
>
> *So, what would be the first step? - Defining ABI (bring examples of
> existing 8 bit ABI's) for entire toolchain. LINK NEEDED - Porting GAS, and
> use a custom GAS-libre8 in platformio project. Could anyone point out out
> which files need to be edited exactly?*
>
> Thank you all.
> Elijax Apps.
>

  reply	other threads:[~2021-07-06 22:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06 21:08 ElijaxApps
2021-07-06 22:00 ` Joel Sherrill [this message]
2021-07-06 23:50   ` Paul Koning
2021-07-07  0:29     ` ElijaxApps
2021-07-07 15:09   ` Grant Edwards
  -- strict thread matches above, loose matches on Subject: below --
2021-07-06  0:49 ElijaxApps
2021-07-06  4:35 ` Mike Frysinger
2021-07-06 13:05   ` Paul Koning
2021-07-07 20:32     ` ElijaxApps
2021-07-07 20:56       ` Orlando Arias
2021-07-06 14:02   ` Brian Inglis
2021-07-06 14:35     ` Orlando Arias
2021-07-06 18:08       ` Brian Inglis
2021-07-06 19:04         ` Orlando Arias
2021-07-06 20:01           ` Hans-Bernhard Bröker
2021-07-06 20:46             ` Orlando Arias
2021-07-07  5:45               ` Brian Inglis
2021-07-07 13:58                 ` Orlando Arias
2021-07-07 15:18                   ` Dave Nadler
2021-07-07 18:43               ` Hans-Bernhard Bröker
2021-07-07 20:23                 ` Orlando Arias

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAF9ehCXPuRAr7yj9fZsLbZ2uHOZFUuVLvCYQVfftrZB+h7WiMQ@mail.gmail.com \
    --to=joel@rtems.org \
    --cc=elijaxapps@gmail.com \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).