\chapter{Guides}

\section{How to implement a lookup or branch table}
Due to the limitation of the \verb=ldr= instruction,
addressing large fields of constants with it is not feasible,
especially if those constants are refered to by more than one part of the program.

This can be circumvented by using the assemblers directive \verb|=labelname| to store a pointer to a labels location (See Section~\ref{sec:AssemblerDirectives}).
Pointers to data in memory can be stored conviently close to an \verb=ldr= instruction, 
making the access to the memory content via a pointer based load or store instruction possible.

The most common use of this mechanic is the lookup table.
An example is given in Listing~\ref{lst:ldr_useage}.

\begin{asm}[Example on indirect LDR use]{lst:ldr_useage}
.align
lookup_table:
    .word 0x0001
    .word 0x0010
//...
// large amounts of code and/or data
//...

.align
lookuptable_ptr: 
    .word =lookup_table
//...
    ldr rX , >lookuptable_ptr
//...
    ld32 rY,rX // load from pointer
    addi rX, 4
    ld32 rZ,rX // load from pointer with offset
//...
\end{asm}
