Writing and Using LoongArch exception handlers in LARS

Introduction

Exception handlers, also known as trap handlers or interrupt handlers, can easily be incorporated into a LoongArch program. This guide is not intended to be comprehensive but provides the essential information for writing and using exception handlers.

Although the same mechanism services all three, exceptions, traps and interrupts are all distinct from each other. Exceptions are caused by exceptional conditions that occur at runtime such as invalid memory address references. Traps are caused by instructions constructed especially for this purpose, listed below. Interrupts are caused by external devices.

LARS partially but not completely implements the exception and interrupt mechanism of LoongArch.

Essential Facts

Some essential facts about writing and using exception handlers include: