Concise Truth Tables

After the opcode table, there is a concise truth table. The concise truth table demonstrates sample inputs and resulting outputs for the corresponding instruction. Rather than showing every possible input/output case, the instruction's concise truth table focuses on exploiting numerical or logical boundaries that result in flag activity and notable destination output. This information can aid in learning or verifying the instruction's intrinsic function and behavior.

Generally, the concise truth tables should be read carefully from the top row towards the bottom row. When multiple boundary cases are possible, the related rows are grouped together for emphasis and separated from other groups by a thick horizontal line.

The following conventions are used:

$FFFF_FFFE; -2
Numbers are values in hexadecimal (left of ';') and decimal (right of ';').
%0_00000011; 3
Numbers are values in binary (left of ';') and decimal (right of ';').
0 –or– 1
Individual zero (0) or one (1) means binary 0 or 1.
wr, wz, wc
Assembly effects indicate execution state; write-result, write-z, write-c.
x
Lower case "x" indicates items where every possible value applies.
---
Hyphens indicate items that are not applicable or not important.

A good example is the truth table for the ADDS instruction:

ADDS Truth Table:

In

Out

Destination

Source

Z

C

Effects

Destination

Z

C

$FFFF_FFFF; -1
$0000_0001; 1
-
-
wz wc
$0000_0000; 0
1
0
$FFFF_FFFF; -1
$0000_0002; 2
-
-
wz wc
$0000_0001; 1
0
0
$0000_0001; 1
$FFFF_FFFF; -1
-
-
wz wc
$0000_0000; 0
1
0
$0000_0001; 1
$FFFF_FFFE; -2
-
-
wz wc
$FFFF_FFFF; -1
0
0
$7FFF_FFFE; 2,147,483,646
$0000_0001; 1
-
-
wz wc
$7FFF_FFFF; 2,147,483,647
0
0
$7FFF_FFFE; 2,147,483,646
$0000_0002; 2
-
-
wz wc
$8000_0000; -2,147,483,648
0
1
$8000_0001; -2,147,483,647
$FFFF_FFFF; -1
-
-
wz wc
$8000_0000; -2,147,483,648
0
0
$8000_0001; -2,147,483,647
$FFFF_FFFE; -2
-
-
wz wc
$7FFF_FFFF; 2,147,483,647
0
1

In the ADDS truth table there are eight data rows grouped into four pairs. Each group exploits a different boundary condition. The first five columns of each row indicate the inputs to the instruction and the last three columns show the resulting outputs.

  • The first pair of data rows demonstrates a simple signed addition (-1 + 1) that results in zero (z flag set) and also an example (-1 + 2) that results in non-zero (Z flag clear).
  • The second pair of rows shows the same concept but with inverted signs on the values; (1 + -1) and (1 + -2).
  • The third pair of rows demonstrates an addition near the highest signed integer boundary (2,147,482,646 + 1) followed by another that crosses that boundary (2,147,482,646 + 2) resulting in a signed overflow (C flag set).
  • The fourth pair of rows shows the same concept but approaching and crossing the signed integer boundary from the negative side, also resulting in a signed overflow (C flag set).

Note that an instruction's destination field actually contains the address to a register that holds the desired operand value, and the source field is often encoded similarly, but the truth tables always simplify this detail by only showing the desired operand value itself for each source and destination.

Unless otherwise noted, content on this site is licensed under the
Creative Commons Attribution-ShareAlike 4.0 International License.