Convert Declets To Binary Coded Decimal

X-Form

  • cdtbcd RA, RS

Pseudo-code:

src <- [0]*64
src[64-XLEN:63] <- (RS)
result <- [0]*64
do i = 0 to 1
  n <- i * 32
  result[n+0:n+7] <- 0
  result[n+8:n+19] <- DPD_TO_BCD(src[n+12:n+21])
  result[n+20:n+31] <- DPD_TO_BCD(src[n+22:n+31])
RA <- result[64-XLEN:63]

Special Registers Altered:

None

Add and Generate Sixes

XO-Form

  • addg6s RT,RA,RB

Pseudo-code:

sum <- (0b0000 || (RA)) + (0b0000 || (RB))
carries <- sum ^ (0b0000 || (RA)) ^ (0b0000 || (RB))
ones <- [0b0001] * (XLEN / 4)
nibbles_need_sixes <- ¬carries[0:XLEN-1] & ones
RT <- nibbles_need_sixes * 0b0110

Special Registers Altered:

None

Convert Binary Coded Decimal To Declets

X-Form

  • cbcdtd RA, RS

Pseudo-code:

src <- [0]*64
src[64-XLEN:63] <- (RS)
result <- [0]*64
do i = 0 to 1
  n <- i * 32
  result[n+0:n+11] <- 0
  result[n+12:n+21] <- BCD_TO_DPD(src[n+8:n+19])
  result[n+22:n+31] <- BCD_TO_DPD(src[n+20:n+31])
RA <- result[64-XLEN:63]

Special Registers Altered:

None