rangecheck op1, op2, op3 ; raise an exception if op1 is not between op2 and op3.
rangecheck op1, op2 ; raise an exception if op1 is not between zero and op2.Ideally, op2, op3 could be immediate values, or whatever the CPU normally uses for operands (registers on RISC, anything on CISC?)Yes, the X86 has such an instruction, available for a long time. Which creates an exception, if the bounds are exceeded.
https://www.felixcloutier.com/x86/bound (https://www.felixcloutier.com/x86/bound)
Here it is, for the 386 cpu (Intel):
https://pdos.csail.mit.edu/6.828/2018/readings/i386/BOUND.htm (https://pdos.csail.mit.edu/6.828/2018/readings/i386/BOUND.htm)
Has there ever been an Instruction set Architecture that includes an explicit "range check" instruction?