• Arduino Programming

    From Gary Scott@21:1/5 to All on Thu Jan 13 09:48:49 2022
    Programming my microcontrollers in (aghast) c...:( Fortran would be so
    much easier. I keep putting Fortran comments in the code :O

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gary Scott@21:1/5 to Gary Scott on Thu Jan 13 13:24:48 2022
    On 1/13/2022 9:48 AM, Gary Scott wrote:
    Programming my microcontrollers in (aghast) c...:( Fortran would be so
    much easier.  I keep putting Fortran comments in the code :O
    Yes there are better ucs I could use, but this one came in a kit with
    lots of the extra sensors and parts that I need for next to nothing.
    The next phase, if I decid to proceed will use the Due (84Mhz) version.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From gah4@21:1/5 to Gary Scott on Thu Jan 13 14:15:57 2022
    On Thursday, January 13, 2022 at 7:48:54 AM UTC-8, Gary Scott wrote:
    Programming my microcontrollers in (aghast) c...:( Fortran would be so
    much easier. I keep putting Fortran comments in the code :O

    I was wondering about that not so long ago.

    The C standard includes mention of hosted and non-hosted systems,
    which mostly means run under and OS, or not. Non-hosted tend
    not to have things like printf, as there (might) not be any character
    based output device. That means much less of the standard library
    is in the resultant object code.

    It isn't so obvious that Fortran is designed to do that.

    One complication with Arduino is that it is Harvard architecture.
    Code and data are in different address spaces. Even more,
    static (constant) data is addressed differently from variables.
    Many processors have fairly large address space for code and
    constant data, but small for variable data. (Maybe 256 bytes.)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ron Shepard@21:1/5 to All on Sun Jan 16 11:43:17 2022
    On 1/13/22 4:15 PM, gah4 wrote:
    Non-hosted tend
    not to have things like printf, as there (might) not be any character
    based output device. That means much less of the standard library
    is in the resultant object code.

    It isn't so obvious that Fortran is designed to do that.

    There is nothing in the fortran standard that requires object code for unused/unreferenced library routines to be included. I have used loaders
    in the past that would optimize out anything that was not referenced
    (the documentation claimed). Unix systems don't do that very well
    because of the way the loader works -- they load everything that was
    created by the compiler (c, fortran, whatever) into a single object
    file, with no further selection or pruning possible within.


    One complication with Arduino is that it is Harvard architecture.

    Von Neumann architectures do allow things like self-modifying code that
    Harvard architectures do not allow, but that capability is not required
    by the fortran language. I have seen self modifying code written in a combination of fortran and assembler, and I think the assembler code
    could have also been done entirely in fortan (using extensions and
    nonstandard ways of modifying memory). The specific case I saw was a
    function that when called, would overwrite the memory locations in the
    calling program to eliminate any subsequent calls to that function. It
    was basically inlining itself at runtime rather than compile time. This
    worked because the function results could be computed within the four or
    five instructions that were required for the function push/pop calling
    sequence operations.

    $.02 -Ron Shepard

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From gah4@21:1/5 to Ron Shepard on Sun Jan 16 13:19:10 2022
    On Sunday, January 16, 2022 at 9:43:24 AM UTC-8, Ron Shepard wrote:
    On 1/13/22 4:15 PM, gah4 wrote:

    (snip)

    One complication with Arduino is that it is Harvard architecture.
    Von Neumann architectures do allow things like self-modifying code that Harvard architectures do not allow, but that capability is not required
    by the fortran language. I have seen self modifying code written in a combination of fortran and assembler, and I think the assembler code
    could have also been done entirely in fortan (using extensions and nonstandard ways of modifying memory). The specific case I saw was a
    function that when called, would overwrite the memory locations in the calling program to eliminate any subsequent calls to that function. It
    was basically inlining itself at runtime rather than compile time. This worked because the function results could be computed within the four or
    five instructions that were required for the function push/pop calling sequence operations.

    The complication is that constants and data are in different address spaces.

    Also, RAM is small, so you can't just copy everything over.
    I believe C compilers have different declarations for pointers, depending
    one which one they point to. I suppose that can be done in Fortran,
    where one would need to have different declarations for dummy arguments depending on which one they might be called with.

    But otherwise, Fortran compilers tend to include a big table of error
    messages that might possibly occur.

    Now, Fortran 66 wasn't so bad, but many bloated features have been
    added that often take a lot of memory, even when you don't need them,
    or only need them rarely.

    C has the idea of hosted vs. unhosted, where some features are not included
    in unhosted versions.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gary Scott@21:1/5 to All on Sun Jan 16 18:55:55 2022
    On 1/16/2022 3:19 PM, gah4 wrote:
    On Sunday, January 16, 2022 at 9:43:24 AM UTC-8, Ron Shepard wrote:
    On 1/13/22 4:15 PM, gah4 wrote:

    (snip)

    One complication with Arduino is that it is Harvard architecture.
    Von Neumann architectures do allow things like self-modifying code that
    Harvard architectures do not allow, but that capability is not required
    by the fortran language. I have seen self modifying code written in a
    combination of fortran and assembler, and I think the assembler code
    could have also been done entirely in fortan (using extensions and
    nonstandard ways of modifying memory). The specific case I saw was a
    function that when called, would overwrite the memory locations in the
    calling program to eliminate any subsequent calls to that function. It
    was basically inlining itself at runtime rather than compile time. This
    worked because the function results could be computed within the four or
    five instructions that were required for the function push/pop calling
    sequence operations.

    The complication is that constants and data are in different address spaces.

    Also, RAM is small, so you can't just copy everything over.
    I believe C compilers have different declarations for pointers, depending
    one which one they point to. I suppose that can be done in Fortran,
    where one would need to have different declarations for dummy arguments depending on which one they might be called with.

    But otherwise, Fortran compilers tend to include a big table of error messages that might possibly occur.

    Now, Fortran 66 wasn't so bad, but many bloated features have been
    added that often take a lot of memory, even when you don't need them,
    or only need them rarely.

    C has the idea of hosted vs. unhosted, where some features are not included in unhosted versions.

    Any problems could be accommodated via a few new statements or
    directives about what can be excluded. Just a little help from your
    system programming friendly standard writers...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From gah4@21:1/5 to Gary Scott on Mon Jan 17 07:00:33 2022
    On Sunday, January 16, 2022 at 4:56:00 PM UTC-8, Gary Scott wrote:

    (snip)

    Any problems could be accommodated via a few new statements or
    directives about what can be excluded. Just a little help from your
    system programming friendly standard writers...

    Part of it is that no-one has done that yet.

    Consider that some have 2K RAM. There are some popular processors
    not used for Arduino with 128 bytes of RAM. (My current favorite,
    the 89C2051.)

    Fortran 66 and 77 were designed around static allocation, such that dynamically allocated temporaries are never required. But with Fortran 90, that isn't true.

    Someone needs to define the unhosted subset, like C, removing things that
    are mostly not needed on such systems.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Koenig@21:1/5 to gah4@u.washington.edu on Mon Jan 17 18:53:49 2022
    gah4 <gah4@u.washington.edu> schrieb:

    C has the idea of hosted vs. unhosted, where some features are not included in unhosted versions.

    Actually, it's "hosted" vs. "freestanding".

    A freestanding implementation has only the bare language; it is
    not even prescribed that there is a function main, or that the
    standard library exists.

    Fortran is a bigger language than C, and the features that
    make it more powerful have their price in code size.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From gah4@21:1/5 to Thomas Koenig on Mon Jan 17 12:49:13 2022
    On Monday, January 17, 2022 at 10:53:52 AM UTC-8, Thomas Koenig wrote:
    gah4 <ga...@u.washington.edu> schrieb:
    C has the idea of hosted vs. unhosted, where some features are not included in unhosted versions.
    Actually, it's "hosted" vs. "freestanding".

    A freestanding implementation has only the bare language; it is
    not even prescribed that there is a function main, or that the
    standard library exists.

    Fortran is a bigger language than C, and the features that
    make it more powerful have their price in code size.

    Code size is less a problem than RAM size, but still could be important.

    The one with 2K RAM has 30K. (32K - 2K bootloader) code space.

    But you do have to at least try to keep as much library routines that
    aren't being used out of the actual code to load.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gary Scott@21:1/5 to All on Mon Jan 17 19:16:40 2022
    On 1/17/2022 2:49 PM, gah4 wrote:
    On Monday, January 17, 2022 at 10:53:52 AM UTC-8, Thomas Koenig wrote:
    gah4 <ga...@u.washington.edu> schrieb:
    C has the idea of hosted vs. unhosted, where some features are not included >>> in unhosted versions.
    Actually, it's "hosted" vs. "freestanding".

    A freestanding implementation has only the bare language; it is
    not even prescribed that there is a function main, or that the
    standard library exists.

    Fortran is a bigger language than C, and the features that
    make it more powerful have their price in code size.

    Code size is less a problem than RAM size, but still could be important.

    The one with 2K RAM has 30K. (32K - 2K bootloader) code space.

    But you do have to at least try to keep as much library routines that
    aren't being used out of the actual code to load.



    That's precisely the one I'm targeting in my version 2 device. 6 of
    them operating in parallel, synchronized by a seventh. Using a Mega in
    the V1 device with one serial process.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)