ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Пятница
29 марта
960603 Топик полностью
klen (24.11.2019 00:25, просмотров: 234) ответил VLLV на А расскажите плз про CortexM3/M4 - Насколько эффективна система команд для работы с битовыми полями? Не приводит ли использование битовых полей к существенному перерасходу программной памяти? А то ОЗУ сэкономлю, а флэш на растерзание.
вот пример как оно есть.. это на входе #include <stdint.h> struct bitfield_t { int16_t a : 5 ; int16_t b : 4 ; int16_t c : 7 ; } ; // 3 поля всего 16 бит void __attribute__((noinline)) zopa_0( struct bitfield_t* bf, const int8_t a, const int8_t b, const int8_t c ) { bf->a = a ; bf->b = b ; bf->c = a + b - c ; } inline void __attribute__((always_inline)) zopa_1( struct bitfield_t* bf, const int8_t a, const int8_t b, const int8_t c ) { bf->a = a ; bf->b = b ; bf->c = a + b - c ; } void client(struct bitfield_t* bf_0, struct bitfield_t* bf_1, const int8_t a, const int8_t b, const int8_t c ) { __asm__ ("nop"); __asm__ ("nop"); zopa_0(bf_0,a,b,c); __asm__ ("nop"); __asm__ ("nop"); __asm__ ("nop"); zopa_1(bf_0,a,b,c); } а это на выходе arm-kgp-eabi-gcc -std=c18 -g0 -mthumb -march=armv7e-m -mfloat-abi=soft -mcpu=cortex-m4 -Os -S test.c zopa_0: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 push {r4, r5, lr} and r5, r2, #15 subs r2, r2, r3 and r4, r1, #31 add r2, r2, r1 orr r4, r4, r5, lsl #5 uxtb r2, r2 orr r2, r4, r2, lsl #9 strh r2, [r0] @ movhi pop {r4, r5, pc} client: nop nop ldrsb r3, [sp, #16] mov r2, r4 bl zopa_0 nop nop nop subs r3, r4, r3 and r0, r4, #15 and r2, r1, #31 add r3, r3, r1 orr r2, r2, r0, lsl #5 uxtb r3, r3 orr r3, r2, r3, lsl #9 strh r3, [r5] @ movhi pop {r3, r4, r5, pc}