jserv / full-stack-hello

minimal instruction set and assembler/compiler for "Hello World" execution
Other
114 stars 49 forks source link

Exception handling mechanism discussion #40

Open pakls opened 7 years ago

pakls commented 7 years ago

At the moment, DIV and MOD considers divide-by-zero (I'll call it as DBZ from now on) as unimplemented.

We are in need of an exception handling mechanism when DBZ happens.

I can think of a few ways now:

  1. Add a (typical) exception handling callback (like ISR) like general CPUs do.
  2. Add a global flag that can be set when DBZ happens and code can explicitly check the flag after a DIV or MOD operation is performed.

The considerations that I can think of by now. They are tradeoffs during most of the time.

A. Speed B. VM Complexity C. Support of higher level semantics, such as C++ Exception