O'Reilly logo

ARM® Cortex® M4 Cookbook by Dr. Mark Fisher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing a jump table

Under certain circumstances, a jump table provides a very efficient way of implementing a C language switch statement block. We can define a jump table as a list of unconditional branch instructions—each referencing a different procedure or subroutine. We branch to one of the subroutines by loading the program counter with the address of the unconditional branch that is stored in the jump table. The effective addresses of items in the jump table are formed using a base + offset addressing mode. Base + offset addressing is commonly used to access data items stored in arrays, and a jump table is effectively just an array of address items.

Getting ready

To illustrate a jump table, we'll develop a recipe called asmJumpTable_c4v0 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required