From 464720b66b5d0a018542765890e5c9368dec7dee Mon Sep 17 00:00:00 2001 From: Sun Yimin Date: Thu, 5 Sep 2024 16:32:57 +0800 Subject: [PATCH] Updated Golang ppc64x asm Reference (markdown) --- Golang-ppc64x-asm-Reference.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Golang-ppc64x-asm-Reference.md b/Golang-ppc64x-asm-Reference.md index f001cae..c88cfdc 100644 --- a/Golang-ppc64x-asm-Reference.md +++ b/Golang-ppc64x-asm-Reference.md @@ -85,6 +85,39 @@ - **LXVDSX** "Load Vector Doubleword Scalar Indexed". This instruction is used to load a doubleword (64-bit element) from memory into a vector register.从指定内存位置加载64位数据,将其存储到目标向量寄存器的lower half(byte index from 0-7)。 - **LVXD2X** "Load Vector Doubleword 2 Indexed". This instruction is used to load two consecutive doublewords (64-bit elements) from memory into a vector register. 加载两个连续的64位数到目标向量寄存器。 +### 示例(PPC64LE) +用**LVXD2X**加载两个连续64位整数: +```asm +DATA ·mask+0x00(SB)/8, $0x0f0e0d0c0b0a0908 // Permute for vector doubleword endian swap +DATA ·mask+0x08(SB)/8, $0x0706050403020100 +GLOBL ·mask(SB), RODATA, $16 + +MOVD $·mask(SB), R4 +LVXD2X (R4), V0 +``` +那V[0] = 0x0f0e0d0c, V[1] = 0x0b0a0908, V[2] = 0x07060504, V[3] = 0x03020100 + +用**LVX**加载两个连续64位整数: +```asm +DATA ·mask+0x00(SB)/8, $0x0f0e0d0c0b0a0908 // Permute for vector doubleword endian swap +DATA ·mask+0x08(SB)/8, $0x0706050403020100 +GLOBL ·mask(SB), RODATA, $16 + +MOVD $·mask(SB), R4 +LVX (R4), V0 +``` +那V[2] = 0x0f0e0d0c, V[3] = 0x0b0a0908, V[0] = 0x07060504, V[1] = 0x03020100 + + +用**LVXD2X**加载四个32位整数: +假设四个连续32位整数为:[0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100] +则V[0] = 0x0b0a0908, V[1] = 0x0f0e0d0c, V[2] = 0x03020100, V[3] = 0x07060504 + + +用**LVX**加载四个32位整数: +假设四个连续32位整数为:[0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100] +则V[0] = 0x03020100, V[1] = 0x07060504, V[2] = 0x0b0a0908, V[3] = 0x0f0e0d0c + ## 存储向量寄存器中的数据到内存 - **STVX** "Store Vector Indexed". This instruction is used to store a vector from a vector register into memory.The **STVX** instructions on ppc64 require 16 byte alignment of the data. To avoid that requirement, data is stored using **STXVD2X** with **VPERM** to reorder bytes correctly. - **STXVD2X** "Store Vector Doubleword 2 Indexed". This instruction is used to store two consecutive doublewords (64-bit elements) from a vector register into memory.