Cwerg icon indicating copy to clipboard operation
Cwerg copied to clipboard

finalize the semantics of those opcodes with potentially undefined behavior

Open robertmuth opened this issue 3 years ago • 1 comments

  • mod with signed ints
  • div/mod with zero divisors
  • shifts with shift amounts exceeding the bitwidth of the operand
  • conversions that widen and change from signed to unsigned

see comments interleaved with opcode description.

robertmuth avatar Aug 08 '21 21:08 robertmuth

suggestion from a reddit user

Don't forget to maintain the identity:

div a 0 -> 0
mod a 0 -> a
(it helps to think of "0" as "2bitwidth, but wrapped around")

robertmuth avatar Sep 14 '21 02:09 robertmuth