Skip to main content
12 events
when toggle format what by license comment
Feb 25, 2019 at 14:59 history edited Marcus Müller CC BY-SA 4.0
deleted 8 characters in body
Feb 25, 2019 at 14:58 comment added Marcus Müller @Lundin aaaaaah you're right; in 1989, where bit-field may have type int , unsigned int , or signed int. C99 does in fact specify differently, but also does only allow int, unsigned int, or _Bool (or implementation-defined type). Huh, never hurt me in real life, but I'll have to slightly change my answer; doesn't make any functional difference though.
Feb 25, 2019 at 13:54 comment added Lundin C doesn't allow to specify bit-fields with type unsigned char. It's a compiler extension.
Feb 25, 2019 at 13:37 comment added Marcus Müller @Lundin not quite sure what you're referring to; I'm casting a pointer to a struct that contains bitfields to an unsigned char pointer. I'm pretty sure the cast to char pointer is always legal, UNLESS you address bitfield elemets (for example, you couldn't have a pointer to word3 of such a struct); or are you referring to something else?
Feb 25, 2019 at 11:35 comment added Lundin "C does allow that" Actually it doesn't. Using unsigned char for bit-fields is a non-standard extension.
Feb 25, 2019 at 6:45 comment added Marcus Müller @Cobusve I must admit I would have just put the raw binary data in a file and used objcopy to make it linkable, or just straight away ld -r -b binary datafile.raw -o table.o and used that; I don't know the compiler Op uses well enough, but an -Os switch should exist?
Feb 25, 2019 at 1:05 comment added Cobusve @marcus, dont be so quick to claim that, write the code and you will see that it ends up using retlw because that is the fastest instruction on the pic to do that...
Feb 24, 2019 at 21:47 comment added anrieff I mean the following: if you define a 200-entry lookup table of uint8_t, it will consume a bit more than 200 words of code space. This is because under the hood the compiler implements it with a string of RETLW instructions and a computed goto. So your code will consume more than 11813 words, larger than what the PIC in question has.
Feb 24, 2019 at 20:23 comment added Marcus Müller No, it won't – RETLW is an instruction, and this is not code, but data.. What happens to constants is that the linker puts them in them some data section.
Feb 24, 2019 at 19:59 comment added anrieff I'm sorry, this is a good technique, but misses the core of the question completely. The packing style you suggest will again be translated in to a string of RETLWs, essentially using only 8 bits out of every 14-bit word. The array will again not fit in the progmem of the PIC16F1829.
Feb 24, 2019 at 19:30 history edited Marcus Müller CC BY-SA 4.0
added 49 characters in body
Feb 24, 2019 at 19:23 history answered Marcus Müller CC BY-SA 4.0