Re:The Little C Function From Hell
by silentbicycle on Tuesday June 19, 2012 @11:54AM
(#4132481)
C compilers can be buggy, particularly when you start working with vendor-supplied compilers for embedded platforms. A colleague was furious when he realized that his board's compiler didn't support function pointers.
[ Parent
| on HN ]
that does seem like a rather large omission. how did he work around that issue?
I could imagine a DSP architecture that doesn't intrinsically support indirect jumps. (especially as DSPs frequently use the Harvard memory model) That would make implementing function pointers tricky. I'd probably work around this by making a set of dispatch macros that expand into a giant switch block where each case is a (static) function call. The other option would be self-modifying code, which is annoying to do, to say the least, particularly for Harvard systems.
If your CPU supports keeping function return addresses on a stack that you can push other things onto, you can do an indirect jump by pushing the address you want to jump to and then "returning" to it. That's a lot easier than self-modifying code or massive switch statements, and just as easy on Harvard as on von Neumann architectures.
Re:The Little C Function From Hell
by silentbicycle on Wednesday June 20, 2012 @12:48PM
(#4137806)
To be honest, I don't know, except that there was a lot of scowling. I think it was a PIC micro.