Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

VirtualMachine

Guides

  • Virtual Machine Package

Symbols

  • VirtualMachineAdd
  • VirtualMachineDefinition
  • VirtualMachineExecute
  • VirtualMachineList
  • VirtualMachine
  • VirtualMachineObject
  • VirtualMachineObjectQ
  • $VirtualMachines

Other

  • Intel4004
  • MOS6502
  • NFA
  • PDP1
  • PDP8
  • RegisterMachine
"RegisterMachine"
​
"RegisterMachine" a register machine
​
▪
Creating a virtual machine instance:
VirtualMachine
["RegisterMachine",assoc]
create a new instance of a register machine configured according to
assoc
▪
The following keys can be used to specify a
"RegisterMachine"
given as an association:
"Model"
Automatic
register machine model to be used
"Program"
{
instr
1
,
instr
2
,…}
register machine program
"ProgramCounter"
1
program counter
"Registers"
Automatic
registers configuration
▪
"Program"
is the only required key in
VirtualMachine
["RegisterMachine",assoc]
.
▪
The value for
"Program"
is a list of instructions of the following form:
"CLR"[r]
clear register
r
"CPY"[
r
i
,
r
j
]
copy register
r
i
into register
r
j
"DEC"[r]
decrement register
r
"DECJ"[r,z]
decrement register
r
, then jump to instruction
z
"INC"[r]
increment register
r
"INCJ"[r,z]
increment register
r
, then jump to instruction
z
"J"[z]
jump to instruction
z
"JE"[
r
i
,
r
j
,z]
jump to instruction
z
if the contents of register
r
i
equals the contents of register
r
j
"JNZ"[r,z]
jump to instruction
z
if register
r
does not contain zero
"JZ"[r,z]
jump to instruction
z
if register
r
contains zero
"JZDEC"[r,
z
true
,
z
false
]
jump to
z
true
if register
r
​
contains zero, else decrement register
r
by 1 and jump to
z
false
▪
The value for
"Registers"
can have one of the following forms:
n
integer representing the number of available registers
{
n
1
,
n
2
,…}
list of integers representing the contents of each register
▪
If
"Registers"
Automatic
, the number of available registers is computed from
"Program"
and is taken to be the minimum number of registers necessary to execute the program.
▪
The following table shows the possible values for
"Model"
, whether its instruction-execution is sequential, and a list of allowed register machine instructions:
"AbacusMachine"
False
{"INCJ","JZDEC"}
"ElgotRobinson"
True
{"INC","CPY","JE"}
"MinskyMachine"
False
{"INCJ","JZDEC"}
"NKS"
True
{"INC","DECJ"}
"ProgramMachine"
True
{"INC","DEC","JZ"}
"Set1"
True
{"INC","DEC","JZ"}
"Set2"
True
{"CLR","INC","JE"}
"Set3"
True
{"INC","CPY","JE"}
"ShepherdsonSturgisMachine"
True
{"INC","DEC","CLR","CPY","JNZ","J"}
"SuccesorMachine"
True
{"CLR","INC","JE"}
▪
A model is non-sequential if the program counter is not incremented by default after executing each instruction.
▪
When specifying
"Model"
Automatic
, the instruction-execution is sequential and all of the register machine instructions are allowed.
▪
For the
"RegisterMachine"
virtual machine, the following properties can be queried:
obj["Definition"]
an
Association
representing the definition of the machine
obj["Evolution"]
a list representing the evolution of the machine
obj["EvolutionDataset"]
a
Dataset
representing the evolution of the machine
obj["MachineState"]
an
Association
representing the current state of the machine
obj["Model"]
a
Dataset
representing the type of the register machine
obj["Program"]
the list of instructions to be executed
obj["ProgramMnemonic"]
a formatted view of
obj["Program"]
obj["RegisterCount"]
the number of registers available
obj["RegisterEvolution"]
a list representing the evolution of the register's contents
obj["RegisterEvolutionPlot"]
a plot of
obj["RegisterEvolution"]
obj["StepCount"]
the number of steps run
▪
For the
"RegisterMachine"
virtual machine, the following commands can be executed using
VirtualMachineExecute
:
VirtualMachineExecute
[obj,"Reset"]
reset the state of the machine to its initial configuration
VirtualMachineExecute
[obj,"Run",n]
run
n
steps of the machine
Examples
MoreExamples⊳
Create an instance of a
"RegisterMachine"
defined by a simple program:
In[1]:=
rm=
VirtualMachine
["RegisterMachine","Program"{"INC"[1],"DECJ"[1,1]}]
Out[1]=
VirtualMachineObject
Machine: RegisterMachine
StepCount: 0
Status: Waiting

Obtain information about the object:
In[2]:=
Information[rm]
Out[2]=
VirtualMachineObject
Machine Name
RegisterMachine
Properties
{Definition,Evolution,EvolutionDataset,Machine,MachineState,Model,Program,ProgramMnemonic,RegisterCount,RegisterEvolution,RegisterEvolutionPlot,StepCount}
Commands
{Reset,Run}
Functions
{Information,Normal}
Get an association representing the machine state:
In[3]:=
rm["MachineState"]
Out[3]=
Registers{0},ProgramCounter1,StatusWaiting,TerminationReasonStepsConstrained
Run 10 steps of the register machine:
In[4]:=
VirtualMachineExecute
[rm,"Run",10]
Out[4]=
VirtualMachineObject
Machine: RegisterMachine
StepCount: 10
Status: Waiting
(StepsConstrained)

Extract the evolution history of the executed steps:
In[5]:=
rm["EvolutionDataset"]
Out[5]=
Step
Instruction
ProgramCounter
Registers
0
None
1
{0}
1
INC[1]
2
{1}
2
DECJ[1, 1]
1
{0}
3
INC[1]
2
{1}
4
DECJ[1, 1]
1
{0}
5
INC[1]
2
{1}
6
DECJ[1, 1]
1
{0}
7
INC[1]
2
{1}
8
DECJ[1, 1]
1
{0}
9
INC[1]
2
{1}
10
DECJ[1, 1]
1
{0}
""

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com