No$gba exception setup guide

No$gba exception system allows to catch common programming errors.

When an exception is triggered, No$gba stops the execution of the ROM and shows the assembler instruction that has triggered the exception.

If you load an *.elf file instead of a *.gba file, it also shows the high level code that has triggered the exception. Please remember that *.elf support only works with devkitARM, it doesn't work if you're using Wonderful Toolchain.

Getting started

Download the "no$gba Windows debug version" from here. The gaming versions can't show the code that has triggered an exception, they only show the number of exceptions detected.

Enable exceptions

Exceptions are disabled by default. You need to enable them in the Xcept tab of the setup menu:

Image

Exception example

Let's trigger an exception by dereferencing a null pointer:

#include "bn_core.h"

int main()
{
    bn::core::init();
    int skip_frames = 1;
    int* ptr = nullptr;
    skip_frames += *ptr;
    bn::core::set_skip_frames(skip_frames);

    while(true)
    {
        bn::core::update();
    }
}

If we build the project and we run the *.elf file with No$gba, it should stop the execution and display the following warning:

Image

As we can see, it also shows the C++ code that has triggered the exception:

Image