Forum > Embedded
light pascal
marcov:
--- Quote from: devport on December 23, 2019, 07:07:26 pm ---I have written a similar program in C for uC Cortex-M0. And my point is that in Pascal I haven't even achieved half of the functionality, and I'm already exceeding 5kB Flash more than the one written in C.
--- End quote ---
With such constraints you indeed need to lay off the automated types. (though I would avoid textual I/O in microcontrollers in general)
--- Quote ---It worries me very much
I am slowly beginning to come to the conclusion that Pascal is not suitable for writing in microcontrollers.
--- End quote ---
Pascal and C are nearly equivalent in theoretical performance. The difference is more in the amount and quality of compilers and what their optimization targets are.
Free Pascal's Object Pascal is like C++. It is high level language, but the lowlevel (in C++ case: C) still lives there.
Just like that, rock bottom Pascal is like C without macros. (iow #define only for constants).
You will need to learn to adjust the level
--- Quote ---I have big problems writing in this language ... I do the same thing as in C, and yet I encounter Hard Fault more often than I did in C.
--- End quote ---
It could be a compiler bug, but 9 to 10 this is some mistake you made. If you are less proficient in embedded Pascal that can happen. Stay critical and try to isolate the problem. It could be as little as translating char buff[5] into array[0..5] of char; {1 char more!}
valdir.marcos:
--- Quote from: marcov on December 23, 2019, 07:31:59 pm ---
--- Quote from: devport on December 23, 2019, 07:07:26 pm ---I have written a similar program in C for uC Cortex-M0. And my point is that in Pascal I haven't even achieved half of the functionality, and I'm already exceeding 5kB Flash more than the one written in C.
--- End quote ---
With such constraints you indeed need to lay off the automated types. (though I would avoid textual I/O in microcontrollers in general)
--- Quote ---It worries me very much
I am slowly beginning to come to the conclusion that Pascal is not suitable for writing in microcontrollers.
--- End quote ---
Pascal and C are nearly equivalent in theoretical performance. The difference is more in the amount and quality of compilers and what their optimization targets are.
Free Pascal's Object Pascal is like C++. It is high level language, but the lowlevel (in C++ case: C) still lives there.
Just like that, rock bottom Pascal is like C without macros. (iow #define only for constants).
You will need to learn to adjust the level
--- Quote ---I have big problems writing in this language ... I do the same thing as in C, and yet I encounter Hard Fault more often than I did in C.
--- End quote ---
It could be a compiler bug, but 9 to 10 this is some mistake you made. If you are less proficient in embedded Pascal that can happen. Stay critical and try to isolate the problem. It could be as little as translating char buff[5] into array[0..5] of char; {1 char more!}
--- End quote ---
Could PicPas example help this discussion?
PicPas, Pascal compiler for Microchip PIC
https://forum.lazarus.freepascal.org/index.php/topic,36595.0.html
https://github.com/t-edson/PicPas
devport:
However, I will not give up without a fight yet. : P
I will learn the behavior of the Pascal compiler and correct my code first.
devport:
PicPas, For me, this is a good approach to programming microcontrollers. I thought about it myself in the context of ARM Cortex ;D
MarkMLl:
To be honest, I don't think it's fair comparing Pascal against C on account of the implicit complexity (support for finally blocks etc.) that Pascal carries around even if strings etc. aren't used.
It's only marginally fair to compare Pascal against C++ (with managed strings support) on account of the flexibility that C/C++ have to recompile stuff rather than making do with precompiled "one size fits all" units.
MarkMLl
Navigation
[0] Message Index
[#] Next page
[*] Previous page