From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) by sourceware.org (Postfix) with ESMTPS id CABF33877425 for ; Tue, 6 Jul 2021 22:00:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CABF33877425 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rtems.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f182.google.com with SMTP id r16so10059ljk.9 for ; Tue, 06 Jul 2021 15:00:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=j46oHmdbWtTryUdqn+dICfxWHgirjQ+oXR3ffZ7YHAg=; b=CZ6QBrrQH1MRELL6fdX2FUv0YyyX6sgA1ZF/99AQVIkBXkurwT94KOiA7z17t7M4+K RdXMqDlKgOuVY/fa8nc1e+Vle2kf1H47BFLipS5b1tGooduI0MuA2b7TeaFcho31iwnD CaNXmy5KEApEECHyv8jKjhq/uJufMSH11IAV/T6x9UkDnopYnT224nrnJyA2a0pSY6V4 nR3YKkKlKk2XP9YMThKig4cVrmhpv7/NoJDzid5iRDNVTEJhJOhDxK/VO/Q7UPzicG1o hOZl6EiMl8oGSy1jAZx38FO8hQjInBtt/ymVj0BRtpM2pbivETpSEhHOHj2egI1C69os eqpg== X-Gm-Message-State: AOAM532P3PMcMZuIaYpKq/QZInIAYP025UVko9TfahvJKGV0xwIFPAkz a8miw8wn8q6tBBUZ31J4xKl3JYMbAJek/g== X-Google-Smtp-Source: ABdhPJy3JkNyBAtBZBYScGzxi406fdj7Cuos9RX0WimxkdJ5ZYWIot1CbEB0FShNP1Z1+dlmog/CGQ== X-Received: by 2002:a05:651c:1312:: with SMTP id u18mr17082628lja.62.1625608832460; Tue, 06 Jul 2021 15:00:32 -0700 (PDT) Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com. [209.85.167.52]) by smtp.gmail.com with ESMTPSA id p21sm1511732lfa.264.2021.07.06.15.00.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Jul 2021 15:00:31 -0700 (PDT) Received: by mail-lf1-f52.google.com with SMTP id c28so364193lfp.11 for ; Tue, 06 Jul 2021 15:00:31 -0700 (PDT) X-Received: by 2002:a05:6512:38c1:: with SMTP id p1mr16834415lft.50.1625608831787; Tue, 06 Jul 2021 15:00:31 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Reply-To: joel@rtems.org From: Joel Sherrill Date: Tue, 6 Jul 2021 17:00:20 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Help porting newlib to a new CPU architecture (sorta) To: ElijaxApps Cc: Newlib X-Spam-Status: No, score=-3031.8 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Jul 2021 22:00:36 -0000 On Tue, Jul 6, 2021, 4:10 PM ElijaxApps 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. >