LEA

Integer, logic, video and predicate instructions

fixed bit field field the encoding fixes should be

LEA (hi reg)

6362616059585756555453525150494847464544434241403938373635343332
0101101111011
313029282726252423222120191817161514131211109876543210
pred.notpredRaRd

bits 63:48: 0101 1011 1101 1---

Runs execute_LEA with Form() 3.

LEA (hi cbuf)

6362616059585756555453525150494847464544434241403938373635343332
000110
313029282726252423222120191817161514131211109876543210
pred.notpredRaRd

bits 63:48: 0001 10-- ---- ----

Runs execute_LEA with Form() 4.

LEA (lo reg)

6362616059585756555453525150494847464544434241403938373635343332
0101101111010
313029282726252423222120191817161514131211109876543210
pred.notpredRaRd

bits 63:48: 0101 1011 1101 0---

Runs execute_LEA with Form() 0.

LEA (lo cbuf)

6362616059585756555453525150494847464544434241403938373635343332
010010111101
313029282726252423222120191817161514131211109876543210
pred.notpredRaRd

bits 63:48: 0100 1011 1101 ----

Runs execute_LEA with Form() 1.

LEA (lo imm)

6362616059585756555453525150494847464544434241403938373635343332
001101111010
313029282726252423222120191817161514131211109876543210
pred.notpredRaRd

bits 63:48: 0011 011- 1101 0---

Runs execute_LEA 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
[50:48]50:48execute_LEA
sum47execute_LEA
hi46:39execute_LEA
pred.not19the decoder
pred18:16the decoder
Ra15:8RegA()
Rd7:0Dst()

Operation Sail

LEA: (a << shift) + b, its high form the high word of (c:a) << shift; negated with 45 (37, 56 in the high forms: the high word's two's complement with the low word's carry). .X adds the carry in (LO at 46, HI at 38 or 57), .CC writes the flags, and LO's predicate takes the add's carry out: LEA.LO ... P0 then LEA.HI.X is how a 64-bit address is formed

let f = Form(); /* 0 LR, 1 LC, 2 LI, 3 HR, 4 HC */
let high_form = f >= 3;
let shift = UInt(Field(if high_form then (if f == 3 then 28 else 51) else 39, 5));
let negative = Field(if high_form then (if f == 3 then 37 else 56) else 45, 1) == 0b1;
let source0 = R_read(RegA());
let rhs = if f == 0 | f == 3 then R_read(RegB()) else if f == 2 then Right(2) else Right(1);
let value : bits(32) = if high_form then {
    let hi = R_read(UInt(Field(39, 8)));
    let v = if shift != 0 then (source0 >> to_bits(32, 32 - shift)) | (hi << to_bits(32, shift)) else hi;
    if negative then {
        let carry = (source0 << to_bits(32, shift)) == 0x00000000;
        not_vec(v) + (if carry then 0x00000001 else 0x00000000)
    } else v
} else {
    let source = if negative then 0x00000000 - source0 else source0;
    source << to_bits(32, shift)
};
let extended = Field(if f == 3 then 38 else if f == 4 then 57 else 46, 1) == 0b1;
let old_carry = if extended then FlagRead(2) else false;
let sum = IntegerAdd(value, rhs, 0, if extended then 1 else 0, UInt(Field(47, 1)));
R_write(Dst(), sum);
if UInt(Field(48, 3)) < 7 then {
    let carry0 = UInt(sum) < UInt(value);
    let carry = if extended then RawOr(carry0, RawAnd(old_carry, sum == value)) else carry0;
    PredWrite(UInt(Field(48, 3)), carry)
}

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).