Skip to main content

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_REGHEXsOP00sOP01OP-1
Write 03E8 to R1C10001C03E8
info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FTarget register
OP-10000~FFFFValue

0x11 Register Copyโ€‹

Copy value of one register to another.

tip

Check the result on the secondary display on the corresponding page.

INST_REG_COPYHEXsOP00sOP01sOP10sOP11
Copy value from R1C to R1D11001D001C
info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FTarget register Index
sOP1000Ignored
sOP1100~3FSource 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_DECHEXsOP00sOP01OP-1
Increase R1C by 03E8๏ผŒoverflow not permitted 12001C03E8
Increase R1C by 0FFF๏ผŒoverflow permitted 12011C0FFF

Suppose the value in R1C is FF00, in the first example, the increment is 03E8:

(FF00)16+(03E8)16=(1โ€…โ€Š02E8)16(FF00)_{16}+(03E8)_{16}=(1\;02E8)_{16}

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/sOPValue/RangeRemarks
sOP0000Increasing, overflow NOT allowed
01Increasing, overflow allowed
10Decreasing, overflow NOT allowed
11Decreasing, overflow allowed
sOP0100~3FTarget register index
OP-100~FFValue to increase or decrease

0x13 Register Value to Digital Outputโ€‹

Use the least 4 bits are digital output.

INST_REG_TO_PORTHEXsOP00sOP01OP-1
Use the least 4 bits of R04 as digital output value1300040000

Suppose the current value in R04 is 3579:

(3579)16=(13689)10(3579)_{16}=(13689)_{10}

In binary:

(11โ€…โ€Š0101โ€…โ€Š0111โ€…โ€Š1001)2(11\;0101\;0111\;1001)_{2}

The last 4 bits are:

(9)16=(9)10=(1001)2(9)_{16}=(9)_{10}=(1001)_{2}

The hexadecimal value 9, or b1001 in binary, will be sent to the digital output.

info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FSource register index
OP-10000Ignored

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.

(000F)16=(1111)2(000F)_{16}=(1111)_{2}

The maximum value is 0xF when all bits are 1.

INST_PORT_TO_REGHEXsOP00sOP01OP-1
Save the digital input value in R041400040000

Suppose the four pins are HIGH, LOW, HIGH and LOW, i.e. 1010, then:

(1010)2=(000C)16(1010)_{2}=(000C)_{16}

In hexadecimal it is 000C, which is saved in R04.

info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FTarget register index
OP-10000Ignored

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_BITSHIFTHEXsOP00sOP01sOP10sOP11
Shift R07 2 bits to the right1500070002
Shift R07 2 bits to the left, in circular mode1511070002

Suppose the current value in R07 is 8009, in binary, it is:

(8009)16=(1000โ€…โ€Š0000โ€…โ€Š0000โ€…โ€Š1001)2(8009)_{16}=(1000\;0000\;0000\;1001)_{2}

If circular mode is not allowed, shifting 2 bits to the right:

(0010โ€…โ€Š0000โ€…โ€Š0000โ€…โ€Š0010)2=(2002)16(0010\;0000\;0000\;0010)_{2}=(2002)_{16}

The least 2 bits are shifted out, therefore it become 2002; in circular mode, it is:

(0110โ€…โ€Š0000โ€…โ€Š0000โ€…โ€Š0010)2=(6002)16(0110\;0000\;0000\;0010)_{2}=(6002)_{16}

The least 2 bits 01 are shifted out and shifted in from the left, therefore it become 6002.

info
OP/sOPValue/RangeRemarks
sOP0000Shift to the right
01Shift to the right in circular mode
10Shift to the left
11Shift to the left in circular mode
sOP0100~3FRegister index
sOP1000Ignored
sOP1100~FFNumber of bits to shift

0x16 Logic Operation: Bits Inversionโ€‹

Inverse the bits in a register.

INST_BIT_REVERSEHEXsOP00sOP01OP-1
Reverse bits in R071600070000

Suppose the current value in R07 is 8009, in binary, it is:

(8009)16=(1000โ€…โ€Š0000โ€…โ€Š0000โ€…โ€Š1001)2(8009)_{16}=(1000\;0000\;0000\;1001)_{2}

All bits reversed:

(0111โ€…โ€Š1111โ€…โ€Š1111โ€…โ€Š0110)2=(7FF6)16(0111\;1111\;1111\;0110)_{2}=(7FF6)_{16}

Therefore the new value in the register is 7FF6.

info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FRegister index
OP-10000Ignored

0x17 Logic Operation: Bitwise ANDโ€‹

Bitwise AND of two registers.

INST_REG_ANDHEXsOP00sOP01sOP10sOP11
Bit AND of R07 and R09๏ผŒand store the result in R091700070009

Suppose the value in R07 is 8009, and value in R09 is FF00, in binary:

