How to compare values for equality by subtraction (SUBWF and STATUS Z) | PIC assembly programming

Опубликовано: 24 Июль 2026
на канале: Pizzey Technology
3,776
42

PIC assembly programming for GCE A level Electronics.
In this video I demonstrate how to check the value stored in a file register (a "variable") by subtraction and then checking the STATUS Z bit.
The general method is as follows:
Store value1 into the working file register.
Move the contents of the working file register into a specified file register.
Store value2 into the working file register.
Subtract value2 from value1 stored in the file register. Output the result to the working file register.
Check the STATUS Z bit. If this "flag" is set the subtraction resulted in zero, therefore value1=value2.
Perform a conditional branch based on the value of the Z bit.

Please note there are other ways to compare values. This method may not be ideal for your application.