IRIS/IRIS++ | Game Development Programming Language

Top Top | Previous Prev | Next Next

Virtual Machine


This section briefly explains how the Virtual Machine interprets the byte code.

Execution Flow

The basic execution steps involved in the compilation flow are:

  1. Virtual Machine (VM) opens a compiled IRIS script
  2. The VM loads the script with code containing sequence of : type_of_code, code, type_of_code, code, ...
  3. For each code, the VM determines its type_of_code and executes accordingly
  4. When all codes are executed (or told to halt by the instruction), the execution ends

The Virtual Machine (ulyvm.exe) does not take any command line arguments. It will automatically execute init.bin located under the bin/data/script directory.

Byte Code Contents

The loaded byte code contains the following:

type_of_code: 0=Instruction, 1=Object, 2=Command, 3=Register, 4=Character, 5=Number

  • Instruction : Represents an IRIS instruction set
  • Object : Represents an external object that is not part of the basic IRIS language
  • Command : Represents a command of the external object
  • Register : Represents a register number
  • Character : Represents a character (a character is encoded in Unicode and contains upper and lower bytes to represent it)
  • Number : Represents a number of size byte (0 -> 255)

The code will be either the following instruction or a value represented in bytes:

NOP = 0x00
CLR = 0x01
ATR = 0x02
HLT = 0x03
PTX = 0x04
ATB = 0x05
JMP = 0x06
JMS = 0x07
RET = 0x08
SUM = 0x09
SBT = 0x0A
MLT = 0x0B
DIV = 0x0C
SKZ = 0x0D
SKL = 0x0E
SKG = 0x0F
SKE = 0x10
SKN = 0x11
RUN = 0x12
IMP = 0x13
REG = 0x14
CLB = 0x15
PTB = 0x16
ENG = 0x17


0x000x00Instruction: NOP
0x030x02Register 0x02: $2
0x040x03Upper byte of character 'A'
0x040x91Lower byte of character 'A'

Code Layout:

The code is arranged in a way so that values are read prior, and instructions called after.

For example:


REG $0
ATR "Hello"
PTX $0

[Byte Code]


Register Contents:

A register hold its value information as follows:

  • Number: As it is. Cannot exceed more than the size of 32 bit integer (-2147483647 ~ 2147483647)
  • Register: As byte, each representing a register number(0 ~ 255)
  • String: As byte position (See below for example)

[Memory Dump]

[0] H
[1] e
[2] l
[3] l
[4] o <-- Register will store the byte position 4 (end of string "Hello")
[5] PTX

In case of handling a character string, once the program counter reaches memory position [5], the VM traces backwards the characters until the top of code is reached, or another instruction is found. Then, displays the string.

Virtual Machine On PHP

This is one example of how you could implement the Virtual Machine in PHP. Note that MBCS is not supported and extended features are not implemented.

Download UlyVM PHP