Inside DVD-Video/Interaction Machine

DVD-Video specifies a low-level machine-language instruction set that is used to define interactions with the user. Instruction sequences are invoked when the user selects an on-screen button, and may also be triggered at various other points, such as the end of a cell or a PGC, or when the disc is inserted into the player.

The instruction set is commonly referred to as the “VM” (Virtual Machine) language, but the implication of calling it “virtual” is that there cannot be real hardware that directly implements this instruction set. But why not? That’s why I am here using the term “interaction machine”, which makes it clearer what the purpose of the instruction set is.

(Note that I’m avoiding using the term “program” for sequences of instructions in this instruction set, because that already has a completely different meaning in DVD-Video.)

Data Model
The only available data storage consists of 16 general-purpose parameter registers (GPRMs) and 24 system parameter registers (SPRMs). Each holds a single 16-bit unsigned integer value. As their name indicates, GPRMs may be freely used for any purpose, while the SPRMs have predefined meanings.

Any GPRM may also be put into counter mode, where its value increments once per second.

Instruction Format
Each instruction is 8 bytes, and can encode up to 3 separate operations, up to one from each of the following categories:


 * Setting a register
 * Transferring control
 * Performing a comparison, the result of which is used to control conditional execution of the rest of the instruction.

The top three bits of the first byte define the instruction group, as follows:


 * Group 0: miscellaneous (including transfer of control within an instruction sequence). These can also be made conditional according to format 1 (below).
 * Group 1: Link/Jump/Call: transfer of control between parts of the video stream. The Link instructions can be made conditional according to format 1, while Jump and Call use conditional format 2.
 * Group 2: set SPRM. This also includes the instructions for setting GPRMs in counter mode. These can be made conditional according to format 2, or combined with a Link, but not both at once.
 * Group 3: set GPRM. These can be made conditional according to format 3, or combined with a Link, but not both at once.

Groups 4, 5 and 6 perform a set GPRM, comparison and a link, all in one instruction, but with the three operations interacting as follows:


 * Group 4: perform the set, perform the comparison, and conditionally link.
 * Group 5: perform the comparison, and conditionally set and link.
 * Group 6: perform the comparison, and conditionally perform the set. Always link.

Group 7 does not seem to be used.

Register numbering: fields for reading the value of a register are 8 bits wide, and can access both GPRMs and SPRMs. Bit 7 is 0 to indicate a GPRM access, 1 for an SPRM access. The actual register number is in the rest of the bits.

Literal operands: some instruction forms allow for a 16-bit literal operand value within the instruction. This is always stored in big-endian order, i.e. most significant byte first.

Interaction instructions can be found in the following places:


 * a cell can end with a single instruction to be executed when the cell has finished playing.
 * a button specifies a single instruction to be executed when the button is selected.
 * the pre- and post-sections of a PGC can each contain a sequence of instructions, to be executed before the PGC starts playing and after it finishes, respectively.
 * the FPC contains a sequence of instructions which automatically start executing when the disc is inserted into the player.

The single-instruction limitation on buttons is not a big issue in practice; it’s easy enough for the single instruction to be “set GPRM i to j and link to post-section of PGC”, to execute a longer sequence of instructions in the PGC post-section that does different things for different buttons, based on the value of GPRM i.

System Parameter Registers
In the following table, “writable” indicates whether there is an instruction for explicitly writing into that register. Non-writable registers may be implicitly altered via control-transfer instructions or automatically as playback progresses (these can change the current title/PGC/chapter), or explicitly by the user via some device-provided interface (e.g. preferred video and language settings), or may be readonly (e.g. player audio capabilities, region mask).

ISO-639 language codes and ISO-3166 country codes are represented as integers with the first character in the high byte and the second character in the low byte.

(SPRM listing comes from here)

Link Versus Jump Versus Call
The instructions for diverting the flow of playback are divided into Link, Jump and Call categories. Link instructions allow for transfers within a PGC/title/domain, or to a fixed set of related PGCs (“next”, “previous” and “up”), while Jump and Call allow for more wide-ranging transfers across domains, menus, titles and chapters. Titles and chapters may be entered via Jump instructions, while menus (and the FPC) may be entered via Jump or Call instructions. The Jump-to-menu and Call-to-menu sets support the same set of possible transfers, except that Jump-to-menu instructions are only allowed within menus, while the Call-to-menu equivalents are only allowed within titles.

Call instructions perform the same action as their Jump equivalents, except they also save a playback point for later resumption. (This can be the current playback point, or another point explicitly specified in the instruction.) Only a single resume point can be saved: the “resume stack” (if you can call it that) is only a single element deep.

Thus, the resume point from a Call is always within a title, never a menu. The model is that invoking a menu involves temporarily suspending the playback of a title, which can be resumed when the menu is dismissed (unless a menu option starts playback somewhere else).

Allowable transfers using Jump or Call:

Note that, from a VTS (menu or title), it is not permitted to jump directly into another VTS. You have to set up indirect jumps via the VMG.

The RSM command in the Link Subset (see below) resumes playback from the last-saved resume point. The Return button on the remote does the same thing.

Conditional Formats
Every instruction can be made conditional, where a comparison is made between two operands, and execution of the rest of the instruction depends on whether the comparison evaluates to true or not.

The layout of the conditional fields can vary between instruction groups. In the following instruction formats, the dots represent bits encoded as per the unconditional form of the instruction. The 3-bit cmp field indicates the comparison operator to be applied on the two operands:

These particular formats are usable with instructions in groups 0, 1, 2, 3. Instructions in groups 4, 5 and 6 use the same cmp codes, but have their own arrangements for the comparison operands. Though note that the cmp field (and immediate flag for comparison operand 2) is in the same place for all instructions.

Format 1
This form allows for comparison between two registers, or between a register and a 16-bit literal value.

Format 2
This form allows only for comparison between two registers.

Format 3
This form allows for comparison between two registers, or between a register and a 16-bit literal value.

Set-Operations
Instructions that assign a new value to a GPRM have an op field and a source-operand field (specifying either a register or a literal value). The new value for the destination is computed as a function of its existing value, the source operand, and the op. Furthermore, the swap operation alters the source as well (the others do not). Valid values of op (and corresponding restrictions on the source operand) are as follows:

Instruction Set Details
See the next page.