Generalises a few macros

Implements a generic version of the most important macros so they can
be reused with different prefixes.