Skip to content

C and Z flags in comparisons

FlagMeaning (unsigned subtract)
Z1 if result is zero
C1 if no borrow (A ≥ B); 0 if borrow (A < B)

C acts as bit 9 of the unsigned result (course PDF).

MOVF B,W
SUBWF A,W ; A - B, updates C and Z

A − B ≠ B − A in flags.

RelationFlags
A = BZ = 1
A > BC = 1, Z = 0
A < BC = 0
A ≥ BC = 1
A ≤ BC = 0 or Z = 1
InstructionSkips if
BTFSS STATUS,ZZ = 1
BTFSC STATUS,ZZ = 0
BTFSS STATUS,CC = 1
BTFSC STATUS,CC = 0

Ejercicio · Parcial

Predict

A=8,B=8 → C=1,Z=1. A=12,B=5 → C=1,Z=0. A=1,B=10 → C=0,Z=0.

Next: Equal to zero.

Interactive exam

C and Z flags

Based on: Clase Tema 4 y 5.pdf

0 of 0 answered

In unsigned subtraction, C=0 after A−B usually means...
Flag Z=1 after an operation means...
SUBWF f,d computes...
BTFSC STATUS,C skips if...
For A > B after A−B you need C=1 and...
In the course PDF, C acts as bit...