From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,95dad97c56f9de95 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-25 08:31:18 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!195.27.83.146!news-FFM2.ecrc.net!news.cesnet.cz!crax.cesnet.cz!news.felk.cvut.cz!not-for-mail From: "Sergey Koshcheyev" Newsgroups: comp.lang.ada Subject: Re: Curiousity: pragma No_Run_Time for Gnat Date: Tue, 25 Sep 2001 17:20:05 +0200 Organization: Czech Technical University Message-ID: <9oq7b6$2vuh$1@ns.felk.cvut.cz> References: <9oo006$fdf$1@nh.pace.co.uk> <9oo7ne$145d$1@ns.felk.cvut.cz> <9ooa2p$j91$1@nh.pace.co.uk> <9opbv7$1vg1$1@ns.felk.cvut.cz> <9oq2mf$9as$1@nh.pace.co.uk> NNTP-Posting-Host: r41.dkm.cz X-Trace: ns.felk.cvut.cz 1001431206 98257 62.24.83.41 (25 Sep 2001 15:20:06 GMT) X-Complaints-To: usenet@ns.felk.cvut.cz NNTP-Posting-Date: Tue, 25 Sep 2001 15:20:06 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Xref: archiver1.google.com comp.lang.ada:13341 Date: 2001-09-25T17:20:05+02:00 List-Id: "Marin David Condic" wrote in message news:9oq2mf$9as$1@nh.pace.co.uk... > "Sergey Koshcheyev" wrote in message > news:9opbv7$1vg1$1@ns.felk.cvut.cz... > > What I mean by "pure" (probably a misuse since the term usually refers to > reentrant code) is that what I would like as output is a collection of > instructions that rely only on the Intel x86 processor. (Or, if one were > targeting MIPS, PowerPC, whatever,... instructions for that particular > target processor) If I understand the PC architecture correctly, code can be > generated that will create interrupts that the BIOS will pick up and utilize > as a kind of subroutine - the ISR accomplishing some kind of I/O operation, > etc. If one is saying "Well, maybe I don't have a BIOS or I don't have this > particular BIOS - maybe I've just got an Intel processor with some > specialized hardware & I want to make code that doesn't assume any BIOS or > OS or DLLs or anything..." then the question is will the compiler make > appropriate code that (after passage through the correct linker, etc.) can > run on such a machine? The answer is "yes, but..." :-) If you use pragma No_Run_Time, GNAT won't use runtime features implicitly (most importantly, tasking, and except probably using memcpy to copy arrays). It kind of brings Ada closer to C by cutting off features. But you can, for example, explicitly use dynamic allocation. GNAT won't use BIOS, since it neither has any reason to (it doesn't do any I/O), nor any knowledge how to use it. To compile a completely stand-alone program on Linux (my little OS kernel), I use pragma No_Run_Time, -nostdlib -static flags for gnatbind, and -nostdlib -static -lc (link with C library statically, because of the memcpy thing mentioned above) flags for gnatlink. This way I get an executable in ELF format that can be booted into using grub, but nothing ties it to the OS (i.e. it does no system calls) nor does it use any DLLs. One thing I'm not so sure about, though, are predefined exceptions, most importantly Constraint_Error. I think that GNAT calls a function named something like __gnat_raise_constraint_error when it needs to raise it, and you can (or even most probably have to) redefine that function. Or you can use pragma No_Exceptions or -gnatp flag to eliminate that worry also. Also, in your example, you will have to somehow ensure that the processor is in 32bit flat mode prior to executing Ada code, but that's a minor point. > I suppose what I'm wondering is can the use of the No_Run_Time pragma cause > the Gnat compiler to be suitable as an embedded compiler? It doesn't matter > if you don't get full-up Ada - just that you get embeddable code or compiler > errors for any feature that might not be embeddable. (I can live with a > subset of Ada if the compiler tells me when I can't do something.) > Presumably, one could then implement the low-level operations needed by > full-up Ada (create your own runtime) so long as you could find out what > mechanisms the compiler used to get the required services from its own > runtime. I don't have any experience with embedded devices, so I can't tell. The compiler does output an error message if you use a forbidden feature. Once again, any corrections are welcome, since everything I said above is based only on my personal experiences and I don't already remember everything exactly. Sergey Koshcheyev. > > MDC > -- > Marin David Condic > Senior Software Engineer > Pace Micro Technology Americas www.pacemicro.com > Enabling the digital revolution > e-Mail: marin.condic@pacemicro.com > Web: http://www.mcondic.com/