MCPcopy Create free account
hub / github.com/MCUdude/MiniCore / ub_dist_rjmp

Function ub_dist_rjmp

avr/libraries/Flash/src/urboot.cpp:224–230  ·  view source on GitHub ↗

Compute from rjmp opcode the relative distance, in bytes, of rjmp destination to rjmp address

Source from the content-addressed store, hash-verified

222
223// Compute from rjmp opcode the relative distance, in bytes, of rjmp destination to rjmp address
224int16_t ub_dist_rjmp(uint16_t rjmp) {
225 int16_t dist;
226
227 dist = (int16_t)(rjmp<<4) >> 3; // Sign-extend 12-bit word distance and multiply by 2
228
229 return ub_rjmpdistwrap(dist+2); // Wraps around in flashes smaller than 8k
230}
231
232// rjmp opcode from byte distance (rjmp address minus destination address); 0xcfff is an endless loop, 0xc000 is a nop
233uint16_t ub_rjmp_opcode(int16_t dist) {

Callers

nothing calls this directly

Calls 1

ub_rjmpdistwrapFunction · 0.85

Tested by

no test coverage detected