Some time ago I had to implement a supervisor (a system that manages many others smaller systems) for a manufacturing plant on a PIC microcontroller. So, I did shitty programming. Lots and lots of if/else, and global vars, and lots of macros and everything in a single file. Here is some of it (github link].
So, why so shitty? Well, the supervisor logic was mapped into a graph with thousands of nodes. And the PIC I was using had very limited memory (can't recall exactly, but like 16KB), and it was divided into Data Memory and Instruction Code Memory. I could not fit the graph into Data Memory. So I had a plan, lets put the data into instruction code memory :) And there we go, lots of if/else.
It was so shitty that I had to write a Python program to code it for me (Link].
Well, it worked (Video In Action), but then again, I'm not very proud, and never touched embedded system again.
I remember trying to do something similar by encoding a video entirely inside of an OpenGL fragment shader using a massive tree of if statements. There is no limitation on the size and complexity of shader programs in the specification, but in the real world, I ran into compiler limits, so I couldn't get it to work.
3
u/AranHase Jun 28 '15
Some time ago I had to implement a supervisor (a system that manages many others smaller systems) for a manufacturing plant on a PIC microcontroller. So, I did shitty programming. Lots and lots of if/else, and global vars, and lots of macros and everything in a single file. Here is some of it (github link].
So, why so shitty? Well, the supervisor logic was mapped into a graph with thousands of nodes. And the PIC I was using had very limited memory (can't recall exactly, but like 16KB), and it was divided into Data Memory and Instruction Code Memory. I could not fit the graph into Data Memory. So I had a plan, lets put the data into instruction code memory :) And there we go, lots of if/else.
It was so shitty that I had to write a Python program to code it for me (Link].
Well, it worked (Video In Action), but then again, I'm not very proud, and never touched embedded system again.