Re: Help porting newlib to a new CPU architecture (sorta)
Joel Sherrill <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <CAF9ehCXPuRAr7yj9fZsLbZ2uHOZFUuVLvCYQVfftrZB+h7WiMQ@mail.gmail.com> |
On Tue, Jul 6, 2021, 4:10 PM ElijaxApps <[email protected]> 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. >