From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.8 required=3.0 tests=BAYES_00,PLING_QUERY autolearn=no autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!JUN8/iIzeA71QWaIWFKODA.user.gioia.aioe.org.POSTED!not-for-mail From: "Luke A. Guest" Newsgroups: comp.lang.ada Subject: Re: Adapting an Ada compiler to generate 8051 code (Again?! ;-) Date: Wed, 31 Mar 2021 05:46:36 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <41bc7a62-9c70-466d-b316-5fc74a3ee845n@googlegroups.com> <87im58a1up.fsf@nightsong.com> <87a6qk9uua.fsf@nightsong.com> NNTP-Posting-Host: JUN8/iIzeA71QWaIWFKODA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-GB Xref: reader02.eternal-september.org comp.lang.ada:61695 List-Id: On 30/03/2021 22:48, Paul Rubin wrote: > "Luke A. Guest" writes: >>> there are any really large obstacles to targeting GCC to the 8051 >> The biggest obstacles will be the severe lack of registers. But it's >> possible, lm78 for example. > > Do you mean this? https://www.ti.com/lit/gpn/lm78 Probably, same as the name in gcc/config. > I wasn't familiar with it. It looks awful, a couple special purpose > registers and something like 19 bytes of ram (I didn't look closely). Yup, very basic. I spoke to the author over email, he said he virtualises registers in the rtl and then generates code for the tiny amount of regs. I was looking at z80 at the time. > Does gcc actually generate code for it? I don't know whether gcc Yup, apparently. > targets any old-fashioned accumulator machines with no registers. I > thought it did, but maybe not. I do know lots of people use it for the > AVR8 / Aruino etc. AVR isn't really an accumulator arch, it's got 32 registers. Even the 6502 has a port, but that uses the zero page as virtual registers. The Z80 cannot do that as it starts executing from address 0 iirc. > It hadn't occurred to me but yeah, maybe gcc is built more around > register architectures and sdcc works differently. I haven't really > looked. sdcc is much much simpler, has to be for the architectures it supports. Much more ad hoc than GCC. GCC is based around flat memory architecture and "many registers," that's in quotes because, well x86 ffs. > I know SWEET16 is a 16 bit virtual machine that Steve Wozniak > implemented on the 6502 in the original Apple II, to get higher code > density than 6502 asm code. It had 16 registers. Doing something like > that on an 8051 and targeting GCC to it sounds fairly plausible. I > wouldn't be surprised if it's been done already. Dunno. > Does a minimal Ada runtime (Ravenscar or whatever) make particular > demands that require much outside-the-compiler support? Ravenscare is 2 tasks max, no? > Adacore Ada-to-C is proprietary? Oh well. I wonder if generating C > output from GCC intermediate code is terribly difficult. > Only way to do Ada to C that I can think of is with llvm with the C backend. If that's still being worked on.