bcdsetsgn.

Set Sign for Packed Decimal

bcdsetsgn. VRT,VRB,PS

Sets the sign of a packed decimal value in a vector register based on the specified conditions.

Details

The bcdsetsgn. instruction sets the sign of a packed decimal value in VSR[VRT+32] based on the contents of VSR[VRB+32] and the PS flag.

Pseudocode Operation

if MSR.VEC=0 then
    Vector_Unavailable()

inv_flag ←(VSR[VRB+32].nibble[31] < 0xA)
do i = 0 to 30
    inv_flag ←inv_flag |
               (VSR[VRB+32].nibble[i] > 0x9)
end

src_sign ←(VSR[VRB+32].nibble[31] = 0xB) |
           (VSR[VRB+32].nibble[31] = 0xD)

eq_flag  ←(VSR[VRB+32].nibble[0:30] = 0)
lt_flag  ←(eq_flag=0) & (src_sign=1)
gt_flag  ←(eq_flag=0) & (src_sign=0)

result.nibble[0:30] ←VSR[VRB+32].nibble[0:30]
result.nibble[31] ←
   (src_sign=0) ? ((PS=0) ? 0xC:0xF) : 0xD

VSR[VRT+32] ←inv_flag ? undefined : result

CR.bit[56]  ←inv_flag ? 0b0 : lt_flag
CR.bit[57]  ←inv_flag ? 0b0 : gt_flag
CR.bit[58]  ←inv_flag ? 0b0 : eq_flag
CR.bit[59]  ←inv_flag

Programming Note

The bcdsetsgn. instruction is used to set the sign of a packed decimal value in VSR[VRT+32] based on the contents of VSR[VRB+32]. Ensure that the Vector Facility (MSR.VEC) is enabled; otherwise, a Vector_Unavailable exception will be raised. The instruction checks for invalid characters in the input and sets the sign accordingly, updating condition register bits CR[56-59] to reflect the result's status.

Example

bcdsetsgn. v1, v3, 0

Encoding

Binary Layout
4
0
VRT
6
VRB
11
PS
21
 
Format VX-form
Opcode 0x10000181
Extension Decimal Floating-Point
Registers Altered CR6, FPSCR

Operands

  • VRT
    Target Vector Register
  • VRB
    Source Vector Register
  • PS
    Packed Sign Flag
  • RT
    Target General Purpose Register
  • RA
    Source General Purpose Register
  • RB
    Source General Purpose Register