IADD3

Integer, logic, video and predicate instructions

fixed bit field field the encoding fixes should be

IADD3 (reg)

6362616059585756555453525150494847464544434241403938373635343332
010111001100
313029282726252423222120191817161514131211109876543210
Rbpred.notpredRaRd

bits 63:48: 0101 1100 1100 ----

Runs execute_IADD3 with Form() 0.

IADD3 (cbuf)

6362616059585756555453525150494847464544434241403938373635343332
010011001100cbuf.bankcbuf.offset
313029282726252423222120191817161514131211109876543210
cbuf.offsetpred.notpredRaRd

bits 63:48: 0100 1100 1100 ----

Runs execute_IADD3 with Form() 1.

IADD3 (imm)

6362616059585756555453525150494847464544434241403938373635343332
0011100imm.sign1100imm
313029282726252423222120191817161514131211109876543210
immpred.notpredRaRd

bits 63:48: 0011 100- 1100 ----

Runs execute_IADD3 with Form() 2.

Fields

The operation reads some of these fields in some forms alone (it chooses by Form()), so the diagrams show only the decoder's.

FieldBitsFrom
first51execute_IADD3
second50execute_IADD3
third49execute_IADD3
[48]48execute_IADD3
[47]47execute_IADD3
third046:39execute_IADD3
shift38:37execute_IADD3
first136:35execute_IADD3
second134:33execute_IADD3
third132:31execute_IADD3
Rb27:20the right operand
pred.not19the decoder
pred18:16the decoder
Ra15:8RegA()
Rd7:0Dst()

Operation Sail

let reg_form = Form() == 0;
let first0 = R_read(RegA());
let second0 = RightOf(Form());
let third0 = R_read(UInt(Field(39, 8)));
let first1 = if reg_form then HalfOf3(first0, UInt(Field(35, 2))) else first0;
let second1 = if reg_form then HalfOf3(second0, UInt(Field(33, 2))) else second0;
let third1 = if reg_form then HalfOf3(third0, UInt(Field(31, 2))) else third0;
let first = if Field(51, 1) == 0b1 then 0x00000000 - first1 else first1;
let second = if Field(50, 1) == 0b1 then 0x00000000 - second1 else second1;
let third = if Field(49, 1) == 0b1 then 0x00000000 - third1 else third1;
let sum0 = first + second;
let carry0 = UInt(sum0) < UInt(first);
let shift = if reg_form then UInt(Field(37, 2)) else 0;
/* the 33-bit sum shifted: its carry becomes bit 16 */
let sum = if shift == 1 then (sum0 >> 16) | (if carry0 then 0x00010000 else 0x00000000)
          else if shift == 2 then sum0 << 16 else sum0;
var sum2 : bits(32) = sum + third;
let carry1 = UInt(sum2) < UInt(sum);
var carry2 : bool = false;
if Field(48, 1) == 0b1 then {
    let cin = if FlagRead(2) then 0x00000001 else 0x00000000;
    let total = sum2 + cin;
    carry2 = UInt(total) < UInt(sum2);
    sum2 = total
};
if Field(47, 1) == 0b1 then {
    let carry12 = RawOr(carry1, carry2);
    let carry = if shift != 1 & shift != 2 then RawOr(carry12, carry0) else carry12;
    let zero0 = sum2 == 0x00000000;
    let zero = if Field(48, 1) == 0b1 then RawAnd(zero0, FlagRead(0)) else zero0;
    let sign = (sum2 & 0x80000000) != 0x00000000;
    FlagWrite(2, carry);
    FlagWrite(0, zero);
    FlagWrite(1, sign)
};
R_write(Dst(), sum2)

Made from ScarletNX's Sail at 166ad3910f80. The Sail and the encodings' file are ScarletNX's (GPL-3.0-or-later); its encodings are from Eden's maxwell.inc (GPL-2.0-or-later).