Other Parts Discussed in Thread: OMAP-L138
Hi,
in PRU assembly language, ADD instruction is defined as
Syntax:
ADD REG1, REG2, OP(255)
Operation:
REG1 = REG2 + OP(255)
carry = (( REG2 + OP(255) ) >> bitwidth(REG1)) & 1
SUC instruction (subtract with carry) is defined as (should, because in SPRUIJ2 April 2018, + are used instead of -)
Syntax:
SUC REG1, REG2, OP(255)
Operation:
REG1 = REG2 - OP(255) - carry
carry = (( REG2 - OP(255) - carry ) >> bitwidth(REG1)) & 1
I try this sequence of code
LDI r0.w0, 65534
ADD r0.w0, r0.w0, 1 ; no carry expected
SUC r0.w0, r0.w0, 0 ; so should not change the result, 65535 expected
LDI r0.w0, 65535
ADD r0.w0, r0.w0, 1 ; carry expected
SUC r0.w0, r0.w0, 0 ; so should subtract 1 and return to 65535
surprisingly, after both SUC instruction, the result is the opposite of what was expected, like if subtract use a carry inverted... (in first case result is 65534 and in second case result is 0)
Could TI explain that behavior and correct/update the PRU Assembly Instruction User Guide SPRUIJ2 ?
Thanks in advance.