Registers
Internal registers are containers of data. Data values of registers can be modified by a series of register-related instructions.
0x10
Write Value of a Registerโ
Modify value in a register.
tip
Values of all registers are available on page 4 to page 7 on secondary display.
INST_WRITE_REG | HEX | sOP01 | OP-1 | |
---|---|---|---|---|
Write 03E8 to R1C | 10 | 00 | 1C | 03E8 |
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Target register |
OP-1 | 0000 ~FFFF | Value |
0x11
Register Copyโ
Copy value of one register to another.
tip
Check the result on the secondary display on the corresponding page.
INST_REG_COPY | HEX | sOP01 | sOP11 | ||
---|---|---|---|---|---|
Copy value from R1C to R1D | 11 | 00 | 1D | 00 | 1C |
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Target register Index |
sOP10 | 00 | Ignored |
sOP11 | 00 ~3F | Source register Index |
0x12
Increment/Decrementโ
Increment or decrement register value.
tip
Rules for overflow can be applied in this instruction.
caution
If overflow is not allowed, the maximum value of a register is 0xFFFF
when keep on increasing, and the minimum value is 0x0000
when keep on decreasing.
INST_REG_INC_DEC | HEX | sOP00 | sOP01 | OP-1 |
---|---|---|---|---|
Increase R1C by 03E8 ๏ผoverflow not permitted | 12 | 00 | 1C | 03E8 |
Increase R1C by 0FFF ๏ผoverflow permitted | 12 | 01 | 1C | 0FFF |
Suppose the value in R1C
is FF00
, in the first example, the increment is 03E8
:
The result should be 1 02E8
, which needs 17 bits. As overflow is not allowed as configured in the opcode, only the least 16 bits will be kept in the register R1C
, leaving 0x02E8
as the result.
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Increasing, overflow NOT allowed |
01 | Increasing, overflow allowed | |
10 | Decreasing, overflow NOT allowed | |
11 | Decreasing, overflow allowed | |
sOP01 | 00 ~3F | Target register index |
OP-1 | 00 ~FF | Value to increase or decrease |
0x13
Register Value to Digital Outputโ
Use the least 4 bits are digital output.
INST_REG_TO_PORT | HEX | sOP01 | ||
---|---|---|---|---|
Use the least 4 bits of R04 as digital output value | 13 | 00 | 04 | 0000 |
Suppose the current value in R04
is 3579
:
In binary:
The last 4 bits are:
The hexadecimal value 9, or b1001 in binary, will be sent to the digital output.
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Source register index |
OP-1 | 0000 | Ignored |
0x14
Digital Input Value to Registerโ
Capture the input values on the 4 digital input pins and save it to a register.
tip
The digital input input value ranges in 0000
~000F
.
The maximum value is 0xF
when all bits are 1
.
INST_PORT_TO_REG | HEX | sOP01 | ||
---|---|---|---|---|
Save the digital input value in R04 | 14 | 00 | 04 | 0000 |
Suppose the four pins are HIGH
, LOW
, HIGH
and LOW
, i.e. 1010
, then:
In hexadecimal it is 000C
, which is saved in R04
.
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Target register index |
OP-1 | 0000 | Ignored |
0x15
Logic Operation: Bit Shiftโ
Shift the bits to left or to right in a register for specified bit positions, in circular mode or not.
INST_BITSHIFT | HEX | sOP00 | sOP01 | sOP11 | |
---|---|---|---|---|---|
Shift R07 2 bits to the right | 15 | 00 | 07 | 00 | 02 |
Shift R07 2 bits to the left, in circular mode | 15 | 11 | 07 | 00 | 02 |
Suppose the current value in R07
is 8009
, in binary, it is:
If circular mode is not allowed, shifting 2 bits to the right:
The least 2 bits are shifted out, therefore it become 2002
; in circular mode, it is:
The least 2 bits 01
are shifted out and shifted in from the left, therefore it become 6002
.
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Shift to the right |
01 | Shift to the right in circular mode | |
10 | Shift to the left | |
11 | Shift to the left in circular mode | |
sOP01 | 00 ~3F | Register index |
sOP10 | 00 | Ignored |
sOP11 | 00 ~FF | Number of bits to shift |
0x16
Logic Operation: Bits Inversionโ
Inverse the bits in a register.
INST_BIT_REVERSE | HEX | sOP01 | ||
---|---|---|---|---|
Reverse bits in R07 | 16 | 00 | 07 | 0000 |
Suppose the current value in R07
is 8009
, in binary, it is:
All bits reversed:
Therefore the new value in the register is 7FF6
.
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Register index |
OP-1 | 0000 | Ignored |
0x17
Logic Operation: Bitwise ANDโ
Bitwise AND of two registers.
INST_REG_AND | HEX | sOP01 | sOP11 | ||
---|---|---|---|---|---|
Bit AND of R07 and R09 ๏ผand store the result in R09 | 17 | 00 | 07 | 00 | 09 |
Suppose the value in R07
is 8009
, and value in R09
is FF00
, in binary:
The AND result is:
8000
is stored in R07
.
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Register index |
sOP10 | 00 | Ignored |
sOP11 | 00 ~3F | Register index |
0x18
Logic Operation: Bitwise ORโ
Bitwise OR of two registers.
INST_REG_OR | HEX | sOP01 | sOP11 | ||
---|---|---|---|---|---|
Bit OR of R07 and R09 ๏ผand store the result in R09 | 18 | 00 | 07 | 00 | 09 |
Suppose the value in R07
is 8009
, and value in R09
is FF00
, in binary:
The OR result is:
FF09
is stored in R07
.
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Register index |
sOP10 | 00 | Ignored |
sOP11 | 00 ~3F | Register index |
0x1A
Arithemic Calculation: Summationโ
Summation of two registers.
INST_REG_SUM | HEX | sOP01 | sOP11 | ||
---|---|---|---|---|---|
Calculate the summation of values in R08 and R06 ๏ผand save the result in R08 | 1A | 00 | 08 | 00 | 06 |
Suppose R08
is 1234
, R06
is 0020
. The summation result 1254
is stored in R08
.
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Register index (result) |
sOP10 | 00 | Ignored |
sOP11 | 00 ~3F | Register index |
0x1B
Arithmetic Calclation: Subtractionโ
Subtraction of two registers.
INST_REG_SUB | HEX | sOP01 | sOP11 | ||
---|---|---|---|---|---|
Calculate the subtraction of R08 and R06 ๏ผand save the result in R08 | 1B | 00 | 08 | 00 | 06 |
Suppose R08
is 1234
, R06
is 0020
. The subtraction result 1214
is stored in R08
.
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Register index (result) |
sOP10 | 00 | Ignored |
sOP11 | 00 ~3F | Register index |
0x1C
Arithmetic Calclation: Productionโ
Product of two registers.
INST_REG_PROD | HEX | sOP01 | sOP11 | ||
---|---|---|---|---|---|
Calculate the product of R08 and R06 ๏ผand save the result in R08 | 1C | 00 | 08 | 00 | 06 |
Suppose R08
is 1234
, R06
is 0020
.
The multiplication result should be 24680
, but only the least 16 bits are kept. The product 4680
is stored in R08
.
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Register index (result) |
sOP10 | 00 | Ignored |
sOP11 | 00 ~3F | Register index |
0x1D
Arithmetic Calclation: Division (Mod)โ
Division of two registers.
INST_REG_DIVISION | HEX | sOP01 | sOP11 | ||
---|---|---|---|---|---|
Calculate the division of R08 and R06 ๏ผand save the result in R08 | 1D | 00 | 08 | 00 | 06 |
Suppose R08
is 1234
, R06
is 0020
:
The result of division is 0091
, stored in R08
after the operation.
caution
Notice the division is between integers, the result is an integer qoute, instruction 1E
should be excuted if remainder is needed.
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Register index (result) |
sOP10 | 00 | Ignored |
sOP11 | 00 ~3F | Register index |
0x1E
Arithmetic Calclation: Remainderโ
Calculate the division remainder of vaules in two registers.
INST_REG_REMAINDER | HEX | sOP01 | sOP11 | ||
---|---|---|---|---|---|
Calculate the remainder of division of R08 and R06 ๏ผand save the result in R08 | 1D | 00 | 08 | 00 | 06 |
Suppose R08
is 1234
, R06
is 0020
:
The former divided by the later results in a remainder 0014
, stored in R08
.
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | register index (result) |
sOP10 | 00 | Ignored |
sOP11 | 00 ~3F | Register index |
0x1F
Generate a Random Numberโ
Generate a random 16-bit number in a target register.
INST_REG_REMAINDE | HEX | sOP01 | ||
---|---|---|---|---|
Generate a random number in R05 | 1F | 00 | 05 | 0000 |
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Target register index |
OP-1 | 0000 | Ignored |
0x20
Byte Recompositionโ
Recompose the high and low bytes of two registers.
INST_BYTE_COMPOSE | HEX | sOP01 | sOP11 | ||
---|---|---|---|---|---|
Recompose the high byte of R05 and low byte of R06 , and store the result in R05 | 20 | 00 | 05 | 00 | 06 |
Suppose the value in R05
is 2450
, the high byte is 24
;
Suppose the value in R06
is FF00
, the low byte is 00
;
The result of recomposing in R05
is 2400
.
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Register index (result) |
sOP10 | 00 | Ignored |
sOP11 | 00 ~3F | Register index |
0x21
Byte Swapโ
Swap the high and low bytes of a register.
INST_BYTE_SWAP | HEX | sOP01 | ||
---|---|---|---|---|
Swap the high and low bytes of R05 | 21 | 00 | 05 | 0000 |
info
OP/sOP | Value/Range | Remarks |
---|---|---|
sOP00 | 00 | Ignored |
sOP01 | 00 ~3F | Target register index |
OP-1 | 0000 | Ignored |