1
votes

I just wanted to know the basic difference among them.

I found at some places that TRAP is essentially also called as a software interrupt,or something like an exception.

Also what is the basic difference between a software interrupt and an exception.

Software interrupt can be generated by the INT instruction,but TRAP can only be generated by certain scenarios like divide by zero? Is that right?

Kindly give a suitable answer to this query,which covers,s/w interrupts trap and exception .

1
We are not the place for queries, or a discussion site. - too honest for this site
truck or lorry, braces or suspenders, holiday or vacation. And we can add others of course. One group of humans at one company uses one or one set of terms. trap, exception, interrupt, etc. Datasheet, databook, reference manual, users manual, programmers reference manual, technical reference manual, etc. Dont get too hung up on a particular word, just translate in your head, someone asks you where the loo is you point them to the toilet. - old_timer
while reading a particular datasheet or some named manual, using the context around the words you can figure out that chip vendor or manual author is using one particular term and hopefully sticks to it throughout. you will see arm for example use both exception and interrupt, some of the exceptions are from peripheral (external to the core) interrupts, and some are internal like undefined instruction, so in that case they are all exceptions handled by the exception table addresses (cortex-m) but some are from hardware interrupts. - old_timer

1 Answers

5
votes

The terminology is indeed a bit blurry and may depend on the CPU vendor.

What is clear is that a hardware interrupt is triggered by a hardware signal and makes the CPU enter a predefined ISR. These are exceptions triggered by (typically external) hardware.

The notation of a trap varies a bit between CPU vendors. Traps on non-Intel CPUs can (e.g. on a 68000 or PowerPC CPU) be software interrupts. Those CPUs have a TRAP instruction. On an x86, this instruction would be INT xxx, on an ARM CPU SWI/SVC, on a PowerPC TRAP #xx. This would be an exception deliberately triggered by a user program (typically used to enter the operating system)

Traps in the Intel world are exceptional conditions, like division by zero or other errors like invalid memory access (but might also be triggered by a set single step flag). Other CPU vendors simply call that an exception. Those are exceptions typically triggered by erroneous programs or conditions the CPU is not able to handle during normal program flow.

And all of them are normally called exceptions.