(8009)16=(1000โ€…โ€Š0000โ€…โ€Š0000โ€…โ€Š1001)2(FF00)16=(1111โ€…โ€Š1111โ€…โ€Š0000โ€…โ€Š0000)2(8009)_{16}=(1000\;0000\;0000\;1001)_{2}\\ (FF00)_{16}=(1111\;1111\;0000\;0000)_{2}

The AND result is:

(1000โ€…โ€Š0000โ€…โ€Š0000โ€…โ€Š0000)2=(8000)16(1000\;0000\;0000\;0000)_{2}=(8000)_{16}

8000 is stored in R07.

info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FRegister index
sOP1000Ignored
sOP1100~3FRegister index

0x18 Logic Operation: Bitwise ORโ€‹

Bitwise OR of two registers.

INST_REG_ORHEXsOP00sOP01sOP10sOP11
Bit OR of R07 and R09๏ผŒand store the result in R091800070009

Suppose the value in R07 is 8009, and value in R09 is FF00, in binary:

(8009)16=(1000โ€…โ€Š0000โ€…โ€Š0000โ€…โ€Š1001)2(FF00)16=(1111โ€…โ€Š1111โ€…โ€Š0000โ€…โ€Š0000)2(8009)_{16}=(1000\;0000\;0000\;1001)_{2}\\ (FF00)_{16}=(1111\;1111\;0000\;0000)_{2}

The OR result is:

(1111โ€…โ€Š1111โ€…โ€Š0000โ€…โ€Š1001)2=(FF09)16(1111\;1111\;0000\;1001)_{2}=(FF09)_{16}

FF09 is stored in R07.

info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FRegister index
sOP1000Ignored
sOP1100~3FRegister index

0x1A Arithemic Calculation: Summationโ€‹

Summation of two registers.

INST_REG_SUMHEXsOP00sOP01sOP10sOP11
Calculate the summation of values in R08 and R06๏ผŒand save the result in R081A00080006

Suppose R08 is 1234, R06 is 0020. The summation result 1254 is stored in R08.

info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FRegister index (result)
sOP1000Ignored
sOP1100~3FRegister index

0x1B Arithmetic Calclation: Subtractionโ€‹

Subtraction of two registers.

INST_REG_SUBHEXsOP00sOP01sOP10sOP11
Calculate the subtraction of R08 and R06๏ผŒand save the result in R081B00080006

Suppose R08 is 1234, R06 is 0020. The subtraction result 1214 is stored in R08.

info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FRegister index (result)
sOP1000Ignored
sOP1100~3FRegister index

0x1C Arithmetic Calclation: Productionโ€‹

Product of two registers.

INST_REG_PRODHEXsOP00sOP01sOP10sOP11
Calculate the product of R08 and R06๏ผŒand save the result in R081C00080006

Suppose R08 is 1234, R06 is 0020.

(1234)16โ‹…(0020)16=(2โ€…โ€Š4680)16(1234)_{16}\cdot(0020)_{16}=(2\;4680)_{16}

The multiplication result should be 24680, but only the least 16 bits are kept. The product 4680 is stored in R08.

info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FRegister index (result)
sOP1000Ignored
sOP1100~3FRegister index

0x1D Arithmetic Calclation: Division (Mod)โ€‹

Division of two registers.

INST_REG_DIVISIONHEXsOP00sOP01sOP10sOP11
Calculate the division of R08 and R06๏ผŒand save the result in R081D00080006

Suppose R08 is 1234, R06 is 0020:

(1234)16รท(0020)16=(0091)16(1234)_{16}\div(0020)_{16}=(0091)_{16}

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/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FRegister index (result)
sOP1000Ignored
sOP1100~3FRegister index

0x1E Arithmetic Calclation: Remainderโ€‹

Calculate the division remainder of vaules in two registers.

INST_REG_REMAINDERHEXsOP00sOP01sOP10sOP11
Calculate the remainder of division of R08 and R06๏ผŒand save the result in R081D00080006

Suppose R08 is 1234, R06 is 0020:

(1234)16%(0020)16=(0014)16(1234)_{16}\%(0020)_{16}=(0014)_{16}

The former divided by the later results in a remainder 0014, stored in R08.

info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3Fregister index (result)
sOP1000Ignored
sOP1100~3FRegister index

0x1F Generate a Random Numberโ€‹

Generate a random 16-bit number in a target register.

INST_REG_REMAINDEHEXsOP00sOP01OP-1
Generate a random number in R051F00050000
info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FTarget register index
OP-10000Ignored

0x20 Byte Recompositionโ€‹

Recompose the high and low bytes of two registers.

INST_BYTE_COMPOSEHEXsOP00sOP01sOP10sOP11
Recompose the high byte of R05 and low byte of R06, and store the result in R052000050006

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/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FRegister index (result)
sOP1000Ignored
sOP1100~3FRegister index

0x21 Byte Swapโ€‹

Swap the high and low bytes of a register.

INST_BYTE_SWAPHEXsOP00sOP01OP-1
Swap the high and low bytes of R052100050000
info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FTarget register index
OP-10000Ignored