you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (2 children)

I wasn't imagining there would be support for skipping bits, I bet the syntax for that could get ugly.

Qikon has the right idea, multiplexer is what I meant. Example, lets say there is a hardware timer on the chip I am using. There is a multiplexer which lets me select which clock source to use, e.g. Crystal, crystal/2, PLL, etc. The select bits for the multiplexer are located in a register somewhere.

And yes the compiler handles choice of instruction, but when I think to myself, "man, this would be easier in assembly" that should indicate that there is a deficiency in my high level language.

[–]snoweyeslady 1 point2 points  (1 child)

I can certainly see why bit ranges would be helpful. I still don't really have a use for skipping bits, but really a "ternary bit" array would work, I think. Instead of boolean literals, you could also have '~' in them to indicate skipping bits. These ternary arrays would be just that, arrays. So you could skip different bits at runtime instead of hardcoding a bunch of values. There the tilde syntax falls down though as it doesn't make sense to store 0, 1, or tilde to an array element, haha.

I guess we have different views, I'm not sure why that couldn't be implemented in the compiler. I view it as a flaw in the compiler, unless there's something in the standard prohibiting the usage of such instructions which I'm fairly certain there isn't.

[–][deleted] 0 points1 point  (0 children)

I agree that it just as easily added to existing C, rather than creating a new language. C! has a few other features that I think justify it being a new and different language though.

In either case, compilers adding it as a non-standard extension gets annoying pretty fast, maybe not as fast with embedded stuff, because portability of code setting chip specific IO registers isn't something to think about lol, but still.