fix: pin_write calls optimized away by XC8 #19

Merged
daru merged 1 commit from fix/pin_write_optimized_away into main 2026-07-27 01:03:53 +00:00
Contributor

Fixes #18

XC8 was silently dropping pin_write calls because the ternary macro (val ? (LATA |= ...) : (LATA &= ...)) produced a discarded expression whose volatile LATA side-effects were treated as side-effect-free. Replaced with direct writes to XC8's volatile __bit variables (LATAx), which the compiler cannot optimize away.

Confirmed by:

  • Zero (759) warnings at lines 171/185/340/350/359
  • Program space decreased 1722→1704 bytes (18 bytes), indicating the operations are now actually being emitted
Fixes #18 XC8 was silently dropping `pin_write` calls because the ternary macro `(val ? (LATA |= ...) : (LATA &= ...))` produced a discarded expression whose volatile LATA side-effects were treated as side-effect-free. Replaced with direct writes to XC8's `volatile __bit` variables (`LATAx`), which the compiler cannot optimize away. Confirmed by: - Zero (759) warnings at lines 171/185/340/350/359 - Program space decreased 1722→1704 bytes (18 bytes), indicating the operations are now actually being emitted
XC8 was silently dropping pin_write calls because the ternary macro produced a
discarded expression whose volatile LATA side-effects were incorrectly treated as
side-effect-free. Replaced the ternary with direct writes to XC8's volatile
__bit variables (LATAx), which the compiler cannot optimize away. Confirmed by
zero warnings at lines 171/185/340/350/359 and 18-byte code size reduction
(1722→1704 bytes), indicating the operations are now actually emitted.
daru merged commit ea8d962ba2 into main 2026-07-27 01:03:53 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
daru/PICsense!19
No description provided.