Programming my microcontrollers in (aghast) c...:( Fortran would be soYes there are better ucs I could use, but this one came in a kit with
much easier. I keep putting Fortran comments in the code :O
Programming my microcontrollers in (aghast) c...:( Fortran would be so
much easier. I keep putting Fortran comments in the code :O
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.
On 1/13/22 4:15 PM, gah4 wrote:
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.
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...
C has the idea of hosted vs. unhosted, where some features are not included in unhosted versions.
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.
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.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 159 |
Nodes: | 16 (0 / 16) |
Uptime: | 98:19:32 |
Calls: | 3,209 |
Files: | 10,563 |
Messages: | 3,009,579 |