ADDX

Instruction: Add two unsigned values plus C.

ADDX Value1, < # > Value2


Result: Sum of unsigned Value1 and unsigned Value2 plus C flag is stored in Value1.

  • Value1 (d-field) is the register containing the value to add to Value2 plus C, and is the destination in which to write the result.
  • Value2 (s-field) is a register or a 9-bit literal whose value plus C is added into Value1.

Opcode Table:

–INSTR–  ZCRI –CON–    –DEST–         –SRC–

Z Result

C Result

Result

Clocks

 110010    001i    1111    ddddddddd    sssssssss

Z & (D+S+C = 0)

Unsigned Carry

Written

4

Concise Truth Table:

In

Out

Destination1

Source1

Z

C

Effects

Destination

Z

C

$FFFF_FFFE; 4,294,967,294

$0000_0001; 1

x

0

wz wc

$FFFF_FFFF; 4,294,967,295

0

0

$FFFF_FFFE; 4,294,967,294

$0000_0001; 1

0

1

wz wc

$0000_0000; 0

0

1

$FFFF_FFFE; 4,294,967,294

$0000_0001; 1

1

1

wz wc

$0000_0000; 0

1

1

1 Both Source and Destination are treated as unsigned values.

Explanation

ADDX (Add Extended) sums the two unsigned values of Value1 and Value2 plus C, and stores the result into the Value1 register. The ADDX instruction is used to perform multi long addition; 64-bit additions, for example.

For example, an unsigned double-long (64-bit) addition may look like this:

add     XLow,     YLow    wc    wz     'Add low longs together; save C and Z
addx    XHigh,    YHigh                'Add high longs together

After executing the above, the double-long (64-bit) result is in the long registers XHigh:XLow. If XHigh:XLow started out as $0000_0000:FFFF_FFFF (4,294,967,295) and YHigh:YLow was $0000_0000:0000_0001 (1) the result in XHigh:XLow would be $0000_0001:0000_0000 (4,294,967,296). This is demonstrated below.

                         Hexadecimal             Decimal
                      (high)     (low) 
  (XHigh:XLow)      $0000_0000:FFFF_FFFF      4,294,967,295
+ (YHigh:YLow)    + $0000_0000:0000_0001                + 1
                  ----------------------    ---------------
                  = $0000_0001:0000_0000    = 4,294,967,296 

Of course, it may be necessary to specify the WC and WZ effects on the final instruction, ADDX, in order to watch for a result of zero or an unsigned overflow condition.

For ADDX, if the WZ effect is specified, the Z flag is set (1) if Z was previously set and Value1 + Value2 + C equals zero (use WC and WZ on preceding ADD and ADDX instructions). If the WC effect is specified, the C flag is set (1) if the summation resulted in an unsigned carry (32-bit overflow). The result is written to Value1 unless the NR effect is specified.

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