bcdctn.

Decimal Convert to National

bcdctn. vD, vB

Converts a packed decimal value to national decimal format and stores it in a vector register.

Details

The instruction converts the packed decimal value from VSR[VRB+32] into national decimal format and places it into VSR[VRT+32]. It also updates the condition register CR6 based on the validity of the input and its comparison to zero.

Pseudocode Operation

if MSR.VEC=0 then
    Vector_Unavailable()
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)
inv_flag ←false
ox_flag ←false
do i = 0 to 23
    ox_flag ←ox_flag | (VSR[VRB+32].nibble[i] != 0x0)
end
do i = 0 to 30
    inv_flag ←inv_flag | (VSR[VRB+32].nibble[i] > 0x9)
end
if inv_flag then
    VSR[VRT+32] ←undefined
else
    do i = 0 to 6
        result.hword[i].nibble[0:2] ←0x003
        result.hword[i].nibble[3] ←VSR[VRB+32].nibble[i+24]
    end
    result.hword[7] ←(src_sign=1) ? 0x002D : 0x002B
    VSR[VRT+32] ←result
end
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 | ox_flag

Programming Note

The bcdctn. instruction is used to convert packed decimal values into national decimal format, updating CR6 with flags indicating the result's validity and sign. Ensure VSR[VRB+32] contains valid packed decimal data; otherwise, VSR[VRT+32] will be undefined. This instruction requires vector mode enabled (MSR.VEC=1) and operates at user privilege level.

Example

bcdctn. vd, vb

Encoding

Binary Layout
4
0
VRT
6
5
11
VRB
16
1
21
/
22
385
23
 
Format VX-form
Opcode 0x100005C1
Extension Vector BCD
Registers Altered CR6

Operands

  • vD
    Target
  • vB
    Source
  • VRT
    Target Vector Register
  • VRB
    Source Vector Register