Nios® V Processor Software Developer Handbook

ID 743810
Date 4/01/2024
Public
Document Table of Contents

8.7.2. Registering an Instruction-Related Exception Handler

The HAL API function alt_instruction_exception_register() registers a single instruction-related exception handler. When you register an instruction-related exception handler, it replaces the default EBREAK.

The function prototype is as follows:
alt_instruction_exception_register
(
  alt_exception_result( * handler)
  (alt_exception_cause cause, alt_u32 exception_­ pc,
    alt_u32 bad_addr)
);

The handler argument is a pointer to the instruction-related exception handler.

To use alt_instruction_exception_register(), include the following header file:
#include "sys/alt_exceptions.h"
Note: The hal.enable_instruction_related_exceptions_api setting must be enabled in the BSP in order for you to register an instruction-related exception handler.
For more information, refer to Settings Managed by the Nios V Processor Board Support Package Editor section.
Note: Register the instruction-related exception handler as early as possible in function main(). This allows you to handle abnormal condition during startup. You can register an exception handler from the alt_main() function.
For more information about alt_main(), refer to Boot Sequence and Entry Point section.