IXP2400/2800 Programming: The Complete Microengine Coding Guide

The tips and tricks in this chapter are categorized by topic: debugging, optimizing, or pitfalls. Depending on your background and previous involvement with the IXP12XX processor and the IXP2XXX processor, some of the tips and tricks might seem obvious, while others may surprise you. Some of the tips and tricks apply to writing in a particular language, microengine C or microengine assembly, and some are independent of the implementation language. So feel free to skip around through this chapter to suit your needs.
To help you quickly understand the tip or trick, a summary note is placed at the beginning of each section. You can scan these summaries to determine whether the information is useful to you. These tips and tricks can be read in any order.
| Summary: | The ctx_arb[kill] instruction (and ctx_wait(kill) intrinsic) can be used to implement a simple assert statement for debugging. |
We have found no substitute for the workbench, simulator, and breakpoints for debugging microcode. But, occasionally we have found that some form of an assert statement for microcode helpful in debugging. For example, we have used an assert statement when debugging code on the hardware without the workbench. Assert statements are also convenient in that they reduce the number of breakpoints we have to set.
The ctx_wait(kill) intrinsic can be used to implement a simple assert statement as follows in microengine C:
#ifdef MICRO_DEBUG#define micro_assert(__e) \ if (!(__e)) \ ctx_wait(kill);#else#define micro_assert(__e)#endif/* An example usage...