Wo ist da eine "Lücke" in C?
Ist vielleicht etwas umständlich hinzuschreiben, dafür bleibt man bei den Standards:
Sieht doch gut aus, was avr-gcc daraus macht, oder?! sbic/sbis sind eh nur auf einige SFRs anwendbar...Code:extern uint8_t command_rc5, Ir_data_tmp; void foo() { if (Ir_data_tmp & (1<<5)) command_rc5 |= (1<<7); else command_rc5 &= ~(1<<7); }
Und falls das immer noch zu lange ist:Code:foo: lds r24,Ir_data_tmp lds r25,command_rc5 sbrs r24,5 rjmp .L5 ori r25,lo8(-128) rjmp .L7 .L5: andi r25,lo8(127) .L7: sts command_rc5,r25 ret
gibt:Code:void foo() { uint8_t cmd = command_rc5 & ~(1<<7); if (Ir_data_tmp & (1<<5)) cmd |= (1<<7); command_rc5 = cmd; }
Kürzer oder schneller schreibt das niemand.Code:foo: lds r25,command_rc5 andi r25,lo8(127) lds r24,Ir_data_tmp sbrc r24,5 ori r25,lo8(-128) .L5: sts command_rc5,r25 ret








Zitieren

Lesezeichen