Vault 7: Projects
This publication series is about specific projects related to the Vault 7 main publication.
© 2005-2011 Microchip Technology Inc. DS70157F-page 77
Section 4. Instruction Set Details
Instruction Set
Details
4
4.9 Z STATUS BIT
The Z Status bit is a special zero Status bit that is useful for extended precision arithmetic. The
Z bit functions like a normal Z flag for all instructions, except those that use the Carry/Borrow
input (ADDC, CPB, SUBB and SUBBR). For the ADDC, CPB, SUBB and SUBBR instructions, the
Z bit can only be cleared and never set. If the result of one of these instructions is non-zero, the
Z bit will be cleared and will remain cleared, regardless of the result of subsequent ADDC, CPB,
SUBB or SUBBR operations. This allows the Z bit to be used for performing a simple zero check
on the result of a series of extended precision operations.
A sequence of instructions working on multi-precision data (starting with an instruction with no
Carry/Bo
rrow input), will automatically logically AND the successive results of the zero test. All
results must be zero for the Z flag to remain set at the end of the sequence of operations. If the
result of the ADDC, CPB, SUBB or SUBBR instruction is non-zero, the Z bit will be cleared and
remain cleared for all subsequent ADDC, CPB, SUBB or SUBBR instructions.
Example 4-15
shows how the Z bit operates for a 32-bit addition. It shows how the Z bit is affected for a 32-bit
addition implemented with an ADD/ADDC instruction sequence. The first example generates a
zero result for only the most significant word, and the second example generates a zero result
for both the least significant word and most significant word.
Example 4-15: ‘Z’ Status bit Operation for 32-bit Addition
; Add two doubles (W0:W1 and W2:W3)
; Store the result in W5:W4
ADD W0, W2, W4 ; Add LSWord and store to W4
ADDC W1, W3, W5 ; Add MSWord and store to W5
Before 32-bit Addition (zero result for the most significant word):
W0 = 0x2342
W1 = 0xFFF0
W2 = 0x39AA
W3 = 0x0010
W4 = 0x0000
W5 = 0x0000
SR = 0x0000
After 32-bit Addition:
W0 = 0x2342
W1 = 0xFFF0
W2 = 0x39AA
W3 = 0x0010
W4 = 0x5CEC
W5 = 0x0000
SR = 0x0201 (DC,C=1)
Before 32-bit Addition (zero result for the least significant word and most significant word):
W0 = 0xB76E
W1 = 0xFB7B
W2 = 0x4892
W3 = 0x0484
W4 = 0x0000
W5 = 0x0000
SR = 0x0000
After 32-bit Addition:
W0 = 0xB76E
W1 = 0xFB7B
W2 = 0x4892
W3 = 0x0485
W4 = 0x0000
W5 = 0x0000
SR = 0x0103 (DC,Z,C=1)
Protego_Release_01_05-Related-OEM-Documentation-PIC24FJ64GA004-Programmers_Reference_Manual.pdf