Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
min.c File Reference

Implements the OP_MIN opcode for finding the minimum of two values in the VM. More...

Go to the source code of this file.

Functions

 if (a.type !=VAL_INT||b.type !=VAL_INT)
 push_value (vm, make_int(a.i< b.i ? a.i :b.i))
 free_value (a)
 free_value (b)

Variables

case OP_MIN
Value a = pop_value(vm)
 break

Detailed Description

Implements the OP_MIN opcode for finding the minimum of two values in the VM.

This file handles the OP_MIN instruction, which finds the minimum of two integer values. The values are popped from the stack, and the result is pushed back.

Behavior:

  • Pops two integer values from the stack.
  • Finds the minimum of the two values.
  • Pushes the result onto the stack.

Error Handling:

  • Exits with an error if the operands are not integers.

Example: // Bytecode: OP_MIN // Stack before: [10, 42] // Stack after: [10]

Definition in file min.c.

Function Documentation

◆ free_value() [1/2]

free_value(a)

◆ free_value() [2/2]

free_value(b)

◆ if()

if(a.type ! = VAL_INT || b.type != VAL_INT)

Definition at line 34 of file min.c.

◆ push_value()

push_value(vm,
make_int(a.i< b.i ? a.i :b.i) )

Variable Documentation

◆ a

Value a = pop_value(vm)

Definition at line 33 of file min.c.

◆ break

break

Definition at line 41 of file min.c.

◆ OP_MIN

case OP_MIN

Definition at line 31 of file min.c.