The sum is always stored in a register
add rdest, rsrc1, #n // rdest = rsrc1 + n add rdest, rsrc1, rsrc2 // rdest = rsrc1 + rsrc2
Examples:
add r0, r0, #1 // r0 = r0 + 1 add r0, r1, r2 // r0 = r1 + r2 add r0, r0, r0 // r0 = r0 + r0 = 2Śr0
DEMO: demo/asm/2+add/add.s
The difference is always stored in a register
sub rdest, rsrc1, #n // rdest = rsrc1 - n sub rdest, rsrc1, rsrc2 // rdest = rsrc1 - rsrc2
sub r0, r0, #1 // r0 = r0 - 1 sub r0, r1, r2 // r0 = r1 - r2
DEMO: demo/asm/2+add/sub.s
rsb rdest, rsrc1, #n // rdest = n - rsrc1 rsb rdest, rsrc1, rsrc2 // rdest = rsrc2 - rsrc1
rsb is only used as follows:
rsb r1, r0, #0 // r1 = 0 - r0 = -r0 // Same as: neg r1, r0
DEMO: demo/asm/2+add/rsb.s
The product is always stored in a register
mul rdest, rsrc1, rsrc2 // rdest = rsrc1 × rsrc2 // Note: rdest and rsrc1 must be different
mul r2, r0, r1 // r2 = r0 * r1 mul r0, r0, r1 // Error !
DEMO: demo/asm/2+add/mul.s
Note: