Top | Prev | Next
This section briefly explains how the Virtual Machine interprets the byte code.
The basic execution steps involved in the compilation flow are:
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.
The loaded byte code contains the following:
type_of_code: 0=Instruction, 1=Object, 2=Command, 3=Register, 4=Character, 5=Number
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
Example:
Code Layout:
The code is arranged in a way so that values are read prior, and instructions called after.
For example:
[Script] REG $0 ATR "Hello" PTX $0 [Byte Code] $0 REG H e l l o ATR $0 PTX
Register Contents:
A register hold its value information as follows:
[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.
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