Search code examples
assemblyembeddedmsp430

Whats exactly does tst.b or tst.w instruction do?


I understand its supposed to "Test destination", but what exactly does that mean? The operations for .w and .b are below: dst+0FFFFh+1
dst+0FFh+1



Solution

  • Normally test means: combine the two values using bitwise AND, then set the status register according to the result, but do not store the result itself.

    On the MSP430, the TST instruction has only one argument; in this case, "testing a value" seems to be identical to "comparing a value to 0".

    And, indeed, the manual of some unknown compiler for the MSP430 says:

    TST(.B) xxx is an abbreviation of CMP(.B) #0, xxx