We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bb5a2a3 commit 5a427fbCopy full SHA for 5a427fb
src/rp2_common/hardware_irq/irq.c
@@ -135,9 +135,9 @@ irq_handler_t irq_get_exclusive_handler(uint num) {
135
static uint16_t make_branch(uint16_t *from, void *to) {
136
uint32_t ui_from = (uint32_t)from;
137
uint32_t ui_to = (uint32_t)to;
138
- uint32_t delta = (ui_to - ui_from - 4) / 2;
139
- assert(!(delta >> 11u));
140
- return (uint16_t)(0xe000 | (delta & 0x7ff));
+ int32_t delta = (int32_t)(ui_to - ui_from - 4);
+ assert(delta >= -2048 && delta <= 2046 && !(delta & 1));
+ return (uint16_t)(0xe000 | ((delta >> 1) & 0x7ff));
141
}
142
143
static void insert_branch_and_link(uint16_t *from, void *to) {
0 commit comments