From: Jacob Lifshay Date: Mon, 7 Aug 2023 23:04:00 +0000 (-0700) Subject: split out instructions from openpower/isa/bcd.mdwn X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8e28f51980968703174fa1e8bd03ec97f0ccda17;p=openpower-isa.git split out instructions from openpower/isa/bcd.mdwn --- diff --git a/openpower/isa/bcd.mdwn b/openpower/isa/bcd.mdwn index 3707692f..a5aea01b 100644 --- a/openpower/isa/bcd.mdwn +++ b/openpower/isa/bcd.mdwn @@ -7,66 +7,8 @@ -# Convert Declets To Binary Coded Decimal +[[!inline pagenames="openpower/isa/bcd/cdtbcd" raw="yes"]] -X-Form +[[!inline pagenames="openpower/isa/bcd/addg6s" raw="yes"]] -* 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 - - +[[!inline pagenames="openpower/isa/bcd/cbcdtd" raw="yes"]] diff --git a/openpower/isa/bcd/addg6s.mdwn b/openpower/isa/bcd/addg6s.mdwn new file mode 100644 index 00000000..b0905f73 --- /dev/null +++ b/openpower/isa/bcd/addg6s.mdwn @@ -0,0 +1,13 @@ +# Add and Generate Sixes + +XO-Form + +* addg6s RT,RA,RB + +Pseudo-code: + +[[!inline pagenames="openpower/isa/bcd/addg6s_code" raw="yes"]] + +Special Registers Altered: + + None diff --git a/openpower/isa/bcd/addg6s_code.mdwn b/openpower/isa/bcd/addg6s_code.mdwn new file mode 100644 index 00000000..e05b204c --- /dev/null +++ b/openpower/isa/bcd/addg6s_code.mdwn @@ -0,0 +1,5 @@ + 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 diff --git a/openpower/isa/bcd/cbcdtd.mdwn b/openpower/isa/bcd/cbcdtd.mdwn new file mode 100644 index 00000000..572da96b --- /dev/null +++ b/openpower/isa/bcd/cbcdtd.mdwn @@ -0,0 +1,15 @@ +# Convert Binary Coded Decimal To Declets + +X-Form + +* cbcdtd RA,RS + +Pseudo-code: + +[[!inline pagenames="openpower/isa/bcd/cbcdtd_code" raw="yes"]] + +Special Registers Altered: + + None + + diff --git a/openpower/isa/bcd/cbcdtd_code.mdwn b/openpower/isa/bcd/cbcdtd_code.mdwn new file mode 100644 index 00000000..ce4e38e5 --- /dev/null +++ b/openpower/isa/bcd/cbcdtd_code.mdwn @@ -0,0 +1,9 @@ + 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] diff --git a/openpower/isa/bcd/cdtbcd.mdwn b/openpower/isa/bcd/cdtbcd.mdwn new file mode 100644 index 00000000..4dba6b36 --- /dev/null +++ b/openpower/isa/bcd/cdtbcd.mdwn @@ -0,0 +1,13 @@ +# Convert Declets To Binary Coded Decimal + +X-Form + +* cdtbcd RA,RS + +Pseudo-code: + +[[!inline pagenames="openpower/isa/bcd/cdtbcd_code" raw="yes"]] + +Special Registers Altered: + + None diff --git a/openpower/isa/bcd/cdtbcd_code.mdwn b/openpower/isa/bcd/cdtbcd_code.mdwn new file mode 100644 index 00000000..340bb713 --- /dev/null +++ b/openpower/isa/bcd/cdtbcd_code.mdwn @@ -0,0 +1,9 @@ + 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]