Q-Code User Manual
Ver. 7.0 2021/11/30
129
No.
Variables
Note
Example
4
Var1 = Var2 * Var3
[Var1, Var2 ] = Var3 * Var4
Multiplication
NX1 does not support second
form.
X1 = R0 * R1,
X1 = R0 * 5
[R0, R1] = R2 * 15
5
Var1 = Var2 / Var3
[Var1, Var2] = Var3 / Var4
Division
In second form, the quotient of
division operation is saved in
Var1, and the remainder is
saved in Var2.
R2 = R0 / 5,
X2 = X1 / R0,
[R2, R1] = R0 / 5
6
Var1 = Var2 % Var3
Remainder operation
R2 = R1 % 15
8
Var++
Increment operation
R0++
9
Var--
Decrement operation
PA--
10 Var1 = Var2 & Var3
“AND” operation
R2 = R0 & R1
11 Var1 = Var2 | Var3
“OR” operation
R2 = R0 | R1
12 Var1 = Var2 ^ Var3
“XOR” operation
R2 = R0 ^ R1
13 Var1 = Var2 << Var3
Left shift
R2 = R0 << 2, R2 = R0 << R1
14 Var1 = Var2 >> Var3
Right shift
R2 = R0 >> 2, R2 = R0 >> R1
15 !Var
Invert operation
!R0, !R0.3
Note:
1. Supported system variables are listed below.
No.
Variables
Note
Example
1
Vol
Volume
Vol = R1 + 2
2
Px
IO port
PA = R0 ^ 0x9
3
V_Chx_Vol
The channel volume of voice
V_Ch0_Vol = X0
4
M_Chx_Vol
The individual channel volume of Melody
M_Ch10_Vol = R0
5
SPIVol
The channel volume of SPIPlay
SPIVol = R0
6
PxM
Input / Output mode of IO port
PAM = PFM | 0x1
7
PxM.n
Input / Output mode of IO pin
PAM.0 = PFM.0
8
RandomL
Low nibble of random number
Read only, do not use at the left side of “=”
R0 = RandomL ^ 0x5
9
RandomH
Hight nibble of random number
Read only, do not use at the left side of “=”
R0 = RandomH | 0x9
10 Random
Random number
Read only, do not use at the left side of “=”
X0 = Random ^ 0x33
2. When 1-bit / 4-bit / 8-bit variables are used in variable operation, assigning the variable or
operation result to variable with less bit, the overflow bits would be truncated
Ex.
X0 = 0xFA, R3 = X0
; R3 = 0xA