![]() | Fun 0.41.5 The programming language that makes You have fun |
Implements the OP_SCLAMP opcode for signed N-bit two's-complement wrapping. More...
Go to the source code of this file.
Functions | |
| if (bits<=0) | |
| if (bits >=64) | |
| if (wrapped &sign_bit) | |
| push_value (vm, make_int(out)) | |
| free_value (v) | |
Variables | |
| case | OP_SCLAMP |
| int | bits = inst.operand |
| int64_t | vi = (v.type == VAL_INT) ? v.i : 0 |
| int64_t | out = 0 |
| else | |
| uint64_t | wrapped = ((uint64_t)vi) & mask |
| break | |
Implements the OP_SCLAMP opcode for signed N-bit two's-complement wrapping.
This VM opcode wraps an integer into the signed N-bit range using two's complement semantics. It first masks to N bits and then sign-extends if the sign bit is set, yielding a value in the range [-2^(N-1) .. 2^(N-1)-1]. N is provided by the instruction operand.
Stack contract:
Definition in file sclamp.c.
| free_value | ( | v | ) |
| else |