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.
The following data entry commands "assemble" data in R0, the Data Register:
[ 0x5B ClearR0 0..9 0x30..0x39 Increment R0 by the digit specified and nibble swap. a..f 0x61..0x66 Increment R0 by the hex digit specified and nibble swap. ] 0x5D Swap nibbles in R0.
For example, the script to enter the hex value A6 to R0 is [a6].
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:
@ 0x40 Copy R0 to Address Register R1. # 0x23 Copy 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]#.
All other registers are programmed using the following two commands which move data between R0 and any other register addressed by R1 or R2.
s 0x73 Store. Copy R0 to register (R1). l 0x6C Load. 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.
The value in any register may be "printed" to the serial port to read its value:
p 0x70 Print 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 commands are available for the convenience of programming:
n 0x6E Increment Address Register R1. + 0x2B Increment register (R1). - 0x70 Decrement 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