Virtual Machine Programming

The three registers R0, R1 and R2 are the core virtual machine registers.

They are used to facilitate data entry, register addressing and programming, and related general purpose functions such as data display and address arithmetic.

The techniques described here are used to program all the registers required to make use of BitScope's programmable features.

Data Entry

The following data entry commands "assemble" data in R0, the Data Register:

[0x5BClearR0
0..90x30..0x39Increment R0 by the digit specified and nibble swap.
a..f0x61..0x66Increment R0 by the hex digit specified and nibble swap.
]0x5DSwap nibbles in R0.

For example, the script to enter the hex value A6 to R0 is [a6].

Address Register Programming

The following register operation commands move data between R0 and registers pointed to by the Address Registers R1 and R2. Two commands are available to initialize the Address Registers:

@0x40Copy R0 to Address Register R1.
#0x23Copy R0 to Source Address Register R2.

For example, the script to write the hex value B2 to the R1 Address Register is [b2]@ and the script to program the hex value 34 to the R2 Source Address Register is [34]#.

General Register Programming

All other registers are programmed using the following two commands which move data between R0 and any other register addressed by R1 or R2.

s0x73Store. Copy R0 to register (R1).
l0x6CLoad. Copy register (R2) to R0.

For example, the script to program the hex value 0xA0 to the R4 register is [4]@[a0]s. To move a value from register R3 to R9 it is[3]#[9]@ls.

Printing Registers

The value in any register may be "printed" to the serial port to read its value:

p0x70Print register (R1).

For example, the script to print the value in R12 is [c]@p. The register's value is printed to the serial port as four characters <CR><DIGIT><DIGIT><CR>.

Increment and Decrement

Increment and decrement commands are available for the convenience of programming:

n0x6EIncrement Address Register R1.
+0x2BIncrement register (R1).
-0x70Decrement register (R1).

The n command can be quite convenient to write a value to range of registers. For example, to clear registers R3 and R4 use [3]@[sns