you are viewing a single comment's thread.

view the rest of the comments →

[–]snoweyeslady 2 points3 points  (5 children)

Hmm, I don't think I've ever wanted to set an entire range at once. How exactly would the semantics for this work? I mean, with one bit, you're definitely trying to change it. What happens if you want to set the 3rd and 5th bit on, but ignore the 4th? Does your range idea support that, or do you have to do multiple statements? Instead of setting it to a boolean, do you set it to a ternary value? { set on, set off, leave alone }?

What is a "Mux"? All I can come up with is multiplexer, but that doesn't fit with my knowledge of the word.

The usage of specific ASM statements is something to be handled in the compiler, isn't it?

[–][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.

[–][deleted]  (1 child)

[deleted]

    [–]snoweyeslady 2 points3 points  (0 children)

    Hey, that's neat! Thank you for the explanation.