From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id C3BEC389802A for ; Tue, 6 Jul 2021 21:08:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C3BEC389802A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x532.google.com with SMTP id t3so476292edc.7 for ; Tue, 06 Jul 2021 14:08:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=mNJYX/yanDHGp29my7o4L8ZiISZJhd/rwyyuJbQQ3ZE=; b=u3gOFdA+luqsfw34qEU5xCQ59spmBmsLYW6Il4STDSTI0sGu4aH/AhwHalKmd02bmE RjT1I407D0/vsQaRo4d3lXTTpGN8Ch+9hhCd6tA2vHxCd1C8Do3S16uZJnY8MwVix7+x EO07yzpf+u5VBXUNWT9yAap15XbOE29FaDWhcDVlpUR7UXiy/dg7IATa/sZEAVjqZP5b usXfL7HIr8bHs7X2rKTtkggl1I92sBe4ri+uhiUaRQ32EZ2BJBz7iKAzZjgND/tammO1 YJzEgtnGtVY52uN0ey/KdF9q2IkLEhpTXXF1EIYi5rRPVFcVqva2mkxgP+rdPgVE2FWq Gx8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=mNJYX/yanDHGp29my7o4L8ZiISZJhd/rwyyuJbQQ3ZE=; b=iUUzbiq4yIQsmBEyhlXatQFfRDl5/hq2SggulXa8aIr9OTJWNPsfhq4RD6zGkutWMD FmeB5LgITCUcQUrwnYjh/ZielYg5AuXeoJNjRof0VnzuaUSlpCntKxIOIon5MwM+u8oI zF3FsasmjvxGzLh2VX6BBX2wjX1kS1QXLCFb62cddc2lPrbd+LWea2E1v8zYiNwEun6v ClC3O8H3wRalqxphkVKr8TlvpdA3H+dxzF52bfRJOgEHtjNlq37f3NmFbCswUqjZSKNr SviMrpbHNrrjtkrtBuwgYdb9mX1PHzT8UdRwwY4VrvQAHUg6SV74QULz0jxU+JTSlc2b OMjg== X-Gm-Message-State: AOAM5331xn4DLZdurDBikdh0yUz6IISStJzm8BEabiOB1nWaq1+svOCy OJVHbXUOhxb7FzKZ/jattCegYBVOdr6mIUO7vAkREO1sthw= X-Google-Smtp-Source: ABdhPJyjG9lOTD5PhJ4cCkDrZTLffRoBmL/aCRd/DL1qU7RIO6tyQkVG/8rkQ7gR8OG5w0hvN7APcgnJzL4b/SzvOtk= X-Received: by 2002:a05:6402:7c4:: with SMTP id u4mr25854165edy.69.1625605717352; Tue, 06 Jul 2021 14:08:37 -0700 (PDT) MIME-Version: 1.0 From: ElijaxApps Date: Tue, 6 Jul 2021 23:08:26 +0200 Message-ID: Subject: Help porting newlib to a new CPU architecture (sorta) To: newlib@sourceware.org X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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 21:08:40 -0000 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. >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 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.