Basic Arithmetic
See
src/vm_core/utility/arithmetic.ts
Since the JavaScript only have number
type, which is an abstraction of float
/int
. We use functions in arithmetic.ts
to perform basic arithmetic operations like +
, -
, *
or /
.
export function c_add(x: DataView, y: DataView): DataView; // x + y
export function c_sub(x: DataView, y: DataView): DataView; // x - y
export function c_mul(x: DataView, y: DataView, Issue_Handler: MessageEmitter): DataView; // x * y
export function c_div(x: DataView, y: DataView): DataView; // x / y
export function c_rem(x: DataView, y: DataView): DataView; // x % y
export function c_lsh(x: DataView, y: DataView): DataView; // x << y
export function c_rsh(x: DataView, y: DataView): DataView; // x >> y
export function c_and(x: DataView, y: DataView): DataView; // x & y
export function c_or(x: DataView, y: DataView): DataView; // x | y
export function c_xor(x: DataView, y: DataView): DataView; // x ^ y
These functions will try its best to mimic the overflow behavior of C program.
Last updated